Skip to content

Commit 0c513cb

Browse files
authored
Add survey logic (codesandbox#2243)
1 parent bbb3c79 commit 0c513cb

File tree

8 files changed

+168
-5
lines changed

8 files changed

+168
-5
lines changed

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"@codesandbox/template-icons": "^0.6.1",
141141
"@emmetio/codemirror-plugin": "^0.3.5",
142142
"@svgr/core": "^2.4.1",
143+
"@typeform/embed": "^0.12.0",
143144
"@vue/babel-preset-app": "^3.2.0",
144145
"airtable": "^0.5.8",
145146
"apollo-boost": "^0.4.3",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import * as typeformEmbed from '@typeform/embed';
3+
import { useStore, useSignals } from 'app/store';
4+
import hash from '@codesandbox/common/lib/utils/hash';
5+
6+
import { Container } from '../elements';
7+
8+
export const SurveyModal = () => {
9+
const store = useStore();
10+
const signals = useSignals();
11+
12+
const initializeTypeform = (el: HTMLDivElement) => {
13+
if (el) {
14+
typeformEmbed.makeWidget(
15+
el,
16+
`https://codesandbox.typeform.com/to/LYbjII?userid=${hash(
17+
store.user.id
18+
)}&ispatron=${store.isPatron}`,
19+
{
20+
opacity: 0,
21+
hideScrollbars: true,
22+
hideFooter: true,
23+
hideHeaders: true,
24+
onSubmit: () => {
25+
setTimeout(() => {
26+
signals.modalClosed();
27+
}, 3000);
28+
},
29+
}
30+
);
31+
}
32+
};
33+
34+
return (
35+
<Container style={{ borderRadius: 4, paddingTop: '1rem' }}>
36+
<div style={{ width: '100%', height: 500 }} ref={initializeTypeform} />
37+
</Container>
38+
);
39+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { SurveyModal } from './SurveyModal';

packages/app/src/app/pages/common/Modals/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import NetlifyLogs from './NetlifyLogs';
3333
import ForkFrozenSandboxModal from './ForkFrozenSandboxModal';
3434
// eslint-disable-next-line
3535
import SignInForTemplates from './SignInForTemplates/index.ts';
36+
import { SurveyModal } from './SurveyModal';
3637

3738
const MoveSandboxFolderModal = Loadable(() =>
3839
import('./MoveSandboxFolderModal')
@@ -139,6 +140,10 @@ const modals = {
139140
Component: FeedbackModal,
140141
width: 450,
141142
},
143+
userSurvey: {
144+
Component: SurveyModal,
145+
width: 850,
146+
},
142147
};
143148

144149
class Modals extends Component {

packages/app/src/app/store/actions.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
sandboxUrl,
1212
editorUrl,
1313
} from '@codesandbox/common/lib/utils/url-generator';
14+
import { notificationState } from '@codesandbox/common/lib/utils/notifications';
15+
import { NotificationStatus } from '@codesandbox/notifications';
1416

1517
import { parseConfigurations } from './utils/parse-configurations';
1618
import { mainModule, defaultOpenedModule } from './utils/main-module';
@@ -177,6 +179,29 @@ export function setCurrentModuleShortid({ props, state }) {
177179
}
178180
}
179181

182+
export function showUserSurveyIfNeeded({ state, controller }) {
183+
if (state.get('user.sendSurvey')) {
184+
notificationState.addNotification({
185+
title: 'Help improve CodeSandbox',
186+
message: 'Help us improve CodeSandbox by answering a small survey!',
187+
status: NotificationStatus.NOTICE,
188+
sticky: true,
189+
actions: {
190+
primary: [
191+
{
192+
label: 'Open Survey',
193+
run: () => {
194+
controller.getSignal('modalOpened')({
195+
modal: 'userSurvey',
196+
});
197+
},
198+
},
199+
],
200+
},
201+
});
202+
}
203+
}
204+
180205
export function setMainModuleShortid({ props, state }) {
181206
const sandbox = props.sandbox;
182207
const parsedConfigs = parseConfigurations(sandbox);

packages/app/src/app/store/factories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export function withLoadApp(continueSequence) {
122122
actions.setPatronPrice,
123123
actions.setSignedInCookie,
124124
actions.connectWebsocket,
125+
actions.showUserSurveyIfNeeded,
125126
initializeNotifications,
126127
actions.loadTemplatesForStartModal,
127128
],

packages/app/src/app/store/model.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default {
4343
})
4444
),
4545
username: types.maybeNull(types.string),
46+
sendSurvey: types.maybeNull(types.boolean),
4647
})
4748
),
4849
connected: types.boolean,

yarn.lock

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,6 +3143,27 @@
31433143
prop-types "^15.6.2"
31443144
tippy.js "^4.3.4"
31453145

3146+
"@typeform/embed@^0.12.0":
3147+
version "0.12.0"
3148+
resolved "https://registry.yarnpkg.com/@typeform/embed/-/embed-0.12.0.tgz#65b6260cc3aa84102f1ad04ce9981c24ee55d22a"
3149+
integrity sha512-Eng8w8yqirpzLQ0j37vR0COf0XAoE6hU71iD1SdsSqFF392IEC5hC7YqsTn+acnqbVORBzwkIemdYqShcbdgEQ==
3150+
dependencies:
3151+
classnames "^2.2.5"
3152+
core-js "^3.0.1"
3153+
create-emotion "^9.0.2"
3154+
create-emotion-styled "^9.0.1"
3155+
custom-event "^1.0.1"
3156+
fetch-jsonp "^1.0.6"
3157+
is-url "^1.2.2"
3158+
preact "^8.2.7"
3159+
preact-compat "^3.15.0"
3160+
prop-types "^15.5.10"
3161+
scrollbar-width "^3.1.1"
3162+
spin.js "^2.3.2"
3163+
tinycolor2 "^1.4.1"
3164+
url-parse "^1.1.7"
3165+
webfontloader "^1.6.27"
3166+
31463167
"@types/babel__core@^7.1.0":
31473168
version "7.1.2"
31483169
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.2.tgz#608c74f55928033fce18b99b213c16be4b3d114f"
@@ -8799,7 +8820,7 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0:
87998820
integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=
88008821

88018822
console-feed@CompuIves/console-feed#build2:
8802-
version "2.8.9"
8823+
version "2.8.8"
88038824
resolved "https://codeload.github.com/CompuIves/console-feed/tar.gz/42f10eb3063f0f26ee9745c4c9e4542cb5591f46"
88048825
dependencies:
88058826
emotion "^9.1.1"
@@ -9322,14 +9343,14 @@ create-ecdh@^4.0.0:
93229343
bn.js "^4.1.0"
93239344
elliptic "^6.0.0"
93249345

9325-
create-emotion-styled@^9.2.8:
9346+
create-emotion-styled@^9.0.1, create-emotion-styled@^9.2.8:
93269347
version "9.2.8"
93279348
resolved "https://registry.yarnpkg.com/create-emotion-styled/-/create-emotion-styled-9.2.8.tgz#c0050e768ba439609bec108600467adf2de67cc3"
93289349
integrity sha512-2LrNM5MREWzI5hZK+LyiBHglwE18WE3AEbBQgpHQ1+zmyLSm/dJsUZBeFAwuIMb+TjNZP0KsMZlV776ufOtFdg==
93299350
dependencies:
93309351
"@emotion/is-prop-valid" "^0.6.1"
93319352

9332-
create-emotion@^9.2.12:
9353+
create-emotion@^9.0.2, create-emotion@^9.2.12:
93339354
version "9.2.12"
93349355
resolved "https://registry.yarnpkg.com/create-emotion/-/create-emotion-9.2.12.tgz#0fc8e7f92c4f8bb924b0fef6781f66b1d07cb26f"
93359356
integrity sha512-P57uOF9NL2y98Xrbl2OuiDQUZ30GVmASsv5fbsjF4Hlraip2kyAvMm+2PoYUvFFw03Fhgtxk3RqZSm2/qHL9hA==
@@ -9853,6 +9874,11 @@ currently-unhandled@^0.4.1:
98539874
dependencies:
98549875
array-find-index "^1.0.1"
98559876

9877+
custom-event@^1.0.1:
9878+
version "1.0.1"
9879+
resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425"
9880+
integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=
9881+
98569882
cwebp-bin@^5.0.0:
98579883
version "5.1.0"
98589884
resolved "https://registry.yarnpkg.com/cwebp-bin/-/cwebp-bin-5.1.0.tgz#d5bea87c127358558e7bf7a90a6d440d42dcb074"
@@ -12107,6 +12133,11 @@ fd-slicer@~1.1.0:
1210712133
dependencies:
1210812134
pend "~1.2.0"
1210912135

12136+
fetch-jsonp@^1.0.6:
12137+
version "1.1.3"
12138+
resolved "https://registry.yarnpkg.com/fetch-jsonp/-/fetch-jsonp-1.1.3.tgz#9eb9e585ba08aaf700563538d17bbebbcd5a3db2"
12139+
integrity sha1-nrnlhboIqvcAVjU40Xu+u81aPbI=
12140+
1211012141
figgy-pudding@^3.5.1:
1211112142
version "3.5.1"
1211212143
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"
@@ -15094,7 +15125,7 @@ immer@^0.8.5:
1509415125
dependencies:
1509515126
cpx "^1.5.0"
1509615127

15097-
immutability-helper@^2.6.6:
15128+
immutability-helper@^2.6.6, immutability-helper@^2.7.1:
1509815129
version "2.9.1"
1509915130
resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-2.9.1.tgz#71c423ba387e67b6c6ceba0650572f2a2a6727df"
1510015131
integrity sha512-r/RmRG8xO06s/k+PIaif2r5rGc3j4Yhc01jSBfwPCXDLYZwp/yxralI37Df1mwmuzcCsen/E/ITKcTEvc1PQmQ==
@@ -22344,6 +22375,40 @@ potrace@^2.1.1:
2234422375
dependencies:
2234522376
jimp "^0.6.4"
2234622377

22378+
preact-compat@^3.15.0:
22379+
version "3.19.0"
22380+
resolved "https://registry.yarnpkg.com/preact-compat/-/preact-compat-3.19.0.tgz#a71457b6a3bf051690a4411603bc2085aa061c2f"
22381+
integrity sha512-f83A4hIhH8Uzhb9GbIcGk8SM19ffWlwP9mDaYwQdRnMdekZwcCA7eIAbeV4EMQaV9C0Yuy8iKgBAtyTKPZQt/Q==
22382+
dependencies:
22383+
immutability-helper "^2.7.1"
22384+
preact-context "^1.1.3"
22385+
preact-render-to-string "^3.8.2"
22386+
preact-transition-group "^1.1.1"
22387+
prop-types "^15.6.2"
22388+
standalone-react-addons-pure-render-mixin "^0.1.1"
22389+
22390+
preact-context@^1.1.3:
22391+
version "1.1.3"
22392+
resolved "https://registry.yarnpkg.com/preact-context/-/preact-context-1.1.3.tgz#26d06db0f39d8d9c890df5ada9a99a943586ec68"
22393+
integrity sha512-2LcpjZG6JUhBgqziVH+nJtmu9PS5KzWoFx6wX2svXw0oBHhU6e8tQZhEkKLMOAxdmj7gVzApfS/B6V+fjJ/llA==
22394+
22395+
preact-render-to-string@^3.8.2:
22396+
version "3.8.2"
22397+
resolved "https://registry.yarnpkg.com/preact-render-to-string/-/preact-render-to-string-3.8.2.tgz#bd72964d705a57da3a9e72098acaa073dd3ceff9"
22398+
integrity sha512-przuZPajiurStGgxMoJP0EJeC4xj5CgHv+M7GfF3YxAdhGgEWAkhOSE0xympAFN20uMayntBZpttIZqqLl77fw==
22399+
dependencies:
22400+
pretty-format "^3.5.1"
22401+
22402+
preact-transition-group@^1.1.1:
22403+
version "1.1.1"
22404+
resolved "https://registry.yarnpkg.com/preact-transition-group/-/preact-transition-group-1.1.1.tgz#f0a49327ea515ece34ea2be864c4a7d29e5d6e10"
22405+
integrity sha1-8KSTJ+pRXs406ivoZMSn0p5dbhA=
22406+
22407+
preact@^8.2.7:
22408+
version "8.4.2"
22409+
resolved "https://registry.yarnpkg.com/preact/-/preact-8.4.2.tgz#1263b974a17d1ea80b66590e41ef786ced5d6a23"
22410+
integrity sha512-TsINETWiisfB6RTk0wh3/mvxbGRvx+ljeBccZ4Z6MPFKgu/KFGyf2Bmw3Z/jlXhL5JlNKY6QAbA9PVyzIy9//A==
22411+
2234722412
prebuild-install@^5.3.0:
2234822413
version "5.3.0"
2234922414
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.0.tgz#58b4d8344e03590990931ee088dd5401b03004c8"
@@ -22467,6 +22532,11 @@ pretty-format@^24.8.0:
2246722532
ansi-styles "^3.2.0"
2246822533
react-is "^16.8.4"
2246922534

22535+
pretty-format@^3.5.1:
22536+
version "3.8.0"
22537+
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-3.8.0.tgz#bfbed56d5e9a776645f4b1ff7aa1a3ac4fa3c385"
22538+
integrity sha1-v77VbV6ad2ZF9LH/eqGjrE+jw4U=
22539+
2247022540
pretty-hrtime@^1.0.0, pretty-hrtime@^1.0.3:
2247122541
version "1.0.3"
2247222542
resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1"
@@ -25339,6 +25409,11 @@ scroll-behavior@^0.9.9:
2533925409
dom-helpers "^3.2.1"
2534025410
invariant "^2.2.2"
2534125411

25412+
scrollbar-width@^3.1.1:
25413+
version "3.1.1"
25414+
resolved "https://registry.yarnpkg.com/scrollbar-width/-/scrollbar-width-3.1.1.tgz#c62e63efa5934dac37b43da34f7550caca8444a2"
25415+
integrity sha1-xi5j76WTTaw3tD2jT3VQysqERKI=
25416+
2534225417
scss-tokenizer@^0.2.3:
2534325418
version "0.2.3"
2534425419
resolved "https://registry.yarnpkg.com/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz#8eb06db9a9723333824d3f5530641149847ce5d1"
@@ -26191,6 +26266,11 @@ speedometer@~0.1.2:
2619126266
resolved "https://registry.yarnpkg.com/speedometer/-/speedometer-0.1.4.tgz#9876dbd2a169d3115402d48e6ea6329c8816a50d"
2619226267
integrity sha1-mHbb0qFp0xFUAtSObqYynIgWpQ0=
2619326268

26269+
spin.js@^2.3.2:
26270+
version "2.3.2"
26271+
resolved "https://registry.yarnpkg.com/spin.js/-/spin.js-2.3.2.tgz#6caa56d520673450fd5cfbc6971e6d0772c37a1a"
26272+
integrity sha1-bKpW1SBnNFD9XPvGlx5tB3LDeho=
26273+
2619426274
split-on-first@^1.0.0:
2619526275
version "1.1.0"
2619626276
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
@@ -26331,6 +26411,11 @@ stacktrace-js@^2.0.0:
2633126411
stack-generator "^2.0.1"
2633226412
stacktrace-gps "^3.0.1"
2633326413

26414+
standalone-react-addons-pure-render-mixin@^0.1.1:
26415+
version "0.1.1"
26416+
resolved "https://registry.yarnpkg.com/standalone-react-addons-pure-render-mixin/-/standalone-react-addons-pure-render-mixin-0.1.1.tgz#3c7409f4c79c40de9ac72c616cf679a994f37551"
26417+
integrity sha1-PHQJ9MecQN6axyxhbPZ5qZTzdVE=
26418+
2633426419
state-toggle@^1.0.0:
2633526420
version "1.0.2"
2633626421
resolved "https://registry.yarnpkg.com/state-toggle/-/state-toggle-1.0.2.tgz#75e93a61944116b4959d665c8db2d243631d6ddc"
@@ -28551,7 +28636,7 @@ url-parse-lax@^3.0.0:
2855128636
dependencies:
2855228637
prepend-http "^2.0.0"
2855328638

28554-
url-parse@^1.1.8, url-parse@^1.4.3:
28639+
url-parse@^1.1.7, url-parse@^1.1.8, url-parse@^1.4.3:
2855528640
version "1.4.7"
2855628641
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.4.7.tgz#a8a83535e8c00a316e403a5db4ac1b9b853ae278"
2855728642
integrity sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==
@@ -28988,6 +29073,11 @@ web-namespaces@^1.0.0, web-namespaces@^1.1.2:
2898829073
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.3.tgz#9bbf5c99ff0908d2da031f1d732492a96571a83f"
2898929074
integrity sha512-r8sAtNmgR0WKOKOxzuSgk09JsHlpKlB+uHi937qypOu3PZ17UxPrierFKDye/uNHjNTTEshu5PId8rojIPj/tA==
2899029075

29076+
webfontloader@^1.6.27:
29077+
version "1.6.28"
29078+
resolved "https://registry.yarnpkg.com/webfontloader/-/webfontloader-1.6.28.tgz#db786129253cb6e8eae54c2fb05f870af6675bae"
29079+
integrity sha1-23hhKSU8tujq5UwvsF+HCvZnW64=
29080+
2899129081
webidl-conversions@^3.0.0:
2899229082
version "3.0.1"
2899329083
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"

0 commit comments

Comments
 (0)