Skip to content

TCA-755 Implement Survey -> dev #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@datadog/browser-logs": "^4.21.2",
"@heroicons/react": "^1.0.6",
"@sprig-technologies/sprig-browser": "^2.20.1",
"@stripe/react-stripe-js": "1.13.0",
"@stripe/stripe-js": "1.41.0",
"apexcharts": "^3.36.0",
Expand Down
40 changes: 21 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
<html lang="en">

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description"
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." />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<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" />
<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" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo_512x512.png" />
<link rel="stylesheet" href="%PUBLIC_URL%/global.css">
<!--
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description"
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." />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<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" />
<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" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo_512x512.png" />
<link rel="stylesheet" href="%PUBLIC_URL%/global.css">
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -28,13 +30,13 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Topcoder Top Technology Talent On-Demand</title>
<title>Topcoder Top Technology Talent On-Demand</title>
</head>

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

Expand Down
6 changes: 3 additions & 3 deletions src-ts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { routeContext, RouteContextData } from './lib'

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

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

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

useEffect(() => {
if (ready) {
document.getElementById('root')?.classList.add('app-ready');
document.getElementById('root')?.classList.add('app-ready')
}
}, [ready]);
}, [ready])

return (
<>
Expand Down
3 changes: 3 additions & 0 deletions src-ts/config/environments/environment.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const EnvironmentConfigDefault: EnvironmentConfigModel = {
SERVICE: 'platform-ui',
},
REAUTH_OFFSET: 55,
SPRIG: {
ENVIRONMENT_ID: 'bUcousVQ0-yF',
},
// TODO: Move stripe creds to .env file
STRIPE: {
ADMIN_TOKEN:
Expand Down
3 changes: 3 additions & 0 deletions src-ts/config/environments/environment.prod.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const EnvironmentConfigProd: EnvironmentConfigModel = {
},
DISABLED_TOOLS: [],
ENV: 'prod',
SPRIG: {
ENVIRONMENT_ID: 'a-IZBZ6-r7bU',
},
// TODO: Move stripe creds to .env file
STRIPE: {
ADMIN_TOKEN:
Expand Down
1 change: 1 addition & 0 deletions src-ts/lib/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export * from './error-functions'
export * from './file-functions'
export * from './logging-functions'
export * from './text-format-functions'
export * from './survey-functions'
export * from './user-functions'
export * from './xhr-functions'
1 change: 1 addition & 0 deletions src-ts/lib/functions/survey-functions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { triggerForUser as surveyTriggerForUser } from './survey.functions'
22 changes: 22 additions & 0 deletions src-ts/lib/functions/survey-functions/survey.functions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { sprig, SprigAPI } from '@sprig-technologies/sprig-browser'

import { EnvironmentConfig } from '../../../config'

const Sprig: SprigAPI = sprig.configure({
environmentId: EnvironmentConfig.SPRIG.ENVIRONMENT_ID,
})

export function triggerForUser(surveyName: string, userId?: number): void {

if (!userId) {
Sprig.track(surveyName)
return
}

Sprig.identifyAndTrack({
anonymousId: '',
eventName: surveyName,
metadata: undefined,
userId: `${userId}`,
})
}
3 changes: 3 additions & 0 deletions src-ts/lib/global-config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface GlobalConfig {
SERVICE: string
}
REAUTH_OFFSET: number
SPRIG: {
ENVIRONMENT_ID: string
}
STRIPE: {
ADMIN_TOKEN: string
API_KEY: string
Expand Down
1 change: 1 addition & 0 deletions src-ts/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
logError,
logInfo,
logInitialize,
surveyTriggerForUser,
textFormatDateLocaleShortString,
textFormatGetSafeString,
textFormatMoneyLocaleString,
Expand Down
Loading