@openreplay/tracker 14.0.7-beta.0 → 14.0.7

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 14.0.7
2
+
3
+ - check for stopping status during restarts
4
+ - restart if token expired during canvas fetch
5
+
1
6
  # 14.0.6
2
7
 
3
8
  - support feature off toggle for feature flags and usability testing
package/bun.lockb CHANGED
Binary file
package/cjs/app/canvas.js CHANGED
@@ -81,7 +81,7 @@ class CanvasRecorder {
81
81
  return;
82
82
  }
83
83
  if (!canvas || !(0, guards_js_1.hasTag)(canvas, 'canvas') || canvas !== node) {
84
- this.app.debug.log('Canvas element not in sync');
84
+ this.app.debug.log('Canvas element not in sync', canvas, node);
85
85
  clearInterval(int);
86
86
  return;
87
87
  }
@@ -125,6 +125,13 @@ class CanvasRecorder {
125
125
  saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
126
126
  }
127
127
  });
128
+ const initRestart = () => {
129
+ this.app.debug.log('Restarting tracker; token expired');
130
+ this.app.stop(false);
131
+ setTimeout(() => {
132
+ void this.app.start({}, true);
133
+ }, 250);
134
+ };
128
135
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
129
136
  method: 'POST',
130
137
  headers: {
@@ -132,7 +139,10 @@ class CanvasRecorder {
132
139
  },
133
140
  body: formData,
134
141
  })
135
- .then(() => {
142
+ .then((r) => {
143
+ if (r.status === 401) {
144
+ return initRestart();
145
+ }
136
146
  return true;
137
147
  })
138
148
  .catch((e) => {
package/cjs/app/index.js CHANGED
@@ -94,7 +94,7 @@ class App {
94
94
  this.stopCallbacks = [];
95
95
  this.commitCallbacks = [];
96
96
  this.activityState = ActivityState.NotActive;
97
- this.version = '14.0.7-beta.0'; // TODO: version compatability check inside each plugin.
97
+ this.version = '14.0.7'; // TODO: version compatability check inside each plugin.
98
98
  this.socketMode = false;
99
99
  this.compressionThreshold = 24 * 1000;
100
100
  this.bc = null;
@@ -31,6 +31,7 @@ export default class Session {
31
31
  private projectID;
32
32
  private tabId;
33
33
  userInfo: UserInfo;
34
+ private token;
34
35
  constructor(app: App, options: Options);
35
36
  attachUpdateCallback(cb: OnUpdateCallback): void;
36
37
  private handleUpdate;
@@ -72,9 +72,11 @@ class Session {
72
72
  return pageNo;
73
73
  }
74
74
  getSessionToken() {
75
- return this.app.sessionStorage.getItem(this.options.session_token_key) || undefined;
75
+ const token = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
76
+ return token || undefined;
76
77
  }
77
78
  setSessionToken(token) {
79
+ this.token = token;
78
80
  this.app.sessionStorage.setItem(this.options.session_token_key, token);
79
81
  }
80
82
  applySessionHash(hash) {
package/cjs/index.js CHANGED
@@ -98,7 +98,7 @@ class API {
98
98
  const orig = this.options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
99
99
  req.open('POST', orig + '/v1/web/not-started');
100
100
  req.send(JSON.stringify({
101
- trackerVersion: '14.0.7-beta.0',
101
+ trackerVersion: '14.0.7',
102
102
  projectKey: this.options.projectKey,
103
103
  doNotTrack,
104
104
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
package/lib/app/canvas.js CHANGED
@@ -79,7 +79,7 @@ class CanvasRecorder {
79
79
  return;
80
80
  }
81
81
  if (!canvas || !hasTag(canvas, 'canvas') || canvas !== node) {
82
- this.app.debug.log('Canvas element not in sync');
82
+ this.app.debug.log('Canvas element not in sync', canvas, node);
83
83
  clearInterval(int);
84
84
  return;
85
85
  }
@@ -123,6 +123,13 @@ class CanvasRecorder {
123
123
  saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
124
124
  }
125
125
  });
126
+ const initRestart = () => {
127
+ this.app.debug.log('Restarting tracker; token expired');
128
+ this.app.stop(false);
129
+ setTimeout(() => {
130
+ void this.app.start({}, true);
131
+ }, 250);
132
+ };
126
133
  fetch(this.app.options.ingestPoint + '/v1/web/images', {
127
134
  method: 'POST',
128
135
  headers: {
@@ -130,7 +137,10 @@ class CanvasRecorder {
130
137
  },
131
138
  body: formData,
132
139
  })
133
- .then(() => {
140
+ .then((r) => {
141
+ if (r.status === 401) {
142
+ return initRestart();
143
+ }
134
144
  return true;
135
145
  })
136
146
  .catch((e) => {
package/lib/app/index.js CHANGED
@@ -65,7 +65,7 @@ export default class App {
65
65
  this.stopCallbacks = [];
66
66
  this.commitCallbacks = [];
67
67
  this.activityState = ActivityState.NotActive;
68
- this.version = '14.0.7-beta.0'; // TODO: version compatability check inside each plugin.
68
+ this.version = '14.0.7'; // TODO: version compatability check inside each plugin.
69
69
  this.socketMode = false;
70
70
  this.compressionThreshold = 24 * 1000;
71
71
  this.bc = null;
@@ -31,6 +31,7 @@ export default class Session {
31
31
  private projectID;
32
32
  private tabId;
33
33
  userInfo: UserInfo;
34
+ private token;
34
35
  constructor(app: App, options: Options);
35
36
  attachUpdateCallback(cb: OnUpdateCallback): void;
36
37
  private handleUpdate;
@@ -70,9 +70,11 @@ export default class Session {
70
70
  return pageNo;
71
71
  }
72
72
  getSessionToken() {
73
- return this.app.sessionStorage.getItem(this.options.session_token_key) || undefined;
73
+ const token = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
74
+ return token || undefined;
74
75
  }
75
76
  setSessionToken(token) {
77
+ this.token = token;
76
78
  this.app.sessionStorage.setItem(this.options.session_token_key, token);
77
79
  }
78
80
  applySessionHash(hash) {
package/lib/index.js CHANGED
@@ -67,7 +67,7 @@ export default class API {
67
67
  const orig = this.options.ingestPoint || DEFAULT_INGEST_POINT;
68
68
  req.open('POST', orig + '/v1/web/not-started');
69
69
  req.send(JSON.stringify({
70
- trackerVersion: '14.0.7-beta.0',
70
+ trackerVersion: '14.0.7',
71
71
  projectKey: this.options.projectKey,
72
72
  doNotTrack,
73
73
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
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": "14.0.7-beta.0",
4
+ "version": "14.0.7",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"