Skip to content

Commit a0fa269

Browse files
authored
Add angular runtime version to device info (#2288)
* feat: ✨ add angular runtime version to device info * refactor: ♻️ move device metadata callbacks to error handler
1 parent 0754876 commit a0fa269

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- Introduce `sendPayloadChecksums` option and set `Bugsnag-Integrity` headers on events and sessions [#2221](https://github.com/bugsnag/bugsnag-js/pull/2221)
8+
- (plugin-angular) Added Angular runtime version to device info [#2288](https://github.com/bugsnag/bugsnag-js/pull/2288)
89

910
### Changed
1011

packages/plugin-angular/src/lib/bugsnag-error-handler.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorHandler } from '@angular/core'
1+
import { ErrorHandler, VERSION } from '@angular/core'
22
import Bugsnag, { Client } from '@bugsnag/js'
33

44
type BugsnagWithInternals = typeof Bugsnag & {
@@ -14,6 +14,15 @@ class BugsnagErrorHandler implements ErrorHandler {
1414
} else {
1515
this.bugsnagClient = (Bugsnag as BugsnagWithInternals)._client
1616
}
17+
18+
// Add angular runtime to device metadata
19+
const device = { runtimeVersions: { angular: VERSION.full } }
20+
this.bugsnagClient.addOnSession(session => {
21+
session.device = { ...session.device, ...device }
22+
})
23+
this.bugsnagClient.addOnError((event) => {
24+
event.device = { ...event.device, ...device }
25+
})
1726
}
1827

1928
handleError (error: any): void {

packages/plugin-angular/src/lib/plugin.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const plugin: Plugin = {
1818
name: 'Angular',
1919
load: (client: Client): ErrorHandler => {
2020
const originalNotify = client._notify
21-
2221
client._notify = function () {
2322
const event = arguments as unknown as Event
2423
if (isNgZoneEnabled) {

test/browser/features/plugin_angular.feature

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Scenario Outline: basic error handler usage
99
And the test should run in this browser
1010
Then I wait to receive an error
1111
And the error is a valid browser payload for the error reporting API
12+
And the error payload field "events.0.device.runtimeVersions.angular" is not null
1213
Examples:
1314
| version |
1415
| 12 |

0 commit comments

Comments
 (0)