@openreplay/tracker 3.6.0-beta.0 → 3.6.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.
@@ -2,90 +2,89 @@
2
2
  // Auto-generated, do not edit
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.CreateIFrameDocument = exports.MouseClick = exports.CSSInsertRuleURLBased = exports.CustomIssue = exports.TechnicalInfo = exports.SetCSSDataURLBased = exports.SetNodeAttributeURLBased = exports.LongTask = exports.SetPageVisibility = exports.ConnectionInformation = exports.ResourceTiming = exports.PerformanceTrack = exports.GraphQL = exports.NgRx = exports.MobX = exports.Vuex = exports.Redux = exports.StateAction = exports.OTable = exports.Profiler = exports.Fetch = exports.CSSDeleteRule = exports.CSSInsertRule = exports.Metadata = exports.UserAnonymousID = exports.UserID = exports.RawCustomEvent = exports.JSException = exports.PageRenderTiming = exports.PageLoadTiming = exports.ConsoleLog = exports.MouseMove = exports.SetInputChecked = exports.SetInputValue = exports.SetInputTarget = exports.SetNodeScroll = exports.SetNodeData = exports.RemoveNodeAttribute = exports.SetNodeAttribute = exports.RemoveNode = exports.MoveNode = exports.CreateTextNode = exports.CreateElementNode = exports.CreateDocument = exports.SetViewportScroll = exports.SetViewportSize = exports.SetPageLocation = exports.Timestamp = exports.PartitionedMessage = exports.BatchMetadata = void 0;
5
- const Messages = require("../common/messages.gen.js");
6
5
  function BatchMetadata(version, pageNo, firstIndex, timestamp, location) {
7
- return [Messages.Type.BatchMetadata, version, pageNo, firstIndex, timestamp, location];
6
+ return [81 /* BatchMetadata */, version, pageNo, firstIndex, timestamp, location];
8
7
  }
9
8
  exports.BatchMetadata = BatchMetadata;
10
9
  function PartitionedMessage(partNo, partTotal) {
11
- return [Messages.Type.PartitionedMessage, partNo, partTotal];
10
+ return [82 /* PartitionedMessage */, partNo, partTotal];
12
11
  }
13
12
  exports.PartitionedMessage = PartitionedMessage;
14
13
  function Timestamp(timestamp) {
15
- return [Messages.Type.Timestamp, timestamp];
14
+ return [0 /* Timestamp */, timestamp];
16
15
  }
17
16
  exports.Timestamp = Timestamp;
18
17
  function SetPageLocation(url, referrer, navigationStart) {
19
- return [Messages.Type.SetPageLocation, url, referrer, navigationStart];
18
+ return [4 /* SetPageLocation */, url, referrer, navigationStart];
20
19
  }
21
20
  exports.SetPageLocation = SetPageLocation;
22
21
  function SetViewportSize(width, height) {
23
- return [Messages.Type.SetViewportSize, width, height];
22
+ return [5 /* SetViewportSize */, width, height];
24
23
  }
25
24
  exports.SetViewportSize = SetViewportSize;
26
25
  function SetViewportScroll(x, y) {
27
- return [Messages.Type.SetViewportScroll, x, y];
26
+ return [6 /* SetViewportScroll */, x, y];
28
27
  }
29
28
  exports.SetViewportScroll = SetViewportScroll;
30
29
  function CreateDocument() {
31
- return [Messages.Type.CreateDocument];
30
+ return [7 /* CreateDocument */];
32
31
  }
33
32
  exports.CreateDocument = CreateDocument;
34
33
  function CreateElementNode(id, parentID, index, tag, svg) {
35
- return [Messages.Type.CreateElementNode, id, parentID, index, tag, svg];
34
+ return [8 /* CreateElementNode */, id, parentID, index, tag, svg];
36
35
  }
37
36
  exports.CreateElementNode = CreateElementNode;
38
37
  function CreateTextNode(id, parentID, index) {
39
- return [Messages.Type.CreateTextNode, id, parentID, index];
38
+ return [9 /* CreateTextNode */, id, parentID, index];
40
39
  }
41
40
  exports.CreateTextNode = CreateTextNode;
42
41
  function MoveNode(id, parentID, index) {
43
- return [Messages.Type.MoveNode, id, parentID, index];
42
+ return [10 /* MoveNode */, id, parentID, index];
44
43
  }
45
44
  exports.MoveNode = MoveNode;
46
45
  function RemoveNode(id) {
47
- return [Messages.Type.RemoveNode, id];
46
+ return [11 /* RemoveNode */, id];
48
47
  }
49
48
  exports.RemoveNode = RemoveNode;
50
49
  function SetNodeAttribute(id, name, value) {
51
- return [Messages.Type.SetNodeAttribute, id, name, value];
50
+ return [12 /* SetNodeAttribute */, id, name, value];
52
51
  }
53
52
  exports.SetNodeAttribute = SetNodeAttribute;
54
53
  function RemoveNodeAttribute(id, name) {
55
- return [Messages.Type.RemoveNodeAttribute, id, name];
54
+ return [13 /* RemoveNodeAttribute */, id, name];
56
55
  }
57
56
  exports.RemoveNodeAttribute = RemoveNodeAttribute;
58
57
  function SetNodeData(id, data) {
59
- return [Messages.Type.SetNodeData, id, data];
58
+ return [14 /* SetNodeData */, id, data];
60
59
  }
61
60
  exports.SetNodeData = SetNodeData;
62
61
  function SetNodeScroll(id, x, y) {
63
- return [Messages.Type.SetNodeScroll, id, x, y];
62
+ return [16 /* SetNodeScroll */, id, x, y];
64
63
  }
65
64
  exports.SetNodeScroll = SetNodeScroll;
66
65
  function SetInputTarget(id, label) {
67
- return [Messages.Type.SetInputTarget, id, label];
66
+ return [17 /* SetInputTarget */, id, label];
68
67
  }
69
68
  exports.SetInputTarget = SetInputTarget;
70
69
  function SetInputValue(id, value, mask) {
71
- return [Messages.Type.SetInputValue, id, value, mask];
70
+ return [18 /* SetInputValue */, id, value, mask];
72
71
  }
73
72
  exports.SetInputValue = SetInputValue;
74
73
  function SetInputChecked(id, checked) {
75
- return [Messages.Type.SetInputChecked, id, checked];
74
+ return [19 /* SetInputChecked */, id, checked];
76
75
  }
77
76
  exports.SetInputChecked = SetInputChecked;
78
77
  function MouseMove(x, y) {
79
- return [Messages.Type.MouseMove, x, y];
78
+ return [20 /* MouseMove */, x, y];
80
79
  }
81
80
  exports.MouseMove = MouseMove;
82
81
  function ConsoleLog(level, value) {
83
- return [Messages.Type.ConsoleLog, level, value];
82
+ return [22 /* ConsoleLog */, level, value];
84
83
  }
85
84
  exports.ConsoleLog = ConsoleLog;
86
85
  function PageLoadTiming(requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, firstPaint, firstContentfulPaint) {
87
86
  return [
88
- Messages.Type.PageLoadTiming,
87
+ 23 /* PageLoadTiming */,
89
88
  requestStart,
90
89
  responseStart,
91
90
  responseEnd,
@@ -99,80 +98,80 @@ function PageLoadTiming(requestStart, responseStart, responseEnd, domContentLoad
99
98
  }
100
99
  exports.PageLoadTiming = PageLoadTiming;
101
100
  function PageRenderTiming(speedIndex, visuallyComplete, timeToInteractive) {
102
- return [Messages.Type.PageRenderTiming, speedIndex, visuallyComplete, timeToInteractive];
101
+ return [24 /* PageRenderTiming */, speedIndex, visuallyComplete, timeToInteractive];
103
102
  }
104
103
  exports.PageRenderTiming = PageRenderTiming;
105
104
  function JSException(name, message, payload) {
106
- return [Messages.Type.JSException, name, message, payload];
105
+ return [25 /* JSException */, name, message, payload];
107
106
  }
108
107
  exports.JSException = JSException;
109
108
  function RawCustomEvent(name, payload) {
110
- return [Messages.Type.RawCustomEvent, name, payload];
109
+ return [27 /* RawCustomEvent */, name, payload];
111
110
  }
112
111
  exports.RawCustomEvent = RawCustomEvent;
113
112
  function UserID(id) {
114
- return [Messages.Type.UserID, id];
113
+ return [28 /* UserID */, id];
115
114
  }
116
115
  exports.UserID = UserID;
117
116
  function UserAnonymousID(id) {
118
- return [Messages.Type.UserAnonymousID, id];
117
+ return [29 /* UserAnonymousID */, id];
119
118
  }
120
119
  exports.UserAnonymousID = UserAnonymousID;
121
120
  function Metadata(key, value) {
122
- return [Messages.Type.Metadata, key, value];
121
+ return [30 /* Metadata */, key, value];
123
122
  }
124
123
  exports.Metadata = Metadata;
125
124
  function CSSInsertRule(id, rule, index) {
126
- return [Messages.Type.CSSInsertRule, id, rule, index];
125
+ return [37 /* CSSInsertRule */, id, rule, index];
127
126
  }
128
127
  exports.CSSInsertRule = CSSInsertRule;
129
128
  function CSSDeleteRule(id, index) {
130
- return [Messages.Type.CSSDeleteRule, id, index];
129
+ return [38 /* CSSDeleteRule */, id, index];
131
130
  }
132
131
  exports.CSSDeleteRule = CSSDeleteRule;
133
132
  function Fetch(method, url, request, response, status, timestamp, duration) {
134
- return [Messages.Type.Fetch, method, url, request, response, status, timestamp, duration];
133
+ return [39 /* Fetch */, method, url, request, response, status, timestamp, duration];
135
134
  }
136
135
  exports.Fetch = Fetch;
137
136
  function Profiler(name, duration, args, result) {
138
- return [Messages.Type.Profiler, name, duration, args, result];
137
+ return [40 /* Profiler */, name, duration, args, result];
139
138
  }
140
139
  exports.Profiler = Profiler;
141
140
  function OTable(key, value) {
142
- return [Messages.Type.OTable, key, value];
141
+ return [41 /* OTable */, key, value];
143
142
  }
144
143
  exports.OTable = OTable;
145
144
  function StateAction(type) {
146
- return [Messages.Type.StateAction, type];
145
+ return [42 /* StateAction */, type];
147
146
  }
148
147
  exports.StateAction = StateAction;
149
148
  function Redux(action, state, duration) {
150
- return [Messages.Type.Redux, action, state, duration];
149
+ return [44 /* Redux */, action, state, duration];
151
150
  }
152
151
  exports.Redux = Redux;
153
152
  function Vuex(mutation, state) {
154
- return [Messages.Type.Vuex, mutation, state];
153
+ return [45 /* Vuex */, mutation, state];
155
154
  }
156
155
  exports.Vuex = Vuex;
157
156
  function MobX(type, payload) {
158
- return [Messages.Type.MobX, type, payload];
157
+ return [46 /* MobX */, type, payload];
159
158
  }
160
159
  exports.MobX = MobX;
161
160
  function NgRx(action, state, duration) {
162
- return [Messages.Type.NgRx, action, state, duration];
161
+ return [47 /* NgRx */, action, state, duration];
163
162
  }
164
163
  exports.NgRx = NgRx;
165
164
  function GraphQL(operationKind, operationName, variables, response) {
166
- return [Messages.Type.GraphQL, operationKind, operationName, variables, response];
165
+ return [48 /* GraphQL */, operationKind, operationName, variables, response];
167
166
  }
168
167
  exports.GraphQL = GraphQL;
169
168
  function PerformanceTrack(frames, ticks, totalJSHeapSize, usedJSHeapSize) {
170
- return [Messages.Type.PerformanceTrack, frames, ticks, totalJSHeapSize, usedJSHeapSize];
169
+ return [49 /* PerformanceTrack */, frames, ticks, totalJSHeapSize, usedJSHeapSize];
171
170
  }
172
171
  exports.PerformanceTrack = PerformanceTrack;
173
172
  function ResourceTiming(timestamp, duration, ttfb, headerSize, encodedBodySize, decodedBodySize, url, initiator) {
174
173
  return [
175
- Messages.Type.ResourceTiming,
174
+ 53 /* ResourceTiming */,
176
175
  timestamp,
177
176
  duration,
178
177
  ttfb,
@@ -185,16 +184,16 @@ function ResourceTiming(timestamp, duration, ttfb, headerSize, encodedBodySize,
185
184
  }
186
185
  exports.ResourceTiming = ResourceTiming;
187
186
  function ConnectionInformation(downlink, type) {
188
- return [Messages.Type.ConnectionInformation, downlink, type];
187
+ return [54 /* ConnectionInformation */, downlink, type];
189
188
  }
190
189
  exports.ConnectionInformation = ConnectionInformation;
191
190
  function SetPageVisibility(hidden) {
192
- return [Messages.Type.SetPageVisibility, hidden];
191
+ return [55 /* SetPageVisibility */, hidden];
193
192
  }
194
193
  exports.SetPageVisibility = SetPageVisibility;
195
194
  function LongTask(timestamp, duration, context, containerType, containerSrc, containerId, containerName) {
196
195
  return [
197
- Messages.Type.LongTask,
196
+ 59 /* LongTask */,
198
197
  timestamp,
199
198
  duration,
200
199
  context,
@@ -206,30 +205,30 @@ function LongTask(timestamp, duration, context, containerType, containerSrc, con
206
205
  }
207
206
  exports.LongTask = LongTask;
208
207
  function SetNodeAttributeURLBased(id, name, value, baseURL) {
209
- return [Messages.Type.SetNodeAttributeURLBased, id, name, value, baseURL];
208
+ return [60 /* SetNodeAttributeURLBased */, id, name, value, baseURL];
210
209
  }
211
210
  exports.SetNodeAttributeURLBased = SetNodeAttributeURLBased;
212
211
  function SetCSSDataURLBased(id, data, baseURL) {
213
- return [Messages.Type.SetCSSDataURLBased, id, data, baseURL];
212
+ return [61 /* SetCSSDataURLBased */, id, data, baseURL];
214
213
  }
215
214
  exports.SetCSSDataURLBased = SetCSSDataURLBased;
216
215
  function TechnicalInfo(type, value) {
217
- return [Messages.Type.TechnicalInfo, type, value];
216
+ return [63 /* TechnicalInfo */, type, value];
218
217
  }
219
218
  exports.TechnicalInfo = TechnicalInfo;
220
219
  function CustomIssue(name, payload) {
221
- return [Messages.Type.CustomIssue, name, payload];
220
+ return [64 /* CustomIssue */, name, payload];
222
221
  }
223
222
  exports.CustomIssue = CustomIssue;
224
223
  function CSSInsertRuleURLBased(id, rule, index, baseURL) {
225
- return [Messages.Type.CSSInsertRuleURLBased, id, rule, index, baseURL];
224
+ return [67 /* CSSInsertRuleURLBased */, id, rule, index, baseURL];
226
225
  }
227
226
  exports.CSSInsertRuleURLBased = CSSInsertRuleURLBased;
228
227
  function MouseClick(id, hesitationTime, label, selector) {
229
- return [Messages.Type.MouseClick, id, hesitationTime, label, selector];
228
+ return [69 /* MouseClick */, id, hesitationTime, label, selector];
230
229
  }
231
230
  exports.MouseClick = MouseClick;
232
231
  function CreateIFrameDocument(frameID, id) {
233
- return [Messages.Type.CreateIFrameDocument, frameID, id];
232
+ return [70 /* CreateIFrameDocument */, frameID, id];
234
233
  }
235
234
  exports.CreateIFrameDocument = CreateIFrameDocument;
@@ -7,7 +7,7 @@ export default class Nodes {
7
7
  constructor(node_id: string);
8
8
  attachNodeCallback(nodeCallback: NodeCallback): void;
9
9
  attachElementListener(type: string, node: Element, elementListener: EventListener): void;
10
- registerNode(node: Node): [id: number, isNew: boolean];
10
+ registerNode(node: Node): [/*id:*/ number, /*isNew:*/ boolean];
11
11
  unregisterNode(node: Node): number | undefined;
12
12
  cleanTree(): void;
13
13
  callNodeCallbacks(node: Node, isStart: boolean): void;
@@ -3,7 +3,8 @@ import App from '../index.js';
3
3
  export interface Options {
4
4
  captureIFrames: boolean;
5
5
  }
6
- declare type ContextCallback = (context: Window & typeof globalThis) => void;
6
+ declare type Context = Window & typeof globalThis;
7
+ declare type ContextCallback = (context: Context) => void;
7
8
  declare type Offset = {
8
9
  top: number;
9
10
  left: number;
@@ -12,6 +13,7 @@ export default class TopObserver extends Observer {
12
13
  private readonly options;
13
14
  constructor(app: App, options: Partial<Options>);
14
15
  private readonly contextCallbacks;
16
+ private readonly contextsSet;
15
17
  attachContextCallback(cb: ContextCallback): void;
16
18
  getDocumentOffset(doc: Document): Offset;
17
19
  private iframeObservers;
@@ -15,6 +15,8 @@ class TopObserver extends observer_js_1.default {
15
15
  constructor(app, options) {
16
16
  super(app, true);
17
17
  this.contextCallbacks = [];
18
+ // Attached once per Tracker instance
19
+ this.contextsSet = new Set();
18
20
  this.iframeObservers = [];
19
21
  this.shadowRootObservers = [];
20
22
  this.options = Object.assign({
@@ -35,7 +37,6 @@ class TopObserver extends observer_js_1.default {
35
37
  }
36
38
  });
37
39
  }
38
- // Attached once per Tracker instance
39
40
  attachContextCallback(cb) {
40
41
  this.contextCallbacks.push(cb);
41
42
  }
@@ -70,7 +71,12 @@ class TopObserver extends observer_js_1.default {
70
71
  };
71
72
  };
72
73
  }
73
- if (currentWin && currentWin !== win) {
74
+ if (currentWin &&
75
+ // Sometimes currentWin.window is null (not in specification). Such window object is not functional
76
+ currentWin === currentWin.window &&
77
+ !this.contextsSet.has(currentWin) // for each context callbacks called once per Tracker (TopObserver) instance
78
+ ) {
79
+ this.contextsSet.add(currentWin);
74
80
  //@ts-ignore https://github.com/microsoft/TypeScript/issues/41684
75
81
  this.contextCallbacks.forEach((cb) => cb(currentWin));
76
82
  win = currentWin;
@@ -4,6 +4,7 @@ interface SessionInfo {
4
4
  metadata: Record<string, string>;
5
5
  userID: string | null;
6
6
  timestamp: number;
7
+ projectID?: string;
7
8
  }
8
9
  declare type OnUpdateCallback = (i: Partial<SessionInfo>) => void;
9
10
  export declare type Options = {
@@ -12,12 +13,13 @@ export declare type Options = {
12
13
  };
13
14
  export default class Session {
14
15
  private readonly app;
15
- private options;
16
+ private readonly options;
16
17
  private metadata;
17
18
  private userID;
18
19
  private sessionID;
19
20
  private readonly callbacks;
20
21
  private timestamp;
22
+ private projectID;
21
23
  constructor(app: App, options: Options);
22
24
  attachUpdateCallback(cb: OnUpdateCallback): void;
23
25
  private handleUpdate;
@@ -29,7 +31,7 @@ export default class Session {
29
31
  getSessionToken(): string | undefined;
30
32
  setSessionToken(token: string): void;
31
33
  applySessionHash(hash: string): void;
32
- getSessionHash(): string;
34
+ getSessionHash(): string | undefined;
33
35
  getInfo(): SessionInfo;
34
36
  reset(): void;
35
37
  }
@@ -35,6 +35,9 @@ class Session {
35
35
  if (newInfo.timestamp !== undefined) {
36
36
  this.timestamp = newInfo.timestamp;
37
37
  }
38
+ if (newInfo.projectID !== undefined) {
39
+ this.projectID = newInfo.projectID;
40
+ }
38
41
  this.handleUpdate(newInfo);
39
42
  }
40
43
  setMetadata(key, value) {
@@ -70,7 +73,13 @@ class Session {
70
73
  this.app.sessionStorage.setItem(this.options.session_token_key, token);
71
74
  }
72
75
  applySessionHash(hash) {
73
- const [pageNoStr, token] = decodeURI(hash).split('&');
76
+ const hashParts = decodeURI(hash).split('&');
77
+ let token = hash;
78
+ let pageNoStr = '100500'; // back-compat for sessionToken
79
+ if (hashParts.length == 2) {
80
+ ;
81
+ [token, pageNoStr] = hashParts;
82
+ }
74
83
  if (!pageNoStr || !token) {
75
84
  return;
76
85
  }
@@ -81,9 +90,9 @@ class Session {
81
90
  const pageNo = this.getPageNumber();
82
91
  const token = this.getSessionToken();
83
92
  if (pageNo === undefined || token === undefined) {
84
- return '';
93
+ return;
85
94
  }
86
- return encodeURI(String(pageNo) + "&" + token);
95
+ return encodeURI(String(pageNo) + '&' + token);
87
96
  }
88
97
  getInfo() {
89
98
  return {
@@ -91,6 +100,7 @@ class Session {
91
100
  metadata: this.metadata,
92
101
  userID: this.userID,
93
102
  timestamp: this.timestamp,
103
+ projectID: this.projectID,
94
104
  };
95
105
  }
96
106
  reset() {