Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
494a619
Adds breadcrumb origin in RNSentryBreadcrumb dictionary parsing
antonis Sep 27, 2024
cc0b364
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 8, 2024
a636be5
Use 8.38.0-beta.1 Cocoa SDK that has the new origin field
antonis Oct 8, 2024
522897a
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 9, 2024
197f863
Adds changelog
antonis Oct 9, 2024
9bee5c9
Fixes sentry-java breaking changes
antonis Oct 9, 2024
6268a43
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 10, 2024
6095218
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 11, 2024
0e43c5d
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 15, 2024
8832cf9
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 15, 2024
7a108ee
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 16, 2024
aff18bf
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 23, 2024
611cd97
Adds origin native tests
antonis Oct 23, 2024
37553f2
Adds Capture exception with breadcrumb in the sample
antonis Oct 23, 2024
24a527b
Set react native as event origin
antonis Oct 28, 2024
fabf052
Filter out events with react-native origin from the native layer
antonis Oct 28, 2024
d0b1633
Merge event breadcrumbs with native context
antonis Oct 28, 2024
5d2711c
Lint: removes empty line
antonis Oct 28, 2024
fb0057d
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Oct 31, 2024
78c24f0
Use predicate to filter breadcrumbs
antonis Oct 31, 2024
6fcd93d
Respect max breadcrumbs limit
antonis Oct 31, 2024
80add4f
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 1, 2024
44e02ec
Updates changelog
antonis Nov 1, 2024
a2d29de
Update test names
antonis Nov 1, 2024
52c9e54
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 6, 2024
81a11c3
Fixes lint issue
antonis Nov 6, 2024
f828fc7
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 6, 2024
67bd716
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 7, 2024
c4246d7
Keep the last maxBreadcrumbs (default 100) when merging native and js…
antonis Nov 7, 2024
17e2201
Use client from function parameter
antonis Nov 11, 2024
fef2173
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 11, 2024
76285fa
Refactor and test RNSentryModuleImpl.fetchNativeDeviceContexts (#4253)
antonis Nov 11, 2024
6ea1fe1
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis Nov 18, 2024
af1ab5a
Move changelog to unreleased section
antonis Nov 18, 2024
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
Prev Previous commit
Next Next commit
Keep the last maxBreadcrumbs (default 100) when merging native and js…
… breadcrumbs
  • Loading branch information
antonis committed Nov 7, 2024
commit c4246d789b690da34fb47056f38c63e25064a9ee
5 changes: 4 additions & 1 deletion packages/core/src/js/integrations/devicecontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ async function processEvent(event: Event): Promise<Event> {
: undefined;
if (nativeBreadcrumbs) {
const maxBreadcrumbs = getClient()?.getOptions().maxBreadcrumbs ?? 100; // Default is 100.
event.breadcrumbs = nativeBreadcrumbs.concat(event.breadcrumbs || []).slice(0, maxBreadcrumbs);
event.breadcrumbs = nativeBreadcrumbs
.concat(event.breadcrumbs || []) // concatenate the native and js breadcrumbs
.sort((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) // sort by timestamp
.slice(-maxBreadcrumbs); // keep the last maxBreadcrumbs
}

return event;
Expand Down
59 changes: 37 additions & 22 deletions packages/core/test/integrations/devicecontext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('Device Context Integration', () => {
});

it('merge native and event breadcrumbs', async () => {
getClient().getOptions().maxBreadcrumbs = undefined; // Default 100
const { processedEvent } = await processEventWith({
nativeContexts: { breadcrumbs: [{ message: 'native-breadcrumb-1' }, { message: 'native-breadcrumb-2' }] },
mockEvent: { breadcrumbs: [{ message: 'event-breadcrumb-1' }, { message: 'event-breadcrumb-2' }] },
Expand All @@ -181,43 +182,57 @@ describe('Device Context Integration', () => {
});
});

it('use only native breadcrumb if the maxBreadcrumbs limit does not leave space for event breadcrumbs', async () => {
getClient().getOptions().maxBreadcrumbs = 1;
it('respect breadcrumb order when merging', async () => {
getClient().getOptions().maxBreadcrumbs = undefined; // Default 100
const { processedEvent } = await processEventWith({
nativeContexts: { breadcrumbs: [{ message: 'native-breadcrumb' }] },
mockEvent: { breadcrumbs: [{ message: 'event-breadcrumb' }] },
nativeContexts: {
breadcrumbs: [
{ message: 'native-breadcrumb-3', timestamp: 'Thursday, November 7, 2024 3:24:59 PM GMT+02:00' }, // 1730985899
{ message: 'native-breadcrumb-1', timestamp: 'Thursday, November 7, 2024 3:24:57 PM GMT+02:00' }, // 1730985897
],
},
mockEvent: {
breadcrumbs: [
{ message: 'event-breadcrumb-4', timestamp: 1730985999 },
{ message: 'event-breadcrumb-2', timestamp: 1730985898 },
],
},
});
expect(processedEvent).toStrictEqual({
breadcrumbs: [{ message: 'native-breadcrumb' }],
breadcrumbs: [
{ message: 'native-breadcrumb-1', timestamp: 1730985897 },
{ message: 'event-breadcrumb-2', timestamp: 1730985898 },
{ message: 'native-breadcrumb-3', timestamp: 1730985899 },
{ message: 'event-breadcrumb-4', timestamp: 1730985999 },
],
});
});

it('use native breadcrumbs and pick only the event breadcrumbs that fit the maxBreadcrumbs limit', async () => {
it('keep the last maxBreadcrumbs when merging', async () => {
getClient().getOptions().maxBreadcrumbs = 3;
const { processedEvent } = await processEventWith({
nativeContexts: { breadcrumbs: [{ message: 'native-breadcrumb-1' }, { message: 'native-breadcrumb-2' }] },
mockEvent: { breadcrumbs: [{ message: 'event-breadcrumb-1' }, { message: 'event-breadcrumb-2' }] },
nativeContexts: {
breadcrumbs: [
{ message: 'native-breadcrumb-3', timestamp: 'Thursday, November 7, 2024 3:24:59 PM GMT+02:00' }, // 1730985899
{ message: 'native-breadcrumb-1', timestamp: 'Thursday, November 7, 2024 3:24:57 PM GMT+02:00' }, // 1730985897
],
},
mockEvent: {
breadcrumbs: [
{ message: 'event-breadcrumb-4', timestamp: 1730985999 },
{ message: 'event-breadcrumb-2', timestamp: 1730985898 },
],
},
});
expect(processedEvent).toStrictEqual({
breadcrumbs: [
{ message: 'native-breadcrumb-1' },
{ message: 'native-breadcrumb-2' },
{ message: 'event-breadcrumb-1' },
{ message: 'event-breadcrumb-2', timestamp: 1730985898 },
{ message: 'native-breadcrumb-3', timestamp: 1730985899 },
{ message: 'event-breadcrumb-4', timestamp: 1730985999 },
],
});
});

it('do not use any breadcrumbs if the maxBreadcrumbs limit is set to zero', async () => {
getClient().getOptions().maxBreadcrumbs = 0;
const { processedEvent } = await processEventWith({
nativeContexts: { breadcrumbs: [{ message: 'native-breadcrumb' }] },
mockEvent: { breadcrumbs: [{ message: 'event-breadcrumb' }] },
});
expect(processedEvent).toStrictEqual({
breadcrumbs: [],
});
});

it('adds in_foreground false to native app contexts', async () => {
mockCurrentAppState = 'background';
const { processedEvent } = await processEventWith({
Expand Down
Loading