diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c230b1d8..6a74a8ad7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -261,6 +261,7 @@ workflows: - dev - justin_fixes - talent_search_fixes + - PROD-4398_integrate-userflow-remove-sprig - deployQa: context: org-global diff --git a/package.json b/package.json index 02f4a2ec9..2ef92fbc4 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "tc-auth-lib": "topcoder-platform/tc-auth-lib#1.0.26", "turndown": "^4.0.2", "typescript": "^4.8.4", - "universal-navigation": "https://github.com/topcoder-platform/universal-navigation#9e62ddc61d", + "universal-navigation": "https://github.com/topcoder-platform/universal-navigation#9fc50d938be7182", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/src/apps/accounts/src/config/constants.ts b/src/apps/accounts/src/config/constants.ts index 34fea4367..2a9a036cd 100644 --- a/src/apps/accounts/src/config/constants.ts +++ b/src/apps/accounts/src/config/constants.ts @@ -1 +1,3 @@ -export const SPRIG_CES_SURVEY_ID = 'onAccountSettingsUpdate' +import { EnvironmentConfig } from '~/config' + +export const CES_SURVEY_ID = EnvironmentConfig.USERFLOW_SURVEYS.ACCOUNT_SETTINGS diff --git a/src/apps/accounts/src/lib/index.ts b/src/apps/accounts/src/lib/index.ts index 288161703..81de86514 100644 --- a/src/apps/accounts/src/lib/index.ts +++ b/src/apps/accounts/src/lib/index.ts @@ -1,4 +1,4 @@ export * from './accounts-swr' export * from './components' export * from './assets' -export * from './sprig-survey' +export * from './userflow-survey' diff --git a/src/apps/accounts/src/lib/sprig-survey.ts b/src/apps/accounts/src/lib/sprig-survey.ts deleted file mode 100644 index 15998d2b7..000000000 --- a/src/apps/accounts/src/lib/sprig-survey.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { sprigTriggerForUser } from '~/libs/shared' -import { UserProfile } from '~/libs/core' - -import { SPRIG_CES_SURVEY_ID } from '../config' - -export function triggerSprigSurvey({ userId }: UserProfile): void { - sprigTriggerForUser(SPRIG_CES_SURVEY_ID, userId) -} diff --git a/src/apps/accounts/src/lib/userflow-survey.ts b/src/apps/accounts/src/lib/userflow-survey.ts new file mode 100644 index 000000000..b86e2d62e --- /dev/null +++ b/src/apps/accounts/src/lib/userflow-survey.ts @@ -0,0 +1,9 @@ +import { TcUniNavFn } from 'universal-navigation' + +import { CES_SURVEY_ID } from '../config' + +declare let tcUniNav: TcUniNavFn + +export function triggerSurvey(): void { + tcUniNav('triggerFlow', CES_SURVEY_ID, {}) +} diff --git a/src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx b/src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx index eb5123500..90b2f9b1e 100644 --- a/src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx +++ b/src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx @@ -2,7 +2,7 @@ import { Dispatch, FC, SetStateAction, useState } from 'react' import { BaseModal, Button, Collapsible } from '~/libs/ui' import { authUrlLogout, updatePrimaryMemberRoleAsync, UserProfile } from '~/libs/core' -import { triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { triggerSurvey } from '~/apps/accounts/src/lib' import styles from './AccountRole.module.scss' @@ -36,7 +36,7 @@ const AccountRole: FC = (props: AccountRoleProps) => { .then(() => { setMemberRole(newRole) setIsRoleChangeConfirmed(true) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .finally(() => { setIsUpdating(false) diff --git a/src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx b/src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx index 9eb2799a2..86a03a005 100644 --- a/src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx +++ b/src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx @@ -13,7 +13,7 @@ import { useCountryLookup, UserProfile, } from '~/libs/core' -import { triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { triggerSurvey } from '~/apps/accounts/src/lib' import styles from './MemberAddress.module.scss' @@ -88,7 +88,7 @@ const MemberAddress: FC = (props: MemberAddressProps) => { .then(() => { toast.success('Your account has been updated.', { position: toast.POSITION.BOTTOM_RIGHT }) setFormErrors({}) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Something went wrong. Please try again.', { position: toast.POSITION.BOTTOM_RIGHT }) diff --git a/src/apps/accounts/src/settings/tabs/account/security/Security.tsx b/src/apps/accounts/src/settings/tabs/account/security/Security.tsx index 42b3998e9..f8a608d40 100644 --- a/src/apps/accounts/src/settings/tabs/account/security/Security.tsx +++ b/src/apps/accounts/src/settings/tabs/account/security/Security.tsx @@ -4,7 +4,7 @@ import { KeyedMutator } from 'swr' import { noop } from 'lodash' import { Button, Collapsible, FormToggleSwitch, IconSolid, Tooltip } from '~/libs/ui' -import { diceIdLogo, MFAImage, SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { diceIdLogo, MFAImage, SettingSection, triggerSurvey } from '~/apps/accounts/src/lib' import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core' import { DiceSetupModal } from './dice-setup-modal' @@ -39,7 +39,7 @@ const Security: FC = (props: SecurityProps) => { .then(() => { setMFAEnabled(!mfaEnabled) toast.success('Your Multi Factor Authentication (MFA) status was updated.') - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Something went wrong. Please try again later.') diff --git a/src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx b/src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx index 1d0997664..08237cb34 100644 --- a/src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx +++ b/src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx @@ -17,7 +17,7 @@ import { UserTrait, UserTraits, } from '~/libs/core' -import { SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { SettingSection, triggerSurvey } from '~/apps/accounts/src/lib' import { UserAndPassFromConfig } from './user-and-pass.form.config' import styles from './UserAndPassword.module.scss' @@ -82,7 +82,7 @@ const UserAndPassword: FC = (props: UserAndPasswordProps) setUserConsent(!userConsent) mutateTraits() toast.success('User consent updated successfully.') - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Failed to update user consent.') diff --git a/src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx b/src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx index ae5101f90..7ce18be7e 100644 --- a/src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx +++ b/src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx @@ -7,7 +7,7 @@ import { MemberEmailPreferenceAPI, updateMemberEmailPreferencesAsync, useMemberE import { Button, FormToggleSwitch, LoadingSpinner } from '~/libs/ui' import { EnvironmentConfig } from '~/config' -import { EmailIcon, ForumIcon, SettingSection, triggerSprigSurvey } from '../../../lib' +import { EmailIcon, ForumIcon, SettingSection, triggerSurvey } from '../../../lib' import { newsletters, programs, subscribeLink, unsubscribeLink } from './preferences.config' import styles from './PreferencesTab.module.scss' @@ -43,7 +43,7 @@ const PreferencesTab: FC = (props: PreferencesTabProps) => .then(() => { toast.success('Your email preferences ware updated.') mutateEmailPreferencesData() - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Something went wrong. Please try again later.') diff --git a/src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx b/src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx index 447ee24b6..28cf80e93 100644 --- a/src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx +++ b/src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx @@ -5,7 +5,7 @@ import { toast } from 'react-toastify' import { updateOrCreateMemberTraitsAsync, useMemberTraits, UserProfile, UserTraits } from '~/libs/core' import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui' -import { triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { triggerSurvey } from '~/apps/accounts/src/lib' import { communitiesConfig } from './communities-config' import styles from './Communities.module.scss' @@ -49,7 +49,7 @@ const Communities: FC = (props: CommunitiesProps) => { setMemberCommunities(updatedCommunities) mutateTraits() toast.success('Communities updated successfully.') - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Failed to update user Communities.') diff --git a/src/apps/accounts/src/settings/tabs/tcandyou/tracks/Tracks.tsx b/src/apps/accounts/src/settings/tabs/tcandyou/tracks/Tracks.tsx index 58243df74..99982750f 100644 --- a/src/apps/accounts/src/settings/tabs/tcandyou/tracks/Tracks.tsx +++ b/src/apps/accounts/src/settings/tabs/tcandyou/tracks/Tracks.tsx @@ -9,7 +9,7 @@ import { DesignTrackIcon, DevelopmentTrackIcon, SettingSection, - triggerSprigSurvey, + triggerSurvey, } from '~/apps/accounts/src/lib' import styles from './Tracks.module.scss' @@ -54,7 +54,7 @@ const Tracks: FC = (props: TracksProps) => { } as any, }) toast.success('Your profile has been updated.') - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Failed to update your profile.') diff --git a/src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx b/src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx index 1415d58f2..14e8dfc29 100644 --- a/src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx +++ b/src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx @@ -20,7 +20,7 @@ import { SettingSection, SmartphoneIcon, TabletIcon, - triggerSprigSurvey, + triggerSurvey, WearableIcon, } from '~/apps/accounts/src/lib' @@ -172,7 +172,7 @@ const Devices: FC = (props: DevicesProps) => { .then(() => { toast.success('Device deleted successfully') setDeviceTypesData(updatedDeviceTypesData) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error deleting Device') @@ -278,7 +278,7 @@ const Devices: FC = (props: DevicesProps) => { ...updatedDeviceTypesData || [], deviceUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error updating Device') diff --git a/src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx b/src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx index b7cca7170..bde91ea72 100644 --- a/src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx +++ b/src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx @@ -12,7 +12,7 @@ import { OtherServiceProviderIcon, SettingSection, TelevisionServiceProviderIcon, - triggerSprigSurvey, + triggerSurvey, } from '~/apps/accounts/src/lib' import { serviceProviderTypes } from './service-provider-types.config' @@ -151,7 +151,7 @@ const ServiceProvider: FC = (props: ServiceProviderProps) ...updatedServiceProviderTypesData || [], serviceProviderTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error updating Service Provider') @@ -180,7 +180,7 @@ const ServiceProvider: FC = (props: ServiceProviderProps) ...serviceProviderTypesData || [], serviceProviderTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error adding new Service Provider') @@ -220,7 +220,7 @@ const ServiceProvider: FC = (props: ServiceProviderProps) .then(() => { toast.success('Service Provider deleted successfully') setServiceProviderTypesData(updatedServiceProviderTypesData) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error deleting Service Provider') diff --git a/src/apps/accounts/src/settings/tabs/tools/software/Software.tsx b/src/apps/accounts/src/settings/tabs/tools/software/Software.tsx index 20f052af1..368ca63b6 100644 --- a/src/apps/accounts/src/settings/tabs/tools/software/Software.tsx +++ b/src/apps/accounts/src/settings/tabs/tools/software/Software.tsx @@ -5,7 +5,7 @@ import classNames from 'classnames' import { updateMemberTraitsAsync, updateOrCreateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core' import { Button, Collapsible, ConfirmModal, IconOutline, InputSelect, InputText } from '~/libs/ui' -import { SettingSection, SoftwareIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { SettingSection, SoftwareIcon, triggerSurvey } from '~/apps/accounts/src/lib' import { softwareTypes } from './software-types.config' import styles from './Software.module.scss' @@ -139,7 +139,7 @@ const Software: FC = (props: SoftwareProps) => { ...updatedSoftwareTypesData || [], softwareTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error updating software') @@ -168,7 +168,7 @@ const Software: FC = (props: SoftwareProps) => { ...softwareTypesData || [], softwareTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error adding new software') @@ -208,7 +208,7 @@ const Software: FC = (props: SoftwareProps) => { .then(() => { toast.success('Software deleted successfully') setSoftwareTypesData(updatedSoftwareTypesData) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error deleting software') diff --git a/src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx b/src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx index b6b9698e5..47b512fe7 100644 --- a/src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx +++ b/src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx @@ -5,7 +5,7 @@ import classNames from 'classnames' import { updateMemberTraitsAsync, updateOrCreateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core' import { Button, Collapsible, ConfirmModal, IconOutline, InputText } from '~/libs/ui' -import { SettingSection, SubscriptionsIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib' +import { SettingSection, SubscriptionsIcon, triggerSurvey } from '~/apps/accounts/src/lib' import styles from './Subscriptions.module.scss' @@ -124,7 +124,7 @@ const Subscriptions: FC = (props: SubscriptionsProps) => { ...updatedSubscriptionsTypesData || [], softwareTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error updating subscription') @@ -153,7 +153,7 @@ const Subscriptions: FC = (props: SubscriptionsProps) => { ...subscriptionsTypesData || [], softwareTypeUpdate, ]) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error adding new subscription') @@ -193,7 +193,7 @@ const Subscriptions: FC = (props: SubscriptionsProps) => { .then(() => { toast.success('Subscription deleted successfully') setSubscriptionsTypesData(updatedSubscriptionsTypesData) - triggerSprigSurvey(props.profile) + triggerSurvey() }) .catch(() => { toast.error('Error deleting subscription') diff --git a/src/apps/learn/src/free-code-camp/FreeCodeCamp.tsx b/src/apps/learn/src/free-code-camp/FreeCodeCamp.tsx index e18ef45e2..819cad557 100644 --- a/src/apps/learn/src/free-code-camp/FreeCodeCamp.tsx +++ b/src/apps/learn/src/free-code-camp/FreeCodeCamp.tsx @@ -25,14 +25,13 @@ import { ProfileContextData, UserRole, } from '~/libs/core' -import { sprigTriggerForUser, textFormatGetSafeString } from '~/libs/shared' +import { textFormatGetSafeString } from '~/libs/shared' import { CoursesProviderData, LearnLesson, LearnModule, LearnModuleProgress, - LearnModuleStatus, LearnUserCertificationProgress, LessonProviderData, PageTitle, @@ -275,10 +274,6 @@ const FreeCodeCamp: FC<{}> = () => { return } - // get the current module as it exists before it's completed - const currentModule: LearnModuleProgress | undefined = getModuleFromProgress(certificateProgress) - const certWasInProgress: boolean = currentModule?.moduleStatus !== LearnModuleStatus.completed - userCertificationProgressUpdateAsync( certificateProgress.id, UserCertificationUpdateProgressActions.completeLesson, @@ -286,8 +281,6 @@ const FreeCodeCamp: FC<{}> = () => { ) .then((progress: LearnUserCertificationProgress) => { setCertificateProgress(progress) - handleSurvey(certWasInProgress, progress) - }) // eslint-disable-next-line react-hooks/exhaustive-deps }, 30), [ @@ -296,42 +289,6 @@ const FreeCodeCamp: FC<{}> = () => { moduleParam, ]) - function getModuleFromProgress(certProgress: LearnUserCertificationProgress): - LearnModuleProgress | undefined { - - return certProgress.moduleProgresses.find(m => m.module === moduleParam) - } - - function handleSurvey(certWasInProgress: boolean, progress: LearnUserCertificationProgress): void { - - // if the current module wasn't in progress, there's nothing to do - if (!certWasInProgress) { - return - } - - // if the updated module isn't completed now, there's nothing to do - const moduleResult: LearnModuleProgress | undefined = getModuleFromProgress(progress) - if (moduleResult?.moduleStatus !== LearnModuleStatus.completed) { - return - } - - // if there are any other modules that have been completed, there's nothing to do - if (progress.moduleProgresses - .some(m => m.module !== moduleParam && m.moduleStatus === LearnModuleStatus.completed) - ) { - return - } - - // This is the last lesson to be completed in the first module completed, - // so it's time to trigger the survey - - // NOTE: We have to add a delay, otherwise the survey closes when the user - // is automatically redirected to the next lesson. - setTimeout(() => { - sprigTriggerForUser('TCA First Module Completed', profile?.userId) - }, 1000) - } - /** * Handle the navigation away from the last step of the course in the FCC frame * @returns diff --git a/src/apps/platform/src/components/app-header/AppHeader.tsx b/src/apps/platform/src/components/app-header/AppHeader.tsx index ca0d7dd7d..48d81e331 100644 --- a/src/apps/platform/src/components/app-header/AppHeader.tsx +++ b/src/apps/platform/src/components/app-header/AppHeader.tsx @@ -91,9 +91,6 @@ const AppHeader: FC<{}> = () => { navElementId, { handleNavigation: navigationHandler, - integrations: { - sprig: 'disable', - }, onReady() { setReady(true) }, showSalesCta: routeNavConfigs?.showSalesCta, signIn() { window.location.href = authUrlLogin() }, diff --git a/src/apps/profiles/src/config/constants.ts b/src/apps/profiles/src/config/constants.ts index fc99bcd02..f5a2b1cf5 100644 --- a/src/apps/profiles/src/config/constants.ts +++ b/src/apps/profiles/src/config/constants.ts @@ -1,3 +1,5 @@ +import { EnvironmentConfig } from '~/config' + export enum TRACKS_PROFILE_MAP { DEVELOP = 'Developer', DESIGN = 'Designer', @@ -21,4 +23,4 @@ export enum profileEditModes { onboardingCompleted = 'onboardingCompleted', } -export const SPRIG_CES_SURVEY_ID = 'onProfileUpdate' +export const CES_SURVEY_ID = EnvironmentConfig.USERFLOW_SURVEYS.PROFILES diff --git a/src/apps/profiles/src/lib/index.ts b/src/apps/profiles/src/lib/index.ts index ff0eaff29..419187c80 100644 --- a/src/apps/profiles/src/lib/index.ts +++ b/src/apps/profiles/src/lib/index.ts @@ -1,2 +1,2 @@ export * from './helpers' -export * from './sprig-survey' +export * from './userflow-survey' diff --git a/src/apps/profiles/src/lib/sprig-survey.ts b/src/apps/profiles/src/lib/sprig-survey.ts deleted file mode 100644 index 15998d2b7..000000000 --- a/src/apps/profiles/src/lib/sprig-survey.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { sprigTriggerForUser } from '~/libs/shared' -import { UserProfile } from '~/libs/core' - -import { SPRIG_CES_SURVEY_ID } from '../config' - -export function triggerSprigSurvey({ userId }: UserProfile): void { - sprigTriggerForUser(SPRIG_CES_SURVEY_ID, userId) -} diff --git a/src/apps/profiles/src/lib/userflow-survey.ts b/src/apps/profiles/src/lib/userflow-survey.ts new file mode 100644 index 000000000..b86e2d62e --- /dev/null +++ b/src/apps/profiles/src/lib/userflow-survey.ts @@ -0,0 +1,9 @@ +import { TcUniNavFn } from 'universal-navigation' + +import { CES_SURVEY_ID } from '../config' + +declare let tcUniNav: TcUniNavFn + +export function triggerSurvey(): void { + tcUniNav('triggerFlow', CES_SURVEY_ID, {}) +} diff --git a/src/apps/profiles/src/member-profile/MemberProfilePage.tsx b/src/apps/profiles/src/member-profile/MemberProfilePage.tsx index 206207faf..648c928b2 100644 --- a/src/apps/profiles/src/member-profile/MemberProfilePage.tsx +++ b/src/apps/profiles/src/member-profile/MemberProfilePage.tsx @@ -6,7 +6,7 @@ import { profileContext, ProfileContextData, profileGetPublicAsync, UserProfile import { TALENT_SEARCH_PATHS } from '~/apps/talent-search' import { LoadingSpinner } from '~/libs/ui' -import { notifyUniNavi, triggerSprigSurvey } from '../lib' +import { notifyUniNavi, triggerSurvey } from '../lib' import { ProfilePageLayout } from './page-layout' import { MemberProfileContextValue, useMemberProfileContext } from './MemberProfile.context' @@ -50,7 +50,7 @@ const MemberProfilePage: FC<{}> = () => { setProfile({ ...userProfile } as UserProfile) if (userProfile) { notifyUniNavi(userProfile) - triggerSprigSurvey(userProfile) + triggerSurvey() } }) ), []) diff --git a/src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx b/src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx index 103353020..0c7f35983 100644 --- a/src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx +++ b/src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx @@ -14,7 +14,7 @@ import { import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../config' import { AddButton, EditMemberPropertyBtn, EmptySection } from '../../components' import { MemberTCAInfo } from '../tca-info' -import { triggerSprigSurvey } from '../../lib' +import { triggerSurvey } from '../../lib' import { ModifyEducationModal } from './ModifyEducationModal' import { EducationCard } from './EducationCard' @@ -72,7 +72,7 @@ const EducationAndCertifications: FC = (props: setIsEditMode(false) mutateTraits() props.refreshProfile(props.profile.handle) - triggerSprigSurvey(props.profile) + triggerSurvey() }, 1000) } diff --git a/src/apps/profiles/src/member-profile/languages/MemberLanguages.tsx b/src/apps/profiles/src/member-profile/languages/MemberLanguages.tsx index 41c3357c6..8abb48c2f 100644 --- a/src/apps/profiles/src/member-profile/languages/MemberLanguages.tsx +++ b/src/apps/profiles/src/member-profile/languages/MemberLanguages.tsx @@ -5,7 +5,7 @@ import { MemberTraitsAPI, useMemberTraits, UserProfile, UserTrait, UserTraitIds import { AddButton, EditMemberPropertyBtn } from '../../components' import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../config' -import { notifyUniNavi, triggerSprigSurvey } from '../../lib' +import { notifyUniNavi, triggerSurvey } from '../../lib' import { ModifyLanguagesModal } from './ModifyLanguagesModal' import styles from './MemberLanguages.module.scss' @@ -50,7 +50,7 @@ const MemberLanguages: FC = (props: MemberLanguagesProps) setIsEditMode(false) mutateTraits() notifyUniNavi(props.profile) - triggerSprigSurvey(props.profile) + triggerSurvey() }, 1000) } diff --git a/src/apps/profiles/src/member-profile/links/MemberLinks.tsx b/src/apps/profiles/src/member-profile/links/MemberLinks.tsx index e7e0a4fed..e7b1f4a75 100644 --- a/src/apps/profiles/src/member-profile/links/MemberLinks.tsx +++ b/src/apps/profiles/src/member-profile/links/MemberLinks.tsx @@ -11,7 +11,7 @@ import { import { AddButton, EditMemberPropertyBtn } from '../../components' import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../config' -import { notifyUniNavi, triggerSprigSurvey } from '../../lib' +import { notifyUniNavi, triggerSurvey } from '../../lib' import { ModifyMemberLinksModal } from './ModifyMemberLinksModal' import { ReactComponent as GitHubLinkIcon } from './assets/github-link-icon.svg' @@ -80,7 +80,7 @@ const MemberLinks: FC = (props: MemberLinksProps) => { setIsEditMode(false) mutateTraits() notifyUniNavi(props.profile) - triggerSprigSurvey(props.profile) + triggerSurvey() }, 1000) } diff --git a/src/apps/profiles/src/member-profile/profile-header/OpenForGigs/OpenForGigs.tsx b/src/apps/profiles/src/member-profile/profile-header/OpenForGigs/OpenForGigs.tsx index 466b697d6..d3e70563d 100644 --- a/src/apps/profiles/src/member-profile/profile-header/OpenForGigs/OpenForGigs.tsx +++ b/src/apps/profiles/src/member-profile/profile-header/OpenForGigs/OpenForGigs.tsx @@ -8,7 +8,7 @@ import { useMemberTraits, UserProfile, UserTrait, UserTraitIds, UserTraits } fro import { EditMemberPropertyBtn } from '../../../components' import { OpenForGigsModifyModal } from '../OpenForGigsModifyModal' import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../../config' -import { triggerSprigSurvey } from '../../../lib' +import { triggerSurvey } from '../../../lib' import styles from './OpenForGigs.module.scss' @@ -57,7 +57,7 @@ const OpenForGigs: FC = (props: OpenForGigsProps) => { setIsEditMode(false) mutateTraits() props.refreshProfile(props.profile.handle) - triggerSprigSurvey(props.profile) + triggerSurvey() }, 1000) } diff --git a/src/apps/profiles/src/member-profile/work-expirence/WorkExpirence.tsx b/src/apps/profiles/src/member-profile/work-expirence/WorkExpirence.tsx index e39d8cc7f..296dcfa21 100644 --- a/src/apps/profiles/src/member-profile/work-expirence/WorkExpirence.tsx +++ b/src/apps/profiles/src/member-profile/work-expirence/WorkExpirence.tsx @@ -4,7 +4,7 @@ import { useSearchParams } from 'react-router-dom' import { MemberTraitsAPI, useMemberTraits, UserProfile, UserTrait, UserTraitIds } from '~/libs/core' import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../config' -import { triggerSprigSurvey } from '../../lib' +import { triggerSurvey } from '../../lib' import { AddButton, EditMemberPropertyBtn, EmptySection } from '../../components' import { ModifyWorkExpirenceModal } from './ModifyWorkExpirenceModal' @@ -52,7 +52,7 @@ const WorkExpirence: FC = (props: WorkExpirenceProps) => { setIsEditMode(false) mutateTraits() props.refreshProfile(props.profile.handle) - triggerSprigSurvey(props.profile) + triggerSurvey() }, 1000) } diff --git a/src/apps/talent-search/src/config/constants.ts b/src/apps/talent-search/src/config/constants.ts index b70da38c4..a9f8b1fa1 100644 --- a/src/apps/talent-search/src/config/constants.ts +++ b/src/apps/talent-search/src/config/constants.ts @@ -1,2 +1,4 @@ -export const SPRIG_CES_SURVEY_ID = 'onTalentSearchResults' +import { EnvironmentConfig } from '~/config' + +export const CES_SURVEY_ID = EnvironmentConfig.USERFLOW_SURVEYS.TALENTSEARCH export const SKILL_SEARCH_LIMIT = 7 diff --git a/src/apps/talent-search/src/lib/services/index.ts b/src/apps/talent-search/src/lib/services/index.ts index 902d3e2be..58af3d16f 100644 --- a/src/apps/talent-search/src/lib/services/index.ts +++ b/src/apps/talent-search/src/lib/services/index.ts @@ -1,2 +1,2 @@ export * from './use-fetch-talent-matches' -export * from './sprig-survey' +export * from './userflow-survey' diff --git a/src/apps/talent-search/src/lib/services/sprig-survey.ts b/src/apps/talent-search/src/lib/services/sprig-survey.ts deleted file mode 100644 index 622b6b54e..000000000 --- a/src/apps/talent-search/src/lib/services/sprig-survey.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { sprigTriggerForUser } from '~/libs/shared' -import { UserProfile } from '~/libs/core' - -import { SPRIG_CES_SURVEY_ID } from '../../config' - -export function triggerSprigSurvey(profile?: UserProfile): void { - if (profile?.userId) { - sprigTriggerForUser(SPRIG_CES_SURVEY_ID, profile?.userId) - } else { - sprigTriggerForUser(SPRIG_CES_SURVEY_ID) - } -} diff --git a/src/apps/talent-search/src/lib/services/userflow-survey.ts b/src/apps/talent-search/src/lib/services/userflow-survey.ts new file mode 100644 index 000000000..990f3384a --- /dev/null +++ b/src/apps/talent-search/src/lib/services/userflow-survey.ts @@ -0,0 +1,9 @@ +import { TcUniNavFn } from 'universal-navigation' + +import { CES_SURVEY_ID } from '../../config' + +declare let tcUniNav: TcUniNavFn + +export function triggerSurvey(): void { + tcUniNav('triggerFlow', CES_SURVEY_ID, {}) +} diff --git a/src/apps/talent-search/src/routes/search-page/SearchPage.tsx b/src/apps/talent-search/src/routes/search-page/SearchPage.tsx index 98dc7c5b1..501a1e4a6 100644 --- a/src/apps/talent-search/src/routes/search-page/SearchPage.tsx +++ b/src/apps/talent-search/src/routes/search-page/SearchPage.tsx @@ -1,7 +1,6 @@ -import { FC, useContext, useEffect, useRef, useState } from 'react' +import { FC, useEffect, useRef, useState } from 'react' import { useNavigate, useSearchParams } from 'react-router-dom' -import { profileContext, ProfileContextData } from '~/libs/core' import { ContentLayout, IconOutline } from '~/libs/ui' import { Skill } from '~/libs/shared' @@ -9,12 +8,12 @@ import { SearchInput } from '../../components/search-input' import { PopularSkills } from '../../components/popular-skills' import { TALENT_SEARCH_PATHS } from '../../talent-search.routes' import { encodeUrlQuerySearch } from '../../lib/utils/search-query' -import { triggerSprigSurvey } from '../../lib/services' +import { triggerSurvey } from '../../lib/services' import styles from './SearchPage.module.scss' export const SearchPage: FC = () => { - const sprigFlag = useRef(false) + const surveyFlag = useRef(false) const [params] = useSearchParams() const isMissingProfileRoute = params.get('memberNotFound') !== null @@ -23,8 +22,6 @@ export const SearchPage: FC = () => { const navigate = useNavigate() const [skillsFilter, setSkillsFilter] = useState([]) - const { profile }: ProfileContextData = useContext(profileContext) - function navigateToResults(): void { const searchParams = encodeUrlQuerySearch(skillsFilter) navigate(`${TALENT_SEARCH_PATHS.results}?${searchParams}`) @@ -36,16 +33,12 @@ export const SearchPage: FC = () => { } useEffect(() => { - if (!sprigFlag.current && skillsFilter && skillsFilter.length > 0) { - if (profile?.userId) { - triggerSprigSurvey(profile) - } else { - triggerSprigSurvey() - } + if (!surveyFlag.current && skillsFilter && skillsFilter.length > 0) { + triggerSurvey() - sprigFlag.current = true + surveyFlag.current = true } - }, [profile, skillsFilter]) + }, [skillsFilter]) function renderHeader(): JSX.Element { return isMissingProfileRoute ? ( diff --git a/src/config/environments/default.env.ts b/src/config/environments/default.env.ts index 078849971..cd4d469e4 100644 --- a/src/config/environments/default.env.ts +++ b/src/config/environments/default.env.ts @@ -72,3 +72,9 @@ export const DICE_VERIFY_URL = get({ export const RESTRICT_TALENT_SEARCH = getReactEnv('RESTRICT_TALENT_SEARCH', false) export const SEGMENT_ANALYTICS_KEY = getReactEnv('SEGMENT_ANALYTICS_KEY', undefined) + +export const USERFLOW_SURVEYS = { + ACCOUNT_SETTINGS: getReactEnv('USERFLOW_SURVEY_ACCOUNT_SETTINGS', '3e704fe0-dff4-4af4-abee-383ed162729e'), + PROFILES: getReactEnv('USERFLOW_SURVEY_PROFILES', '5cfae36f-0700-41c4-8938-0add4037acb2'), + TALENTSEARCH: getReactEnv('USERFLOW_SURVEY_TALENTSEARCH', 'd1030c93-dd36-4ae0-b5d0-95004b8e9d32'), +} diff --git a/src/config/environments/global-config.model.ts b/src/config/environments/global-config.model.ts index 26b44c240..8e6f23699 100644 --- a/src/config/environments/global-config.model.ts +++ b/src/config/environments/global-config.model.ts @@ -18,9 +18,6 @@ export interface GlobalConfig { SERVICE: string } REAUTH_OFFSET: number - SPRIG: { - ENVIRONMENT_ID: string | undefined - } STRIPE: { API_KEY: string API_VERSION: string | undefined @@ -42,4 +39,9 @@ export interface GlobalConfig { DICE_VERIFY_URL: string RESTRICT_TALENT_SEARCH: boolean SEGMENT_ANALYTICS_KEY: string + USERFLOW_SURVEYS: { + ACCOUNT_SETTINGS: string + PROFILES: string + TALENTSEARCH: string + } } diff --git a/src/libs/shared/lib/utils/index.ts b/src/libs/shared/lib/utils/index.ts index 15b86a7bf..770e9f178 100644 --- a/src/libs/shared/lib/utils/index.ts +++ b/src/libs/shared/lib/utils/index.ts @@ -2,6 +2,5 @@ export * from './copy-text-to-clipboard' export * from './files' export * from './generic-data-object.type' export * from './handle-error' -export * from './sprig-trigger' export * from './string' export * from './text-format' diff --git a/src/libs/shared/lib/utils/sprig-trigger.ts b/src/libs/shared/lib/utils/sprig-trigger.ts deleted file mode 100644 index 843e3edbe..000000000 --- a/src/libs/shared/lib/utils/sprig-trigger.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { sprig, SprigAPI } from '@sprig-technologies/sprig-browser' -import { EnvironmentConfig } from '~/config' - -const sprigEnvId: string | undefined = EnvironmentConfig.SPRIG.ENVIRONMENT_ID - -const Sprig: SprigAPI | undefined = sprigEnvId ? sprig.configure({ - environmentId: EnvironmentConfig.SPRIG.ENVIRONMENT_ID, -}) : undefined - -export function sprigTriggerForUser(surveyName: string, userId?: number): void { - - if (!userId) { - Sprig?.track(surveyName) - return - } - - Sprig?.identifyAndTrack({ - anonymousId: '', - eventName: surveyName, - metadata: undefined, - userId: `${userId}`, - }) -} diff --git a/yarn.lock b/yarn.lock index 49682dae8..8954e2c9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19095,9 +19095,9 @@ unist-util-visit@^4.0.0: unist-util-is "^5.0.0" unist-util-visit-parents "^5.1.1" -"universal-navigation@https://github.com/topcoder-platform/universal-navigation#9e62ddc61d": - version "1.0.17" - resolved "https://github.com/topcoder-platform/universal-navigation#9e62ddc61d44711e501b02e4c0890c348a3aa96d" +"universal-navigation@https://github.com/topcoder-platform/universal-navigation#9fc50d938be7182": + version "1.0.21" + resolved "https://github.com/topcoder-platform/universal-navigation#9fc50d938be7182934f3a8a6c417767af0ab52b2" universalify@^0.2.0: version "0.2.0"