@tracelog/lib 2.6.1 → 2.6.2-rc.94.6

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.
@@ -527,6 +527,18 @@ interface DeviceInfo {
527
527
  browser: string;
528
528
  }
529
529
 
530
+ /**
531
+ * Visitor identity data from identify() call.
532
+ *
533
+ * Sent piggyback in every batch so the backend always has the latest identity,
534
+ * even if earlier batches were lost.
535
+ */
536
+ interface IdentifyData {
537
+ /** External user identifier assigned by the site owner */
538
+ userId: string;
539
+ /** Optional user attributes (name, email, plan, etc.) */
540
+ traits?: Record<string, string>;
541
+ }
530
542
  /**
531
543
  * Event queue structure sent to backend.
532
544
  *
@@ -543,6 +555,8 @@ interface EventsQueue {
543
555
  events: EventData[];
544
556
  /** Optional metadata attached to all events in this batch */
545
557
  global_metadata?: Record<string, MetadataType>;
558
+ /** Visitor identity from identify() call — included in every batch */
559
+ identify?: IdentifyData;
546
560
  }
547
561
  /**
548
562
  * Extended queue structure for localStorage persistence with expiration tracking.
@@ -735,6 +749,8 @@ interface State {
735
749
  scrollEventCount?: number;
736
750
  sessionReferrer?: string;
737
751
  sessionUtm?: UTM;
752
+ /** Visitor identity from identify() call */
753
+ identity?: IdentifyData;
738
754
  }
739
755
 
740
756
  /**
@@ -1589,6 +1605,8 @@ declare class EventManager extends StateManager {
1589
1605
  private pruneOldFingerprints;
1590
1606
  private createEventFingerprint;
1591
1607
  private createEventSignature;
1608
+ /** Deterministic JSON string with sorted keys to ensure consistent fingerprints regardless of property insertion order */
1609
+ private stableStringify;
1592
1610
  private addToQueue;
1593
1611
  private scheduleSendTimeout;
1594
1612
  private calculateSendDelay;
@@ -2369,6 +2387,8 @@ interface TraceLogTestBridge {
2369
2387
  scroll: ScrollHandler | null;
2370
2388
  viewport: ViewportHandler | null;
2371
2389
  };
2390
+ identify(userId: string, traits?: Record<string, string>): void;
2391
+ resetIdentity(): Promise<void>;
2372
2392
  waitForInitialization(timeout?: number): Promise<void>;
2373
2393
  flushQueue(): Promise<void>;
2374
2394
  clearQueue(): void;
@@ -2531,6 +2551,8 @@ declare const tracelog: {
2531
2551
  setQaMode: (enabled: boolean) => void;
2532
2552
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2533
2553
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2554
+ identify: (userId: string, traits?: Record<string, string>) => void;
2555
+ resetIdentity: () => Promise<void>;
2534
2556
  };
2535
2557
 
2536
- export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, TimeoutError, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, 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 };
2558
+ export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type IdentifyData, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, TimeoutError, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, 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 };
@@ -527,6 +527,18 @@ interface DeviceInfo {
527
527
  browser: string;
528
528
  }
529
529
 
530
+ /**
531
+ * Visitor identity data from identify() call.
532
+ *
533
+ * Sent piggyback in every batch so the backend always has the latest identity,
534
+ * even if earlier batches were lost.
535
+ */
536
+ interface IdentifyData {
537
+ /** External user identifier assigned by the site owner */
538
+ userId: string;
539
+ /** Optional user attributes (name, email, plan, etc.) */
540
+ traits?: Record<string, string>;
541
+ }
530
542
  /**
531
543
  * Event queue structure sent to backend.
532
544
  *
@@ -543,6 +555,8 @@ interface EventsQueue {
543
555
  events: EventData[];
544
556
  /** Optional metadata attached to all events in this batch */
545
557
  global_metadata?: Record<string, MetadataType>;
558
+ /** Visitor identity from identify() call — included in every batch */
559
+ identify?: IdentifyData;
546
560
  }
547
561
  /**
548
562
  * Extended queue structure for localStorage persistence with expiration tracking.
@@ -735,6 +749,8 @@ interface State {
735
749
  scrollEventCount?: number;
736
750
  sessionReferrer?: string;
737
751
  sessionUtm?: UTM;
752
+ /** Visitor identity from identify() call */
753
+ identity?: IdentifyData;
738
754
  }
739
755
 
740
756
  /**
@@ -1589,6 +1605,8 @@ declare class EventManager extends StateManager {
1589
1605
  private pruneOldFingerprints;
1590
1606
  private createEventFingerprint;
1591
1607
  private createEventSignature;
1608
+ /** Deterministic JSON string with sorted keys to ensure consistent fingerprints regardless of property insertion order */
1609
+ private stableStringify;
1592
1610
  private addToQueue;
1593
1611
  private scheduleSendTimeout;
1594
1612
  private calculateSendDelay;
@@ -2369,6 +2387,8 @@ interface TraceLogTestBridge {
2369
2387
  scroll: ScrollHandler | null;
2370
2388
  viewport: ViewportHandler | null;
2371
2389
  };
2390
+ identify(userId: string, traits?: Record<string, string>): void;
2391
+ resetIdentity(): Promise<void>;
2372
2392
  waitForInitialization(timeout?: number): Promise<void>;
2373
2393
  flushQueue(): Promise<void>;
2374
2394
  clearQueue(): void;
@@ -2531,6 +2551,8 @@ declare const tracelog: {
2531
2551
  setQaMode: (enabled: boolean) => void;
2532
2552
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2533
2553
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2554
+ identify: (userId: string, traits?: Record<string, string>) => void;
2555
+ resetIdentity: () => Promise<void>;
2534
2556
  };
2535
2557
 
2536
- export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, TimeoutError, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, 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 };
2558
+ export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, type CustomHeadersProvider, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, type IdentifyData, type InitResult, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, TimeoutError, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, 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 };