Skip to content
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

[No QA] Fullstory small changes #55487

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/libs/Fullstory/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FullStory, {FSPage} from '@fullstory/react-native';
import {Str} from 'expensify-common';
import type {OnyxEntry} from 'react-native-onyx';
import {isExpensifyTeam} from '@libs/PolicyUtils';
import {isConciergeChatReport, shouldUnmaskChat} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
Expand Down Expand Up @@ -43,7 +43,7 @@ const FS = {
// UserMetadata onyx key.
Environment.getEnvironment().then((envName: string) => {
const isTestEmail = value.email !== undefined && value.email.startsWith('fullstory') && value.email.endsWith(CONST.EMAIL.QA_DOMAIN);
if ((CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) || isExpensifyTeam(value?.email)) {
if ((CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) || Str.extractEmailDomain(value.email ?? '') === CONST.EXPENSIFY_PARTNER_NAME) {
return;
}
FullStory.restart();
Expand Down
13 changes: 11 additions & 2 deletions src/libs/Fullstory/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FullStory, init, isInitialized} from '@fullstory/browser';
import {Str} from 'expensify-common';
import type {OnyxEntry} from 'react-native-onyx';
import {isExpensifyTeam} from '@libs/PolicyUtils';
import {isConciergeChatReport, shouldUnmaskChat} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
Expand Down Expand Up @@ -103,6 +103,12 @@ const FS = {
new Promise((resolve) => {
if (!isInitialized()) {
init({orgId: ''}, resolve);

// FS init function might have a race condition with the head snippet. If the head snipped is loaded first,
// then the init function will not call the resolve function, and we'll never identify the user logging in,
// and we need to call resolve manually. We're adding a 1s timeout to make sure the init function has enough
// time to call the resolve function in case it ran successfully.
setTimeout(resolve, 1000);
} else {
FullStory('observe', {type: 'start', callback: resolve});
}
Expand Down Expand Up @@ -130,9 +136,12 @@ const FS = {
try {
Environment.getEnvironment().then((envName: string) => {
const isTestEmail = value.email !== undefined && value.email.startsWith('fullstory') && value.email.endsWith(CONST.EMAIL.QA_DOMAIN);
if ((CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) || isExpensifyTeam(value?.email)) {
if ((CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) || Str.extractEmailDomain(value.email ?? '') === CONST.EXPENSIFY_PARTNER_NAME) {
// On web, if we started FS at some point in a browser, it will run forever. So let's shut it down if we don't want it to run.
FullStory('shutdown');
return;
}
FullStory('restart');
FS.onReady().then(() => {
FS.consent(true);
const localMetadata = value;
Expand Down
Loading