Skip to content

MP-307 - account settings CES sprig survey -> dev #853

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 1 commit into from
Jul 31, 2023
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 src/apps/accounts/src/config/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SPRIG_CES_SURVEY_ID = 'onAccountSettingsUpdate'
1 change: 1 addition & 0 deletions src/apps/accounts/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './constants'
1 change: 1 addition & 0 deletions src/apps/accounts/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './accounts-swr'
export * from './components'
export * from './assets'
export * from './sprig-survey'
8 changes: 8 additions & 0 deletions src/apps/accounts/src/lib/sprig-survey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 styles from './AccountRole.module.scss'

Expand Down Expand Up @@ -35,6 +36,7 @@ const AccountRole: FC<AccountRoleProps> = (props: AccountRoleProps) => {
.then(() => {
setMemberRole(newRole)
setIsRoleChangeConfirmed(true)
triggerSprigSurvey(props.profile)
})
.finally(() => {
setIsUpdating(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useCountryLookup,
UserProfile,
} from '~/libs/core'
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'

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

Expand Down Expand Up @@ -87,6 +88,7 @@ const MemberAddress: FC<MemberAddressProps> = (props: MemberAddressProps) => {
.then(() => {
toast.success('Your account has been updated.', { position: toast.POSITION.BOTTOM_RIGHT })
setFormErrors({})
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Something went wrong. Please try again.', { position: toast.POSITION.BOTTOM_RIGHT })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 } from '~/apps/accounts/src/lib'
import { diceIdLogo, MFAImage, SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'
import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core'

import { DiceSetupModal } from './dice-setup-modal'
Expand Down Expand Up @@ -39,6 +39,7 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
.then(() => {
setMFAEnabled(!mfaEnabled)
toast.success('Your Multi Factor Authentication (MFA) status was updated.')
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Something went wrong. Please try again later.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
UserTrait,
UserTraits,
} from '~/libs/core'
import { SettingSection } from '~/apps/accounts/src/lib'
import { SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'

import { UserAndPassFromConfig } from './user-and-pass.form.config'
import styles from './UserAndPassword.module.scss'
Expand Down Expand Up @@ -82,6 +82,7 @@ const UserAndPassword: FC<UserAndPasswordProps> = (props: UserAndPasswordProps)
setUserConsent(!userConsent)
mutateTraits()
toast.success('User consent updated successfully.')
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Failed to update user consent.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MemberEmailPreferenceAPI, updateMemberEmailPreferencesAsync, useMemberE
import { Button, FormToggleSwitch, LoadingSpinner } from '~/libs/ui'
import { EnvironmentConfig } from '~/config'

import { EmailIcon, ForumIcon, SettingSection } from '../../../lib'
import { EmailIcon, ForumIcon, SettingSection, triggerSprigSurvey } from '../../../lib'

import { newsletters, programs, subscribeLink, unsubscribeLink } from './preferences.config'
import styles from './PreferencesTab.module.scss'
Expand Down Expand Up @@ -43,6 +43,7 @@ const PreferencesTab: FC<PreferencesTabProps> = (props: PreferencesTabProps) =>
.then(() => {
toast.success('Your email preferences ware updated.')
mutateEmailPreferencesData()
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Something went wrong. Please try again later.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { toast } from 'react-toastify'

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

import { communitiesConfig } from './communities-config'
import styles from './Communities.module.scss'
Expand Down Expand Up @@ -48,6 +49,7 @@ const Communities: FC<CommunitiesProps> = (props: CommunitiesProps) => {
setMemberCommunities(updatedCommunities)
mutateTraits()
toast.success('Communities updated successfully.')
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Failed to update user Communities.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { toast } from 'react-toastify'

import { profileContext, ProfileContextData, TC_TRACKS, updateMemberProfileAsync, UserProfile } from '~/libs/core'
import { Collapsible, FormToggleSwitch } from '~/libs/ui'
import { DataScienceTrackIcon, DesignTrackIcon, DevelopmentTrackIcon, SettingSection } from '~/apps/accounts/src/lib'
import {
DataScienceTrackIcon,
DesignTrackIcon,
DevelopmentTrackIcon,
SettingSection,
triggerSprigSurvey,
} from '~/apps/accounts/src/lib'

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

Expand Down Expand Up @@ -48,6 +54,7 @@ const Tracks: FC<TracksProps> = (props: TracksProps) => {
} as any,
})
toast.success('Your profile has been updated.')
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Failed to update your profile.')
Expand Down
3 changes: 3 additions & 0 deletions src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SettingSection,
SmartphoneIcon,
TabletIcon,
triggerSprigSurvey,
WearableIcon,
} from '~/apps/accounts/src/lib'

Expand Down Expand Up @@ -176,6 +177,7 @@ const Devices: FC<DevicesProps> = (props: DevicesProps) => {
.then(() => {
toast.success('Device deleted successfully')
setDeviceTypesData(updatedDeviceTypesData)
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error deleting Device')
Expand Down Expand Up @@ -281,6 +283,7 @@ const Devices: FC<DevicesProps> = (props: DevicesProps) => {
...updatedDeviceTypesData || [],
deviceUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error updating Device')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
OtherServiceProviderIcon,
SettingSection,
TelevisionServiceProviderIcon,
triggerSprigSurvey,
} from '~/apps/accounts/src/lib'

import { serviceProviderTypes } from './service-provider-types.config'
Expand Down Expand Up @@ -155,6 +156,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
...updatedServiceProviderTypesData || [],
serviceProviderTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error updating Service Provider')
Expand Down Expand Up @@ -183,6 +185,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
...serviceProviderTypesData || [],
serviceProviderTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error adding new Service Provider')
Expand Down Expand Up @@ -222,6 +225,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
.then(() => {
toast.success('Service Provider deleted successfully')
setServiceProviderTypesData(updatedServiceProviderTypesData)
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error deleting Service Provider')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import classNames from 'classnames'

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

import { softwareTypes } from './software-types.config'
import styles from './Software.module.scss'
Expand Down Expand Up @@ -144,6 +144,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
...updatedSoftwareTypesData || [],
softwareTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error updating software')
Expand Down Expand Up @@ -172,6 +173,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
...softwareTypesData || [],
softwareTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error adding new software')
Expand Down Expand Up @@ -211,6 +213,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
.then(() => {
toast.success('Software deleted successfully')
setSoftwareTypesData(updatedSoftwareTypesData)
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error deleting software')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import classNames from 'classnames'

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

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

Expand Down Expand Up @@ -129,6 +129,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
...updatedSubscriptionsTypesData || [],
softwareTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error updating subscription')
Expand Down Expand Up @@ -157,6 +158,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
...subscriptionsTypesData || [],
softwareTypeUpdate,
])
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error adding new subscription')
Expand Down Expand Up @@ -196,6 +198,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
.then(() => {
toast.success('Subscription deleted successfully')
setSubscriptionsTypesData(updatedSubscriptionsTypesData)
triggerSprigSurvey(props.profile)
})
.catch(() => {
toast.error('Error deleting subscription')
Expand Down