@tracelog/lib 2.6.2 → 2.7.0

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
  /**
@@ -2371,6 +2387,8 @@ interface TraceLogTestBridge {
2371
2387
  scroll: ScrollHandler | null;
2372
2388
  viewport: ViewportHandler | null;
2373
2389
  };
2390
+ identify(userId: string, traits?: Record<string, string>): void;
2391
+ resetIdentity(): Promise<void>;
2374
2392
  waitForInitialization(timeout?: number): Promise<void>;
2375
2393
  flushQueue(): Promise<void>;
2376
2394
  clearQueue(): void;
@@ -2533,6 +2551,8 @@ declare const tracelog: {
2533
2551
  setQaMode: (enabled: boolean) => void;
2534
2552
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2535
2553
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2554
+ identify: (userId: string, traits?: Record<string, string>) => void;
2555
+ resetIdentity: () => Promise<void>;
2536
2556
  };
2537
2557
 
2538
- 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
  /**
@@ -2371,6 +2387,8 @@ interface TraceLogTestBridge {
2371
2387
  scroll: ScrollHandler | null;
2372
2388
  viewport: ViewportHandler | null;
2373
2389
  };
2390
+ identify(userId: string, traits?: Record<string, string>): void;
2391
+ resetIdentity(): Promise<void>;
2374
2392
  waitForInitialization(timeout?: number): Promise<void>;
2375
2393
  flushQueue(): Promise<void>;
2376
2394
  clearQueue(): void;
@@ -2533,6 +2551,8 @@ declare const tracelog: {
2533
2551
  setQaMode: (enabled: boolean) => void;
2534
2552
  updateGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2535
2553
  mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
2554
+ identify: (userId: string, traits?: Record<string, string>) => void;
2555
+ resetIdentity: () => Promise<void>;
2536
2556
  };
2537
2557
 
2538
- 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 };