-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Send client reports (#12951)
- Loading branch information
Showing
14 changed files
with
275 additions
and
33 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ackages/node-integration-tests/suites/client-reports/drop-reasons/before-send/scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
(async () => { | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: loggingTransport, | ||
beforeSend(event) { | ||
return !event.type ? null : event; | ||
}, | ||
}); | ||
|
||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
|
||
await Sentry.flush(); | ||
|
||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
Sentry.flush(); | ||
})(); |
32 changes: 32 additions & 0 deletions
32
dev-packages/node-integration-tests/suites/client-reports/drop-reasons/before-send/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner'; | ||
|
||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('should record client report for beforeSend', done => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.expect({ | ||
client_report: { | ||
discarded_events: [ | ||
{ | ||
category: 'error', | ||
quantity: 1, | ||
reason: 'before_send', | ||
}, | ||
], | ||
}, | ||
}) | ||
.expect({ | ||
client_report: { | ||
discarded_events: [ | ||
{ | ||
category: 'error', | ||
quantity: 2, | ||
reason: 'before_send', | ||
}, | ||
], | ||
}, | ||
}) | ||
.start(done); | ||
}); |
24 changes: 24 additions & 0 deletions
24
...es/node-integration-tests/suites/client-reports/drop-reasons/event-processors/scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
(async () => { | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: loggingTransport, | ||
}); | ||
|
||
Sentry.addEventProcessor(event => { | ||
return !event.type ? null : event; | ||
}); | ||
|
||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
|
||
await Sentry.flush(); | ||
|
||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
Sentry.captureException(new Error('this should get dropped by the event processor')); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
Sentry.flush(); | ||
})(); |
32 changes: 32 additions & 0 deletions
32
...ckages/node-integration-tests/suites/client-reports/drop-reasons/event-processors/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner'; | ||
|
||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('should record client report for event processors', done => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.expect({ | ||
client_report: { | ||
discarded_events: [ | ||
{ | ||
category: 'error', | ||
quantity: 1, | ||
reason: 'event_processor', | ||
}, | ||
], | ||
}, | ||
}) | ||
.expect({ | ||
client_report: { | ||
discarded_events: [ | ||
{ | ||
category: 'error', | ||
quantity: 2, | ||
reason: 'event_processor', | ||
}, | ||
], | ||
}, | ||
}) | ||
.start(done); | ||
}); |
13 changes: 13 additions & 0 deletions
13
dev-packages/node-integration-tests/suites/client-reports/periodic-send/scenario.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
transport: loggingTransport, | ||
clientReportFlushInterval: 5000, | ||
beforeSend(event) { | ||
return !event.type ? null : event; | ||
}, | ||
}); | ||
|
||
Sentry.captureException(new Error('this should get dropped by before send')); |
21 changes: 21 additions & 0 deletions
21
dev-packages/node-integration-tests/suites/client-reports/periodic-send/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; | ||
|
||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('should flush client reports automatically after the timeout interval', done => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.expect({ | ||
client_report: { | ||
discarded_events: [ | ||
{ | ||
category: 'error', | ||
quantity: 1, | ||
reason: 'before_send', | ||
}, | ||
], | ||
}, | ||
}) | ||
.start(done); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.