@tracelog/lib 0.11.5 → 0.12.1

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.
@@ -58,60 +58,6 @@ interface ViewportConfig {
58
58
  maxTrackedElements?: number;
59
59
  }
60
60
 
61
- interface Config {
62
- /** Session inactivity timeout in milliseconds. @default 900000 */
63
- sessionTimeout?: number;
64
- /** Metadata appended to every tracked event. */
65
- globalMetadata?: Record<string, MetadataType>;
66
- /** Query parameters to remove before tracking URLs. */
67
- sensitiveQueryParams?: string[];
68
- /** Error event sampling rate between 0 and 1. @default 1 */
69
- errorSampling?: number;
70
- /** Event sampling rate between 0 and 1. @default 1 */
71
- samplingRate?: number;
72
- /** CSS selector to manually override primary scroll container detection. */
73
- primaryScrollSelector?: string;
74
- /** Viewport visibility tracking configuration. */
75
- viewport?: ViewportConfig;
76
- /** Page view throttle duration in milliseconds to prevent rapid navigation spam. @default 1000 */
77
- pageViewThrottleMs?: number;
78
- /** Click throttle duration in milliseconds to prevent double-clicks and rapid spam. @default 300 */
79
- clickThrottleMs?: number;
80
- /** Maximum number of same custom event name allowed per minute to prevent infinite loops. @default 60 */
81
- maxSameEventPerMinute?: number;
82
- /** Optional configuration for third-party integrations. */
83
- integrations?: {
84
- /** TraceLog integration options. */
85
- tracelog?: {
86
- /** Required project ID TraceLog SaaS integration. */
87
- projectId: string;
88
- };
89
- /** Custom integration options. */
90
- custom?: {
91
- /** Endpoint for collecting events. */
92
- collectApiUrl: string;
93
- /** Allow HTTP URLs (not recommended for production). @default false */
94
- allowHttp?: boolean;
95
- };
96
- /** Google Analytics integration options. */
97
- googleAnalytics?: {
98
- /** Required measurement ID for Google Analytics. */
99
- measurementId: string;
100
- };
101
- };
102
- }
103
- declare enum SpecialApiUrl {
104
- Localhost = "localhost:8080",
105
- Fail = "localhost:9999"
106
- }
107
-
108
- declare enum DeviceType {
109
- Mobile = "mobile",
110
- Tablet = "tablet",
111
- Desktop = "desktop",
112
- Unknown = "unknown"
113
- }
114
-
115
61
  type SessionEndReason = 'inactivity' | 'page_unload' | 'manual_stop' | 'orphaned_cleanup' | 'tab_closed';
116
62
 
117
63
  /**
@@ -347,6 +293,79 @@ interface EventData {
347
293
  utm?: UTM;
348
294
  }
349
295
 
296
+ /**
297
+ * Web Vitals filtering mode
298
+ * - 'all': Track all Web Vitals metrics (full analytics)
299
+ * - 'needs-improvement': Track metrics that need improvement or are poor (default, balanced)
300
+ * - 'poor': Track only poor metrics (minimal data)
301
+ */
302
+ type WebVitalsMode = 'all' | 'needs-improvement' | 'poor';
303
+ interface Config {
304
+ /** Session inactivity timeout in milliseconds. @default 900000 */
305
+ sessionTimeout?: number;
306
+ /** Metadata appended to every tracked event. */
307
+ globalMetadata?: Record<string, MetadataType>;
308
+ /** Query parameters to remove before tracking URLs. */
309
+ sensitiveQueryParams?: string[];
310
+ /** Error event sampling rate between 0 and 1. @default 1 */
311
+ errorSampling?: number;
312
+ /** Event sampling rate between 0 and 1. @default 1 */
313
+ samplingRate?: number;
314
+ /** CSS selector to manually override primary scroll container detection. */
315
+ primaryScrollSelector?: string;
316
+ /** Viewport visibility tracking configuration. */
317
+ viewport?: ViewportConfig;
318
+ /** Page view throttle duration in milliseconds to prevent rapid navigation spam. @default 1000 */
319
+ pageViewThrottleMs?: number;
320
+ /** Click throttle duration in milliseconds to prevent double-clicks and rapid spam. @default 300 */
321
+ clickThrottleMs?: number;
322
+ /** Maximum number of same custom event name allowed per minute to prevent infinite loops. @default 60 */
323
+ maxSameEventPerMinute?: number;
324
+ /**
325
+ * Web Vitals filtering mode. @default 'needs-improvement'
326
+ * - 'all': Track all metrics (good, needs-improvement, poor) - full trend analysis
327
+ * - 'needs-improvement': Track metrics that need improvement or are poor - balanced approach
328
+ * - 'poor': Track only poor metrics - minimal data, focus on problems
329
+ */
330
+ webVitalsMode?: WebVitalsMode;
331
+ /**
332
+ * Custom Web Vitals thresholds in milliseconds (except CLS which is unitless).
333
+ * Only applies when webVitalsMode is set. Overrides default thresholds for the selected mode.
334
+ */
335
+ webVitalsThresholds?: Partial<Record<WebVitalType, number>>;
336
+ /** Optional configuration for third-party integrations. */
337
+ integrations?: {
338
+ /** TraceLog integration options. */
339
+ tracelog?: {
340
+ /** Required project ID TraceLog SaaS integration. */
341
+ projectId: string;
342
+ };
343
+ /** Custom integration options. */
344
+ custom?: {
345
+ /** Endpoint for collecting events. */
346
+ collectApiUrl: string;
347
+ /** Allow HTTP URLs (not recommended for production). @default false */
348
+ allowHttp?: boolean;
349
+ };
350
+ /** Google Analytics integration options. */
351
+ googleAnalytics?: {
352
+ /** Required measurement ID for Google Analytics. */
353
+ measurementId: string;
354
+ };
355
+ };
356
+ }
357
+ declare enum SpecialApiUrl {
358
+ Localhost = "localhost:8080",
359
+ Fail = "localhost:9999"
360
+ }
361
+
362
+ declare enum DeviceType {
363
+ Mobile = "mobile",
364
+ Tablet = "tablet",
365
+ Desktop = "desktop",
366
+ Unknown = "unknown"
367
+ }
368
+
350
369
  interface EventsQueue {
351
370
  user_id: string;
352
371
  session_id: string;
@@ -407,8 +426,8 @@ type SecondaryScrollEvent = EventData & {
407
426
  is_primary: false;
408
427
  };
409
428
  };
410
- declare function isPrimaryScrollEvent(event: EventData): event is PrimaryScrollEvent;
411
- declare function isSecondaryScrollEvent(event: EventData): event is SecondaryScrollEvent;
429
+ declare const isPrimaryScrollEvent: (event: EventData) => event is PrimaryScrollEvent;
430
+ declare const isSecondaryScrollEvent: (event: EventData) => event is SecondaryScrollEvent;
412
431
 
413
432
  interface State {
414
433
  mode?: Mode;
@@ -657,7 +676,7 @@ declare class PerformanceHandler extends StateManager {
657
676
  private readonly reportedByNav;
658
677
  private readonly navigationHistory;
659
678
  private readonly observers;
660
- private readonly vitalThresholds;
679
+ private vitalThresholds;
661
680
  private lastLongTaskSentAt;
662
681
  constructor(eventManager: EventManager);
663
682
  startTracking(): Promise<void>;
@@ -812,6 +831,11 @@ declare global {
812
831
  }
813
832
  }
814
833
 
834
+ /**
835
+ * Consolidated configuration constants for TraceLog
836
+ * This file centralizes all timing, limits, browser, and initialization constants
837
+ */
838
+ declare const DEFAULT_SESSION_TIMEOUT: number;
815
839
  declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
816
840
  declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
817
841
  declare const MAX_CUSTOM_EVENT_KEYS = 10;
@@ -822,12 +846,50 @@ declare const MAX_STRING_LENGTH = 1000;
822
846
  declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
823
847
  declare const MAX_ARRAY_LENGTH = 100;
824
848
 
825
- declare const PERFORMANCE_CONFIG: {
826
- readonly WEB_VITALS_THRESHOLDS: Record<WebVitalType, number>;
827
- };
828
- declare const DATA_PROTECTION: {
829
- readonly PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
830
- };
849
+ /**
850
+ * Performance monitoring and web vitals constants for TraceLog
851
+ * Centralizes thresholds and configuration for performance tracking
852
+ */
853
+
854
+ /**
855
+ * Web Vitals "good" thresholds (75th percentile boundaries)
856
+ * Metrics below or equal to these values are considered good performance.
857
+ * Reference: https://web.dev/articles/vitals
858
+ */
859
+ declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
860
+ /**
861
+ * Web Vitals "needs improvement" thresholds
862
+ * Metrics exceeding these values need attention but aren't critically poor.
863
+ * Reference: https://web.dev/articles/vitals
864
+ */
865
+ declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
866
+ /**
867
+ * Web Vitals "poor" thresholds
868
+ * Metrics exceeding these values indicate poor performance requiring immediate attention.
869
+ * Reference: https://web.dev/articles/vitals
870
+ */
871
+ declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
872
+ /**
873
+ * Default Web Vitals mode
874
+ * 'needs-improvement' provides balanced approach - captures metrics that need attention
875
+ * while filtering out good performance (reduces noise and costs)
876
+ */
877
+ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
878
+ /**
879
+ * Get Web Vitals thresholds for the specified mode
880
+ */
881
+ declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
882
+
883
+ /**
884
+ * Error handling and PII sanitization constants for TraceLog
885
+ * Centralizes patterns and limits for error tracking and data protection
886
+ */
887
+ /**
888
+ * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
889
+ * These patterns are used to replace sensitive information with [REDACTED] in error messages
890
+ */
891
+ declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
892
+
831
893
  declare const ENGAGEMENT_THRESHOLDS: {
832
894
  readonly LOW_ACTIVITY_EVENT_COUNT: 50;
833
895
  readonly HIGH_ACTIVITY_EVENT_COUNT: 1000;
@@ -843,18 +905,7 @@ declare const SESSION_ANALYTICS: {
843
905
  readonly MEDIUM_SESSION_THRESHOLD_MS: number;
844
906
  readonly LONG_SESSION_THRESHOLD_MS: number;
845
907
  readonly MAX_REALISTIC_SESSION_DURATION_MS: number;
846
- };
847
- declare const DEVICE_ANALYTICS: {
848
- readonly MOBILE_MAX_WIDTH: 768;
849
- readonly TABLET_MAX_WIDTH: 1024;
850
- readonly MOBILE_PERFORMANCE_FACTOR: 1.5;
851
- readonly TABLET_PERFORMANCE_FACTOR: 1.2;
852
- };
853
- declare const CONTENT_ANALYTICS: {
854
- readonly MIN_TEXT_LENGTH_FOR_ANALYSIS: 10;
855
- readonly MIN_CLICKS_FOR_HOT_ELEMENT: 10;
856
- readonly MIN_SCROLL_COMPLETION_PERCENT: 80;
857
- readonly MIN_TIME_ON_PAGE_FOR_READ_MS: number;
908
+ readonly MIN_EVENTS_FOR_DURATION: 2;
858
909
  };
859
910
  declare const INSIGHT_THRESHOLDS: {
860
911
  readonly SIGNIFICANT_CHANGE_PERCENT: 20;
@@ -866,20 +917,6 @@ declare const INSIGHT_THRESHOLDS: {
866
917
  readonly HIGH_ERROR_RATE_PERCENT: 5;
867
918
  readonly CRITICAL_ERROR_RATE_PERCENT: 10;
868
919
  };
869
- declare const TEMPORAL_ANALYSIS: {
870
- readonly SHORT_TERM_TREND_HOURS: 24;
871
- readonly MEDIUM_TERM_TREND_DAYS: 7;
872
- readonly LONG_TERM_TREND_DAYS: 30;
873
- readonly MIN_DATA_POINTS_FOR_TREND: 5;
874
- readonly WEEKLY_PATTERN_MIN_WEEKS: 4;
875
- readonly DAILY_PATTERN_MIN_DAYS: 14;
876
- };
877
- declare const SEGMENTATION_ANALYTICS: {
878
- readonly MIN_SEGMENT_SIZE: 10;
879
- readonly MIN_COHORT_SIZE: 5;
880
- readonly COHORT_ANALYSIS_DAYS: readonly [1, 3, 7, 14, 30];
881
- readonly MIN_FUNNEL_EVENTS: 20;
882
- };
883
920
  declare const ANALYTICS_QUERY_LIMITS: {
884
921
  readonly DEFAULT_EVENTS_LIMIT: 5;
885
922
  readonly DEFAULT_SESSIONS_LIMIT: 5;
@@ -888,14 +925,6 @@ declare const ANALYTICS_QUERY_LIMITS: {
888
925
  readonly MAX_TIME_RANGE_DAYS: 365;
889
926
  readonly ANALYTICS_BATCH_SIZE: 1000;
890
927
  };
891
- declare const ANOMALY_DETECTION: {
892
- readonly ANOMALY_THRESHOLD_SIGMA: 2.5;
893
- readonly STRONG_ANOMALY_THRESHOLD_SIGMA: 3;
894
- readonly TRAFFIC_DROP_ALERT_PERCENT: -30;
895
- readonly TRAFFIC_SPIKE_ALERT_PERCENT: 200;
896
- readonly MIN_BASELINE_DAYS: 7;
897
- readonly MIN_EVENTS_FOR_ANOMALY_DETECTION: 50;
898
- };
899
928
  declare const SPECIAL_PAGE_URLS: {
900
929
  readonly PAGE_URL_EXCLUDED: "excluded";
901
930
  readonly PAGE_URL_UNKNOWN: "unknown";
@@ -908,6 +937,7 @@ declare const tracelog: {
908
937
  off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
909
938
  isInitialized: () => boolean;
910
939
  destroy: () => void;
940
+ setQaMode: (enabled: boolean) => void;
911
941
  };
912
942
 
913
- export { ANALYTICS_QUERY_LIMITS, ANOMALY_DETECTION, AppConfigValidationError, CONTENT_ANALYTICS, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DATA_PROTECTION, DEVICE_ANALYTICS, DeviceType, ENGAGEMENT_THRESHOLDS, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventsQueue, INSIGHT_THRESHOLDS, InitializationTimeoutError, IntegrationValidationError, type LogLevel, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PERFORMANCE_CONFIG, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SEGMENTATION_ANALYTICS, SESSION_ANALYTICS, SPECIAL_PAGE_URLS, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEndReason, SessionTimeoutValidationError, SpecialApiUrl, type State, TEMPORAL_ANALYSIS, type TraceLogTestBridge, TraceLogValidationError, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, type WebVitalType, type WebVitalsData, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
943
+ export { ANALYTICS_QUERY_LIMITS, AppConfigValidationError, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, DeviceType, ENGAGEMENT_THRESHOLDS, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventsQueue, INSIGHT_THRESHOLDS, InitializationTimeoutError, IntegrationValidationError, type LogLevel, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SESSION_ANALYTICS, SPECIAL_PAGE_URLS, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEndReason, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
@@ -58,60 +58,6 @@ interface ViewportConfig {
58
58
  maxTrackedElements?: number;
59
59
  }
60
60
 
61
- interface Config {
62
- /** Session inactivity timeout in milliseconds. @default 900000 */
63
- sessionTimeout?: number;
64
- /** Metadata appended to every tracked event. */
65
- globalMetadata?: Record<string, MetadataType>;
66
- /** Query parameters to remove before tracking URLs. */
67
- sensitiveQueryParams?: string[];
68
- /** Error event sampling rate between 0 and 1. @default 1 */
69
- errorSampling?: number;
70
- /** Event sampling rate between 0 and 1. @default 1 */
71
- samplingRate?: number;
72
- /** CSS selector to manually override primary scroll container detection. */
73
- primaryScrollSelector?: string;
74
- /** Viewport visibility tracking configuration. */
75
- viewport?: ViewportConfig;
76
- /** Page view throttle duration in milliseconds to prevent rapid navigation spam. @default 1000 */
77
- pageViewThrottleMs?: number;
78
- /** Click throttle duration in milliseconds to prevent double-clicks and rapid spam. @default 300 */
79
- clickThrottleMs?: number;
80
- /** Maximum number of same custom event name allowed per minute to prevent infinite loops. @default 60 */
81
- maxSameEventPerMinute?: number;
82
- /** Optional configuration for third-party integrations. */
83
- integrations?: {
84
- /** TraceLog integration options. */
85
- tracelog?: {
86
- /** Required project ID TraceLog SaaS integration. */
87
- projectId: string;
88
- };
89
- /** Custom integration options. */
90
- custom?: {
91
- /** Endpoint for collecting events. */
92
- collectApiUrl: string;
93
- /** Allow HTTP URLs (not recommended for production). @default false */
94
- allowHttp?: boolean;
95
- };
96
- /** Google Analytics integration options. */
97
- googleAnalytics?: {
98
- /** Required measurement ID for Google Analytics. */
99
- measurementId: string;
100
- };
101
- };
102
- }
103
- declare enum SpecialApiUrl {
104
- Localhost = "localhost:8080",
105
- Fail = "localhost:9999"
106
- }
107
-
108
- declare enum DeviceType {
109
- Mobile = "mobile",
110
- Tablet = "tablet",
111
- Desktop = "desktop",
112
- Unknown = "unknown"
113
- }
114
-
115
61
  type SessionEndReason = 'inactivity' | 'page_unload' | 'manual_stop' | 'orphaned_cleanup' | 'tab_closed';
116
62
 
117
63
  /**
@@ -347,6 +293,79 @@ interface EventData {
347
293
  utm?: UTM;
348
294
  }
349
295
 
296
+ /**
297
+ * Web Vitals filtering mode
298
+ * - 'all': Track all Web Vitals metrics (full analytics)
299
+ * - 'needs-improvement': Track metrics that need improvement or are poor (default, balanced)
300
+ * - 'poor': Track only poor metrics (minimal data)
301
+ */
302
+ type WebVitalsMode = 'all' | 'needs-improvement' | 'poor';
303
+ interface Config {
304
+ /** Session inactivity timeout in milliseconds. @default 900000 */
305
+ sessionTimeout?: number;
306
+ /** Metadata appended to every tracked event. */
307
+ globalMetadata?: Record<string, MetadataType>;
308
+ /** Query parameters to remove before tracking URLs. */
309
+ sensitiveQueryParams?: string[];
310
+ /** Error event sampling rate between 0 and 1. @default 1 */
311
+ errorSampling?: number;
312
+ /** Event sampling rate between 0 and 1. @default 1 */
313
+ samplingRate?: number;
314
+ /** CSS selector to manually override primary scroll container detection. */
315
+ primaryScrollSelector?: string;
316
+ /** Viewport visibility tracking configuration. */
317
+ viewport?: ViewportConfig;
318
+ /** Page view throttle duration in milliseconds to prevent rapid navigation spam. @default 1000 */
319
+ pageViewThrottleMs?: number;
320
+ /** Click throttle duration in milliseconds to prevent double-clicks and rapid spam. @default 300 */
321
+ clickThrottleMs?: number;
322
+ /** Maximum number of same custom event name allowed per minute to prevent infinite loops. @default 60 */
323
+ maxSameEventPerMinute?: number;
324
+ /**
325
+ * Web Vitals filtering mode. @default 'needs-improvement'
326
+ * - 'all': Track all metrics (good, needs-improvement, poor) - full trend analysis
327
+ * - 'needs-improvement': Track metrics that need improvement or are poor - balanced approach
328
+ * - 'poor': Track only poor metrics - minimal data, focus on problems
329
+ */
330
+ webVitalsMode?: WebVitalsMode;
331
+ /**
332
+ * Custom Web Vitals thresholds in milliseconds (except CLS which is unitless).
333
+ * Only applies when webVitalsMode is set. Overrides default thresholds for the selected mode.
334
+ */
335
+ webVitalsThresholds?: Partial<Record<WebVitalType, number>>;
336
+ /** Optional configuration for third-party integrations. */
337
+ integrations?: {
338
+ /** TraceLog integration options. */
339
+ tracelog?: {
340
+ /** Required project ID TraceLog SaaS integration. */
341
+ projectId: string;
342
+ };
343
+ /** Custom integration options. */
344
+ custom?: {
345
+ /** Endpoint for collecting events. */
346
+ collectApiUrl: string;
347
+ /** Allow HTTP URLs (not recommended for production). @default false */
348
+ allowHttp?: boolean;
349
+ };
350
+ /** Google Analytics integration options. */
351
+ googleAnalytics?: {
352
+ /** Required measurement ID for Google Analytics. */
353
+ measurementId: string;
354
+ };
355
+ };
356
+ }
357
+ declare enum SpecialApiUrl {
358
+ Localhost = "localhost:8080",
359
+ Fail = "localhost:9999"
360
+ }
361
+
362
+ declare enum DeviceType {
363
+ Mobile = "mobile",
364
+ Tablet = "tablet",
365
+ Desktop = "desktop",
366
+ Unknown = "unknown"
367
+ }
368
+
350
369
  interface EventsQueue {
351
370
  user_id: string;
352
371
  session_id: string;
@@ -407,8 +426,8 @@ type SecondaryScrollEvent = EventData & {
407
426
  is_primary: false;
408
427
  };
409
428
  };
410
- declare function isPrimaryScrollEvent(event: EventData): event is PrimaryScrollEvent;
411
- declare function isSecondaryScrollEvent(event: EventData): event is SecondaryScrollEvent;
429
+ declare const isPrimaryScrollEvent: (event: EventData) => event is PrimaryScrollEvent;
430
+ declare const isSecondaryScrollEvent: (event: EventData) => event is SecondaryScrollEvent;
412
431
 
413
432
  interface State {
414
433
  mode?: Mode;
@@ -657,7 +676,7 @@ declare class PerformanceHandler extends StateManager {
657
676
  private readonly reportedByNav;
658
677
  private readonly navigationHistory;
659
678
  private readonly observers;
660
- private readonly vitalThresholds;
679
+ private vitalThresholds;
661
680
  private lastLongTaskSentAt;
662
681
  constructor(eventManager: EventManager);
663
682
  startTracking(): Promise<void>;
@@ -812,6 +831,11 @@ declare global {
812
831
  }
813
832
  }
814
833
 
834
+ /**
835
+ * Consolidated configuration constants for TraceLog
836
+ * This file centralizes all timing, limits, browser, and initialization constants
837
+ */
838
+ declare const DEFAULT_SESSION_TIMEOUT: number;
815
839
  declare const MAX_CUSTOM_EVENT_NAME_LENGTH = 120;
816
840
  declare const MAX_CUSTOM_EVENT_STRING_SIZE: number;
817
841
  declare const MAX_CUSTOM_EVENT_KEYS = 10;
@@ -822,12 +846,50 @@ declare const MAX_STRING_LENGTH = 1000;
822
846
  declare const MAX_STRING_LENGTH_IN_ARRAY = 500;
823
847
  declare const MAX_ARRAY_LENGTH = 100;
824
848
 
825
- declare const PERFORMANCE_CONFIG: {
826
- readonly WEB_VITALS_THRESHOLDS: Record<WebVitalType, number>;
827
- };
828
- declare const DATA_PROTECTION: {
829
- readonly PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
830
- };
849
+ /**
850
+ * Performance monitoring and web vitals constants for TraceLog
851
+ * Centralizes thresholds and configuration for performance tracking
852
+ */
853
+
854
+ /**
855
+ * Web Vitals "good" thresholds (75th percentile boundaries)
856
+ * Metrics below or equal to these values are considered good performance.
857
+ * Reference: https://web.dev/articles/vitals
858
+ */
859
+ declare const WEB_VITALS_GOOD_THRESHOLDS: Record<WebVitalType, number>;
860
+ /**
861
+ * Web Vitals "needs improvement" thresholds
862
+ * Metrics exceeding these values need attention but aren't critically poor.
863
+ * Reference: https://web.dev/articles/vitals
864
+ */
865
+ declare const WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS: Record<WebVitalType, number>;
866
+ /**
867
+ * Web Vitals "poor" thresholds
868
+ * Metrics exceeding these values indicate poor performance requiring immediate attention.
869
+ * Reference: https://web.dev/articles/vitals
870
+ */
871
+ declare const WEB_VITALS_POOR_THRESHOLDS: Record<WebVitalType, number>;
872
+ /**
873
+ * Default Web Vitals mode
874
+ * 'needs-improvement' provides balanced approach - captures metrics that need attention
875
+ * while filtering out good performance (reduces noise and costs)
876
+ */
877
+ declare const DEFAULT_WEB_VITALS_MODE: WebVitalsMode;
878
+ /**
879
+ * Get Web Vitals thresholds for the specified mode
880
+ */
881
+ declare const getWebVitalsThresholds: (mode?: WebVitalsMode) => Record<WebVitalType, number>;
882
+
883
+ /**
884
+ * Error handling and PII sanitization constants for TraceLog
885
+ * Centralizes patterns and limits for error tracking and data protection
886
+ */
887
+ /**
888
+ * Regular expressions for detecting and sanitizing Personally Identifiable Information (PII)
889
+ * These patterns are used to replace sensitive information with [REDACTED] in error messages
890
+ */
891
+ declare const PII_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
892
+
831
893
  declare const ENGAGEMENT_THRESHOLDS: {
832
894
  readonly LOW_ACTIVITY_EVENT_COUNT: 50;
833
895
  readonly HIGH_ACTIVITY_EVENT_COUNT: 1000;
@@ -843,18 +905,7 @@ declare const SESSION_ANALYTICS: {
843
905
  readonly MEDIUM_SESSION_THRESHOLD_MS: number;
844
906
  readonly LONG_SESSION_THRESHOLD_MS: number;
845
907
  readonly MAX_REALISTIC_SESSION_DURATION_MS: number;
846
- };
847
- declare const DEVICE_ANALYTICS: {
848
- readonly MOBILE_MAX_WIDTH: 768;
849
- readonly TABLET_MAX_WIDTH: 1024;
850
- readonly MOBILE_PERFORMANCE_FACTOR: 1.5;
851
- readonly TABLET_PERFORMANCE_FACTOR: 1.2;
852
- };
853
- declare const CONTENT_ANALYTICS: {
854
- readonly MIN_TEXT_LENGTH_FOR_ANALYSIS: 10;
855
- readonly MIN_CLICKS_FOR_HOT_ELEMENT: 10;
856
- readonly MIN_SCROLL_COMPLETION_PERCENT: 80;
857
- readonly MIN_TIME_ON_PAGE_FOR_READ_MS: number;
908
+ readonly MIN_EVENTS_FOR_DURATION: 2;
858
909
  };
859
910
  declare const INSIGHT_THRESHOLDS: {
860
911
  readonly SIGNIFICANT_CHANGE_PERCENT: 20;
@@ -866,20 +917,6 @@ declare const INSIGHT_THRESHOLDS: {
866
917
  readonly HIGH_ERROR_RATE_PERCENT: 5;
867
918
  readonly CRITICAL_ERROR_RATE_PERCENT: 10;
868
919
  };
869
- declare const TEMPORAL_ANALYSIS: {
870
- readonly SHORT_TERM_TREND_HOURS: 24;
871
- readonly MEDIUM_TERM_TREND_DAYS: 7;
872
- readonly LONG_TERM_TREND_DAYS: 30;
873
- readonly MIN_DATA_POINTS_FOR_TREND: 5;
874
- readonly WEEKLY_PATTERN_MIN_WEEKS: 4;
875
- readonly DAILY_PATTERN_MIN_DAYS: 14;
876
- };
877
- declare const SEGMENTATION_ANALYTICS: {
878
- readonly MIN_SEGMENT_SIZE: 10;
879
- readonly MIN_COHORT_SIZE: 5;
880
- readonly COHORT_ANALYSIS_DAYS: readonly [1, 3, 7, 14, 30];
881
- readonly MIN_FUNNEL_EVENTS: 20;
882
- };
883
920
  declare const ANALYTICS_QUERY_LIMITS: {
884
921
  readonly DEFAULT_EVENTS_LIMIT: 5;
885
922
  readonly DEFAULT_SESSIONS_LIMIT: 5;
@@ -888,14 +925,6 @@ declare const ANALYTICS_QUERY_LIMITS: {
888
925
  readonly MAX_TIME_RANGE_DAYS: 365;
889
926
  readonly ANALYTICS_BATCH_SIZE: 1000;
890
927
  };
891
- declare const ANOMALY_DETECTION: {
892
- readonly ANOMALY_THRESHOLD_SIGMA: 2.5;
893
- readonly STRONG_ANOMALY_THRESHOLD_SIGMA: 3;
894
- readonly TRAFFIC_DROP_ALERT_PERCENT: -30;
895
- readonly TRAFFIC_SPIKE_ALERT_PERCENT: 200;
896
- readonly MIN_BASELINE_DAYS: 7;
897
- readonly MIN_EVENTS_FOR_ANOMALY_DETECTION: 50;
898
- };
899
928
  declare const SPECIAL_PAGE_URLS: {
900
929
  readonly PAGE_URL_EXCLUDED: "excluded";
901
930
  readonly PAGE_URL_UNKNOWN: "unknown";
@@ -908,6 +937,7 @@ declare const tracelog: {
908
937
  off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
909
938
  isInitialized: () => boolean;
910
939
  destroy: () => void;
940
+ setQaMode: (enabled: boolean) => void;
911
941
  };
912
942
 
913
- export { ANALYTICS_QUERY_LIMITS, ANOMALY_DETECTION, AppConfigValidationError, CONTENT_ANALYTICS, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DATA_PROTECTION, DEVICE_ANALYTICS, DeviceType, ENGAGEMENT_THRESHOLDS, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventsQueue, INSIGHT_THRESHOLDS, InitializationTimeoutError, IntegrationValidationError, type LogLevel, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PERFORMANCE_CONFIG, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SEGMENTATION_ANALYTICS, SESSION_ANALYTICS, SPECIAL_PAGE_URLS, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEndReason, SessionTimeoutValidationError, SpecialApiUrl, type State, TEMPORAL_ANALYSIS, type TraceLogTestBridge, TraceLogValidationError, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, type WebVitalType, type WebVitalsData, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
943
+ export { ANALYTICS_QUERY_LIMITS, AppConfigValidationError, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, DeviceType, ENGAGEMENT_THRESHOLDS, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventsQueue, INSIGHT_THRESHOLDS, InitializationTimeoutError, IntegrationValidationError, type LogLevel, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SESSION_ANALYTICS, SPECIAL_PAGE_URLS, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEndReason, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };