@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.
@@ -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
- // Mark if page environment is unloading
26
- helpers.addEventListener('beforeunload', function () {
27
- _this.pageUnloading = true;
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 beforeunload time to register (avoids race condition)
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
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = '2.62.6';
7
+ var _default = '2.63.0';
8
8
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.62.6",
3
+ "version": "2.63.0",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",