forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
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 Expensify#40294 from LCOleksii/fullstory-integration
Fullstory integration
- Loading branch information
Showing
15 changed files
with
313 additions
and
2 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
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
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,60 @@ | ||
import FullStory, {FSPage} from '@fullstory/react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import type Session from '@src/types/onyx/Session'; | ||
import type {UserSession} from './types'; | ||
|
||
/** | ||
* 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 session with the provided session information. | ||
*/ | ||
consentAndIdentify: (value: OnyxEntry<Session>) => { | ||
try { | ||
const session: UserSession = { | ||
email: value?.email, | ||
accountID: value?.accountID, | ||
}; | ||
// set consent | ||
FullStory.consent(true); | ||
FS.fsIdentify(session); | ||
} catch (e) { | ||
// error handler | ||
} | ||
}, | ||
|
||
/** | ||
* Sets the FullStory user identity based on the provided session information. | ||
* If the session is null or the email is 'undefined', the user identity is anonymized. | ||
* If the session contains an email, the user identity is defined with the email and account ID. | ||
*/ | ||
fsIdentify: (session: UserSession) => { | ||
if (!session || session.email === 'undefined') { | ||
// anonymize FullStory user identity session | ||
FullStory.anonymize(); | ||
} else { | ||
// define FullStory user identity | ||
FullStory.identify(String(session.accountID), { | ||
properties: { | ||
displayName: session.email, | ||
email: session.email, | ||
}, | ||
}); | ||
} | ||
}, | ||
}; | ||
|
||
export default FS; | ||
export {FSPage}; |
Oops, something went wrong.