@openreplay/tracker 4.1.4-beta → 4.1.4-beta.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.
package/cjs/app/index.js CHANGED
@@ -32,7 +32,7 @@ class App {
32
32
  this.stopCallbacks = [];
33
33
  this.commitCallbacks = [];
34
34
  this.activityState = ActivityState.NotActive;
35
- this.version = '4.1.3'; // TODO: version compatability check inside each plugin.
35
+ this.version = '4.1.4-beta.0'; // TODO: version compatability check inside each plugin.
36
36
  this.projectKey = projectKey;
37
37
  this.options = Object.assign({
38
38
  revID: '',
package/cjs/index.js CHANGED
@@ -133,7 +133,7 @@ class API {
133
133
  // no-cors issue only with text/plain or not-set Content-Type
134
134
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
135
135
  req.send(JSON.stringify({
136
- trackerVersion: '4.1.3',
136
+ trackerVersion: '4.1.4-beta.0',
137
137
  projectKey: options.projectKey,
138
138
  doNotTrack,
139
139
  // TODO: add precise reason (an exact API missing)
@@ -28,12 +28,12 @@ function default_1(app) {
28
28
  }
29
29
  const styleSheetIDMap = new Map();
30
30
  const adoptedStyleSheetsOwnings = new Map();
31
- const sendAdoptedStyleSheetsUpdate = (root) => {
31
+ const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
32
32
  let nodeID = app.nodes.getID(root);
33
33
  if (root === document) {
34
34
  nodeID = 0; // main document doesn't have nodeID. ID count starts from the documentElement
35
35
  }
36
- if (!nodeID) {
36
+ if (nodeID === undefined) {
37
37
  return;
38
38
  }
39
39
  let pastOwning = adoptedStyleSheetsOwnings.get(nodeID);
@@ -47,8 +47,8 @@ function default_1(app) {
47
47
  const init = !sheetID;
48
48
  if (!sheetID) {
49
49
  sheetID = nextID();
50
+ styleSheetIDMap.set(s, sheetID);
50
51
  }
51
- nowOwning.push(sheetID);
52
52
  if (!pastOwning.includes(sheetID)) {
53
53
  app.send((0, messages_gen_js_1.AdoptedSSAddOwner)(sheetID, nodeID));
54
54
  }
@@ -58,6 +58,7 @@ function default_1(app) {
58
58
  app.send((0, messages_gen_js_1.AdoptedSSInsertRuleURLBased)(sheetID, rules[i].cssText, i, app.getBaseHref()));
59
59
  }
60
60
  }
61
+ nowOwning.push(sheetID);
61
62
  }
62
63
  for (const sheetID of pastOwning) {
63
64
  if (!nowOwning.includes(sheetID)) {
@@ -65,7 +66,7 @@ function default_1(app) {
65
66
  }
66
67
  }
67
68
  adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
68
- };
69
+ }, 20);
69
70
  function patchAdoptedStyleSheets(prototype) {
70
71
  const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
71
72
  if (nativeAdoptedStyleSheetsDescriptor) {
@@ -88,29 +89,37 @@ function default_1(app) {
88
89
  }
89
90
  patchAdoptedStyleSheets(context.Document.prototype);
90
91
  patchAdoptedStyleSheets(context.ShadowRoot.prototype);
91
- //@ts-ignore TODO: configure ts (use necessary lib)
92
- const { insertRule, deleteRule, replace, replaceSync } = context.CSSStyleSheet.prototype;
92
+ //@ts-ignore TODO: configure ts
93
+ const { replace, replaceSync } = context.CSSStyleSheet.prototype;
93
94
  //@ts-ignore
94
95
  context.CSSStyleSheet.prototype.replace = function (text) {
96
+ styleSheetIDMap.get(this) === 29 && console.log("replace with", text);
95
97
  return replace.call(this, text).then((sheet) => {
96
98
  const sheetID = styleSheetIDMap.get(this);
97
99
  if (sheetID) {
98
100
  app.send((0, messages_gen_js_1.AdoptedSSReplaceURLBased)(sheetID, text, app.getBaseHref()));
99
101
  }
102
+ else {
103
+ console.log("repl-async no sheet-id");
104
+ }
100
105
  return sheet;
101
106
  });
102
107
  };
103
108
  //@ts-ignore
104
109
  context.CSSStyleSheet.prototype.replaceSync = function (text) {
105
110
  const sheetID = styleSheetIDMap.get(this);
111
+ sheetID === 29 && console.log("replacesnc with", text);
106
112
  if (sheetID) {
107
113
  app.send((0, messages_gen_js_1.AdoptedSSReplaceURLBased)(sheetID, text, app.getBaseHref()));
108
114
  }
115
+ else {
116
+ console.log("replsync no sheet-id", this);
117
+ }
109
118
  return replaceSync.call(this, text);
110
119
  };
111
120
  };
112
121
  patchContext(window);
113
- app.observer.attachContextCallback(patchContext);
122
+ app.observer.attachContextCallback(app.safe(patchContext));
114
123
  app.attachStopCallback(() => {
115
124
  styleSheetIDMap.clear();
116
125
  adoptedStyleSheetsOwnings.clear();
@@ -11,12 +11,14 @@ function default_1(app) {
11
11
  app.send((0, messages_gen_js_1.TechnicalInfo)('no_stylesheet_prototype_in_window', ''));
12
12
  return;
13
13
  }
14
- const sendInserDeleteRule = app.safe((sheet, index, rule) => {
14
+ const sendInsertDeleteRule = app.safe((sheet, index, rule) => {
15
15
  const sheetID = constructedStyleSheets_js_1.styleSheetIDMap.get(sheet);
16
16
  if (!sheetID) {
17
17
  // OK-case. Sheet haven't been registered yet. Rules will be sent on registration.
18
+ console.log("no-sheet id", sheet, rule);
18
19
  return;
19
20
  }
21
+ sheetID === 29 && console.log("repdel", sheet, rule);
20
22
  if (typeof rule === 'string') {
21
23
  app.send((0, messages_gen_js_1.AdoptedSSInsertRuleURLBased)(sheetID, rule, index, app.getBaseHref()));
22
24
  }
@@ -51,15 +53,15 @@ function default_1(app) {
51
53
  app.debug.warn('Rule index not found in', sheet, topmostRule);
52
54
  }
53
55
  });
54
- const patchContext = (context) => {
56
+ const patchContext = app.safe((context) => {
55
57
  const { insertRule, deleteRule } = context.CSSStyleSheet.prototype;
56
- const { insertRule: groupInsertRule, deleteRule: groupDeleteRule } = context.CSSGroupingRule.prototype;
58
+ const { insertRule: groupInsertRule, deleteRule: groupDeleteRule, } = context.CSSGroupingRule.prototype;
57
59
  context.CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
58
- sendInserDeleteRule(this, index, rule);
60
+ sendInsertDeleteRule(this, index, rule);
59
61
  return insertRule.call(this, rule, index);
60
62
  };
61
63
  context.CSSStyleSheet.prototype.deleteRule = function (index) {
62
- sendInserDeleteRule(this, index);
64
+ sendInsertDeleteRule(this, index);
63
65
  return deleteRule.call(this, index);
64
66
  };
65
67
  context.CSSGroupingRule.prototype.insertRule = function (rule, index = 0) {
@@ -72,7 +74,7 @@ function default_1(app) {
72
74
  sendReplaceGroupingRule(this);
73
75
  return result;
74
76
  };
75
- };
77
+ });
76
78
  patchContext(window);
77
79
  app.observer.attachContextCallback(patchContext);
78
80
  app.nodes.attachNodeCallback((node) => {
@@ -92,7 +94,7 @@ function default_1(app) {
92
94
  app.send((0, messages_gen_js_1.AdoptedSSAddOwner)(sheetID, nodeID));
93
95
  const rules = sheet.cssRules;
94
96
  for (let i = 0; i < rules.length; i++) {
95
- sendInserDeleteRule(sheet, i, rules[i].cssText);
97
+ sendInsertDeleteRule(sheet, i, rules[i].cssText);
96
98
  }
97
99
  });
98
100
  }
@@ -70,7 +70,7 @@ function default_1(app, opts) {
70
70
  app.attachEventListener(context, 'error', handler);
71
71
  }
72
72
  if (options.captureExceptions) {
73
- app.observer.attachContextCallback(patchContext);
73
+ app.observer.attachContextCallback(patchContext); // TODO: attach once-per-iframe (?)
74
74
  patchContext(window);
75
75
  }
76
76
  }
package/lib/app/index.js CHANGED
@@ -29,7 +29,7 @@ export default class App {
29
29
  this.stopCallbacks = [];
30
30
  this.commitCallbacks = [];
31
31
  this.activityState = ActivityState.NotActive;
32
- this.version = '4.1.3'; // TODO: version compatability check inside each plugin.
32
+ this.version = '4.1.4-beta.0'; // TODO: version compatability check inside each plugin.
33
33
  this.projectKey = projectKey;
34
34
  this.options = Object.assign({
35
35
  revID: '',
package/lib/index.js CHANGED
@@ -128,7 +128,7 @@ export default class API {
128
128
  // no-cors issue only with text/plain or not-set Content-Type
129
129
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
130
130
  req.send(JSON.stringify({
131
- trackerVersion: '4.1.3',
131
+ trackerVersion: '4.1.4-beta.0',
132
132
  projectKey: options.projectKey,
133
133
  doNotTrack,
134
134
  // TODO: add precise reason (an exact API missing)
@@ -24,12 +24,12 @@ export default function (app) {
24
24
  }
25
25
  const styleSheetIDMap = new Map();
26
26
  const adoptedStyleSheetsOwnings = new Map();
27
- const sendAdoptedStyleSheetsUpdate = (root) => {
27
+ const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
28
28
  let nodeID = app.nodes.getID(root);
29
29
  if (root === document) {
30
30
  nodeID = 0; // main document doesn't have nodeID. ID count starts from the documentElement
31
31
  }
32
- if (!nodeID) {
32
+ if (nodeID === undefined) {
33
33
  return;
34
34
  }
35
35
  let pastOwning = adoptedStyleSheetsOwnings.get(nodeID);
@@ -43,8 +43,8 @@ export default function (app) {
43
43
  const init = !sheetID;
44
44
  if (!sheetID) {
45
45
  sheetID = nextID();
46
+ styleSheetIDMap.set(s, sheetID);
46
47
  }
47
- nowOwning.push(sheetID);
48
48
  if (!pastOwning.includes(sheetID)) {
49
49
  app.send(AdoptedSSAddOwner(sheetID, nodeID));
50
50
  }
@@ -54,6 +54,7 @@ export default function (app) {
54
54
  app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
55
55
  }
56
56
  }
57
+ nowOwning.push(sheetID);
57
58
  }
58
59
  for (const sheetID of pastOwning) {
59
60
  if (!nowOwning.includes(sheetID)) {
@@ -61,7 +62,7 @@ export default function (app) {
61
62
  }
62
63
  }
63
64
  adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
64
- };
65
+ }, 20);
65
66
  function patchAdoptedStyleSheets(prototype) {
66
67
  const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
67
68
  if (nativeAdoptedStyleSheetsDescriptor) {
@@ -84,29 +85,37 @@ export default function (app) {
84
85
  }
85
86
  patchAdoptedStyleSheets(context.Document.prototype);
86
87
  patchAdoptedStyleSheets(context.ShadowRoot.prototype);
87
- //@ts-ignore TODO: configure ts (use necessary lib)
88
- const { insertRule, deleteRule, replace, replaceSync } = context.CSSStyleSheet.prototype;
88
+ //@ts-ignore TODO: configure ts
89
+ const { replace, replaceSync } = context.CSSStyleSheet.prototype;
89
90
  //@ts-ignore
90
91
  context.CSSStyleSheet.prototype.replace = function (text) {
92
+ styleSheetIDMap.get(this) === 29 && console.log("replace with", text);
91
93
  return replace.call(this, text).then((sheet) => {
92
94
  const sheetID = styleSheetIDMap.get(this);
93
95
  if (sheetID) {
94
96
  app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
95
97
  }
98
+ else {
99
+ console.log("repl-async no sheet-id");
100
+ }
96
101
  return sheet;
97
102
  });
98
103
  };
99
104
  //@ts-ignore
100
105
  context.CSSStyleSheet.prototype.replaceSync = function (text) {
101
106
  const sheetID = styleSheetIDMap.get(this);
107
+ sheetID === 29 && console.log("replacesnc with", text);
102
108
  if (sheetID) {
103
109
  app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
104
110
  }
111
+ else {
112
+ console.log("replsync no sheet-id", this);
113
+ }
105
114
  return replaceSync.call(this, text);
106
115
  };
107
116
  };
108
117
  patchContext(window);
109
- app.observer.attachContextCallback(patchContext);
118
+ app.observer.attachContextCallback(app.safe(patchContext));
110
119
  app.attachStopCallback(() => {
111
120
  styleSheetIDMap.clear();
112
121
  adoptedStyleSheetsOwnings.clear();
@@ -10,12 +10,14 @@ export default function (app) {
10
10
  app.send(TechnicalInfo('no_stylesheet_prototype_in_window', ''));
11
11
  return;
12
12
  }
13
- const sendInserDeleteRule = app.safe((sheet, index, rule) => {
13
+ const sendInsertDeleteRule = app.safe((sheet, index, rule) => {
14
14
  const sheetID = styleSheetIDMap.get(sheet);
15
15
  if (!sheetID) {
16
16
  // OK-case. Sheet haven't been registered yet. Rules will be sent on registration.
17
+ console.log("no-sheet id", sheet, rule);
17
18
  return;
18
19
  }
20
+ sheetID === 29 && console.log("repdel", sheet, rule);
19
21
  if (typeof rule === 'string') {
20
22
  app.send(AdoptedSSInsertRuleURLBased(sheetID, rule, index, app.getBaseHref()));
21
23
  }
@@ -50,15 +52,15 @@ export default function (app) {
50
52
  app.debug.warn('Rule index not found in', sheet, topmostRule);
51
53
  }
52
54
  });
53
- const patchContext = (context) => {
55
+ const patchContext = app.safe((context) => {
54
56
  const { insertRule, deleteRule } = context.CSSStyleSheet.prototype;
55
- const { insertRule: groupInsertRule, deleteRule: groupDeleteRule } = context.CSSGroupingRule.prototype;
57
+ const { insertRule: groupInsertRule, deleteRule: groupDeleteRule, } = context.CSSGroupingRule.prototype;
56
58
  context.CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
57
- sendInserDeleteRule(this, index, rule);
59
+ sendInsertDeleteRule(this, index, rule);
58
60
  return insertRule.call(this, rule, index);
59
61
  };
60
62
  context.CSSStyleSheet.prototype.deleteRule = function (index) {
61
- sendInserDeleteRule(this, index);
63
+ sendInsertDeleteRule(this, index);
62
64
  return deleteRule.call(this, index);
63
65
  };
64
66
  context.CSSGroupingRule.prototype.insertRule = function (rule, index = 0) {
@@ -71,7 +73,7 @@ export default function (app) {
71
73
  sendReplaceGroupingRule(this);
72
74
  return result;
73
75
  };
74
- };
76
+ });
75
77
  patchContext(window);
76
78
  app.observer.attachContextCallback(patchContext);
77
79
  app.nodes.attachNodeCallback((node) => {
@@ -91,7 +93,7 @@ export default function (app) {
91
93
  app.send(AdoptedSSAddOwner(sheetID, nodeID));
92
94
  const rules = sheet.cssRules;
93
95
  for (let i = 0; i < rules.length; i++) {
94
- sendInserDeleteRule(sheet, i, rules[i].cssText);
96
+ sendInsertDeleteRule(sheet, i, rules[i].cssText);
95
97
  }
96
98
  });
97
99
  }
@@ -65,7 +65,7 @@ export default function (app, opts) {
65
65
  app.attachEventListener(context, 'error', handler);
66
66
  }
67
67
  if (options.captureExceptions) {
68
- app.observer.attachContextCallback(patchContext);
68
+ app.observer.attachContextCallback(patchContext); // TODO: attach once-per-iframe (?)
69
69
  patchContext(window);
70
70
  }
71
71
  }
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": "4.1.4-beta",
4
+ "version": "4.1.4-beta.1",
5
5
  "keywords": [
6
6
  "logging",
7
7
  "replay"