@openreplay/tracker 17.2.6 → 17.2.9

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';
@@ -158,6 +159,7 @@ export default class App {
158
159
  private canvasRecorder;
159
160
  private conditionsManager;
160
161
  private readonly tagWatcher;
162
+ get tagMatcher(): TagMatcher;
161
163
  private canStart;
162
164
  private rootId;
163
165
  private pageFrames;
@@ -169,11 +171,10 @@ export default class App {
169
171
  parentActive: boolean;
170
172
  checkStatus: () => boolean;
171
173
  parentCrossDomainFrameListener: (event: MessageEvent) => void;
172
- /**
173
- * context ids for iframes,
174
- * order is not so important as long as its consistent
175
- * */
176
174
  trackedFrames: string[];
175
+ private frameLastSeen;
176
+ private readonly FRAME_STALE_MS;
177
+ private pruneStaleFrames;
177
178
  crossDomainIframeListener: (event: MessageEvent) => void;
178
179
  /**
179
180
  * { command : [remaining iframes] }
@@ -288,6 +289,7 @@ export default class App {
288
289
  * */
289
290
  uploadOfflineRecording(): Promise<void>;
290
291
  prevOpts: StartOptions;
292
+ private userStartCallback?;
291
293
  private _start;
292
294
  restartCanvasTracking: () => void;
293
295
  flushBuffer: (buffer: Message[]) => Promise<unknown>;
@@ -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;
@@ -28,6 +28,12 @@ export default abstract class Observer {
28
28
  private readonly inlineRemoteCss;
29
29
  private readonly inlinerOptions;
30
30
  private readonly domParser;
31
+ /**
32
+ * Bumped on every disconnect(). Stale async CSS-inlining callbacks from a
33
+ * previous session (e.g. agent reload → tracker restart) compare against
34
+ * this and bail instead of sending messages that reference vanished node ids.
35
+ */
36
+ private generation;
31
37
  constructor(app: App, isTopContext?: boolean, options?: Options);
32
38
  private clear;
33
39
  /**
@@ -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
  }
@@ -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,5 @@ 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
+ 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
581
  export default Message;
@@ -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';
@@ -158,6 +159,7 @@ export default class App {
158
159
  private canvasRecorder;
159
160
  private conditionsManager;
160
161
  private readonly tagWatcher;
162
+ get tagMatcher(): TagMatcher;
161
163
  private canStart;
162
164
  private rootId;
163
165
  private pageFrames;
@@ -169,11 +171,10 @@ export default class App {
169
171
  parentActive: boolean;
170
172
  checkStatus: () => boolean;
171
173
  parentCrossDomainFrameListener: (event: MessageEvent) => void;
172
- /**
173
- * context ids for iframes,
174
- * order is not so important as long as its consistent
175
- * */
176
174
  trackedFrames: string[];
175
+ private frameLastSeen;
176
+ private readonly FRAME_STALE_MS;
177
+ private pruneStaleFrames;
177
178
  crossDomainIframeListener: (event: MessageEvent) => void;
178
179
  /**
179
180
  * { command : [remaining iframes] }
@@ -288,6 +289,7 @@ export default class App {
288
289
  * */
289
290
  uploadOfflineRecording(): Promise<void>;
290
291
  prevOpts: StartOptions;
292
+ private userStartCallback?;
291
293
  private _start;
292
294
  restartCanvasTracking: () => void;
293
295
  flushBuffer: (buffer: Message[]) => Promise<unknown>;
@@ -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;
@@ -28,6 +28,12 @@ export default abstract class Observer {
28
28
  private readonly inlineRemoteCss;
29
29
  private readonly inlinerOptions;
30
30
  private readonly domParser;
31
+ /**
32
+ * Bumped on every disconnect(). Stale async CSS-inlining callbacks from a
33
+ * previous session (e.g. agent reload → tracker restart) compare against
34
+ * this and bail instead of sending messages that reference vanished node ids.
35
+ */
36
+ private generation;
31
37
  constructor(app: App, isTopContext?: boolean, options?: Options);
32
38
  private clear;
33
39
  /**
@@ -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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openreplay/tracker",
3
3
  "description": "The OpenReplay tracker main package",
4
- "version": "17.2.6",
4
+ "version": "17.2.9",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"