-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
index.js
59 lines (51 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const Sentry = require('../../../build/cjs');
const { colorize } = require('../colorize');
const { TextEncoder } = require('util');
let remaining = 2;
function makeDummyTransport() {
return Sentry.createTransport({ recordDroppedEvent: () => undefined, textEncoder: new TextEncoder() }, req => {
--remaining;
if (!remaining) {
console.log(colorize('PASSED: Webpack Node Domain test OK!\n', 'green'));
process.exit(0);
}
return Promise.resolve({
status: 'success',
});
});
}
Sentry.init({
dsn: 'https://a@example.com/1',
transport: makeDummyTransport,
beforeSend(event) {
if (event.message === 'inside') {
if (event.tags.a !== 'x' && event.tags.b !== 'c') {
console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red'));
console.log(colorize(`Got: ${JSON.stringify(event.tags)}\n`, 'red'));
console.log(colorize(`Expected: Object including { a: 'x', b: 'c' }\n`, 'red'));
process.exit(1);
}
}
if (event.message === 'outside') {
if (event.tags.a !== 'b') {
console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red'));
console.log(colorize(`Got: ${JSON.stringify(event.tags)}\n`, 'red'));
console.log(colorize(`Expected: Object including { a: 'b' }\n`, 'red'));
process.exit(1);
}
}
return event;
},
});
Sentry.configureScope(scope => {
scope.setTag('a', 'b');
});
const d = require('domain').create();
d.run(() => {
Sentry.configureScope(scope => {
scope.setTag('a', 'x');
scope.setTag('b', 'c');
});
Sentry.captureMessage('inside');
});
Sentry.captureMessage('outside');