Skip to content

Commit 7066d25

Browse files
authored
fix: Update handling of console breadcrumb arguments (#1741)
* fix: Missing breadcrumb argument * fix: Serialize only 2 levels of console breadcrumb arguments
1 parent d6808f3 commit 7066d25

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Breadcrumb, Integration, SentryBreadcrumbHint, Severity } from '@sentry
33
import { isFunction, isString } from '@sentry/utils/is';
44
import { logger } from '@sentry/utils/logger';
55
import { getEventDescription, getGlobalObject, parseUrl } from '@sentry/utils/misc';
6-
import { deserialize, fill } from '@sentry/utils/object';
6+
import { deserialize, fill, serializeObject } from '@sentry/utils/object';
77
import { includes, safeJoin } from '@sentry/utils/string';
88
import { supportsBeacon, supportsHistory, supportsNativeFetch } from '@sentry/utils/supports';
99
import { BrowserClient } from '../client';
@@ -130,7 +130,7 @@ export class Breadcrumbs implements Integration {
130130
category: 'console',
131131
data: {
132132
extra: {
133-
arguments: args.slice(1),
133+
arguments: serializeObject(args, 2),
134134
},
135135
logger: 'console',
136136
},
@@ -141,7 +141,7 @@ export class Breadcrumbs implements Integration {
141141
if (level === 'assert') {
142142
if (args[0] === false) {
143143
breadcrumbData.message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;
144-
breadcrumbData.data.extra.arguments = args.slice(1);
144+
breadcrumbData.data.extra.arguments = serializeObject(args.slice(1), 2);
145145
}
146146
}
147147

packages/browser/test/integration/console-logs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
console.log('One');
22
console.warn('Two', { a: 1 });
3-
console.error('Error 2');
3+
console.error('Error 2', { b: { c: 1 } });
44
function a() {
55
throw new Error('Error thrown 3');
66
}

packages/browser/test/integration/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,9 @@ for (var idx in frames) {
14221422
var sentryData = iframe.contentWindow.sentryData[0];
14231423
assert.ok(sentryData.breadcrumbs);
14241424
assert.lengthOf(sentryData.breadcrumbs, 3);
1425+
assert.deepEqual(sentryData.breadcrumbs[0].data.extra.arguments, ['One']);
1426+
assert.deepEqual(sentryData.breadcrumbs[1].data.extra.arguments, ['Two', { a: 1 }]);
1427+
assert.deepEqual(sentryData.breadcrumbs[2].data.extra.arguments, ['Error 2', { b: '[Object]' }]);
14251428
done();
14261429
}
14271430
}

packages/utils/src/object.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,8 @@ export function urlEncode(object: { [key: string]: any }): string {
181181

182182
// Default Node.js REPL depth
183183
const MAX_SERIALIZE_EXCEPTION_DEPTH = 3;
184-
// TODO: Or is it 200kb? 🤔 — Kamil
185-
// NOTE: Yes, it is
186-
// 50kB, as 100kB is max payload size, so half sounds reasonable
187-
const MAX_SERIALIZE_EXCEPTION_SIZE = 50 * 1024;
184+
// 100kB, as 200kB is max payload size, so half sounds reasonable
185+
const MAX_SERIALIZE_EXCEPTION_SIZE = 100 * 1024;
188186
const MAX_SERIALIZE_KEYS_LENGTH = 40;
189187

190188
/** JSDoc */

0 commit comments

Comments
 (0)