@openreplay/tracker 9.0.11-beta.0 → 9.0.11-beta.11
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 +1 -1
- package/cjs/app/index.js +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +27 -25
- package/lib/app/index.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +27 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 9.0.11
|
|
2
2
|
|
|
3
|
-
- fix window.open issue with sessionStorage being inherited (replicating tabId bug)
|
|
3
|
+
- new `resetTabOnWindowOpen` option to fix window.open issue with sessionStorage being inherited (replicating tabId bug), users still should use 'noopener=true' in window.open to prevent it in general...
|
|
4
4
|
|
|
5
5
|
# 9.0.10
|
|
6
6
|
|
package/cjs/app/index.js
CHANGED
|
@@ -42,7 +42,7 @@ class App {
|
|
|
42
42
|
this.stopCallbacks = [];
|
|
43
43
|
this.commitCallbacks = [];
|
|
44
44
|
this.activityState = ActivityState.NotActive;
|
|
45
|
-
this.version = '9.0.11-beta.
|
|
45
|
+
this.version = '9.0.11-beta.11'; // TODO: version compatability check inside each plugin.
|
|
46
46
|
this.compressionThreshold = 24 * 1000;
|
|
47
47
|
this.restartAttempts = 0;
|
|
48
48
|
this.bc = null;
|
package/cjs/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & I
|
|
|
20
20
|
sessionToken?: string;
|
|
21
21
|
respectDoNotTrack?: boolean;
|
|
22
22
|
autoResetOnWindowOpen?: boolean;
|
|
23
|
+
resetTabOnWindowOpen?: boolean;
|
|
23
24
|
network?: Partial<NetworkOptions>;
|
|
24
25
|
mouse?: Partial<MouseHandlerOptions>;
|
|
25
26
|
flags?: {
|
package/cjs/index.js
CHANGED
|
@@ -131,34 +131,36 @@ class API {
|
|
|
131
131
|
void this.featureFlags.reloadFlags();
|
|
132
132
|
});
|
|
133
133
|
const wOpen = window.open;
|
|
134
|
-
if (options.autoResetOnWindowOpen) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
if (options.autoResetOnWindowOpen || options.resetTabOnWindowOpen) {
|
|
135
|
+
if (options.autoResetOnWindowOpen) {
|
|
136
|
+
app.attachStartCallback(() => {
|
|
137
|
+
// @ts-ignore ?
|
|
138
|
+
window.open = function (...args) {
|
|
139
|
+
app.resetNextPageSession(true);
|
|
140
|
+
wOpen.call(window, ...args);
|
|
141
|
+
app.resetNextPageSession(false);
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (options.resetTabOnWindowOpen) {
|
|
146
|
+
app.attachStartCallback(() => {
|
|
147
|
+
// window.open causes new tab to inherit sessionStorage completely,
|
|
148
|
+
// we don't really want that so we remove tabId for a short period
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
window.open = function (...args) {
|
|
151
|
+
var _a;
|
|
152
|
+
const tabId = app.getTabId();
|
|
153
|
+
const sessStorage = (_a = app.sessionStorage) !== null && _a !== void 0 ? _a : window.sessionStorage;
|
|
154
|
+
sessStorage.removeItem(options.session_tabid_key || '__openreplay_tabid');
|
|
155
|
+
wOpen.call(window, ...args);
|
|
156
|
+
sessStorage.setItem(options.session_tabid_key || '__openreplay_tabid', tabId);
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
143
160
|
app.attachStopCallback(() => {
|
|
144
161
|
window.open = wOpen;
|
|
145
162
|
});
|
|
146
163
|
}
|
|
147
|
-
else {
|
|
148
|
-
app.attachStartCallback(() => {
|
|
149
|
-
// this function causes new tab to inherit sessionStorage completely,
|
|
150
|
-
// we don't really want that so we remove tabId for a short period
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
window.open = function (...args) {
|
|
153
|
-
var _a;
|
|
154
|
-
const tabId = app.getTabId();
|
|
155
|
-
const sessStorage = (_a = app.sessionStorage) !== null && _a !== void 0 ? _a : window.sessionStorage;
|
|
156
|
-
sessStorage.removeItem(options.session_tabid_key || '__openreplay_tabid');
|
|
157
|
-
wOpen.call(window, ...args);
|
|
158
|
-
sessStorage.setItem(options.session_tabid_key || '__openreplay_tabid', tabId);
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
164
|
}
|
|
163
165
|
else {
|
|
164
166
|
console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
|
|
@@ -168,7 +170,7 @@ class API {
|
|
|
168
170
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
169
171
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
170
172
|
req.send(JSON.stringify({
|
|
171
|
-
trackerVersion: '9.0.11-beta.
|
|
173
|
+
trackerVersion: '9.0.11-beta.11',
|
|
172
174
|
projectKey: options.projectKey,
|
|
173
175
|
doNotTrack,
|
|
174
176
|
// TODO: add precise reason (an exact API missing)
|
package/lib/app/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export default class App {
|
|
|
39
39
|
this.stopCallbacks = [];
|
|
40
40
|
this.commitCallbacks = [];
|
|
41
41
|
this.activityState = ActivityState.NotActive;
|
|
42
|
-
this.version = '9.0.11-beta.
|
|
42
|
+
this.version = '9.0.11-beta.11'; // TODO: version compatability check inside each plugin.
|
|
43
43
|
this.compressionThreshold = 24 * 1000;
|
|
44
44
|
this.restartAttempts = 0;
|
|
45
45
|
this.bc = null;
|
package/lib/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export type Options = Partial<AppOptions & ConsoleOptions & ExceptionOptions & I
|
|
|
20
20
|
sessionToken?: string;
|
|
21
21
|
respectDoNotTrack?: boolean;
|
|
22
22
|
autoResetOnWindowOpen?: boolean;
|
|
23
|
+
resetTabOnWindowOpen?: boolean;
|
|
23
24
|
network?: Partial<NetworkOptions>;
|
|
24
25
|
mouse?: Partial<MouseHandlerOptions>;
|
|
25
26
|
flags?: {
|
package/lib/index.js
CHANGED
|
@@ -126,34 +126,36 @@ export default class API {
|
|
|
126
126
|
void this.featureFlags.reloadFlags();
|
|
127
127
|
});
|
|
128
128
|
const wOpen = window.open;
|
|
129
|
-
if (options.autoResetOnWindowOpen) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
if (options.autoResetOnWindowOpen || options.resetTabOnWindowOpen) {
|
|
130
|
+
if (options.autoResetOnWindowOpen) {
|
|
131
|
+
app.attachStartCallback(() => {
|
|
132
|
+
// @ts-ignore ?
|
|
133
|
+
window.open = function (...args) {
|
|
134
|
+
app.resetNextPageSession(true);
|
|
135
|
+
wOpen.call(window, ...args);
|
|
136
|
+
app.resetNextPageSession(false);
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (options.resetTabOnWindowOpen) {
|
|
141
|
+
app.attachStartCallback(() => {
|
|
142
|
+
// window.open causes new tab to inherit sessionStorage completely,
|
|
143
|
+
// we don't really want that so we remove tabId for a short period
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
window.open = function (...args) {
|
|
146
|
+
var _a;
|
|
147
|
+
const tabId = app.getTabId();
|
|
148
|
+
const sessStorage = (_a = app.sessionStorage) !== null && _a !== void 0 ? _a : window.sessionStorage;
|
|
149
|
+
sessStorage.removeItem(options.session_tabid_key || '__openreplay_tabid');
|
|
150
|
+
wOpen.call(window, ...args);
|
|
151
|
+
sessStorage.setItem(options.session_tabid_key || '__openreplay_tabid', tabId);
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
}
|
|
138
155
|
app.attachStopCallback(() => {
|
|
139
156
|
window.open = wOpen;
|
|
140
157
|
});
|
|
141
158
|
}
|
|
142
|
-
else {
|
|
143
|
-
app.attachStartCallback(() => {
|
|
144
|
-
// this function causes new tab to inherit sessionStorage completely,
|
|
145
|
-
// we don't really want that so we remove tabId for a short period
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
window.open = function (...args) {
|
|
148
|
-
var _a;
|
|
149
|
-
const tabId = app.getTabId();
|
|
150
|
-
const sessStorage = (_a = app.sessionStorage) !== null && _a !== void 0 ? _a : window.sessionStorage;
|
|
151
|
-
sessStorage.removeItem(options.session_tabid_key || '__openreplay_tabid');
|
|
152
|
-
wOpen.call(window, ...args);
|
|
153
|
-
sessStorage.setItem(options.session_tabid_key || '__openreplay_tabid', tabId);
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
159
|
}
|
|
158
160
|
else {
|
|
159
161
|
console.log("OpenReplay: browser doesn't support API required for tracking or doNotTrack is set to 1.");
|
|
@@ -163,7 +165,7 @@ export default class API {
|
|
|
163
165
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
164
166
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
165
167
|
req.send(JSON.stringify({
|
|
166
|
-
trackerVersion: '9.0.11-beta.
|
|
168
|
+
trackerVersion: '9.0.11-beta.11',
|
|
167
169
|
projectKey: options.projectKey,
|
|
168
170
|
doNotTrack,
|
|
169
171
|
// TODO: add precise reason (an exact API missing)
|