Skip to content

Commit a7d61df

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feat/separate-source-reading
2 parents f278e8b + 1bf9883 commit a7d61df

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

packages/hub/src/hub.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class Hub implements HubInterface {
185185
*/
186186
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
187187
public captureException(exception: any, hint?: EventHint): string {
188-
const eventId = (this._lastEventId = uuid4());
188+
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
189189
let finalHint = hint;
190190

191191
// If there's no explicit hint provided, mimic the same thing that would happen
@@ -216,7 +216,7 @@ export class Hub implements HubInterface {
216216
* @inheritDoc
217217
*/
218218
public captureMessage(message: string, level?: Severity, hint?: EventHint): string {
219-
const eventId = (this._lastEventId = uuid4());
219+
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
220220
let finalHint = hint;
221221

222222
// If there's no explicit hint provided, mimic the same thing that would happen
@@ -247,7 +247,7 @@ export class Hub implements HubInterface {
247247
* @inheritDoc
248248
*/
249249
public captureEvent(event: Event, hint?: EventHint): string {
250-
const eventId = uuid4();
250+
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
251251
if (event.type !== 'transaction') {
252252
this._lastEventId = eventId;
253253
}

packages/hub/test/hub.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ describe('Hub', () => {
222222
expect(testClient.captureException.mock.calls[0][1].event_id).toBeTruthy();
223223
});
224224

225+
test('should keep event_id from hint', () => {
226+
const testClient = makeClient();
227+
const hub = new Hub(testClient);
228+
const id = Math.random().toString();
229+
hub.captureException('a', { event_id: id });
230+
expect(testClient.captureException.mock.calls[0][1].event_id).toBe(id);
231+
});
232+
225233
test('should generate hint if not provided in the call', () => {
226234
const testClient = makeClient();
227235
const hub = new Hub(testClient);
@@ -248,6 +256,14 @@ describe('Hub', () => {
248256
expect(testClient.captureMessage.mock.calls[0][2].event_id).toBeTruthy();
249257
});
250258

259+
test('should keep event_id from hint', () => {
260+
const testClient = makeClient();
261+
const hub = new Hub(testClient);
262+
const id = Math.random().toString();
263+
hub.captureMessage('a', undefined, { event_id: id });
264+
expect(testClient.captureMessage.mock.calls[0][2].event_id).toBe(id);
265+
});
266+
251267
test('should generate hint if not provided in the call', () => {
252268
const testClient = makeClient();
253269
const hub = new Hub(testClient);
@@ -279,6 +295,17 @@ describe('Hub', () => {
279295
expect(testClient.captureEvent.mock.calls[0][1].event_id).toBeTruthy();
280296
});
281297

298+
test('should keep event_id from hint', () => {
299+
const event: Event = {
300+
extra: { b: 3 },
301+
};
302+
const testClient = makeClient();
303+
const hub = new Hub(testClient);
304+
const id = Math.random().toString();
305+
hub.captureEvent(event, { event_id: id });
306+
expect(testClient.captureEvent.mock.calls[0][1].event_id).toBe(id);
307+
});
308+
282309
test('sets lastEventId', () => {
283310
const event: Event = {
284311
extra: { b: 3 },

packages/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"build:dev:watch": "run-s build:watch",
4949
"build:es5:watch": "yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***",
5050
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
51-
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts",
51+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular --exclude 'config/types\\.ts' src/index.server.ts # see https://github.com/pahen/madge/issues/306",
5252
"clean": "rimraf dist esm coverage *.js *.js.map *.d.ts",
5353
"fix": "run-s fix:eslint fix:prettier",
5454
"fix:eslint": "eslint . --format stylish --fix",

packages/nextjs/src/index.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function filterTransactions(event: Event): Event | null {
127127
}
128128

129129
export { withSentryConfig } from './config';
130+
export { SentryWebpackPluginOptions } from './config/types';
130131
export { withSentry } from './utils/withSentry';
131132

132133
// Wrap various server methods to enable error monitoring and tracing. (Note: This only happens for non-Vercel

packages/wasm/rollup.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const terserInstance = terser({
1010
// We need those full names to correctly detect our internal frames for stripping.
1111
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
1212
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
13-
properties: false,
13+
properties: {
14+
regex: /^_[^_]/,
15+
},
1416
},
1517
output: {
1618
comments: false,

0 commit comments

Comments
 (0)