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 +40 -17
- package/dist/zar.es.js.map +1 -1
- package/dist/zar.iife.js +4 -4
- package/dist/zar.iife.js.map +1 -1
- package/dist/zar.umd.js +4 -4
- package/dist/zar.umd.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
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
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
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
|
|
4168
|
-
|
|
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
|
});
|