@openreplay/tracker 14.0.5 → 14.0.6-beta.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.
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.5'; // TODO: version compatability check inside each plugin.
97
+ this.version = '14.0.6-beta.0'; // TODO: version compatability check inside each plugin.
98
98
  this.socketMode = false;
99
99
  this.compressionThreshold = 24 * 1000;
100
100
  this.bc = null;
@@ -10,6 +10,10 @@ export default abstract class Observer {
10
10
  private readonly textSet;
11
11
  constructor(app: App, isTopContext?: boolean);
12
12
  private clear;
13
+ /**
14
+ * Unbinds the old content document in case of iframe src change.
15
+ */
16
+ private handleIframeSrcChange;
13
17
  private sendNodeAttribute;
14
18
  private sendNodeData;
15
19
  private bindNode;
@@ -48,6 +48,7 @@ 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);
51
52
  for (const mutation of mutations) {
52
53
  // mutations order is sequential
53
54
  const target = mutation.target;
@@ -57,7 +58,6 @@ class Observer {
57
58
  }
58
59
  if (type === 'childList') {
59
60
  for (let i = 0; i < mutation.removedNodes.length; i++) {
60
- // Should be the same as bindTree(mutation.removedNodes[i]), but logic needs to be be untied
61
61
  if (isObservable(mutation.removedNodes[i])) {
62
62
  this.bindNode(mutation.removedNodes[i]);
63
63
  }
@@ -79,6 +79,9 @@ class Observer {
79
79
  if (name === null) {
80
80
  continue;
81
81
  }
82
+ if (target instanceof HTMLIFrameElement && name === 'src') {
83
+ this.handleIframeSrcChange(target, id);
84
+ }
82
85
  let attr = this.attributesMap.get(id);
83
86
  if (attr === undefined) {
84
87
  this.attributesMap.set(id, (attr = new Set()));
@@ -88,7 +91,6 @@ class Observer {
88
91
  }
89
92
  if (type === 'characterData') {
90
93
  this.textSet.add(id);
91
- continue;
92
94
  }
93
95
  }
94
96
  this.commitNodes();
@@ -101,10 +103,20 @@ class Observer {
101
103
  this.attributesMap.clear();
102
104
  this.textSet.clear();
103
105
  }
106
+ /**
107
+ * Unbinds the old content document in case of iframe src change.
108
+ */
109
+ handleIframeSrcChange(iframe, id) {
110
+ const oldContentDocument = iframe.contentDocument;
111
+ if (oldContentDocument) {
112
+ this.recents.set(id, RecentsType.Removed);
113
+ this.unbindTree(oldContentDocument, true);
114
+ }
115
+ }
104
116
  sendNodeAttribute(id, node, name, value) {
105
117
  if ((0, guards_js_1.isSVGElement)(node)) {
106
- if (name.substr(0, 6) === 'xlink:') {
107
- name = name.substr(6);
118
+ if (name.substring(0, 6) === 'xlink:') {
119
+ name = name.substring(6);
108
120
  }
109
121
  if (value === null) {
110
122
  this.app.send((0, messages_gen_js_1.RemoveNodeAttribute)(id, name));
@@ -125,7 +137,7 @@ class Observer {
125
137
  name === 'integrity' ||
126
138
  name === 'crossorigin' ||
127
139
  name === 'autocomplete' ||
128
- name.substr(0, 2) === 'on') {
140
+ name.substring(0, 2) === 'on') {
129
141
  return;
130
142
  }
131
143
  if (name === 'value' &&
@@ -186,8 +198,11 @@ class Observer {
186
198
  this.bindNode(walker.currentNode);
187
199
  }
188
200
  }
189
- unbindTree(node) {
201
+ unbindTree(node, force) {
190
202
  const id = this.app.nodes.unregisterNode(node);
203
+ if (force && id) {
204
+ this.recents.set(id, RecentsType.Removed);
205
+ }
191
206
  if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
192
207
  // Sending RemoveNode only for parent to maintain
193
208
  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.5',
101
+ trackerVersion: '14.0.6-beta.0',
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.5'; // TODO: version compatability check inside each plugin.
68
+ this.version = '14.0.6-beta.0'; // TODO: version compatability check inside each plugin.
69
69
  this.socketMode = false;
70
70
  this.compressionThreshold = 24 * 1000;
71
71
  this.bc = null;
@@ -10,6 +10,10 @@ export default abstract class Observer {
10
10
  private readonly textSet;
11
11
  constructor(app: App, isTopContext?: boolean);
12
12
  private clear;
13
+ /**
14
+ * Unbinds the old content document in case of iframe src change.
15
+ */
16
+ private handleIframeSrcChange;
13
17
  private sendNodeAttribute;
14
18
  private sendNodeData;
15
19
  private bindNode;
@@ -46,6 +46,7 @@ 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);
49
50
  for (const mutation of mutations) {
50
51
  // mutations order is sequential
51
52
  const target = mutation.target;
@@ -55,7 +56,6 @@ export default class Observer {
55
56
  }
56
57
  if (type === 'childList') {
57
58
  for (let i = 0; i < mutation.removedNodes.length; i++) {
58
- // Should be the same as bindTree(mutation.removedNodes[i]), but logic needs to be be untied
59
59
  if (isObservable(mutation.removedNodes[i])) {
60
60
  this.bindNode(mutation.removedNodes[i]);
61
61
  }
@@ -77,6 +77,9 @@ export default class Observer {
77
77
  if (name === null) {
78
78
  continue;
79
79
  }
80
+ if (target instanceof HTMLIFrameElement && name === 'src') {
81
+ this.handleIframeSrcChange(target, id);
82
+ }
80
83
  let attr = this.attributesMap.get(id);
81
84
  if (attr === undefined) {
82
85
  this.attributesMap.set(id, (attr = new Set()));
@@ -86,7 +89,6 @@ export default class Observer {
86
89
  }
87
90
  if (type === 'characterData') {
88
91
  this.textSet.add(id);
89
- continue;
90
92
  }
91
93
  }
92
94
  this.commitNodes();
@@ -99,10 +101,20 @@ export default class Observer {
99
101
  this.attributesMap.clear();
100
102
  this.textSet.clear();
101
103
  }
104
+ /**
105
+ * Unbinds the old content document in case of iframe src change.
106
+ */
107
+ handleIframeSrcChange(iframe, id) {
108
+ const oldContentDocument = iframe.contentDocument;
109
+ if (oldContentDocument) {
110
+ this.recents.set(id, RecentsType.Removed);
111
+ this.unbindTree(oldContentDocument, true);
112
+ }
113
+ }
102
114
  sendNodeAttribute(id, node, name, value) {
103
115
  if (isSVGElement(node)) {
104
- if (name.substr(0, 6) === 'xlink:') {
105
- name = name.substr(6);
116
+ if (name.substring(0, 6) === 'xlink:') {
117
+ name = name.substring(6);
106
118
  }
107
119
  if (value === null) {
108
120
  this.app.send(RemoveNodeAttribute(id, name));
@@ -123,7 +135,7 @@ export default class Observer {
123
135
  name === 'integrity' ||
124
136
  name === 'crossorigin' ||
125
137
  name === 'autocomplete' ||
126
- name.substr(0, 2) === 'on') {
138
+ name.substring(0, 2) === 'on') {
127
139
  return;
128
140
  }
129
141
  if (name === 'value' &&
@@ -184,8 +196,11 @@ export default class Observer {
184
196
  this.bindNode(walker.currentNode);
185
197
  }
186
198
  }
187
- unbindTree(node) {
199
+ unbindTree(node, force) {
188
200
  const id = this.app.nodes.unregisterNode(node);
201
+ if (force && id) {
202
+ this.recents.set(id, RecentsType.Removed);
203
+ }
189
204
  if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
190
205
  // Sending RemoveNode only for parent to maintain
191
206
  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.5',
70
+ trackerVersion: '14.0.6-beta.0',
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.5",
4
+ "version": "14.0.6-beta.0",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"