Repository navigation
iImplement fullStory analytics instrumentation #93051
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
JS00001
merged 45 commits into
Expensify:main
from
nabi-ebrahimi:feat/fullstory-analytics-instrumentation
Jul 22, 2026
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
8079078
iImplement fullStory analytics instrumentation
nabi-ebrahimi e17bd10
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 53d9ab3
wait for FullStory before syncing user vars
nabi-ebrahimi a047a71
add FullStory timing constants
nabi-ebrahimi ffe367b
fix lint
nabi-ebrahimi c9af14a
fix FullStory test fixture
nabi-ebrahimi 44c3334
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 067f697
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi aae1cbf
fix fullStory login list key
nabi-ebrahimi 27ad354
Format FullStory files
nabi-ebrahimi 2bf7e1a
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 5ff2b0c
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 41bc5ce
Fix FullStory route typecheck
nabi-ebrahimi 09ca2c8
fix prettier
nabi-ebrahimi 37ae691
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 092386b
Avoid FullStory auto-init
nabi-ebrahimi e056ce9
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 0d86c0b
fix fullStory onboarding path matching
nabi-ebrahimi c877b85
fix fullStory context tracking
nabi-ebrahimi 9416fff
fix fullStory toggle key
nabi-ebrahimi 5aed0a9
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi cd8eac2
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 439f83b
skip fullStory transition routes
nabi-ebrahimi 7bb6cce
fix fullStory tracking
nabi-ebrahimi 25bf535
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 391a960
add native FullStory property normalization
nabi-ebrahimi dab71d8
fix fullStory lint
nabi-ebrahimi 0fb7fff
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 94b9ecb
fix fmt
nabi-ebrahimi 5c0d986
fix FullStory user vars
nabi-ebrahimi 0b2d491
sync fullStory trial dates
nabi-ebrahimi 0127530
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi d462d75
fix FullStory dedupe and dates
nabi-ebrahimi f136558
Guard native FullStory events
nabi-ebrahimi 038a046
fix lint
nabi-ebrahimi 649e766
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 1f5a394
Fix FullStory entry point
nabi-ebrahimi 7b4b829
Document FullStory readiness gate
nabi-ebrahimi a8b35f3
Preserve native identify vars
nabi-ebrahimi 636032f
Fix FullStory entry point
nabi-ebrahimi 4492876
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi a6b4f6c
fix FullStory trial date parsing
nabi-ebrahimi 2a7d0f4
Reset FullStory entry point
nabi-ebrahimi d69b0d3
Merge branch 'main' into feat/fullstory-analytics-instrumentation
nabi-ebrahimi 8936975
Track initial FullStory page view
nabi-ebrahimi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import {useEffect, useRef} from 'react'; | ||
|
|
||
| import useOnyx from './hooks/useOnyx'; | ||
| import getEnvironment from './libs/Environment/getEnvironment'; | ||
| import FS from './libs/Fullstory'; | ||
| import {buildFullstoryUserVars, getComparableFullstoryUserVars} from './libs/Fullstory/utils'; | ||
| import {shallowCompare} from './libs/ObjectUtils'; | ||
| import ONYXKEYS from './ONYXKEYS'; | ||
|
|
||
| const SESSION_URL_RETRY_DELAY_MS = 250; | ||
| const MAX_SESSION_URL_RETRY_ATTEMPTS = 20; | ||
|
|
||
| function FullstoryUserContextHandler() { | ||
| const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||
| const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); | ||
| const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); | ||
| const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING); | ||
| const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE); | ||
| const [onboardingLastVisitedPath] = useOnyx(ONYXKEYS.ONBOARDING_LAST_VISITED_PATH); | ||
| const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); | ||
| const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); | ||
| const [session] = useOnyx(ONYXKEYS.SESSION); | ||
| const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA); | ||
|
|
||
| const activePolicy = activePolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`] : undefined; | ||
|
|
||
| const previousUserVars = useRef<ReturnType<typeof getComparableFullstoryUserVars> | undefined>(undefined); | ||
| const previousAccountID = useRef<number | undefined>(undefined); | ||
| const sessionURLRetryAttempts = useRef(0); | ||
|
|
||
| useEffect(() => { | ||
| if (!userMetadata?.accountID) { | ||
| return; | ||
| } | ||
|
|
||
| let didCancel = false; | ||
| let retryTimeoutID: ReturnType<typeof setTimeout> | undefined; | ||
|
|
||
| const syncUserVars = () => { | ||
| getEnvironment() | ||
| .then((envName) => { | ||
| if (didCancel || !FS.shouldInitialize(userMetadata, envName)) { | ||
| return; | ||
| } | ||
|
|
||
| // Use the session URL only as a readiness signal so this handler waits for the existing FullStory init path. | ||
| return FS.getSessionURL().then((sessionURL) => { | ||
| if (didCancel) { | ||
| return; | ||
| } | ||
|
|
||
| if (!sessionURL) { | ||
| sessionURLRetryAttempts.current += 1; | ||
| if (sessionURLRetryAttempts.current >= MAX_SESSION_URL_RETRY_ATTEMPTS) { | ||
| return; | ||
| } | ||
|
|
||
| retryTimeoutID = setTimeout(syncUserVars, SESSION_URL_RETRY_DELAY_MS); | ||
| return; | ||
| } | ||
|
|
||
| sessionURLRetryAttempts.current = 0; | ||
|
|
||
| if (previousAccountID.current !== userMetadata.accountID) { | ||
| previousAccountID.current = userMetadata.accountID; | ||
| previousUserVars.current = undefined; | ||
| } | ||
|
|
||
| const userVars = buildFullstoryUserVars({ | ||
| account, | ||
| activePolicy, | ||
| introSelected, | ||
| onboarding, | ||
| onboardingCompanySize, | ||
| onboardingLastVisitedPath, | ||
| onboardingPurposeSelected, | ||
| policies, | ||
| session, | ||
| userMetadata, | ||
| }); | ||
|
|
||
| const comparableUserVars = getComparableFullstoryUserVars(userVars); | ||
|
|
||
| if (shallowCompare(previousUserVars.current, comparableUserVars)) { | ||
| return; | ||
| } | ||
|
|
||
| previousUserVars.current = comparableUserVars; | ||
| FS.setUserVars(userVars); | ||
| }); | ||
| }) | ||
| .catch(() => { | ||
| if (didCancel) { | ||
| return; | ||
| } | ||
|
|
||
| sessionURLRetryAttempts.current += 1; | ||
| if (sessionURLRetryAttempts.current >= MAX_SESSION_URL_RETRY_ATTEMPTS) { | ||
| return; | ||
| } | ||
|
|
||
| retryTimeoutID = setTimeout(syncUserVars, SESSION_URL_RETRY_DELAY_MS); | ||
| }); | ||
| }; | ||
|
|
||
| syncUserVars(); | ||
|
|
||
| return () => { | ||
| didCancel = true; | ||
| sessionURLRetryAttempts.current = 0; | ||
| if (retryTimeoutID) { | ||
| clearTimeout(retryTimeoutID); | ||
| } | ||
| }; | ||
| }, [account, activePolicy, introSelected, onboarding, onboardingCompanySize, onboardingLastVisitedPath, onboardingPurposeSelected, policies, session, userMetadata]); | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| export default FullstoryUserContextHandler; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.