Skip to content

Commit

Permalink
fix: separator and make changes in bugsnag plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Dec 13, 2024
1 parent a9605d1 commit b69347c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
8 changes: 8 additions & 0 deletions packages/analytics-js-plugins/__tests__/bugsnag/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ describe('Plugin - Bugsnag', () => {
installType: 'npm',
}),
},
session: {
sessionInfo: signal({ id: 'test-session-id' }),
},
autoTrack: {
pageLifecycle: {
visitId: signal('test-visit-id'),
},
},
};

let state: any;
Expand Down
36 changes: 34 additions & 2 deletions packages/analytics-js-plugins/__tests__/bugsnag/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ beforeEach(() => {
lifecycle: {
writeKey: signal('dummy-write-key'),
},
session: {
sessionInfo: signal({ id: 'test-session-id' }),
},
autoTrack: {
pageLifecycle: {
visitId: signal('test-visit-id'),
},
},
};
});

Expand Down Expand Up @@ -235,6 +243,14 @@ describe('Bugsnag utilities', () => {
installType: 'npm',
},
},
session: {
sessionInfo: { id: 'test-session-id' },
},
autoTrack: {
pageLifecycle: {
visitId: 'test-visit-id',
},
},
},
});

Expand Down Expand Up @@ -277,6 +293,14 @@ describe('Bugsnag utilities', () => {
installType: 'npm',
},
},
session: {
sessionInfo: { id: 'test-session-id' },
},
autoTrack: {
pageLifecycle: {
visitId: 'test-visit-id',
},
},
},
});

Expand Down Expand Up @@ -338,7 +362,7 @@ describe('Bugsnag utilities', () => {
maxBreadcrumbs: 40,
releaseStage: 'development',
user: {
id: 'dummy-source-id',
id: 'dummy-source-id..test-session-id..test-visit-id',
},
networkBreadcrumbsEnabled: false,
beforeSend: expect.any(Function),
Expand Down Expand Up @@ -377,7 +401,7 @@ describe('Bugsnag utilities', () => {
maxBreadcrumbs: 40,
releaseStage: 'development',
user: {
id: 'dummy-write-key',
id: 'dummy-write-key..test-session-id..test-visit-id',
},
networkBreadcrumbsEnabled: false,
beforeSend: expect.any(Function),
Expand Down Expand Up @@ -527,6 +551,14 @@ describe('Bugsnag utilities', () => {
installType: 'npm',
},
},
session: {
sessionInfo: { id: 'test-session-id' },
},
autoTrack: {
pageLifecycle: {
visitId: 'test-visit-id',
},
},
});
expect(error.severity).toBe('error');
expect(error.context).toBe('Script load failures');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ describe('Error Reporting utilities', () => {
},
},
user: {
id: 'sample_source_id - test-session-id - test-visit-id',
id: 'sample_source_id..test-session-id..test-visit-id',
},
},
],
Expand Down
3 changes: 2 additions & 1 deletion packages/analytics-js-plugins/src/bugsnag/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ const getNewClient = (state: ApplicationState, logger?: ILogger): BugsnagLib.Cli
maxBreadcrumbs: 40,
releaseStage: getReleaseStage(),
user: {
id: state.source.value?.id || state.lifecycle.writeKey.value,
// Combination of source, session and visit ids
id: `${state.source.value?.id ?? (state.lifecycle.writeKey.value as string)}..${state.session.sessionInfo.value?.id ?? 'NA'}..${state.autoTrack?.pageLifecycle?.visitId?.value ?? 'NA'}`,
},
logger,
networkBreadcrumbsEnabled: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-js-plugins/src/errorReporting/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const getBugsnagErrorEvent = (
},
user: {
// Combination of source, session and visit ids
id: `${state.source.value?.id ?? (state.lifecycle.writeKey.value as string)} - ${state.session.sessionInfo.value?.id ?? 'NA'} - ${state.autoTrack.pageLifecycle.visitId.value ?? 'NA'}`,
id: `${state.source.value?.id ?? (state.lifecycle.writeKey.value as string)}..${state.session.sessionInfo.value?.id ?? 'NA'}..${state.autoTrack?.pageLifecycle?.visitId?.value ?? 'NA'}`,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics-js/.size-limit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
name: 'Core - Legacy - NPM (CJS)',
path: 'dist/npm/legacy/cjs/index.cjs',
import: '*',
limit: '49 KiB',
limit: '49.1 KiB',
},
{
name: 'Core - Legacy - NPM (UMD)',
Expand Down

0 comments on commit b69347c

Please sign in to comment.