Skip to content

Commit 8295ecb

Browse files
committed
move to constants
1 parent 399fd1d commit 8295ecb

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

packages/replay/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ export const RETRY_MAX_COUNT = 3;
3131

3232
/* The max (uncompressed) size in bytes of a network body. Any body larger than this will be truncated. */
3333
export const NETWORK_BODY_MAX_SIZE = 150_000;
34+
35+
/* The max size of a single console arg that is captured. Any arg larger than this will be truncated. */
36+
export const CONSOLE_ARG_MAX_SIZE = 5_000;

packages/replay/src/coreHandlers/handleScope.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { Breadcrumb, Scope } from '@sentry/types';
22
import { normalize } from '@sentry/utils';
33

4+
import { CONSOLE_ARG_MAX_SIZE } from '../constants';
45
import type { ReplayContainer } from '../types';
56
import { createBreadcrumb } from '../util/createBreadcrumb';
67
import { fixJson } from '../util/truncateJson/fixJson';
78
import { addBreadcrumbEvent } from './util/addBreadcrumbEvent';
89

910
let _LAST_BREADCRUMB: null | Breadcrumb = null;
1011

11-
export const CONSOLE_ARG_MAX_SIZE = 5_000;
12-
1312
export const handleScopeListener: (replay: ReplayContainer) => (scope: Scope) => void =
1413
(replay: ReplayContainer) =>
1514
(scope: Scope): void => {

packages/replay/test/unit/coreHandlers/handleScope.test.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Breadcrumb, Scope } from '@sentry/types';
22

3+
import { CONSOLE_ARG_MAX_SIZE } from '../../../src/constants';
34
import * as HandleScope from '../../../src/coreHandlers/handleScope';
45

56
describe('Unit | coreHandlers | handleScope', () => {
@@ -97,10 +98,7 @@ describe('Unit | coreHandlers | handleScope', () => {
9798
category: 'console',
9899
message: 'test',
99100
data: {
100-
arguments: [
101-
'a'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE + 10),
102-
'b'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE + 10),
103-
],
101+
arguments: ['a'.repeat(CONSOLE_ARG_MAX_SIZE + 10), 'b'.repeat(CONSOLE_ARG_MAX_SIZE + 10)],
104102
},
105103
};
106104
const actual = HandleScope.normalizeConsoleBreadcrumb(breadcrumb);
@@ -109,10 +107,7 @@ describe('Unit | coreHandlers | handleScope', () => {
109107
category: 'console',
110108
message: 'test',
111109
data: {
112-
arguments: [
113-
`${'a'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE)}…`,
114-
`${'b'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE)}…`,
115-
],
110+
arguments: [`${'a'.repeat(CONSOLE_ARG_MAX_SIZE)}…`, `${'b'.repeat(CONSOLE_ARG_MAX_SIZE)}…`],
116111
_meta: { warnings: ['CONSOLE_ARG_TRUNCATED'] },
117112
},
118113
});
@@ -125,8 +120,8 @@ describe('Unit | coreHandlers | handleScope', () => {
125120
data: {
126121
arguments: [
127122
{ aa: 'yes' },
128-
{ bb: 'b'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE + 10) },
129-
{ c: 'c'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE + 10) },
123+
{ bb: 'b'.repeat(CONSOLE_ARG_MAX_SIZE + 10) },
124+
{ c: 'c'.repeat(CONSOLE_ARG_MAX_SIZE + 10) },
130125
],
131126
},
132127
};
@@ -138,8 +133,8 @@ describe('Unit | coreHandlers | handleScope', () => {
138133
data: {
139134
arguments: [
140135
{ aa: 'yes' },
141-
{ bb: `${'b'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE - 7)}~~` },
142-
{ c: `${'c'.repeat(HandleScope.CONSOLE_ARG_MAX_SIZE - 6)}~~` },
136+
{ bb: `${'b'.repeat(CONSOLE_ARG_MAX_SIZE - 7)}~~` },
137+
{ c: `${'c'.repeat(CONSOLE_ARG_MAX_SIZE - 6)}~~` },
143138
],
144139
_meta: { warnings: ['CONSOLE_ARG_TRUNCATED'] },
145140
},

0 commit comments

Comments
 (0)