Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function showUserSurveyIfNeeded({ state, controller, api }) {
if (state.get('user.sendSurvey')) {
// Let the server know that we've seen the survey
api.post('/users/survey-seen', {});
notificationState.addNotification({
title: 'Help improve CodeSandbox',
message:
"We'd love to hear your thoughts, it's 7 questions and will only take 2 minutes.",
status: NotificationStatus.NOTICE,
sticky: true,
actions: {
primary: [
{
label: 'Open Survey',
run: () => {
controller.getSignal('modalOpened')({
modal: 'userSurvey',
});
},
},
],
},
});
}
}
export function showUserSurveyIfNeeded ({ state, controller, api }) {
if (state.get('user.sendSurvey')) {
// Let the server know that we've seen the survey
api.post('/users/survey-seen', {})
notificationState.addNotification({
title: 'Help improve CodeSandbox',
message:
"We'd love to hear your thoughts, it's 7 questions and will only take 2 minutes.",
status: NotificationStatus.NOTICE,
sticky: true,
actions: {
primary: [
{
label: 'Open Survey',
run: () => {
controller.getSignal('modalOpened')({
modal: 'userSurvey'
})
}
}
]
}
})
}
}
export const showUserSurveyIfNeeded: Action = ({ state, effects, actions }) => {
if (state.user.sendSurvey) {
// Let the server know that we've seen the survey
effects.api.markSurveySeen();
effects.notificationToast.add({
title: 'Help improve CodeSandbox',
message:
"We'd love to hear your thoughts, it's 7 questions and will only take 2 minutes.",
status: NotificationStatus.NOTICE,
sticky: true,
actions: {
primary: [
{
label: 'Open Survey',
run: () => {
actions.modalOpened({
modal: 'userSurvey',
});
},
},
],
},
});
}
};
return true;
}
return false;
})
.filter(Boolean);
const numRecoveredFiles = recoveredList.length;
if (numRecoveredFiles > 0) {
track('Files Recovered', { fileCount: numRecoveredFiles });
notificationState.addNotification({
message: `We recovered ${numRecoveredFiles} unsaved ${
numRecoveredFiles > 1 ? 'files' : 'file'
} from a previous session`,
status: NotificationStatus.NOTICE,
});
}
return {};
}
export function convertTypeToStatus(
type: NotificationType
): NotificationStatus {
switch (type) {
case 'notice':
return NotificationStatus.NOTICE;
case 'warning':
return NotificationStatus.WARNING;
case 'error':
return NotificationStatus.ERROR;
case 'success':
return NotificationStatus.SUCCESS;
default:
return NotificationStatus.NOTICE;
}
}
const getClosedMessage = () => {
if (removedPorts.length === 1) {
return `Port ${removedPorts[0].port} closed`;
}
return `The following ports closed: ${removedPorts
.map(p => p.port)
.join(', ')}`;
};
if (removedPorts.length > 0) {
notificationState.addNotification({
title: `Server Ports Closed`,
message: getClosedMessage(),
status: NotificationStatus.NOTICE,
});
}
}
if (process.env.NODE_ENV === 'production') {
routeDebugger(
`Sending '${location.pathname + location.search}' to analytics.`
);
if (!DNT) {
trackPageview();
}
}
return null;
}}
/>
<content>
</content>