@@ -5,6 +5,7 @@ import { Integration } from '@sentry/types';
5
5
import {
6
6
addInstrumentationHandler ,
7
7
htmlTreeAsString ,
8
+ logger ,
8
9
parseUrl ,
9
10
safeJoin ,
10
11
severityLevelFromString ,
@@ -19,7 +20,6 @@ interface BreadcrumbsOptions {
19
20
| boolean
20
21
| {
21
22
serializeAttribute ?: string | string [ ] ;
22
- /** maxStringLength gets capped at 1024 to prevent 100 breadcrumbs exceeding 1MB event payload size */
23
23
maxStringLength ?: number ;
24
24
} ;
25
25
fetch : boolean ;
@@ -28,6 +28,9 @@ interface BreadcrumbsOptions {
28
28
xhr : boolean ;
29
29
}
30
30
31
+ /** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */
32
+ const MAX_ALLOWED_STRING_LENGTH = 1024 ;
33
+
31
34
export const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs' ;
32
35
33
36
/**
@@ -103,10 +106,17 @@ function _domBreadcrumb(dom: BreadcrumbsOptions['dom']): (handlerData: { [key: s
103
106
function _innerDomBreadcrumb ( handlerData : { [ key : string ] : any } ) : void {
104
107
let target ;
105
108
let keyAttrs = typeof dom === 'object' ? dom . serializeAttribute : undefined ;
106
- const maxStringLength =
107
- typeof dom === 'object' && typeof dom . maxStringLength === 'number'
108
- ? Math . min ( dom . maxStringLength , 1024 )
109
- : undefined ;
109
+
110
+ let maxStringLength =
111
+ typeof dom === 'object' && typeof dom . maxStringLength === 'number' ? dom . maxStringLength : undefined ;
112
+ if ( maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH ) {
113
+ if ( __DEBUG_BUILD__ ) {
114
+ logger . warn (
115
+ `\`dom.maxStringLength\` cannot exceed ${ MAX_ALLOWED_STRING_LENGTH } , but a value of ${ maxStringLength } was configured. Sentry will use ${ MAX_ALLOWED_STRING_LENGTH } instead.` ,
116
+ ) ;
117
+ }
118
+ maxStringLength = MAX_ALLOWED_STRING_LENGTH ;
119
+ }
110
120
111
121
if ( typeof keyAttrs === 'string' ) {
112
122
keyAttrs = [ keyAttrs ] ;
0 commit comments