|
4 | 4 | import type { Breadcrumb, BreadcrumbLevel, BreadcrumbType, Json, JsonNode } from '@hawk.so/types'; |
5 | 5 | import Sanitizer from '../modules/sanitizer'; |
6 | 6 | import { buildElementSelector } from '../utils/selector'; |
| 7 | +import log from '../utils/log'; |
7 | 8 |
|
8 | 9 | /** |
9 | 10 | * Default maximum number of breadcrumbs to store |
@@ -194,7 +195,7 @@ export class BreadcrumbManager { |
194 | 195 | */ |
195 | 196 | public init(options: BreadcrumbsOptions = {}): void { |
196 | 197 | if (this.isInitialized) { |
197 | | - console.warn('[BreadcrumbManager] init has already been called; breadcrumb configuration is global and subsequent init options are ignored.'); |
| 198 | + log('[BreadcrumbManager] init has already been called; breadcrumb configuration is global and subsequent init options are ignored.', 'warn'); |
198 | 199 |
|
199 | 200 | return; |
200 | 201 | } |
@@ -231,7 +232,8 @@ export class BreadcrumbManager { |
231 | 232 | * Add a breadcrumb to the buffer |
232 | 233 | * |
233 | 234 | * @param breadcrumb - The breadcrumb data to add |
234 | | - * @param hint - Optional hint object with original event data |
| 235 | + * @param hint - Optional hint object with original event data (Event, Response, XMLHttpRequest, etc.) |
| 236 | + * Used by beforeBreadcrumb callback to access original event context |
235 | 237 | */ |
236 | 238 | public addBreadcrumb(breadcrumb: BreadcrumbInput, hint?: BreadcrumbHint): void { |
237 | 239 | /** |
@@ -353,20 +355,13 @@ export class BreadcrumbManager { |
353 | 355 | } |
354 | 356 |
|
355 | 357 | /** |
356 | | - * Sanitize and trim breadcrumb data object |
| 358 | + * Sanitize breadcrumb data object |
| 359 | + * Sanitizer already trims strings, so no additional trimming needed |
357 | 360 | * |
358 | 361 | * @param data - The data object to sanitize |
359 | 362 | */ |
360 | 363 | private sanitizeData(data: Record<string, unknown>): Record<string, JsonNode> { |
361 | | - const sanitized = Sanitizer.sanitize(data) as Record<string, unknown>; |
362 | | - |
363 | | - for (const key in sanitized) { |
364 | | - if (typeof sanitized[key] === 'string') { |
365 | | - sanitized[key] = this.trimString(sanitized[key] as string, this.options.maxValueLength); |
366 | | - } |
367 | | - } |
368 | | - |
369 | | - return sanitized as Record<string, JsonNode>; |
| 364 | + return Sanitizer.sanitize(data) as Record<string, JsonNode>; |
370 | 365 | } |
371 | 366 |
|
372 | 367 | /** |
@@ -441,7 +436,7 @@ export class BreadcrumbManager { |
441 | 436 | manager.addBreadcrumb({ |
442 | 437 | type: 'request', |
443 | 438 | category: 'fetch', |
444 | | - message: `${method} ${url} failed`, |
| 439 | + message: `[FAIL] ${method} ${url}`, |
445 | 440 | level: 'error', |
446 | 441 | data: { |
447 | 442 | url, |
|
0 commit comments