@tracelog/lib 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -390,72 +390,6 @@ interface EventData {
390
390
  utm?: UTM;
391
391
  }
392
392
 
393
- /**
394
- * Consolidated configuration constants for TraceLog
395
- * This file centralizes all timing, limits, browser, and initialization constants
396
- */
397
- declare const DEFAULT_SESSION_TIMEOUT: number;
398
- declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
399
- declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
400
- declare const MAX_CUSTOM_EVENT_KEYS = 10;
401
- declare const MAX_CUSTOM_EVENT_ARRAY_SIZE = 10;
402
- declare const MAX_NESTED_OBJECT_KEYS = 20;
403
- declare const MAX_METADATA_NESTING_DEPTH = 1;
404
- declare const MAX_STRING_LENGTH = 1000;
405
- declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
406
- declare const MAX_ARRAY_LENGTH = 100;
407
-
408
- /**
409
- * Event types that can be disabled from auto-tracking
410
- * Core events (PAGE_VIEW, CLICK, SESSION_*) cannot be disabled as they are essential for analytics
411
- */
412
- declare const DISABLEABLE_EVENT_TYPES: readonly ["scroll", "web_vitals", "error"];
413
- type DisabledEventType = (typeof DISABLEABLE_EVENT_TYPES)[number];
414
-
415
- /**
416
- * Error handling and PII sanitization constants for TraceLog
417
- * Centralizes patterns and limits for error tracking and data protection
418
- */
419
- /**
420
- * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
421
- * These patterns are used to replace sensitive information with [REDACTED] in error messages
422
- */
423
- declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
424
-
425
- /**
426
- * Performance monitoring and web vitals constants for TraceLog
427
- * Centralizes thresholds and configuration for performance tracking
428
- */
429
-
430
- /**
431
- * Web Vitals "good" thresholds (75th percentile boundaries)
432
- * Metrics below or equal to these values are considered good performance.
433
- * Reference: https://web.dev/articles/vitals
434
- */
435
- declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
436
- /**
437
- * Web Vitals "needs improvement" thresholds
438
- * Metrics exceeding these values need attention but aren't critically poor.
439
- * Reference: https://web.dev/articles/vitals
440
- */
441
- declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
442
- /**
443
- * Web Vitals "poor" thresholds
444
- * Metrics exceeding these values indicate poor performance requiring immediate attention.
445
- * Reference: https://web.dev/articles/vitals
446
- */
447
- declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
448
- /**
449
- * Default Web Vitals mode
450
- * 'needs-improvement' provides balanced approach - captures metrics that need attention
451
- * while filtering out good performance (reduces noise and costs)
452
- */
453
- declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
454
- /**
455
- * Get Web Vitals thresholds for the specified mode
456
- */
457
- declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
458
-
459
393
  /**
460
394
  * Web Vitals filtering mode
461
395
  * - 'all': Track all Web Vitals metrics (full analytics)
@@ -496,18 +430,6 @@ interface Config {
496
430
  * Only applies when webVitalsMode is set. Overrides default thresholds for the selected mode.
497
431
  */
498
432
  webVitalsThresholds?: Partial<Record<WebVitalType, number>>;
499
- /**
500
- * Event types to disable from auto-tracking.
501
- * Core events (PAGE_VIEW, CLICK, SESSION_*) cannot be disabled as they are essential for analytics.
502
- * @default []
503
- * @example
504
- * // Disable scroll tracking only
505
- * disabledEvents: ['scroll']
506
- * @example
507
- * // Disable performance and error tracking
508
- * disabledEvents: ['web_vitals', 'error']
509
- */
510
- disabledEvents?: DisabledEventType[];
511
433
  /** Optional configuration for third-party integrations. */
512
434
  integrations?: {
513
435
  /** TraceLog integration options. */
@@ -2434,6 +2356,65 @@ declare global {
2434
2356
  declare function setTransformer(hook: 'beforeSend', fn: BeforeSendTransformer): void;
2435
2357
  declare function setTransformer(hook: 'beforeBatch', fn: BeforeBatchTransformer): void;
2436
2358
 
2359
+ /**
2360
+ * Consolidated configuration constants for TraceLog
2361
+ * This file centralizes all timing, limits, browser, and initialization constants
2362
+ */
2363
+ declare const DEFAULT_SESSION_TIMEOUT: number;
2364
+ declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
2365
+ declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
2366
+ declare const MAX_CUSTOM_EVENT_KEYS = 10;
2367
+ declare const MAX_CUSTOM_EVENT_ARRAY_SIZE = 10;
2368
+ declare const MAX_NESTED_OBJECT_KEYS = 20;
2369
+ declare const MAX_METADATA_NESTING_DEPTH = 1;
2370
+ declare const MAX_STRING_LENGTH = 1000;
2371
+ declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
2372
+ declare const MAX_ARRAY_LENGTH = 100;
2373
+
2374
+ /**
2375
+ * Error handling and PII sanitization constants for TraceLog
2376
+ * Centralizes patterns and limits for error tracking and data protection
2377
+ */
2378
+ /**
2379
+ * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
2380
+ * These patterns are used to replace sensitive information with [REDACTED] in error messages
2381
+ */
2382
+ declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
2383
+
2384
+ /**
2385
+ * Performance monitoring and web vitals constants for TraceLog
2386
+ * Centralizes thresholds and configuration for performance tracking
2387
+ */
2388
+
2389
+ /**
2390
+ * Web Vitals "good" thresholds (75th percentile boundaries)
2391
+ * Metrics below or equal to these values are considered good performance.
2392
+ * Reference: https://web.dev/articles/vitals
2393
+ */
2394
+ declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
2395
+ /**
2396
+ * Web Vitals "needs improvement" thresholds
2397
+ * Metrics exceeding these values need attention but aren't critically poor.
2398
+ * Reference: https://web.dev/articles/vitals
2399
+ */
2400
+ declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
2401
+ /**
2402
+ * Web Vitals "poor" thresholds
2403
+ * Metrics exceeding these values indicate poor performance requiring immediate attention.
2404
+ * Reference: https://web.dev/articles/vitals
2405
+ */
2406
+ declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
2407
+ /**
2408
+ * Default Web Vitals mode
2409
+ * 'needs-improvement' provides balanced approach - captures metrics that need attention
2410
+ * while filtering out good performance (reduces noise and costs)
2411
+ */
2412
+ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
2413
+ /**
2414
+ * Get Web Vitals thresholds for the specified mode
2415
+ */
2416
+ declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
2417
+
2437
2418
  declare const tracelog: {
2438
2419
  init: (config?: Config) => Promise<void>;
2439
2420
  event: (name: string, metadata?: Record<string, MetadataType> | Record<string, MetadataType>[]) => void;
@@ -390,72 +390,6 @@ interface EventData {
390
390
  utm?: UTM;
391
391
  }
392
392
 
393
- /**
394
- * Consolidated configuration constants for TraceLog
395
- * This file centralizes all timing, limits, browser, and initialization constants
396
- */
397
- declare const DEFAULT_SESSION_TIMEOUT: number;
398
- declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
399
- declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
400
- declare const MAX_CUSTOM_EVENT_KEYS = 10;
401
- declare const MAX_CUSTOM_EVENT_ARRAY_SIZE = 10;
402
- declare const MAX_NESTED_OBJECT_KEYS = 20;
403
- declare const MAX_METADATA_NESTING_DEPTH = 1;
404
- declare const MAX_STRING_LENGTH = 1000;
405
- declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
406
- declare const MAX_ARRAY_LENGTH = 100;
407
-
408
- /**
409
- * Event types that can be disabled from auto-tracking
410
- * Core events (PAGE_VIEW, CLICK, SESSION_*) cannot be disabled as they are essential for analytics
411
- */
412
- declare const DISABLEABLE_EVENT_TYPES: readonly ["scroll", "web_vitals", "error"];
413
- type DisabledEventType = (typeof DISABLEABLE_EVENT_TYPES)[number];
414
-
415
- /**
416
- * Error handling and PII sanitization constants for TraceLog
417
- * Centralizes patterns and limits for error tracking and data protection
418
- */
419
- /**
420
- * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
421
- * These patterns are used to replace sensitive information with [REDACTED] in error messages
422
- */
423
- declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
424
-
425
- /**
426
- * Performance monitoring and web vitals constants for TraceLog
427
- * Centralizes thresholds and configuration for performance tracking
428
- */
429
-
430
- /**
431
- * Web Vitals "good" thresholds (75th percentile boundaries)
432
- * Metrics below or equal to these values are considered good performance.
433
- * Reference: https://web.dev/articles/vitals
434
- */
435
- declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
436
- /**
437
- * Web Vitals "needs improvement" thresholds
438
- * Metrics exceeding these values need attention but aren't critically poor.
439
- * Reference: https://web.dev/articles/vitals
440
- */
441
- declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
442
- /**
443
- * Web Vitals "poor" thresholds
444
- * Metrics exceeding these values indicate poor performance requiring immediate attention.
445
- * Reference: https://web.dev/articles/vitals
446
- */
447
- declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
448
- /**
449
- * Default Web Vitals mode
450
- * 'needs-improvement' provides balanced approach - captures metrics that need attention
451
- * while filtering out good performance (reduces noise and costs)
452
- */
453
- declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
454
- /**
455
- * Get Web Vitals thresholds for the specified mode
456
- */
457
- declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
458
-
459
393
  /**
460
394
  * Web Vitals filtering mode
461
395
  * - 'all': Track all Web Vitals metrics (full analytics)
@@ -496,18 +430,6 @@ interface Config {
496
430
  * Only applies when webVitalsMode is set. Overrides default thresholds for the selected mode.
497
431
  */
498
432
  webVitalsThresholds?: Partial<Record<WebVitalType, number>>;
499
- /**
500
- * Event types to disable from auto-tracking.
501
- * Core events (PAGE_VIEW, CLICK, SESSION_*) cannot be disabled as they are essential for analytics.
502
- * @default []
503
- * @example
504
- * // Disable scroll tracking only
505
- * disabledEvents: ['scroll']
506
- * @example
507
- * // Disable performance and error tracking
508
- * disabledEvents: ['web_vitals', 'error']
509
- */
510
- disabledEvents?: DisabledEventType[];
511
433
  /** Optional configuration for third-party integrations. */
512
434
  integrations?: {
513
435
  /** TraceLog integration options. */
@@ -2434,6 +2356,65 @@ declare global {
2434
2356
  declare function setTransformer(hook: 'beforeSend', fn: BeforeSendTransformer): void;
2435
2357
  declare function setTransformer(hook: 'beforeBatch', fn: BeforeBatchTransformer): void;
2436
2358
 
2359
+ /**
2360
+ * Consolidated configuration constants for TraceLog
2361
+ * This file centralizes all timing, limits, browser, and initialization constants
2362
+ */
2363
+ declare const DEFAULT_SESSION_TIMEOUT: number;
2364
+ declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
2365
+ declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
2366
+ declare const MAX_CUSTOM_EVENT_KEYS = 10;
2367
+ declare const MAX_CUSTOM_EVENT_ARRAY_SIZE = 10;
2368
+ declare const MAX_NESTED_OBJECT_KEYS = 20;
2369
+ declare const MAX_METADATA_NESTING_DEPTH = 1;
2370
+ declare const MAX_STRING_LENGTH = 1000;
2371
+ declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
2372
+ declare const MAX_ARRAY_LENGTH = 100;
2373
+
2374
+ /**
2375
+ * Error handling and PII sanitization constants for TraceLog
2376
+ * Centralizes patterns and limits for error tracking and data protection
2377
+ */
2378
+ /**
2379
+ * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
2380
+ * These patterns are used to replace sensitive information with [REDACTED] in error messages
2381
+ */
2382
+ declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
2383
+
2384
+ /**
2385
+ * Performance monitoring and web vitals constants for TraceLog
2386
+ * Centralizes thresholds and configuration for performance tracking
2387
+ */
2388
+
2389
+ /**
2390
+ * Web Vitals "good" thresholds (75th percentile boundaries)
2391
+ * Metrics below or equal to these values are considered good performance.
2392
+ * Reference: https://web.dev/articles/vitals
2393
+ */
2394
+ declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
2395
+ /**
2396
+ * Web Vitals "needs improvement" thresholds
2397
+ * Metrics exceeding these values need attention but aren't critically poor.
2398
+ * Reference: https://web.dev/articles/vitals
2399
+ */
2400
+ declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
2401
+ /**
2402
+ * Web Vitals "poor" thresholds
2403
+ * Metrics exceeding these values indicate poor performance requiring immediate attention.
2404
+ * Reference: https://web.dev/articles/vitals
2405
+ */
2406
+ declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
2407
+ /**
2408
+ * Default Web Vitals mode
2409
+ * 'needs-improvement' provides balanced approach - captures metrics that need attention
2410
+ * while filtering out good performance (reduces noise and costs)
2411
+ */
2412
+ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
2413
+ /**
2414
+ * Get Web Vitals thresholds for the specified mode
2415
+ */
2416
+ declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
2417
+
2437
2418
  declare const tracelog: {
2438
2419
  init: (config?: Config) => Promise<void>;
2439
2420
  event: (name: string, metadata?: Record<string, MetadataType> | Record<string, MetadataType>[]) => void;
@@ -533,14 +533,6 @@ var init_app_constants = __esm({
533
533
  }
534
534
  });
535
535
 
536
- // src/constants/disabled-events.constants.ts
537
- var DISABLEABLE_EVENT_TYPES;
538
- var init_disabled_events_constants = __esm({
539
- "src/constants/disabled-events.constants.ts"() {
540
- DISABLEABLE_EVENT_TYPES = ["scroll", "web_vitals", "error"];
541
- }
542
- });
543
-
544
536
  // src/constants/error.constants.ts
545
537
  var PII_PATTERNS, MAX_ERROR_MESSAGE_LENGTH, ERROR_SUPPRESSION_WINDOW_MS, MAX_TRACKED_ERRORS, MAX_TRACKED_ERRORS_HARD_LIMIT, DEFAULT_ERROR_SAMPLING_RATE, ERROR_BURST_WINDOW_MS, ERROR_BURST_THRESHOLD, ERROR_BURST_BACKOFF_MS, PERMANENT_ERROR_LOG_THROTTLE_MS;
546
538
  var init_error_constants = __esm({
@@ -639,7 +631,7 @@ var init_performance_constants = __esm({
639
631
  var version;
640
632
  var init_package = __esm({
641
633
  "package.json"() {
642
- version = "2.0.1";
634
+ version = "2.0.2";
643
635
  }
644
636
  });
645
637
 
@@ -657,7 +649,6 @@ var init_constants = __esm({
657
649
  "src/constants/index.ts"() {
658
650
  init_app_constants();
659
651
  init_config_constants();
660
- init_disabled_events_constants();
661
652
  init_error_constants();
662
653
  init_storage_constants();
663
654
  init_performance_constants();
@@ -1109,30 +1100,6 @@ var init_config_validations_utils = __esm({
1109
1100
  if (config.viewport !== void 0) {
1110
1101
  validateViewportConfig(config.viewport);
1111
1102
  }
1112
- if (config.disabledEvents !== void 0) {
1113
- if (!Array.isArray(config.disabledEvents)) {
1114
- throw new AppConfigValidationError("disabledEvents must be an array", "config");
1115
- }
1116
- const uniqueEvents = /* @__PURE__ */ new Set();
1117
- for (const eventType of config.disabledEvents) {
1118
- if (typeof eventType !== "string") {
1119
- throw new AppConfigValidationError("All disabled event types must be strings", "config");
1120
- }
1121
- if (!DISABLEABLE_EVENT_TYPES.includes(eventType)) {
1122
- throw new AppConfigValidationError(
1123
- `Invalid disabled event type: "${eventType}". Must be one of: ${DISABLEABLE_EVENT_TYPES.join(", ")}`,
1124
- "config"
1125
- );
1126
- }
1127
- if (uniqueEvents.has(eventType)) {
1128
- throw new AppConfigValidationError(
1129
- `Duplicate disabled event type found: "${eventType}". Each event type should appear only once.`,
1130
- "config"
1131
- );
1132
- }
1133
- uniqueEvents.add(eventType);
1134
- }
1135
- }
1136
1103
  if (config.webVitalsMode !== void 0) {
1137
1104
  if (typeof config.webVitalsMode !== "string") {
1138
1105
  throw new AppConfigValidationError(
@@ -1260,8 +1227,7 @@ var init_config_validations_utils = __esm({
1260
1227
  samplingRate: config?.samplingRate ?? DEFAULT_SAMPLING_RATE,
1261
1228
  pageViewThrottleMs: config?.pageViewThrottleMs ?? DEFAULT_PAGE_VIEW_THROTTLE_MS,
1262
1229
  clickThrottleMs: config?.clickThrottleMs ?? DEFAULT_CLICK_THROTTLE_MS,
1263
- maxSameEventPerMinute: config?.maxSameEventPerMinute ?? MAX_SAME_EVENT_PER_MINUTE,
1264
- disabledEvents: config?.disabledEvents ?? []
1230
+ maxSameEventPerMinute: config?.maxSameEventPerMinute ?? MAX_SAME_EVENT_PER_MINUTE
1265
1231
  };
1266
1232
  if (normalizedConfig.integrations?.custom) {
1267
1233
  normalizedConfig.integrations.custom = {
@@ -6495,7 +6461,6 @@ var init_app = __esm({
6495
6461
  }
6496
6462
  initializeHandlers() {
6497
6463
  const config = this.get("config");
6498
- const disabledEvents = config.disabledEvents ?? [];
6499
6464
  this.handlers.session = new SessionHandler(
6500
6465
  this.managers.storage,
6501
6466
  this.managers.event
@@ -6514,20 +6479,14 @@ var init_app = __esm({
6514
6479
  this.handlers.pageView.startTracking();
6515
6480
  this.handlers.click = new ClickHandler(this.managers.event);
6516
6481
  this.handlers.click.startTracking();
6517
- if (!disabledEvents.includes("scroll")) {
6518
- this.handlers.scroll = new ScrollHandler(this.managers.event);
6519
- this.handlers.scroll.startTracking();
6520
- }
6521
- if (!disabledEvents.includes("web_vitals")) {
6522
- this.handlers.performance = new PerformanceHandler(this.managers.event);
6523
- this.handlers.performance.startTracking().catch((error) => {
6524
- log("warn", "Failed to start performance tracking", { error });
6525
- });
6526
- }
6527
- if (!disabledEvents.includes("error")) {
6528
- this.handlers.error = new ErrorHandler(this.managers.event);
6529
- this.handlers.error.startTracking();
6530
- }
6482
+ this.handlers.scroll = new ScrollHandler(this.managers.event);
6483
+ this.handlers.scroll.startTracking();
6484
+ this.handlers.performance = new PerformanceHandler(this.managers.event);
6485
+ this.handlers.performance.startTracking().catch((error) => {
6486
+ log("warn", "Failed to start performance tracking", { error });
6487
+ });
6488
+ this.handlers.error = new ErrorHandler(this.managers.event);
6489
+ this.handlers.error.startTracking();
6531
6490
  if (config.viewport) {
6532
6491
  this.handlers.viewport = new ViewportHandler(this.managers.event);
6533
6492
  this.handlers.viewport.startTracking();