zar 0.1.2 → 0.1.3

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/dist/zar.es.js CHANGED
@@ -3688,16 +3688,20 @@ function isFunc(value) {
3688
3688
  return value && (Object.prototype.toString.call(value) === "[object Function]" || typeof value === "function" || value instanceof Function);
3689
3689
  }
3690
3690
  function isBot() {
3691
- var ua = navigator.userAgent || "";
3692
- var bots = new RegExp([
3693
- /bot/,
3694
- /spider/,
3695
- /crawl/,
3696
- /mediapartners/,
3697
- /Google-Read-Aloud/,
3698
- /semrush/
3699
- ].map((r2) => r2.source).join("|"), "i");
3700
- return bots.test(ua);
3691
+ try {
3692
+ var ua = navigator.userAgent || "";
3693
+ var bots = new RegExp([
3694
+ /bot/,
3695
+ /spider/,
3696
+ /crawl/,
3697
+ /mediapartners/,
3698
+ /Google-Read-Aloud/,
3699
+ /semrush/
3700
+ ].map((r2) => r2.source).join("|"), "i");
3701
+ return bots.test(ua);
3702
+ } catch (e2) {
3703
+ return false;
3704
+ }
3701
3705
  }
3702
3706
  function afterDOMContentLoaded(func) {
3703
3707
  if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
@@ -4152,20 +4156,39 @@ function zar({ apiUrl, poolConfig }) {
4152
4156
  if ("search" in payload.properties) {
4153
4157
  delete payload.properties["search"];
4154
4158
  }
4155
- var pcfg = config2.poolConfig;
4156
- if (pcfg && pcfg.poolId) {
4157
- payload.properties.pool_id = getPoolId(pcfg.poolId);
4158
- if (pcfg.contextCallback) {
4159
- payload.properties.pool_context = pcfg.contextCallback() || {};
4159
+ try {
4160
+ var pcfg = config2.poolConfig;
4161
+ if (pcfg && pcfg.poolId) {
4162
+ payload.properties.pool_id = getPoolId(pcfg.poolId);
4163
+ if (pcfg.contextCallback) {
4164
+ payload.properties.pool_context = pcfg.contextCallback() || {};
4165
+ }
4160
4166
  }
4167
+ } catch (e2) {
4168
+ warning("error getting pool id: " + JSON.stringify(e2));
4161
4169
  }
4162
4170
  return payload;
4163
4171
  },
4164
4172
  page: function(_0) {
4165
4173
  return __async(this, arguments, function* ({ payload, options, instance, config: config2 }) {
4166
4174
  dbg("page", payload, options, config2);
4167
- var res = yield httpPost({ url: `${config2.apiUrl}/page`, data: payload });
4168
- if (res.pool_data) {
4175
+ var tries = 0;
4176
+ var maxTries = 3;
4177
+ var res;
4178
+ while (tries < maxTries) {
4179
+ try {
4180
+ res = yield httpPost({ url: `${config2.apiUrl}/page`, data: payload });
4181
+ break;
4182
+ } catch (e2) {
4183
+ tries++;
4184
+ if (tries >= maxTries) {
4185
+ warning("error posting page: " + JSON.stringify(e2));
4186
+ throw e2;
4187
+ }
4188
+ yield new Promise((r2) => setTimeout(r2, 1e3));
4189
+ }
4190
+ }
4191
+ if (res && res.pool_data) {
4169
4192
  initTrackingPool({ poolData: res.pool_data, poolConfig: config2.poolConfig, apiUrl: config2.apiUrl });
4170
4193
  }
4171
4194
  });