Skip to content

Commit

Permalink
[PLAT-12474] Support error correlation property in events (#2174)
Browse files Browse the repository at this point in the history
* feat: ✨ add correlation property to eventPayload

* test: 🧪 test correlation property in delivery

* refactor: ♻️ access `event._correlation` without use of .toJSON method
  • Loading branch information
gingerbenw committed Jul 24, 2024
1 parent 024fd4d commit 6118ca0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [8.0.0] - Unreleased

### Added

- (delivery-react-native) Support error correlation properties in event payloads [#2174](https://github.com/bugsnag/bugsnag-js/pull/2174)

### Fixed

- (plugin-angular) Prevent excess change detection cycles when calling `Bugsnag.notify` [#1861](https://github.com/bugsnag/bugsnag-js/pull/1861)
Expand Down
3 changes: 2 additions & 1 deletion packages/delivery-react-native/delivery.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module.exports = (client, NativeClient) => ({
groupingHash: event.groupingHash,
apiKey: event.apiKey,
featureFlags: event.toJSON().featureFlags,
nativeStack: nativeStack
nativeStack: nativeStack,
correlation: event._correlation
}

if (isTurboModuleEnabled) {
Expand Down
3 changes: 3 additions & 0 deletions packages/delivery-react-native/test/delivery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type NativeClientEvent = Pick<EventWithInternals,
severityReason: EventWithInternals['_handledState']['severityReason']
user: EventWithInternals['_user']
metadata: EventWithInternals['_metadata']
correlation: EventWithInternals['_correlation']
nativeStack: NativeStackIOS | NativeStackAndroid
}

Expand Down Expand Up @@ -57,6 +58,7 @@ describe('delivery: react native', () => {
c.setContext('test screen')
c.setUser('123')
c.notify(new Error('oh no'), (e) => {
e.setTraceCorrelation('trace-id', 'span-id')
e.groupingHash = 'ER_GRP_098'
e.apiKey = 'abcdef123456abcdef123456abcdef123456'
}, (err, event) => {
Expand All @@ -80,6 +82,7 @@ describe('delivery: react native', () => {
expect(sent[0].metadata).toEqual({})
expect(sent[0].groupingHash).toEqual('ER_GRP_098')
expect(sent[0].apiKey).toBe('abcdef123456abcdef123456abcdef123456')
expect(sent[0].correlation).toEqual({ traceId: 'trace-id', spanId: 'span-id' })
done()
})
})
Expand Down

0 comments on commit 6118ca0

Please sign in to comment.