@openreplay/tracker 3.6.2 → 4.0.1

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.
Files changed (128) hide show
  1. package/.eslintignore +8 -0
  2. package/.prettierignore +1 -0
  3. package/LICENSE +1 -1
  4. package/cjs/app/guards.d.ts +2 -1
  5. package/cjs/app/guards.js +6 -3
  6. package/cjs/app/index.d.ts +28 -23
  7. package/cjs/app/index.js +107 -86
  8. package/cjs/app/logger.js +6 -3
  9. package/cjs/app/messages.d.ts +52 -0
  10. package/cjs/app/messages.gen.d.ts +58 -0
  11. package/cjs/app/messages.gen.js +501 -0
  12. package/cjs/app/messages.js +234 -0
  13. package/cjs/app/nodes.d.ts +1 -1
  14. package/cjs/app/nodes.js +2 -0
  15. package/cjs/app/observer/iframe_observer.d.ts +1 -1
  16. package/cjs/app/observer/iframe_observer.js +3 -3
  17. package/cjs/app/observer/observer.d.ts +2 -3
  18. package/cjs/app/observer/observer.js +50 -52
  19. package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
  20. package/cjs/app/observer/shadow_root_observer.js +3 -3
  21. package/cjs/app/observer/top_observer.d.ts +13 -2
  22. package/cjs/app/observer/top_observer.js +58 -23
  23. package/cjs/app/sanitizer.d.ts +1 -1
  24. package/cjs/app/sanitizer.js +5 -5
  25. package/cjs/app/session.d.ts +20 -2
  26. package/cjs/app/session.js +65 -6
  27. package/cjs/app/ticker.d.ts +1 -1
  28. package/cjs/common/{webworker.d.ts → interaction.d.ts} +5 -5
  29. package/cjs/common/{types.js → interaction.js} +0 -0
  30. package/cjs/common/messages.gen.d.ts +388 -0
  31. package/cjs/common/{webworker.js → messages.gen.js} +1 -0
  32. package/cjs/index.d.ts +10 -9
  33. package/cjs/index.js +47 -36
  34. package/cjs/modules/adoptedStyleSheets.d.ts +2 -0
  35. package/cjs/modules/adoptedStyleSheets.js +127 -0
  36. package/cjs/modules/connection.d.ts +1 -1
  37. package/cjs/modules/connection.js +2 -2
  38. package/cjs/modules/console.d.ts +1 -1
  39. package/cjs/modules/console.js +7 -21
  40. package/cjs/modules/cssrules.d.ts +1 -1
  41. package/cjs/modules/cssrules.js +18 -14
  42. package/cjs/modules/exception.d.ts +3 -3
  43. package/cjs/modules/exception.js +23 -18
  44. package/cjs/modules/img.d.ts +1 -1
  45. package/cjs/modules/img.js +39 -26
  46. package/cjs/modules/input.d.ts +1 -1
  47. package/cjs/modules/input.js +21 -21
  48. package/cjs/modules/mouse.d.ts +1 -1
  49. package/cjs/modules/mouse.js +50 -43
  50. package/cjs/modules/performance.d.ts +1 -1
  51. package/cjs/modules/performance.js +2 -2
  52. package/cjs/modules/scroll.d.ts +1 -1
  53. package/cjs/modules/scroll.js +16 -7
  54. package/cjs/modules/timing.d.ts +1 -1
  55. package/cjs/modules/timing.js +14 -26
  56. package/cjs/modules/viewport.d.ts +1 -1
  57. package/cjs/modules/viewport.js +4 -4
  58. package/cjs/utils.js +7 -7
  59. package/cjs/vendors/finder/finder.js +53 -48
  60. package/lib/app/guards.d.ts +2 -1
  61. package/lib/app/guards.js +4 -2
  62. package/lib/app/index.d.ts +28 -23
  63. package/lib/app/index.js +115 -94
  64. package/lib/app/logger.js +6 -3
  65. package/lib/app/messages.d.ts +52 -0
  66. package/lib/app/messages.gen.d.ts +58 -0
  67. package/lib/app/messages.gen.js +441 -0
  68. package/lib/app/messages.js +181 -0
  69. package/lib/app/nodes.d.ts +1 -1
  70. package/lib/app/nodes.js +2 -0
  71. package/lib/app/observer/iframe_observer.d.ts +1 -1
  72. package/lib/app/observer/iframe_observer.js +3 -3
  73. package/lib/app/observer/observer.d.ts +2 -3
  74. package/lib/app/observer/observer.js +51 -53
  75. package/lib/app/observer/shadow_root_observer.d.ts +1 -1
  76. package/lib/app/observer/shadow_root_observer.js +3 -3
  77. package/lib/app/observer/top_observer.d.ts +13 -2
  78. package/lib/app/observer/top_observer.js +62 -27
  79. package/lib/app/sanitizer.d.ts +1 -1
  80. package/lib/app/sanitizer.js +7 -7
  81. package/lib/app/session.d.ts +20 -2
  82. package/lib/app/session.js +65 -6
  83. package/lib/app/ticker.d.ts +1 -1
  84. package/lib/common/{webworker.d.ts → interaction.d.ts} +5 -5
  85. package/lib/common/{types.js → interaction.js} +0 -0
  86. package/lib/common/messages.gen.d.ts +388 -0
  87. package/lib/common/messages.gen.js +2 -0
  88. package/lib/common/tsconfig.tsbuildinfo +1 -1
  89. package/lib/index.d.ts +10 -9
  90. package/lib/index.js +60 -49
  91. package/lib/modules/adoptedStyleSheets.d.ts +2 -0
  92. package/lib/modules/adoptedStyleSheets.js +124 -0
  93. package/lib/modules/connection.d.ts +1 -1
  94. package/lib/modules/connection.js +2 -2
  95. package/lib/modules/console.d.ts +1 -1
  96. package/lib/modules/console.js +8 -22
  97. package/lib/modules/cssrules.d.ts +1 -1
  98. package/lib/modules/cssrules.js +19 -15
  99. package/lib/modules/exception.d.ts +3 -3
  100. package/lib/modules/exception.js +23 -18
  101. package/lib/modules/img.d.ts +1 -1
  102. package/lib/modules/img.js +41 -28
  103. package/lib/modules/input.d.ts +1 -1
  104. package/lib/modules/input.js +23 -23
  105. package/lib/modules/mouse.d.ts +1 -1
  106. package/lib/modules/mouse.js +53 -46
  107. package/lib/modules/performance.d.ts +1 -1
  108. package/lib/modules/performance.js +3 -3
  109. package/lib/modules/scroll.d.ts +1 -1
  110. package/lib/modules/scroll.js +17 -8
  111. package/lib/modules/timing.d.ts +1 -1
  112. package/lib/modules/timing.js +16 -28
  113. package/lib/modules/viewport.d.ts +1 -1
  114. package/lib/modules/viewport.js +4 -4
  115. package/lib/utils.js +7 -7
  116. package/lib/vendors/finder/finder.js +53 -48
  117. package/package.json +27 -10
  118. package/cjs/common/messages.d.ts +0 -444
  119. package/cjs/common/messages.js +0 -794
  120. package/cjs/common/types.d.ts +0 -9
  121. package/cjs/modules/longtasks.d.ts +0 -2
  122. package/cjs/modules/longtasks.js +0 -26
  123. package/lib/common/messages.d.ts +0 -444
  124. package/lib/common/messages.js +0 -790
  125. package/lib/common/types.d.ts +0 -9
  126. package/lib/common/webworker.js +0 -1
  127. package/lib/modules/longtasks.d.ts +0 -2
  128. package/lib/modules/longtasks.js +0 -23
@@ -0,0 +1,388 @@
1
+ export declare const enum Type {
2
+ BatchMetadata = 81,
3
+ PartitionedMessage = 82,
4
+ Timestamp = 0,
5
+ SetPageLocation = 4,
6
+ SetViewportSize = 5,
7
+ SetViewportScroll = 6,
8
+ CreateDocument = 7,
9
+ CreateElementNode = 8,
10
+ CreateTextNode = 9,
11
+ MoveNode = 10,
12
+ RemoveNode = 11,
13
+ SetNodeAttribute = 12,
14
+ RemoveNodeAttribute = 13,
15
+ SetNodeData = 14,
16
+ SetNodeScroll = 16,
17
+ SetInputTarget = 17,
18
+ SetInputValue = 18,
19
+ SetInputChecked = 19,
20
+ MouseMove = 20,
21
+ ConsoleLog = 22,
22
+ PageLoadTiming = 23,
23
+ PageRenderTiming = 24,
24
+ JSException = 25,
25
+ RawCustomEvent = 27,
26
+ UserID = 28,
27
+ UserAnonymousID = 29,
28
+ Metadata = 30,
29
+ CSSInsertRule = 37,
30
+ CSSDeleteRule = 38,
31
+ Fetch = 39,
32
+ Profiler = 40,
33
+ OTable = 41,
34
+ StateAction = 42,
35
+ Redux = 44,
36
+ Vuex = 45,
37
+ MobX = 46,
38
+ NgRx = 47,
39
+ GraphQL = 48,
40
+ PerformanceTrack = 49,
41
+ ResourceTiming = 53,
42
+ ConnectionInformation = 54,
43
+ SetPageVisibility = 55,
44
+ LongTask = 59,
45
+ SetNodeAttributeURLBased = 60,
46
+ SetCSSDataURLBased = 61,
47
+ TechnicalInfo = 63,
48
+ CustomIssue = 64,
49
+ CSSInsertRuleURLBased = 67,
50
+ MouseClick = 69,
51
+ CreateIFrameDocument = 70,
52
+ AdoptedSSReplaceURLBased = 71,
53
+ AdoptedSSInsertRuleURLBased = 73,
54
+ AdoptedSSDeleteRule = 75,
55
+ AdoptedSSAddOwner = 76,
56
+ AdoptedSSRemoveOwner = 77,
57
+ Zustand = 79
58
+ }
59
+ export declare type BatchMetadata = [
60
+ Type.BatchMetadata,
61
+ number,
62
+ number,
63
+ number,
64
+ number,
65
+ string
66
+ ];
67
+ export declare type PartitionedMessage = [
68
+ Type.PartitionedMessage,
69
+ number,
70
+ number
71
+ ];
72
+ export declare type Timestamp = [
73
+ Type.Timestamp,
74
+ number
75
+ ];
76
+ export declare type SetPageLocation = [
77
+ Type.SetPageLocation,
78
+ string,
79
+ string,
80
+ number
81
+ ];
82
+ export declare type SetViewportSize = [
83
+ Type.SetViewportSize,
84
+ number,
85
+ number
86
+ ];
87
+ export declare type SetViewportScroll = [
88
+ Type.SetViewportScroll,
89
+ number,
90
+ number
91
+ ];
92
+ export declare type CreateDocument = [
93
+ Type.CreateDocument
94
+ ];
95
+ export declare type CreateElementNode = [
96
+ Type.CreateElementNode,
97
+ number,
98
+ number,
99
+ number,
100
+ string,
101
+ boolean
102
+ ];
103
+ export declare type CreateTextNode = [
104
+ Type.CreateTextNode,
105
+ number,
106
+ number,
107
+ number
108
+ ];
109
+ export declare type MoveNode = [
110
+ Type.MoveNode,
111
+ number,
112
+ number,
113
+ number
114
+ ];
115
+ export declare type RemoveNode = [
116
+ Type.RemoveNode,
117
+ number
118
+ ];
119
+ export declare type SetNodeAttribute = [
120
+ Type.SetNodeAttribute,
121
+ number,
122
+ string,
123
+ string
124
+ ];
125
+ export declare type RemoveNodeAttribute = [
126
+ Type.RemoveNodeAttribute,
127
+ number,
128
+ string
129
+ ];
130
+ export declare type SetNodeData = [
131
+ Type.SetNodeData,
132
+ number,
133
+ string
134
+ ];
135
+ export declare type SetNodeScroll = [
136
+ Type.SetNodeScroll,
137
+ number,
138
+ number,
139
+ number
140
+ ];
141
+ export declare type SetInputTarget = [
142
+ Type.SetInputTarget,
143
+ number,
144
+ string
145
+ ];
146
+ export declare type SetInputValue = [
147
+ Type.SetInputValue,
148
+ number,
149
+ string,
150
+ number
151
+ ];
152
+ export declare type SetInputChecked = [
153
+ Type.SetInputChecked,
154
+ number,
155
+ boolean
156
+ ];
157
+ export declare type MouseMove = [
158
+ Type.MouseMove,
159
+ number,
160
+ number
161
+ ];
162
+ export declare type ConsoleLog = [
163
+ Type.ConsoleLog,
164
+ string,
165
+ string
166
+ ];
167
+ export declare type PageLoadTiming = [
168
+ Type.PageLoadTiming,
169
+ number,
170
+ number,
171
+ number,
172
+ number,
173
+ number,
174
+ number,
175
+ number,
176
+ number,
177
+ number
178
+ ];
179
+ export declare type PageRenderTiming = [
180
+ Type.PageRenderTiming,
181
+ number,
182
+ number,
183
+ number
184
+ ];
185
+ export declare type JSException = [
186
+ Type.JSException,
187
+ string,
188
+ string,
189
+ string
190
+ ];
191
+ export declare type RawCustomEvent = [
192
+ Type.RawCustomEvent,
193
+ string,
194
+ string
195
+ ];
196
+ export declare type UserID = [
197
+ Type.UserID,
198
+ string
199
+ ];
200
+ export declare type UserAnonymousID = [
201
+ Type.UserAnonymousID,
202
+ string
203
+ ];
204
+ export declare type Metadata = [
205
+ Type.Metadata,
206
+ string,
207
+ string
208
+ ];
209
+ export declare type CSSInsertRule = [
210
+ Type.CSSInsertRule,
211
+ number,
212
+ string,
213
+ number
214
+ ];
215
+ export declare type CSSDeleteRule = [
216
+ Type.CSSDeleteRule,
217
+ number,
218
+ number
219
+ ];
220
+ export declare type Fetch = [
221
+ Type.Fetch,
222
+ string,
223
+ string,
224
+ string,
225
+ string,
226
+ number,
227
+ number,
228
+ number
229
+ ];
230
+ export declare type Profiler = [
231
+ Type.Profiler,
232
+ string,
233
+ number,
234
+ string,
235
+ string
236
+ ];
237
+ export declare type OTable = [
238
+ Type.OTable,
239
+ string,
240
+ string
241
+ ];
242
+ export declare type StateAction = [
243
+ Type.StateAction,
244
+ string
245
+ ];
246
+ export declare type Redux = [
247
+ Type.Redux,
248
+ string,
249
+ string,
250
+ number
251
+ ];
252
+ export declare type Vuex = [
253
+ Type.Vuex,
254
+ string,
255
+ string
256
+ ];
257
+ export declare type MobX = [
258
+ Type.MobX,
259
+ string,
260
+ string
261
+ ];
262
+ export declare type NgRx = [
263
+ Type.NgRx,
264
+ string,
265
+ string,
266
+ number
267
+ ];
268
+ export declare type GraphQL = [
269
+ Type.GraphQL,
270
+ string,
271
+ string,
272
+ string,
273
+ string
274
+ ];
275
+ export declare type PerformanceTrack = [
276
+ Type.PerformanceTrack,
277
+ number,
278
+ number,
279
+ number,
280
+ number
281
+ ];
282
+ export declare type ResourceTiming = [
283
+ Type.ResourceTiming,
284
+ number,
285
+ number,
286
+ number,
287
+ number,
288
+ number,
289
+ number,
290
+ string,
291
+ string
292
+ ];
293
+ export declare type ConnectionInformation = [
294
+ Type.ConnectionInformation,
295
+ number,
296
+ string
297
+ ];
298
+ export declare type SetPageVisibility = [
299
+ Type.SetPageVisibility,
300
+ boolean
301
+ ];
302
+ export declare type LongTask = [
303
+ Type.LongTask,
304
+ number,
305
+ number,
306
+ number,
307
+ number,
308
+ string,
309
+ string,
310
+ string
311
+ ];
312
+ export declare type SetNodeAttributeURLBased = [
313
+ Type.SetNodeAttributeURLBased,
314
+ number,
315
+ string,
316
+ string,
317
+ string
318
+ ];
319
+ export declare type SetCSSDataURLBased = [
320
+ Type.SetCSSDataURLBased,
321
+ number,
322
+ string,
323
+ string
324
+ ];
325
+ export declare type TechnicalInfo = [
326
+ Type.TechnicalInfo,
327
+ string,
328
+ string
329
+ ];
330
+ export declare type CustomIssue = [
331
+ Type.CustomIssue,
332
+ string,
333
+ string
334
+ ];
335
+ export declare type CSSInsertRuleURLBased = [
336
+ Type.CSSInsertRuleURLBased,
337
+ number,
338
+ string,
339
+ number,
340
+ string
341
+ ];
342
+ export declare type MouseClick = [
343
+ Type.MouseClick,
344
+ number,
345
+ number,
346
+ string,
347
+ string
348
+ ];
349
+ export declare type CreateIFrameDocument = [
350
+ Type.CreateIFrameDocument,
351
+ number,
352
+ number
353
+ ];
354
+ export declare type AdoptedSSReplaceURLBased = [
355
+ Type.AdoptedSSReplaceURLBased,
356
+ number,
357
+ string,
358
+ string
359
+ ];
360
+ export declare type AdoptedSSInsertRuleURLBased = [
361
+ Type.AdoptedSSInsertRuleURLBased,
362
+ number,
363
+ string,
364
+ number,
365
+ string
366
+ ];
367
+ export declare type AdoptedSSDeleteRule = [
368
+ Type.AdoptedSSDeleteRule,
369
+ number,
370
+ number
371
+ ];
372
+ export declare type AdoptedSSAddOwner = [
373
+ Type.AdoptedSSAddOwner,
374
+ number,
375
+ number
376
+ ];
377
+ export declare type AdoptedSSRemoveOwner = [
378
+ Type.AdoptedSSRemoveOwner,
379
+ number,
380
+ number
381
+ ];
382
+ export declare type Zustand = [
383
+ Type.Zustand,
384
+ string,
385
+ string
386
+ ];
387
+ declare type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSException | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand;
388
+ export default Message;
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
+ // Auto-generated, do not edit
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import App from "./app/index.js";
1
+ import App from './app/index.js';
2
2
  export { default as App } from './app/index.js';
3
- import * as _Messages from "./common/messages.js";
3
+ import * as _Messages from './app/messages.gen.js';
4
4
  export declare const Messages: typeof _Messages;
5
- import type { Options as AppOptions } from "./app/index.js";
6
- import type { Options as ConsoleOptions } from "./modules/console.js";
7
- import type { Options as ExceptionOptions } from "./modules/exception.js";
8
- import type { Options as InputOptions } from "./modules/input.js";
9
- import type { Options as PerformanceOptions } from "./modules/performance.js";
10
- import type { Options as TimingOptions } from "./modules/timing.js";
5
+ import type { Options as AppOptions } from './app/index.js';
6
+ import type { Options as ConsoleOptions } from './modules/console.js';
7
+ import type { Options as ExceptionOptions } from './modules/exception.js';
8
+ import type { Options as InputOptions } from './modules/input.js';
9
+ import type { Options as PerformanceOptions } from './modules/performance.js';
10
+ import type { Options as TimingOptions } from './modules/timing.js';
11
11
  import type { StartOptions } from './app/index.js';
12
12
  import type { StartPromiseReturn } from './app/index.js';
13
13
  export declare type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & InputOptions & PerformanceOptions & TimingOptions> & {
@@ -25,10 +25,11 @@ export default class API {
25
25
  use<T>(fn: (app: App | null, options?: Options) => T): T;
26
26
  isActive(): boolean;
27
27
  start(startOpts?: Partial<StartOptions>): Promise<StartPromiseReturn>;
28
- stop(): void;
28
+ stop(): string | undefined;
29
29
  getSessionToken(): string | null | undefined;
30
30
  getSessionID(): string | null | undefined;
31
31
  sessionID(): string | null | undefined;
32
+ getSessionURL(): string | undefined;
32
33
  setUserID(id: string): void;
33
34
  userID(id: string): void;
34
35
  setUserAnonymousID(id: string): void;
package/cjs/index.js CHANGED
@@ -4,8 +4,8 @@ exports.Messages = exports.App = void 0;
4
4
  const index_js_1 = require("./app/index.js");
5
5
  var index_js_2 = require("./app/index.js");
6
6
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return index_js_2.default; } });
7
- const messages_js_1 = require("./common/messages.js");
8
- const _Messages = require("./common/messages.js");
7
+ const messages_gen_js_1 = require("./app/messages.gen.js");
8
+ const _Messages = require("./app/messages.gen.js");
9
9
  exports.Messages = _Messages;
10
10
  const connection_js_1 = require("./modules/connection.js");
11
11
  const console_js_1 = require("./modules/console.js");
@@ -18,6 +18,7 @@ const performance_js_1 = require("./modules/performance.js");
18
18
  const scroll_js_1 = require("./modules/scroll.js");
19
19
  const viewport_js_1 = require("./modules/viewport.js");
20
20
  const cssrules_js_1 = require("./modules/cssrules.js");
21
+ const adoptedStyleSheets_js_1 = require("./modules/adoptedStyleSheets.js");
21
22
  const utils_js_1 = require("./utils.js");
22
23
  const DOCS_SETUP = '/installation/setup-or';
23
24
  function processOptions(obj) {
@@ -27,22 +28,23 @@ function processOptions(obj) {
27
28
  }
28
29
  if (typeof obj.projectKey !== 'string') {
29
30
  if (typeof obj.projectKey !== 'number') {
30
- if (typeof obj.projectID !== 'number') { // Back compatability
31
+ if (typeof obj.projectID !== 'number') {
32
+ // Back compatability
31
33
  console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${utils_js_1.DOCS_HOST}${DOCS_SETUP} for more information.`);
32
34
  return false;
33
35
  }
34
36
  else {
35
37
  obj.projectKey = obj.projectID.toString();
36
- (0, utils_js_1.deprecationWarn)("`projectID` option", "`projectKey` option", DOCS_SETUP);
38
+ (0, utils_js_1.deprecationWarn)('`projectID` option', '`projectKey` option', DOCS_SETUP);
37
39
  }
38
40
  }
39
41
  else {
40
- console.warn("OpenReplay: projectKey is expected to have a string type.");
42
+ console.warn('OpenReplay: projectKey is expected to have a string type.');
41
43
  obj.projectKey = obj.projectKey.toString();
42
44
  }
43
45
  }
44
- if (typeof obj.sessionToken !== 'string' && obj.sessionToken != null) {
45
- console.warn(`OpenReplay: invalid options argument type. Please, check documentation on ${utils_js_1.DOCS_HOST}${DOCS_SETUP}`);
46
+ if (obj.sessionToken != null) {
47
+ (0, utils_js_1.deprecationWarn)('`sessionToken` option', '`sessionHash` start() option', '/');
46
48
  }
47
49
  return true;
48
50
  }
@@ -69,31 +71,33 @@ class API {
69
71
  return;
70
72
  }
71
73
  if (window.__OPENREPLAY__) {
72
- console.error("OpenReplay: one tracker instance has been initialised already");
74
+ console.error('OpenReplay: one tracker instance has been initialised already');
73
75
  return;
74
76
  }
75
77
  if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {
76
- console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");
78
+ console.error('OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.');
77
79
  return;
78
80
  }
79
81
  const doNotTrack = options.respectDoNotTrack &&
80
- (navigator.doNotTrack == '1'
82
+ (navigator.doNotTrack == '1' ||
81
83
  // @ts-ignore
82
- || window.doNotTrack == '1');
83
- const app = this.app = doNotTrack ||
84
- !('Map' in window) ||
85
- !('Set' in window) ||
86
- !('MutationObserver' in window) ||
87
- !('performance' in window) ||
88
- !('timing' in performance) ||
89
- !('startsWith' in String.prototype) ||
90
- !('Blob' in window) ||
91
- !('Worker' in window)
92
- ? null
93
- : new index_js_1.default(options.projectKey, options.sessionToken, options);
84
+ window.doNotTrack == '1');
85
+ const app = (this.app =
86
+ doNotTrack ||
87
+ !('Map' in window) ||
88
+ !('Set' in window) ||
89
+ !('MutationObserver' in window) ||
90
+ !('performance' in window) ||
91
+ !('timing' in performance) ||
92
+ !('startsWith' in String.prototype) ||
93
+ !('Blob' in window) ||
94
+ !('Worker' in window)
95
+ ? null
96
+ : new index_js_1.default(options.projectKey, options.sessionToken, options));
94
97
  if (app !== null) {
95
98
  (0, viewport_js_1.default)(app);
96
99
  (0, cssrules_js_1.default)(app);
100
+ (0, adoptedStyleSheets_js_1.default)(app);
97
101
  (0, connection_js_1.default)(app);
98
102
  (0, console_js_1.default)(app, options);
99
103
  (0, exception_js_1.default)(app, options);
@@ -123,11 +127,11 @@ class API {
123
127
  console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
124
128
  const req = new XMLHttpRequest();
125
129
  const orig = options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
126
- req.open("POST", orig + "/v1/web/not-started");
130
+ req.open('POST', orig + '/v1/web/not-started');
127
131
  // no-cors issue only with text/plain or not-set Content-Type
128
132
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
129
133
  req.send(JSON.stringify({
130
- trackerVersion: '3.6.2',
134
+ trackerVersion: '4.0.1',
131
135
  projectKey: options.projectKey,
132
136
  doNotTrack,
133
137
  // TODO: add precise reason (an exact API missing)
@@ -146,7 +150,7 @@ class API {
146
150
  start(startOpts) {
147
151
  if (!utils_js_1.IN_BROWSER) {
148
152
  console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${utils_js_1.DOCS_HOST}${DOCS_SETUP}`);
149
- return Promise.reject("Trying to start not in browser.");
153
+ return Promise.reject('Trying to start not in browser.');
150
154
  }
151
155
  if (this.app === null) {
152
156
  return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
@@ -158,7 +162,10 @@ class API {
158
162
  if (this.app === null) {
159
163
  return;
160
164
  }
161
- this.app.stop(true);
165
+ this.app.stop();
166
+ const sessionHash = this.app.session.getSessionHash();
167
+ this.app.session.reset();
168
+ return sessionHash;
162
169
  }
163
170
  getSessionToken() {
164
171
  if (this.app === null) {
@@ -173,36 +180,40 @@ class API {
173
180
  return this.app.getSessionID();
174
181
  }
175
182
  sessionID() {
176
- (0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method", "/");
183
+ (0, utils_js_1.deprecationWarn)("'sessionID' method", "'getSessionID' method", '/');
177
184
  return this.getSessionID();
178
185
  }
186
+ getSessionURL() {
187
+ if (this.app === null) {
188
+ return undefined;
189
+ }
190
+ return this.app.getSessionURL();
191
+ }
179
192
  setUserID(id) {
180
193
  if (typeof id === 'string' && this.app !== null) {
181
194
  this.app.session.setUserID(id);
182
195
  }
183
196
  }
184
197
  userID(id) {
185
- (0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method", "/");
198
+ (0, utils_js_1.deprecationWarn)("'userID' method", "'setUserID' method", '/');
186
199
  this.setUserID(id);
187
200
  }
188
201
  setUserAnonymousID(id) {
189
202
  if (typeof id === 'string' && this.app !== null) {
190
- this.app.send(new messages_js_1.UserAnonymousID(id));
203
+ this.app.send((0, messages_gen_js_1.UserAnonymousID)(id));
191
204
  }
192
205
  }
193
206
  userAnonymousID(id) {
194
- (0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method", "/");
207
+ (0, utils_js_1.deprecationWarn)("'userAnonymousID' method", "'setUserAnonymousID' method", '/');
195
208
  this.setUserAnonymousID(id);
196
209
  }
197
210
  setMetadata(key, value) {
198
- if (typeof key === 'string' &&
199
- typeof value === 'string' &&
200
- this.app !== null) {
211
+ if (typeof key === 'string' && typeof value === 'string' && this.app !== null) {
201
212
  this.app.session.setMetadata(key, value);
202
213
  }
203
214
  }
204
215
  metadata(key, value) {
205
- (0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", "/");
216
+ (0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", '/');
206
217
  this.setMetadata(key, value);
207
218
  }
208
219
  event(key, payload, issue = false) {
@@ -217,7 +228,7 @@ class API {
217
228
  catch (e) {
218
229
  return;
219
230
  }
220
- this.app.send(new messages_js_1.RawCustomEvent(key, payload));
231
+ this.app.send((0, messages_gen_js_1.RawCustomEvent)(key, payload));
221
232
  }
222
233
  }
223
234
  }
@@ -229,7 +240,7 @@ class API {
229
240
  catch (e) {
230
241
  return;
231
242
  }
232
- this.app.send(new messages_js_1.CustomIssue(key, payload));
243
+ this.app.send((0, messages_gen_js_1.CustomIssue)(key, payload));
233
244
  }
234
245
  }
235
246
  }
@@ -0,0 +1,2 @@
1
+ import type App from '../app/index.js';
2
+ export default function (app: App | null): void;