6
6
addInstrumentationHandler ,
7
7
getEventDescription ,
8
8
htmlTreeAsString ,
9
+ logger ,
9
10
parseUrl ,
10
11
safeJoin ,
11
12
severityLevelFromString ,
@@ -20,7 +21,6 @@ interface BreadcrumbsOptions {
20
21
| boolean
21
22
| {
22
23
serializeAttribute ?: string | string [ ] ;
23
- /** maxStringLength gets capped at 1024 to prevent 100 breadcrumbs exceeding 1MB event payload size */
24
24
maxStringLength ?: number ;
25
25
} ;
26
26
fetch : boolean ;
@@ -29,6 +29,9 @@ interface BreadcrumbsOptions {
29
29
xhr : boolean ;
30
30
}
31
31
32
+ /** maxStringLength gets capped to prevent 100 breadcrumbs exceeding 1MB event payload size */
33
+ const MAX_ALLOWED_STRING_LENGTH = 1024 ;
34
+
32
35
export const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs' ;
33
36
34
37
/**
@@ -123,10 +126,17 @@ function _domBreadcrumb(dom: BreadcrumbsOptions['dom']): (handlerData: { [key: s
123
126
function _innerDomBreadcrumb ( handlerData : { [ key : string ] : any } ) : void {
124
127
let target ;
125
128
let keyAttrs = typeof dom === 'object' ? dom . serializeAttribute : undefined ;
126
- const maxStringLength =
127
- typeof dom === 'object' && typeof dom . maxStringLength === 'number'
128
- ? Math . min ( dom . maxStringLength , 1024 )
129
- : undefined ;
129
+
130
+ let maxStringLength =
131
+ typeof dom === 'object' && typeof dom . maxStringLength === 'number' ? dom . maxStringLength : undefined ;
132
+ if ( maxStringLength && maxStringLength > MAX_ALLOWED_STRING_LENGTH ) {
133
+ if ( __DEBUG_BUILD__ ) {
134
+ logger . warn (
135
+ `\`dom.maxStringLength\` cannot exceed ${ MAX_ALLOWED_STRING_LENGTH } , but a value of ${ maxStringLength } was configured. Sentry will use ${ MAX_ALLOWED_STRING_LENGTH } instead.` ,
136
+ ) ;
137
+ }
138
+ maxStringLength = MAX_ALLOWED_STRING_LENGTH ;
139
+ }
130
140
131
141
if ( typeof keyAttrs === 'string' ) {
132
142
keyAttrs = [ keyAttrs ] ;
0 commit comments