Skip to content

Commit

Permalink
Merge pull request #43194 from Expensify/dsilva_addEnvironmentAsPrope…
Browse files Browse the repository at this point in the history
…rtyForFullstory

[NoQA] Add environment as an identifying property for Fullstory
  • Loading branch information
mountiny authored Jun 8, 2024
2 parents 31ff066 + d833d4c commit 0b39c83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/libs/Fullstory/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import FullStory, {FSPage} from '@fullstory/react-native';
import type {OnyxEntry} from 'react-native-onyx';
import * as Environment from '@src/libs/Environment/Environment';
import type {UserMetadata} from '@src/types/onyx';

/**
Expand Down Expand Up @@ -40,9 +41,13 @@ const FS = {
// anonymize FullStory user identity metadata
FullStory.anonymize();
} else {
// define FullStory user identity
FullStory.identify(String(metadata.accountID), {
properties: metadata,
Environment.getEnvironment().then((envName: string) => {
// define FullStory user identity
const localMetadata = metadata;
localMetadata.environment = envName;
FullStory.identify(String(localMetadata.accountID), {
properties: localMetadata,
});
});
}
},
Expand Down
6 changes: 5 additions & 1 deletion src/libs/Fullstory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ const FS = {
}
FS.onReady().then(() => {
FS.consent(true);
FS.fsIdentify(value);
if (value) {
const localMetadata = value;
localMetadata.environment = envName;
FS.fsIdentify(localMetadata);
}
});
});
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/UserMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type UserMetadata = {

/** User's account ID */
accountID?: number;
environment?: string;

Check failure on line 14 in src/types/onyx/UserMetadata.ts

View workflow job for this annotation

GitHub Actions / lint / Run ESLint

Missing JSDoc comment
};

export default UserMetadata;

0 comments on commit 0b39c83

Please sign in to comment.