Skip to content

Commit d62542d

Browse files
committed
MP-307 - account settings CES sprig survey
1 parent ba697c5 commit d62542d

File tree

15 files changed

+46
-6
lines changed

15 files changed

+46
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SPRIG_CES_SURVEY_ID = 'onAccountSettingsUpdate'

src/apps/accounts/src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './constants'

src/apps/accounts/src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './accounts-swr'
22
export * from './components'
33
export * from './assets'
4+
export * from './sprig-survey'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { sprigTriggerForUser } from '~/libs/shared'
2+
import { UserProfile } from '~/libs/core'
3+
4+
import { SPRIG_CES_SURVEY_ID } from '../config'
5+
6+
export function triggerSprigSurvey({ userId }: UserProfile): void {
7+
sprigTriggerForUser(SPRIG_CES_SURVEY_ID, userId)
8+
}

src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Dispatch, FC, SetStateAction, useState } from 'react'
22

33
import { BaseModal, Button, Collapsible } from '~/libs/ui'
44
import { authUrlLogout, updatePrimaryMemberRoleAsync, UserProfile } from '~/libs/core'
5+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
56

67
import styles from './AccountRole.module.scss'
78

@@ -35,6 +36,7 @@ const AccountRole: FC<AccountRoleProps> = (props: AccountRoleProps) => {
3536
.then(() => {
3637
setMemberRole(newRole)
3738
setIsRoleChangeConfirmed(true)
39+
triggerSprigSurvey(props.profile)
3840
})
3941
.finally(() => {
4042
setIsUpdating(false)

src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useCountryLookup,
1414
UserProfile,
1515
} from '~/libs/core'
16+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
1617

1718
import styles from './MemberAddress.module.scss'
1819

@@ -87,6 +88,7 @@ const MemberAddress: FC<MemberAddressProps> = (props: MemberAddressProps) => {
8788
.then(() => {
8889
toast.success('Your account has been updated.', { position: toast.POSITION.BOTTOM_RIGHT })
8990
setFormErrors({})
91+
triggerSprigSurvey(props.profile)
9092
})
9193
.catch(() => {
9294
toast.error('Something went wrong. Please try again.', { position: toast.POSITION.BOTTOM_RIGHT })

src/apps/accounts/src/settings/tabs/account/security/Security.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { KeyedMutator } from 'swr'
44
import { noop } from 'lodash'
55

66
import { Button, Collapsible, FormToggleSwitch, IconSolid, Tooltip } from '~/libs/ui'
7-
import { diceIdLogo, MFAImage, SettingSection } from '~/apps/accounts/src/lib'
7+
import { diceIdLogo, MFAImage, SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'
88
import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core'
99

1010
import { DiceSetupModal } from './dice-setup-modal'
@@ -39,6 +39,7 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
3939
.then(() => {
4040
setMFAEnabled(!mfaEnabled)
4141
toast.success('Your Multi Factor Authentication (MFA) status was updated.')
42+
triggerSprigSurvey(props.profile)
4243
})
4344
.catch(() => {
4445
toast.error('Something went wrong. Please try again later.')

src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
UserTrait,
1818
UserTraits,
1919
} from '~/libs/core'
20-
import { SettingSection } from '~/apps/accounts/src/lib'
20+
import { SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'
2121

2222
import { UserAndPassFromConfig } from './user-and-pass.form.config'
2323
import styles from './UserAndPassword.module.scss'
@@ -82,6 +82,7 @@ const UserAndPassword: FC<UserAndPasswordProps> = (props: UserAndPasswordProps)
8282
setUserConsent(!userConsent)
8383
mutateTraits()
8484
toast.success('User consent updated successfully.')
85+
triggerSprigSurvey(props.profile)
8586
})
8687
.catch(() => {
8788
toast.error('Failed to update user consent.')

src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MemberEmailPreferenceAPI, updateMemberEmailPreferencesAsync, useMemberE
77
import { Button, FormToggleSwitch, LoadingSpinner } from '~/libs/ui'
88
import { EnvironmentConfig } from '~/config'
99

10-
import { EmailIcon, ForumIcon, SettingSection } from '../../../lib'
10+
import { EmailIcon, ForumIcon, SettingSection, triggerSprigSurvey } from '../../../lib'
1111

1212
import { newsletters, programs, subscribeLink, unsubscribeLink } from './preferences.config'
1313
import styles from './PreferencesTab.module.scss'
@@ -43,6 +43,7 @@ const PreferencesTab: FC<PreferencesTabProps> = (props: PreferencesTabProps) =>
4343
.then(() => {
4444
toast.success('Your email preferences ware updated.')
4545
mutateEmailPreferencesData()
46+
triggerSprigSurvey(props.profile)
4647
})
4748
.catch(() => {
4849
toast.error('Something went wrong. Please try again later.')

src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { toast } from 'react-toastify'
55

66
import { updateMemberTraitsAsync, useMemberTraits, UserProfile, UserTraits } from '~/libs/core'
77
import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui'
8+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
89

910
import { communitiesConfig } from './communities-config'
1011
import styles from './Communities.module.scss'
@@ -48,6 +49,7 @@ const Communities: FC<CommunitiesProps> = (props: CommunitiesProps) => {
4849
setMemberCommunities(updatedCommunities)
4950
mutateTraits()
5051
toast.success('Communities updated successfully.')
52+
triggerSprigSurvey(props.profile)
5153
})
5254
.catch(() => {
5355
toast.error('Failed to update user Communities.')

src/apps/accounts/src/settings/tabs/tcandyou/tracks/Tracks.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { toast } from 'react-toastify'
44

55
import { profileContext, ProfileContextData, TC_TRACKS, updateMemberProfileAsync, UserProfile } from '~/libs/core'
66
import { Collapsible, FormToggleSwitch } from '~/libs/ui'
7-
import { DataScienceTrackIcon, DesignTrackIcon, DevelopmentTrackIcon, SettingSection } from '~/apps/accounts/src/lib'
7+
import {
8+
DataScienceTrackIcon,
9+
DesignTrackIcon,
10+
DevelopmentTrackIcon,
11+
SettingSection,
12+
triggerSprigSurvey,
13+
} from '~/apps/accounts/src/lib'
814

915
import styles from './Tracks.module.scss'
1016

@@ -48,6 +54,7 @@ const Tracks: FC<TracksProps> = (props: TracksProps) => {
4854
} as any,
4955
})
5056
toast.success('Your profile has been updated.')
57+
triggerSprigSurvey(props.profile)
5158
})
5259
.catch(() => {
5360
toast.error('Failed to update your profile.')

src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
SettingSection,
2121
SmartphoneIcon,
2222
TabletIcon,
23+
triggerSprigSurvey,
2324
WearableIcon,
2425
} from '~/apps/accounts/src/lib'
2526

@@ -176,6 +177,7 @@ const Devices: FC<DevicesProps> = (props: DevicesProps) => {
176177
.then(() => {
177178
toast.success('Device deleted successfully')
178179
setDeviceTypesData(updatedDeviceTypesData)
180+
triggerSprigSurvey(props.profile)
179181
})
180182
.catch(() => {
181183
toast.error('Error deleting Device')
@@ -281,6 +283,7 @@ const Devices: FC<DevicesProps> = (props: DevicesProps) => {
281283
...updatedDeviceTypesData || [],
282284
deviceUpdate,
283285
])
286+
triggerSprigSurvey(props.profile)
284287
})
285288
.catch(() => {
286289
toast.error('Error updating Device')

src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
OtherServiceProviderIcon,
1313
SettingSection,
1414
TelevisionServiceProviderIcon,
15+
triggerSprigSurvey,
1516
} from '~/apps/accounts/src/lib'
1617

1718
import { serviceProviderTypes } from './service-provider-types.config'
@@ -155,6 +156,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
155156
...updatedServiceProviderTypesData || [],
156157
serviceProviderTypeUpdate,
157158
])
159+
triggerSprigSurvey(props.profile)
158160
})
159161
.catch(() => {
160162
toast.error('Error updating Service Provider')
@@ -183,6 +185,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
183185
...serviceProviderTypesData || [],
184186
serviceProviderTypeUpdate,
185187
])
188+
triggerSprigSurvey(props.profile)
186189
})
187190
.catch(() => {
188191
toast.error('Error adding new Service Provider')
@@ -222,6 +225,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
222225
.then(() => {
223226
toast.success('Service Provider deleted successfully')
224227
setServiceProviderTypesData(updatedServiceProviderTypesData)
228+
triggerSprigSurvey(props.profile)
225229
})
226230
.catch(() => {
227231
toast.error('Error deleting Service Provider')

src/apps/accounts/src/settings/tabs/tools/software/Software.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import classNames from 'classnames'
55

66
import { createMemberTraitsAsync, updateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
77
import { Button, Collapsible, ConfirmModal, IconOutline, InputSelect, InputText } from '~/libs/ui'
8-
import { SettingSection, SoftwareIcon } from '~/apps/accounts/src/lib'
8+
import { SettingSection, SoftwareIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib'
99

1010
import { softwareTypes } from './software-types.config'
1111
import styles from './Software.module.scss'
@@ -144,6 +144,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
144144
...updatedSoftwareTypesData || [],
145145
softwareTypeUpdate,
146146
])
147+
triggerSprigSurvey(props.profile)
147148
})
148149
.catch(() => {
149150
toast.error('Error updating software')
@@ -172,6 +173,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
172173
...softwareTypesData || [],
173174
softwareTypeUpdate,
174175
])
176+
triggerSprigSurvey(props.profile)
175177
})
176178
.catch(() => {
177179
toast.error('Error adding new software')
@@ -211,6 +213,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
211213
.then(() => {
212214
toast.success('Software deleted successfully')
213215
setSoftwareTypesData(updatedSoftwareTypesData)
216+
triggerSprigSurvey(props.profile)
214217
})
215218
.catch(() => {
216219
toast.error('Error deleting software')

src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import classNames from 'classnames'
55

66
import { createMemberTraitsAsync, updateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
77
import { Button, Collapsible, ConfirmModal, IconOutline, InputText } from '~/libs/ui'
8-
import { SettingSection, SubscriptionsIcon } from '~/apps/accounts/src/lib'
8+
import { SettingSection, SubscriptionsIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib'
99

1010
import styles from './Subscriptions.module.scss'
1111

@@ -129,6 +129,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
129129
...updatedSubscriptionsTypesData || [],
130130
softwareTypeUpdate,
131131
])
132+
triggerSprigSurvey(props.profile)
132133
})
133134
.catch(() => {
134135
toast.error('Error updating subscription')
@@ -157,6 +158,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
157158
...subscriptionsTypesData || [],
158159
softwareTypeUpdate,
159160
])
161+
triggerSprigSurvey(props.profile)
160162
})
161163
.catch(() => {
162164
toast.error('Error adding new subscription')
@@ -196,6 +198,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
196198
.then(() => {
197199
toast.success('Subscription deleted successfully')
198200
setSubscriptionsTypesData(updatedSubscriptionsTypesData)
201+
triggerSprigSurvey(props.profile)
199202
})
200203
.catch(() => {
201204
toast.error('Error deleting subscription')

0 commit comments

Comments
 (0)