@openreplay/tracker 14.0.6-beta.0 → 14.0.6-beta.2

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/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.6-beta.0'; // TODO: version compatability check inside each plugin.
97
+ this.version = '14.0.6-beta.2'; // TODO: version compatability check inside each plugin.
98
98
  this.socketMode = false;
99
99
  this.compressionThreshold = 24 * 1000;
100
100
  this.bc = null;
@@ -11,7 +11,7 @@ export default abstract class Observer {
11
11
  constructor(app: App, isTopContext?: boolean);
12
12
  private clear;
13
13
  /**
14
- * Unbinds the old content document in case of iframe src change.
14
+ * Unbinds the removed nodes in case of iframe src change.
15
15
  */
16
16
  private handleIframeSrcChange;
17
17
  private sendNodeAttribute;
@@ -48,7 +48,6 @@ class Observer {
48
48
  this.attributesMap = new Map();
49
49
  this.textSet = new Set();
50
50
  this.observer = (0, utils_js_1.createMutationObserver)(this.app.safe((mutations) => {
51
- console.log(mutations);
52
51
  for (const mutation of mutations) {
53
52
  // mutations order is sequential
54
53
  const target = mutation.target;
@@ -80,7 +79,7 @@ class Observer {
80
79
  continue;
81
80
  }
82
81
  if (target instanceof HTMLIFrameElement && name === 'src') {
83
- this.handleIframeSrcChange(target, id);
82
+ this.handleIframeSrcChange(target);
84
83
  }
85
84
  let attr = this.attributesMap.get(id);
86
85
  if (attr === undefined) {
@@ -104,13 +103,33 @@ class Observer {
104
103
  this.textSet.clear();
105
104
  }
106
105
  /**
107
- * Unbinds the old content document in case of iframe src change.
106
+ * Unbinds the removed nodes in case of iframe src change.
108
107
  */
109
- handleIframeSrcChange(iframe, id) {
108
+ handleIframeSrcChange(iframe) {
110
109
  const oldContentDocument = iframe.contentDocument;
111
110
  if (oldContentDocument) {
112
- this.recents.set(id, RecentsType.Removed);
113
- this.unbindTree(oldContentDocument, true);
111
+ const id = this.app.nodes.getID(oldContentDocument);
112
+ if (id !== undefined) {
113
+ const walker = document.createTreeWalker(oldContentDocument, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
114
+ acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) === undefined
115
+ ? NodeFilter.FILTER_REJECT
116
+ : NodeFilter.FILTER_ACCEPT,
117
+ },
118
+ // @ts-ignore
119
+ false);
120
+ let removed = 0;
121
+ const totalBeforeRemove = this.app.nodes.getNodeCount();
122
+ while (walker.nextNode()) {
123
+ if (!iframe.contentDocument.contains(walker.currentNode)) {
124
+ removed += 1;
125
+ this.app.nodes.unregisterNode(walker.currentNode);
126
+ }
127
+ }
128
+ const removedPercent = Math.floor((removed / totalBeforeRemove) * 100);
129
+ if (removedPercent > 30) {
130
+ this.app.send((0, messages_gen_js_1.UnbindNodes)(removedPercent));
131
+ }
132
+ }
114
133
  }
115
134
  }
116
135
  sendNodeAttribute(id, node, name, value) {
@@ -198,11 +217,8 @@ class Observer {
198
217
  this.bindNode(walker.currentNode);
199
218
  }
200
219
  }
201
- unbindTree(node, force) {
220
+ unbindTree(node) {
202
221
  const id = this.app.nodes.unregisterNode(node);
203
- if (force && id) {
204
- this.recents.set(id, RecentsType.Removed);
205
- }
206
222
  if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
207
223
  // Sending RemoveNode only for parent to maintain
208
224
  this.app.send((0, messages_gen_js_1.RemoveNode)(id));
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.6-beta.0',
101
+ trackerVersion: '14.0.6-beta.2',
102
102
  projectKey: this.options.projectKey,
103
103
  doNotTrack,
104
104
  reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
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.6-beta.0'; // TODO: version compatability check inside each plugin.
68
+ this.version = '14.0.6-beta.2'; // TODO: version compatability check inside each plugin.
69
69
  this.socketMode = false;
70
70
  this.compressionThreshold = 24 * 1000;
71
71
  this.bc = null;
@@ -11,7 +11,7 @@ export default abstract class Observer {
11
11
  constructor(app: App, isTopContext?: boolean);
12
12
  private clear;
13
13
  /**
14
- * Unbinds the old content document in case of iframe src change.
14
+ * Unbinds the removed nodes in case of iframe src change.
15
15
  */
16
16
  private handleIframeSrcChange;
17
17
  private sendNodeAttribute;
@@ -46,7 +46,6 @@ export default class Observer {
46
46
  this.attributesMap = new Map();
47
47
  this.textSet = new Set();
48
48
  this.observer = createMutationObserver(this.app.safe((mutations) => {
49
- console.log(mutations);
50
49
  for (const mutation of mutations) {
51
50
  // mutations order is sequential
52
51
  const target = mutation.target;
@@ -78,7 +77,7 @@ export default class Observer {
78
77
  continue;
79
78
  }
80
79
  if (target instanceof HTMLIFrameElement && name === 'src') {
81
- this.handleIframeSrcChange(target, id);
80
+ this.handleIframeSrcChange(target);
82
81
  }
83
82
  let attr = this.attributesMap.get(id);
84
83
  if (attr === undefined) {
@@ -102,13 +101,33 @@ export default class Observer {
102
101
  this.textSet.clear();
103
102
  }
104
103
  /**
105
- * Unbinds the old content document in case of iframe src change.
104
+ * Unbinds the removed nodes in case of iframe src change.
106
105
  */
107
- handleIframeSrcChange(iframe, id) {
106
+ handleIframeSrcChange(iframe) {
108
107
  const oldContentDocument = iframe.contentDocument;
109
108
  if (oldContentDocument) {
110
- this.recents.set(id, RecentsType.Removed);
111
- this.unbindTree(oldContentDocument, true);
109
+ const id = this.app.nodes.getID(oldContentDocument);
110
+ if (id !== undefined) {
111
+ const walker = document.createTreeWalker(oldContentDocument, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
112
+ acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) === undefined
113
+ ? NodeFilter.FILTER_REJECT
114
+ : NodeFilter.FILTER_ACCEPT,
115
+ },
116
+ // @ts-ignore
117
+ false);
118
+ let removed = 0;
119
+ const totalBeforeRemove = this.app.nodes.getNodeCount();
120
+ while (walker.nextNode()) {
121
+ if (!iframe.contentDocument.contains(walker.currentNode)) {
122
+ removed += 1;
123
+ this.app.nodes.unregisterNode(walker.currentNode);
124
+ }
125
+ }
126
+ const removedPercent = Math.floor((removed / totalBeforeRemove) * 100);
127
+ if (removedPercent > 30) {
128
+ this.app.send(UnbindNodes(removedPercent));
129
+ }
130
+ }
112
131
  }
113
132
  }
114
133
  sendNodeAttribute(id, node, name, value) {
@@ -196,11 +215,8 @@ export default class Observer {
196
215
  this.bindNode(walker.currentNode);
197
216
  }
198
217
  }
199
- unbindTree(node, force) {
218
+ unbindTree(node) {
200
219
  const id = this.app.nodes.unregisterNode(node);
201
- if (force && id) {
202
- this.recents.set(id, RecentsType.Removed);
203
- }
204
220
  if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
205
221
  // Sending RemoveNode only for parent to maintain
206
222
  this.app.send(RemoveNode(id));
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.6-beta.0',
70
+ trackerVersion: '14.0.6-beta.2',
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.6-beta.0",
4
+ "version": "14.0.6-beta.2",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"