@constructor-io/constructorio-client-javascript 2.62.6 → 2.63.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/lib/utils/request-queue.js +12 -4
- package/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -22,9 +22,17 @@ var RequestQueue = /*#__PURE__*/function () {
|
|
|
22
22
|
this.pageUnloading = false;
|
|
23
23
|
this.sendTrackingEvents = options && options.sendTrackingEvents === true ? true : false; // Defaults to 'false'
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
helpers.addEventListener('visibilitychange', function () {
|
|
26
|
+
// Mark if page environment is unloading
|
|
27
|
+
if (document.visibilityState === 'hidden') {
|
|
28
|
+
_this.pageUnloading = true;
|
|
29
|
+
} else if (document.visibilityState === 'visible' && _this.pageUnloading === true) {
|
|
30
|
+
// Send events once page is visible again
|
|
31
|
+
_this.pageUnloading = false;
|
|
32
|
+
if (_this.sendTrackingEvents) {
|
|
33
|
+
_this.send();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
28
36
|
});
|
|
29
37
|
if (this.sendTrackingEvents) {
|
|
30
38
|
this.send();
|
|
@@ -179,7 +187,7 @@ var RequestQueue = /*#__PURE__*/function () {
|
|
|
179
187
|
if (this.options && this.options.trackingSendDelay === 0) {
|
|
180
188
|
this.sendEvents();
|
|
181
189
|
} else {
|
|
182
|
-
// Defer sending of events to give
|
|
190
|
+
// Defer sending of events to give visibilitychange time to register (avoids race condition)
|
|
183
191
|
setTimeout(this.sendEvents.bind(this), this.options && this.options.trackingSendDelay || 250);
|
|
184
192
|
}
|
|
185
193
|
}
|
package/lib/version.js
CHANGED