@openreplay/tracker 17.2.5 → 18.0.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.
@@ -1,6 +1,7 @@
1
1
  import type { Options as WebworkerOptions } from '../../common/interaction.js';
2
2
  import AttributeSender from '../modules/attributeSender.js';
3
3
  import type { Options as NetworkOptions } from '../modules/network.js';
4
+ import type TagMatcher from '../modules/tagMatcher.js';
4
5
  import Logger, { ILogLevel } from './logger.js';
5
6
  import Message from './messages.gen.js';
6
7
  import Nodes from './nodes/index.js';
@@ -63,6 +64,7 @@ type AppOptions = {
63
64
  __is_snippet: boolean;
64
65
  __debug_report_edp: string | null;
65
66
  __debug__?: ILogLevel;
67
+ __local_debug?: boolean;
66
68
  localStorage: Storage | null;
67
69
  sessionStorage: Storage | null;
68
70
  forceSingleTab?: boolean;
@@ -158,6 +160,7 @@ export default class App {
158
160
  private canvasRecorder;
159
161
  private conditionsManager;
160
162
  private readonly tagWatcher;
163
+ get tagMatcher(): TagMatcher;
161
164
  private canStart;
162
165
  private rootId;
163
166
  private pageFrames;
@@ -62,7 +62,6 @@ export declare function AdoptedSSRemoveOwner(sheetID: number, id: number): Messa
62
62
  export declare function JSException(name: string, message: string, payload: string, metadata: string): Messages.JSException;
63
63
  export declare function Zustand(mutation: string, state: string): Messages.Zustand;
64
64
  export declare function BatchMetadata(version: number, pageNo: number, firstIndex: number, timestamp: number, location: string): Messages.BatchMetadata;
65
- export declare function PartitionedMessage(partNo: number, partTotal: number): Messages.PartitionedMessage;
66
65
  export declare function NetworkRequest(type: string, method: string, url: string, request: string, response: string, status: number, timestamp: number, duration: number, transferredBodySize: number): Messages.NetworkRequest;
67
66
  export declare function WSChannel(chType: string, channelName: string, data: string, timestamp: number, dir: string, messageType: string): Messages.WSChannel;
68
67
  export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string, transferredSize: number, cached: boolean, queueing: number, dnsLookup: number, initialConnection: number, ssl: number, contentDownload: number, total: number, stalled: number): Messages.ResourceTiming;
@@ -0,0 +1,28 @@
1
+ export type Tag = {
2
+ id: number;
3
+ selector: string;
4
+ location?: string;
5
+ };
6
+ /**
7
+ * Two-tier tag matching:
8
+ * 1. Fast fingerprint lookup by id, data-attr,
9
+ * or class from the selector's last segment
10
+ * 2. Fallback iteration using native element.matches()
11
+ */
12
+ declare class TagMatcher {
13
+ private tags;
14
+ private byId;
15
+ private byDataAttr;
16
+ private byClass;
17
+ private fallback;
18
+ setTags(tags: Tag[]): void;
19
+ getTags(): Tag[];
20
+ /** Match element, its parent, or direct children against known tag selectors */
21
+ match(el: Element): Tag | null;
22
+ private matchExact;
23
+ clear(): void;
24
+ }
25
+ export declare function matchesLocation(tag: {
26
+ location?: string;
27
+ }): boolean;
28
+ export default TagMatcher;
@@ -1,10 +1,9 @@
1
+ import TagMatcher, { type Tag } from './tagMatcher.js';
1
2
  export declare const WATCHED_TAGS_KEY = "__or__watched_tags__";
2
3
  declare class TagWatcher {
3
4
  interval: ReturnType<typeof setInterval> | null;
4
- tags: {
5
- id: number;
6
- selector: string;
7
- }[];
5
+ tags: Tag[];
6
+ readonly matcher: TagMatcher;
8
7
  observer: IntersectionObserver;
9
8
  private readonly sessionStorage;
10
9
  private readonly errLog;
@@ -15,10 +14,7 @@ declare class TagWatcher {
15
14
  onTag: (tag: number) => void;
16
15
  });
17
16
  fetchTags(ingest: string, token: string): Promise<void>;
18
- setTags(tags: {
19
- id: number;
20
- selector: string;
21
- }[]): void;
17
+ setTags(tags: Tag[]): void;
22
18
  onTagRendered(tagId: number): void;
23
19
  clear(): void;
24
20
  }
@@ -1,4 +1,5 @@
1
1
  import Message from './messages.gen.js';
2
+ export type DataType = 'player' | 'assets' | 'devtools' | 'analytics';
2
3
  export interface Options {
3
4
  connAttemptCount?: number;
4
5
  connAttemptGap?: number;
@@ -10,18 +11,22 @@ type Start = {
10
11
  timestamp: number;
11
12
  url: string;
12
13
  tabId: string;
14
+ localDebug?: boolean;
13
15
  } & Options;
14
16
  type Auth = {
15
17
  type: 'auth';
16
18
  token: string;
17
19
  beaconSizeLimit?: number;
20
+ protocolVersion?: number;
18
21
  };
19
22
  export type ToWorkerData = null | 'stop' | Start | Auth | Array<Message> | {
20
23
  type: 'compressed';
21
24
  batch: Uint8Array;
25
+ dataType: DataType;
22
26
  } | {
23
27
  type: 'uncompressed';
24
28
  batch: Uint8Array;
29
+ dataType: DataType;
25
30
  } | 'forceFlushBatch' | 'closing' | 'check_queue';
26
31
  type Failure = {
27
32
  type: 'failure';
@@ -30,8 +35,14 @@ type Failure = {
30
35
  type QEmpty = {
31
36
  type: 'queue_empty';
32
37
  };
38
+ type LocalSave = {
39
+ type: 'local_save';
40
+ name: string;
41
+ batch: Uint8Array;
42
+ };
33
43
  export type FromWorkerData = 'a_stop' | 'a_start' | Failure | 'not_init' | {
34
44
  type: 'compress';
35
45
  batch: Uint8Array;
36
- } | QEmpty;
46
+ dataType: DataType;
47
+ } | QEmpty | LocalSave;
37
48
  export {};
@@ -61,7 +61,6 @@ export declare const enum Type {
61
61
  JSException = 78,
62
62
  Zustand = 79,
63
63
  BatchMetadata = 81,
64
- PartitionedMessage = 82,
65
64
  NetworkRequest = 83,
66
65
  WSChannel = 84,
67
66
  ResourceTiming = 85,
@@ -442,11 +441,6 @@ export type BatchMetadata = [
442
441
  number,
443
442
  string
444
443
  ];
445
- export type PartitionedMessage = [
446
- Type.PartitionedMessage,
447
- number,
448
- number
449
- ];
450
444
  export type NetworkRequest = [
451
445
  Type.NetworkRequest,
452
446
  string,
@@ -583,5 +577,8 @@ export type WebVitals = [
583
577
  string,
584
578
  string
585
579
  ];
586
- type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals;
580
+ export declare const ASSET_MESSAGES: ReadonlySet<number>;
581
+ export declare const DEVTOOLS_MESSAGES: ReadonlySet<number>;
582
+ export declare const ANALYTICS_MESSAGES: ReadonlySet<number>;
583
+ type Message = Timestamp | SetPageLocationDeprecated | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | StringDictGlobal | SetNodeAttributeDictGlobal | NodeAnimationResult | Profiler | OTable | StateAction | ReduxDeprecated | Vuex | MobX | NgRx | GraphQLDeprecated | PerformanceTrack | StringDictDeprecated | SetNodeAttributeDictDeprecated | StringDict | SetNodeAttributeDict | ResourceTimingDeprecatedDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | SetNodeSlot | MouseClick | MouseClickDeprecated | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | NetworkRequest | WSChannel | ResourceTiming | Incident | LongAnimationTask | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTimingDeprecated | TabChange | TabData | CanvasNode | TagTrigger | Redux | SetPageLocation | GraphQL | WebVitals;
587
584
  export default Message;