File tree Expand file tree Collapse file tree 5 files changed +37
-3
lines changed
Expand file tree Collapse file tree 5 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ type ModalName =
7676 | 'preferences'
7777 | 'share'
7878 | 'searchDependencies'
79- | 'signInForTemplates' ;
79+ | 'signInForTemplates'
80+ | 'userSurvey' ;
8081export const modalOpened : Action < { modal : ModalName ; message ?: string } > = (
8182 { state, effects } ,
8283 { modal, message }
Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ export default {
6868 getCurrentUser ( ) : Promise < CurrentUser > {
6969 return api . get ( '/users/current' ) ;
7070 } ,
71+ markSurveySeen ( ) : Promise < void > {
72+ return api . post ( '/users/survey-seen' , { } ) ;
73+ } ,
7174 getDependency ( name : string ) : Promise < Dependency > {
7275 return api . get ( `/dependencies/${ name } @latest` ) ;
7376 } ,
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export const withLoadApp = <T>(
3030 state . user = await effects . api . getCurrentUser ( ) ;
3131 actions . internal . setPatronPrice ( ) ;
3232 actions . internal . setSignedInCookie ( ) ;
33+ actions . internal . showUserSurveyIfNeeded ( ) ;
3334 effects . live . connect ( ) ;
3435 actions . userNotifications . internal . initialize ( ) ;
3536 effects . api . preloadTemplates ( ) ;
@@ -112,7 +113,7 @@ export const createModals = <
112113 state ?: {
113114 current : keyof T ;
114115 } & {
115- [ K in keyof T ] : T [ K ] [ 'state' ] & { isCurrent : IDerive < any , any , boolean > }
116+ [ K in keyof T ] : T [ K ] [ 'state' ] & { isCurrent : IDerive < any , any , boolean > } ;
116117 } ;
117118 actions ?: {
118119 [ K in keyof T ] : {
@@ -121,7 +122,7 @@ export const createModals = <
121122 T [ K ] [ 'result' ]
122123 > ;
123124 close : AsyncAction < T [ K ] [ 'result' ] > ;
124- }
125+ } ;
125126 } ;
126127} => {
127128 function createModal ( name , modal ) {
Original file line number Diff line number Diff line change 99} from '@codesandbox/common/lib/types' ;
1010import { identify , setUserId } from '@codesandbox/common/lib/utils/analytics' ;
1111
12+ import { NotificationStatus } from '@codesandbox/notifications' ;
1213import { createOptimisticModule } from './utils/common' ;
1314import getItems from './utils/items' ;
1415import { defaultOpenedModule , mainModule } from './utils/main-module' ;
@@ -68,6 +69,33 @@ export const setSignedInCookie: Action = ({ state }) => {
6869 setUserId ( state . user . id ) ;
6970} ;
7071
72+ export const showUserSurveyIfNeeded : Action = ( { state, effects, actions } ) => {
73+ if ( state . user . sendSurvey ) {
74+ // Let the server know that we've seen the survey
75+ effects . api . markSurveySeen ( ) ;
76+
77+ effects . notificationToast . add ( {
78+ title : 'Help improve CodeSandbox' ,
79+ message :
80+ "We'd love to hear your thoughts, it's 7 questions and will only take 2 minutes." ,
81+ status : NotificationStatus . NOTICE ,
82+ sticky : true ,
83+ actions : {
84+ primary : [
85+ {
86+ label : 'Open Survey' ,
87+ run : ( ) => {
88+ actions . modalOpened ( {
89+ modal : 'userSurvey' ,
90+ } ) ;
91+ } ,
92+ } ,
93+ ] ,
94+ } ,
95+ } ) ;
96+ }
97+ } ;
98+
7199export const addNotification : Action < {
72100 title : string ;
73101 type : 'notice' | 'success' | 'warning' | 'error' ;
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ export type CurrentUser = {
125125 email : string ;
126126 } ;
127127 } ;
128+ sendSurvey : boolean ;
128129} ;
129130
130131export type CustomTemplate = {
You can’t perform that action at this time.
0 commit comments