-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42046 from LCOleksii/fullstory-integration
Fullstory integration Update.
- Loading branch information
Showing
24 changed files
with
486 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,24 @@ | ||
type FSPageInterface = { | ||
start: jest.Mock<void, []>; | ||
}; | ||
|
||
export default function mockFSLibrary() { | ||
jest.mock('@fullstory/react-native', () => { | ||
class Fullstory { | ||
consent = jest.fn(); | ||
|
||
anonymize = jest.fn(); | ||
|
||
identify = jest.fn(); | ||
} | ||
|
||
return { | ||
FSPage(): FSPageInterface { | ||
return { | ||
start: jest.fn(), | ||
}; | ||
}, | ||
default: Fullstory, | ||
}; | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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,3 @@ | ||
import FS from '@fullstory/react-native'; | ||
|
||
export default FS; |
This file contains 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 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,52 @@ | ||
import FullStory, {FSPage} from '@fullstory/react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import type {UserMetadata} from '@src/types/onyx'; | ||
|
||
/** | ||
* Fullstory React-Native lib adapter | ||
* Proxy function calls to React-Native lib | ||
* */ | ||
const FS = { | ||
/** | ||
* Sets the identity as anonymous using the FullStory library. | ||
*/ | ||
anonymize: () => FullStory.anonymize(), | ||
|
||
/** | ||
* Sets the identity consent status using the FullStory library. | ||
*/ | ||
consent: (c: boolean) => FullStory.consent(c), | ||
|
||
/** | ||
* Initializes the FullStory metadata with the provided metadata information. | ||
*/ | ||
consentAndIdentify: (value: OnyxEntry<UserMetadata>) => { | ||
try { | ||
// We only use FullStory in production environment | ||
FullStory.consent(true); | ||
FS.fsIdentify(value); | ||
} catch (e) { | ||
// error handler | ||
} | ||
}, | ||
|
||
/** | ||
* Sets the FullStory user identity based on the provided metadata information. | ||
* If the metadata is null or the email is 'undefined', the user identity is anonymized. | ||
* If the metadata contains an accountID, the user identity is defined with it. | ||
*/ | ||
fsIdentify: (metadata: UserMetadata | null) => { | ||
if (!metadata?.accountID) { | ||
// anonymize FullStory user identity metadata | ||
FullStory.anonymize(); | ||
} else { | ||
// define FullStory user identity | ||
FullStory.identify(String(metadata.accountID), { | ||
properties: metadata, | ||
}); | ||
} | ||
}, | ||
}; | ||
|
||
export default FS; | ||
export {FSPage}; |
Oops, something went wrong.