-
-
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): No-code init via
--import=@sentry/node/init
(#11999)
- Loading branch information
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
setTimeout(() => { | ||
throw new Error('Test error'); | ||
}, 1000); |
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,3 @@ | ||
setTimeout(() => { | ||
throw new Error('Test error'); | ||
}, 1000); |
37 changes: 37 additions & 0 deletions
37
dev-packages/node-integration-tests/suites/no-code/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,37 @@ | ||
import { conditionalTest } from '../../utils'; | ||
import { cleanupChildProcesses, createRunner } from '../../utils/runner'; | ||
|
||
const EVENT = { | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'Test error', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
describe('no-code init', () => { | ||
afterAll(() => { | ||
cleanupChildProcesses(); | ||
}); | ||
|
||
test('CJS', done => { | ||
createRunner(__dirname, 'app.js') | ||
.withFlags('--require=@sentry/node/init') | ||
.withMockSentryServer() | ||
.expect({ event: EVENT }) | ||
.start(done); | ||
}); | ||
|
||
conditionalTest({ min: 18 })('--import', () => { | ||
test('ESM', done => { | ||
createRunner(__dirname, 'app.mjs') | ||
.withFlags('--import=@sentry/node/init') | ||
.withMockSentryServer() | ||
.expect({ event: EVENT }) | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { init } from './sdk/init'; | ||
|
||
/** | ||
* The @sentry/node/init export can be used with the node --import and --require args to initialize the SDK entirely via | ||
* environment variables. | ||
* | ||
* > SENTRY_DSN=https://[email protected]/0 SENTRY_TRACES_SAMPLE_RATE=1.0 node --import=@sentry/node/init app.mjs | ||
*/ | ||
init(); |