Skip to content

Commit 2d76796

Browse files
committed
refactor(breadcrumbs): remove maxValueLength option and related logic from BreadcrumbsManager
1 parent f0d9315 commit 2d76796

3 files changed

Lines changed: 4 additions & 45 deletions

File tree

packages/javascript/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ const hawk = new HawkCatcher({
181181
token: 'INTEGRATION_TOKEN',
182182
breadcrumbs: {
183183
maxBreadcrumbs: 20, // Maximum breadcrumbs to store (default: 15)
184-
maxValueLength: 512, // Max string length (default: 1024)
185184
trackFetch: true, // Track fetch/XHR requests (default: true)
186185
trackNavigation: true, // Track navigation events (default: true)
187186
trackClicks: true, // Track UI clicks (default: true)
@@ -201,7 +200,6 @@ const hawk = new HawkCatcher({
201200
| Option | Type | Default | Description |
202201
|--------|------|---------|-------------|
203202
| `maxBreadcrumbs` | `number` | `15` | Maximum number of breadcrumbs to store. When the limit is reached, oldest breadcrumbs are removed (FIFO). |
204-
| `maxValueLength` | `number` | `1024` | Maximum length for string values in breadcrumb data. Longer strings will be trimmed with `` suffix. |
205203
| `trackFetch` | `boolean` | `true` | Automatically track `fetch()` and `XMLHttpRequest` calls as breadcrumbs. Captures request URL, method, status code, and response time. |
206204
| `trackNavigation` | `boolean` | `true` | Automatically track navigation events (History API: `pushState`, `replaceState`, `popstate`). Captures route changes. |
207205
| `trackClicks` | `boolean` | `true` | Automatically track UI click events. Captures element selector, coordinates, and other click metadata. |

packages/javascript/example/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ <h2>Test Vue integration: &lt;test-component&gt;</h2>
306306
},
307307
// breadcrumbs: {
308308
// maxBreadcrumbs: 20, // Maximum breadcrumbs to store (default: 15)
309-
// maxValueLength: 512, // Max string length (default: 1024)
310309
// trackFetch: true, // Track fetch/XHR requests (default: true)
311310
// trackNavigation: true, // Track navigation events (default: true)
312311
// trackClicks: true, // Track UI clicks (default: true)

packages/javascript/src/addons/breadcrumbs.ts

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import log from '../utils/log';
1111
*/
1212
const DEFAULT_MAX_BREADCRUMBS = 15;
1313

14-
/**
15-
* Maximum length for string values in breadcrumb data
16-
*/
17-
const DEFAULT_MAX_VALUE_LENGTH = 1024;
18-
1914
/**
2015
* Hint object passed to beforeBreadcrumb callback
2116
*/
@@ -52,13 +47,6 @@ export interface BreadcrumbsOptions {
5247
*/
5348
maxBreadcrumbs?: number;
5449

55-
/**
56-
* Maximum length for string values (will be trimmed)
57-
*
58-
* @default 1024
59-
*/
60-
maxValueLength?: number;
61-
6250
/**
6351
* Hook called before each breadcrumb is stored
6452
* Return null to discard the breadcrumb
@@ -100,7 +88,6 @@ export type BreadcrumbInput = Omit<Breadcrumb, 'timestamp'> & { timestamp?: Brea
10088
*/
10189
interface InternalBreadcrumbsOptions {
10290
maxBreadcrumbs: number;
103-
maxValueLength: number;
10491
trackFetch: boolean;
10592
trackNavigation: boolean;
10693
trackClicks: boolean;
@@ -172,7 +159,6 @@ export class BreadcrumbManager {
172159
private constructor() {
173160
this.options = {
174161
maxBreadcrumbs: DEFAULT_MAX_BREADCRUMBS,
175-
maxValueLength: DEFAULT_MAX_VALUE_LENGTH,
176162
trackFetch: true,
177163
trackNavigation: true,
178164
trackClicks: true,
@@ -202,7 +188,6 @@ export class BreadcrumbManager {
202188

203189
this.options = {
204190
maxBreadcrumbs: options.maxBreadcrumbs ?? DEFAULT_MAX_BREADCRUMBS,
205-
maxValueLength: options.maxValueLength ?? DEFAULT_MAX_VALUE_LENGTH,
206191
beforeBreadcrumb: options.beforeBreadcrumb,
207192
trackFetch: options.trackFetch ?? true,
208193
trackNavigation: options.trackNavigation ?? true,
@@ -261,18 +246,18 @@ export class BreadcrumbManager {
261246
}
262247

263248
/**
264-
* Sanitize and trim data
249+
* Sanitize data and message
265250
*/
266251
if (bc.data) {
267-
bc.data = this.sanitizeData(bc.data);
252+
bc.data = Sanitizer.sanitize(bc.data) as Record<string, JsonNode>;
268253
}
269254

270255
if (bc.message) {
271-
bc.message = this.trimString(bc.message, this.options.maxValueLength);
256+
bc.message = Sanitizer.sanitize(bc.message) as string;
272257
}
273258

274259
/**
275-
* Add to buffer (FIFO - keep last N breadcrumbs)
260+
* Add to buffer (FIFO)
276261
*/
277262
this.breadcrumbs.push(bc);
278263

@@ -354,29 +339,6 @@ export class BreadcrumbManager {
354339
BreadcrumbManager.instance = null;
355340
}
356341

357-
/**
358-
* Sanitize breadcrumb data object
359-
* Sanitizer already trims strings, so no additional trimming needed
360-
*
361-
* @param data - The data object to sanitize
362-
*/
363-
private sanitizeData(data: Record<string, unknown>): Record<string, JsonNode> {
364-
return Sanitizer.sanitize(data) as Record<string, JsonNode>;
365-
}
366-
367-
/**
368-
* Trim string to max length
369-
*
370-
* @param str - The string to trim
371-
* @param maxLength - Maximum allowed length
372-
*/
373-
private trimString(str: string, maxLength: number): string {
374-
if (str.length > maxLength) {
375-
return str.substring(0, maxLength) + '…';
376-
}
377-
378-
return str;
379-
}
380342

381343
/**
382344
* Monkeypatch fetch API to capture HTTP breadcrumbs

0 commit comments

Comments
 (0)