Skip to content
Merged
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
3 changes: 2 additions & 1 deletion jest/setupMockFullstoryLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export default function mockFSLibrary() {
Page: FSPage,
getChatFSClass: jest.fn(),
init: jest.fn(),
onReady: jest.fn(),
onReady: jest.fn().mockResolvedValue(undefined),
consent: jest.fn(),
identify: jest.fn(),
consentAndIdentify: jest.fn(),
anonymize: jest.fn(),
getSessionId: jest.fn(),
};
});
}
3 changes: 3 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@ const CONST = {
SHOW_HOVER_PREVIEW_ANIMATION_DURATION: 250,
ACTIVITY_INDICATOR_TIMEOUT: 10000,
},
TELEMETRY: {
CONTEXT_FULLSTORY: 'Fullstory',
},
PRIORITY_MODE: {
GSD: 'gsd',
DEFAULT: 'default',
Expand Down
2 changes: 2 additions & 0 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import './libs/registerPaginationConfig';
import setCrashlyticsUserId from './libs/setCrashlyticsUserId';
import StartupTimer from './libs/StartupTimer';
// This lib needs to be imported, but it has nothing to export since all it contains is an Onyx connection
import './libs/TelemetrySynchronizer';
Comment thread
mountiny marked this conversation as resolved.
// This lib needs to be imported, but it has nothing to export since all it contains is an Onyx connection
import './libs/UnreadIndicatorUpdater';
import Visibility from './libs/Visibility';
import ONYXKEYS from './ONYXKEYS';
Expand Down
4 changes: 4 additions & 0 deletions src/libs/Fullstory/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const FS: Fullstory = {
},

anonymize: () => FullStory.anonymize(),

getSessionId: () => {
return FullStory.getCurrentSession();
},
};

export default FS;
4 changes: 4 additions & 0 deletions src/libs/Fullstory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ const FS: Fullstory = {
},

anonymize: () => FullStory(CONST.FULLSTORY.OPERATION.SET_IDENTITY, {anonymous: true}),

getSessionId: () => {
return FullStory('getSessionAsync', {format: 'id'});
},
};

export default FS;
5 changes: 5 additions & 0 deletions src/libs/Fullstory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ type Fullstory = {
* Sets the identity as anonymous using the Fullstory library.
*/
anonymize: () => void;

/**
* Returns the current Fullstory session ID.
*/
getSessionId: () => Promise<string | undefined>;
};

/**
Expand Down
19 changes: 19 additions & 0 deletions src/libs/TelemetrySynchronizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adhorodyski As you proposed I'll put all connection to external file, where I put all logic to enchance sentry data. I am open to comment on the file name

* This file contains the logic for sending additional data to Sentry.
*
* It uses Onyx.connectWithoutView as nothing here is related to the UI. We only send data to external provider and want to keep this outside of the render loop.
*/
import * as Sentry from '@sentry/react-native';
import CONST from '@src/CONST';
import FS from './Fullstory';

/**
* Connect to FullStory to retrieve session id from it. We want to link FullStory with Sentry for easier debugging.
*/
FS.onReady().then(async () => {
const sessionId = await FS.getSessionId();
if (!sessionId) {
return;
}
Sentry.setContext(CONST.TELEMETRY.CONTEXT_FULLSTORY, {sessionId});
});
Loading