Skip to content

Commit 9fc1e01

Browse files
authored
Merge pull request #431 from topcoder-platform/TCA-755_implement-survey
TCA-755 Implement Survey -> dev
2 parents 380e6ff + a19ad96 commit 9fc1e01

File tree

12 files changed

+166
-50
lines changed

12 files changed

+166
-50
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"@datadog/browser-logs": "^4.21.2",
2525
"@heroicons/react": "^1.0.6",
26+
"@sprig-technologies/sprig-browser": "^2.20.1",
2627
"@stripe/react-stripe-js": "1.13.0",
2728
"@stripe/stripe-js": "1.41.0",
2829
"apexcharts": "^3.36.0",

public/index.html

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
<html lang="en">
33

44
<head>
5-
<meta charset="utf-8" />
6-
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<meta name="theme-color" content="#000000" />
9-
<meta name="description"
10-
content="Topcoder is home to the world’s largest community of designers, developers, and data scientists. Allowing you the freedom to start and execute faster." />
11-
<link rel="preconnect" href="https://fonts.googleapis.com" />
12-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
13-
<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Barlow+Condensed:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
14-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Barlow+Condensed:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
15-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo_512x512.png" />
16-
<link rel="stylesheet" href="%PUBLIC_URL%/global.css">
17-
<!--
5+
<meta charset="utf-8" />
6+
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<meta name="theme-color" content="#000000" />
9+
<meta name="description"
10+
content="Topcoder is home to the world’s largest community of designers, developers, and data scientists. Allowing you the freedom to start and execute faster." />
11+
<link rel="preconnect" href="https://fonts.googleapis.com" />
12+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
13+
<link rel="preload" as="style"
14+
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Barlow+Condensed:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
15+
<link rel="stylesheet"
16+
href="https://fonts.googleapis.com/css2?family=Barlow:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Barlow+Condensed:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" />
17+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo_512x512.png" />
18+
<link rel="stylesheet" href="%PUBLIC_URL%/global.css">
19+
<!--
1820
manifest.json provides metadata used when your web app is installed on a
1921
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
2022
-->
21-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
22-
<!--
23+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
24+
<!--
2325
Notice the use of %PUBLIC_URL% in the tags above.
2426
It will be replaced with the URL of the `public` folder during the build.
2527
Only files inside the `public` folder can be referenced from the HTML.
@@ -28,13 +30,13 @@
2830
work correctly both with client-side routing and a non-root public URL.
2931
Learn how to configure a non-root public URL by running `npm run build`.
3032
-->
31-
<title>Topcoder Top Technology Talent On-Demand</title>
33+
<title>Topcoder Top Technology Talent On-Demand</title>
3234
</head>
3335

3436
<body>
35-
<noscript>You need to enable JavaScript to run this app.</noscript>
36-
<div id="root" data-id="root"></div>
37-
<!--
37+
<noscript>You need to enable JavaScript to run this app.</noscript>
38+
<div id="root" data-id="root"></div>
39+
<!--
3840
This HTML file is a template.
3941
If you open it directly in the browser, you will see an empty page.
4042

src-ts/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { routeContext, RouteContextData } from './lib'
77

88
const App: FC<{}> = () => {
99

10-
const [ready, setReady]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
10+
const [ready, setReady]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)
1111
const { allRoutes, getRouteElement }: RouteContextData = useContext(routeContext)
1212

1313
const routeElements: Array<ReactElement> = allRoutes
@@ -19,9 +19,9 @@ const App: FC<{}> = () => {
1919

2020
useEffect(() => {
2121
if (ready) {
22-
document.getElementById('root')?.classList.add('app-ready');
22+
document.getElementById('root')?.classList.add('app-ready')
2323
}
24-
}, [ready]);
24+
}, [ready])
2525

2626
return (
2727
<>

src-ts/config/environments/environment.default.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const EnvironmentConfigDefault: EnvironmentConfigModel = {
2020
SERVICE: 'platform-ui',
2121
},
2222
REAUTH_OFFSET: 55,
23+
SPRIG: {
24+
ENVIRONMENT_ID: 'bUcousVQ0-yF',
25+
},
2326
// TODO: Move stripe creds to .env file
2427
STRIPE: {
2528
ADMIN_TOKEN:

src-ts/config/environments/environment.prod.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export const EnvironmentConfigProd: EnvironmentConfigModel = {
1818
},
1919
DISABLED_TOOLS: [],
2020
ENV: 'prod',
21+
SPRIG: {
22+
ENVIRONMENT_ID: 'a-IZBZ6-r7bU',
23+
},
2124
// TODO: Move stripe creds to .env file
2225
STRIPE: {
2326
ADMIN_TOKEN:

src-ts/lib/functions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export * from './error-functions'
1010
export * from './file-functions'
1111
export * from './logging-functions'
1212
export * from './text-format-functions'
13+
export * from './survey-functions'
1314
export * from './user-functions'
1415
export * from './xhr-functions'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { triggerForUser as surveyTriggerForUser } from './survey.functions'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { sprig, SprigAPI } from '@sprig-technologies/sprig-browser'
2+
3+
import { EnvironmentConfig } from '../../../config'
4+
5+
const Sprig: SprigAPI = sprig.configure({
6+
environmentId: EnvironmentConfig.SPRIG.ENVIRONMENT_ID,
7+
})
8+
9+
export function triggerForUser(surveyName: string, userId?: number): void {
10+
11+
if (!userId) {
12+
Sprig.track(surveyName)
13+
return
14+
}
15+
16+
Sprig.identifyAndTrack({
17+
anonymousId: '',
18+
eventName: surveyName,
19+
metadata: undefined,
20+
userId: `${userId}`,
21+
})
22+
}

src-ts/lib/global-config.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export interface GlobalConfig {
1616
SERVICE: string
1717
}
1818
REAUTH_OFFSET: number
19+
SPRIG: {
20+
ENVIRONMENT_ID: string
21+
}
1922
STRIPE: {
2023
ADMIN_TOKEN: string
2124
API_KEY: string

src-ts/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export {
1818
logError,
1919
logInfo,
2020
logInitialize,
21+
surveyTriggerForUser,
2122
textFormatDateLocaleShortString,
2223
textFormatGetSafeString,
2324
textFormatMoneyLocaleString,

0 commit comments

Comments
 (0)