@solomon-tech/webanalytics-sdk 1.0.7 → 1.0.8
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/sdk/cookies/persistentId.d.ts +4 -0
- package/dist/sdk/cookies/persistentId.js +37 -0
- package/dist/sdk/cookies/session.js +3 -21
- package/dist/sdk/cookies/user.js +3 -21
- package/dist/sdk/events.js +66 -23
- package/dist/sdk/publish.d.ts +2 -2
- package/dist/sdk/publish.js +17 -7
- package/dist/sdk/sdk/core/client.d.ts +2 -0
- package/dist/sdk/sdk/core/client.js +2 -2
- package/dist/sdk/sdk/core/events.d.ts +1 -0
- package/dist/sdk/sdk/core/types.d.ts +1 -0
- package/dist/sdk/solomon-sdk.esm.min.js +1 -1
- package/dist/sdk/solomon-sdk.min.js +1 -1
- package/dist/sdk/utils.d.ts +2 -1
- package/dist/sdk/utils.js +25 -2
- package/package.json +4 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
function generateUUIDv4() {
|
|
11
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
12
|
+
const r = (crypto.getRandomValues(new Uint8Array(1))[0] & 15) >> 0;
|
|
13
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
14
|
+
return v.toString(16);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function getScope() {
|
|
18
|
+
if (typeof self !== "undefined")
|
|
19
|
+
return self;
|
|
20
|
+
if (typeof window !== "undefined")
|
|
21
|
+
return window;
|
|
22
|
+
return globalThis;
|
|
23
|
+
}
|
|
24
|
+
function getPersistentId(lockKey, read, write) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const scope = getScope();
|
|
27
|
+
const prior = Promise.resolve(scope[lockKey]).catch(() => undefined);
|
|
28
|
+
const next = prior.then((cached) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const value = cached || (yield read()) || generateUUIDv4();
|
|
30
|
+
yield write(value);
|
|
31
|
+
return value;
|
|
32
|
+
}));
|
|
33
|
+
scope[lockKey] = next;
|
|
34
|
+
return next;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { getPersistentId };
|
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { getCookie, setCookie } from "../utils";
|
|
2
|
+
import { getPersistentId } from "./persistentId";
|
|
11
3
|
const SESSION_ID_COOKIE_NAME = "solomon-session-id";
|
|
12
4
|
const SESSION_ID_COOKIE_TIME = 30 * 60 * 1000;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const r = (crypto.getRandomValues(new Uint8Array(1))[0] & 15) >> 0;
|
|
16
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
17
|
-
return v.toString(16);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
const getSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
const cookie = (yield getCookie(SESSION_ID_COOKIE_NAME)) || generateUUIDv4();
|
|
22
|
-
yield setCookie(SESSION_ID_COOKIE_NAME, cookie, SESSION_ID_COOKIE_TIME);
|
|
23
|
-
return cookie;
|
|
24
|
-
});
|
|
5
|
+
const SESSION_ID_LOCK = "__SOLOMON_SESSION_ID_LOCK__";
|
|
6
|
+
const getSessionId = () => getPersistentId(SESSION_ID_LOCK, () => getCookie(SESSION_ID_COOKIE_NAME), (value) => setCookie(SESSION_ID_COOKIE_NAME, value, SESSION_ID_COOKIE_TIME));
|
|
25
7
|
export { getSessionId };
|
package/dist/sdk/cookies/user.js
CHANGED
|
@@ -1,25 +1,7 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { getAllStorage, setAllStorage } from "../utils";
|
|
2
|
+
import { getPersistentId } from "./persistentId";
|
|
11
3
|
const USER_ID_KEY = "solomon-user-id";
|
|
12
4
|
const USER_ID_COOKIE_TIME = 365 * 24 * 60 * 60 * 1000;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const r = (crypto.getRandomValues(new Uint8Array(1))[0] & 15) >> 0;
|
|
16
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
17
|
-
return v.toString(16);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
const getUserId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
const cookie = (yield getAllStorage(USER_ID_KEY)) || generateUUIDv4();
|
|
22
|
-
yield setAllStorage(USER_ID_KEY, cookie, USER_ID_COOKIE_TIME);
|
|
23
|
-
return cookie;
|
|
24
|
-
});
|
|
5
|
+
const USER_ID_LOCK = "__SOLOMON_USER_ID_LOCK__";
|
|
6
|
+
const getUserId = () => getPersistentId(USER_ID_LOCK, () => getAllStorage(USER_ID_KEY), (value) => setAllStorage(USER_ID_KEY, value, USER_ID_COOKIE_TIME));
|
|
25
7
|
export { getUserId };
|
package/dist/sdk/events.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getSessionId } from "./cookies/session";
|
|
|
11
11
|
import { getUserId } from "./cookies/user";
|
|
12
12
|
import { getFbp, getFbc } from "./cookies/fbp";
|
|
13
13
|
import { getLegacyId } from "./cookies/legacy";
|
|
14
|
-
import { getUtmParameter, getCookie, setCookie, getLocalStorage, setAllStorage, getCompanyId } from "./utils";
|
|
14
|
+
import { getUtmParameter, getCookie, setCookie, setUtmsTrackCookie, getLocalStorage, setAllStorage, getCompanyId } from "./utils";
|
|
15
15
|
function generateUUIDv4() {
|
|
16
16
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
17
17
|
const r = (crypto.getRandomValues(new Uint8Array(1))[0] & 15) >> 0;
|
|
@@ -126,7 +126,7 @@ const SolomonEvent = (companyId, type, payload, custom_aliases) => __awaiter(voi
|
|
|
126
126
|
voxus_url: (_y = localStorage.getItem('analytics:session')) !== null && _y !== void 0 ? _y : '',
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
|
-
const updateUTMParametersInCookie = (eventData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const updateUTMParametersInCookie = (eventData, platform) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
130
|
const utmKeys = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'sol_source', 'sol_medium', 'sol_campaign', 'sol_content'];
|
|
131
131
|
const existingParams = {};
|
|
132
132
|
const existingCookie = yield getCookie('utmsTrack');
|
|
@@ -191,8 +191,12 @@ const updateUTMParametersInCookie = (eventData) => __awaiter(void 0, void 0, voi
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
let updatedParams = {};
|
|
194
|
+
const realUtmTermCompanies = ['FAtB0BRB4u4QFa5ghBEF', 'Dk7jRvNPfRfqRuTfdEg1', '2JzSzSPMTOSHMElSuyZb'];
|
|
195
|
+
const utmTermForTrack = realUtmTermCompanies.includes(getCompanyId()) ? eventData.old_id : eventData.utm_term;
|
|
194
196
|
if ((hasAnyNewUtm || hasExternalReferrer) && getCompanyId() != 'Sz8mKHeQqQcPpUnSyET0') {
|
|
195
|
-
|
|
197
|
+
if (utmTermForTrack) {
|
|
198
|
+
updatedParams['utm_term'] = utmTermForTrack;
|
|
199
|
+
}
|
|
196
200
|
for (const key of utmKeys) {
|
|
197
201
|
if (newUtmParams[key]) {
|
|
198
202
|
updatedParams[key] = newUtmParams[key];
|
|
@@ -205,8 +209,8 @@ const updateUTMParametersInCookie = (eventData) => __awaiter(void 0, void 0, voi
|
|
|
205
209
|
updatedParams[key] = existingParams[key];
|
|
206
210
|
}
|
|
207
211
|
}
|
|
208
|
-
if (
|
|
209
|
-
updatedParams['utm_term'] =
|
|
212
|
+
if (utmTermForTrack) {
|
|
213
|
+
updatedParams['utm_term'] = utmTermForTrack;
|
|
210
214
|
}
|
|
211
215
|
for (const key of utmKeys) {
|
|
212
216
|
if (newUtmParams[key]) {
|
|
@@ -220,12 +224,17 @@ const updateUTMParametersInCookie = (eventData) => __awaiter(void 0, void 0, voi
|
|
|
220
224
|
updatedString.push(key + '=' + updatedParams[key]);
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
|
-
|
|
227
|
+
if (platform === 'yampi') {
|
|
228
|
+
yield setUtmsTrackCookie(updatedParams, 30);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
yield setCookie('utmsTrack', updatedString.join('&'), 30 * 24 * 60 * 60 * 1000);
|
|
232
|
+
}
|
|
224
233
|
yield setCookie('track_utms', updatedString.join('&'), 30 * 24 * 60 * 60 * 1000);
|
|
225
234
|
yield setCookie('yeverUtmsTrack', updatedString.join('&'), 30 * 24 * 60 * 60 * 1000);
|
|
226
235
|
});
|
|
227
236
|
const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
237
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
229
238
|
let isSeller = new URLSearchParams(window.location.search).get('vendedor') === 'true';
|
|
230
239
|
if (document.referrer.includes('desk.hyperflow.global') || document.referrer.includes('app.yampi.com') || document.referrer.includes('app.reportana.com')) {
|
|
231
240
|
isSeller = true;
|
|
@@ -238,13 +247,47 @@ const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void
|
|
|
238
247
|
if ((yield getCookie('is_seller')) === 'true' || isSeller || localStorage.getItem('is_seller') === 'true') {
|
|
239
248
|
return;
|
|
240
249
|
}
|
|
250
|
+
if (account_id === 'lojasdufins') {
|
|
251
|
+
const hostname = typeof window !== "undefined" ? window.location.hostname : '';
|
|
252
|
+
if (hostname === 'seguro.lojasdufins.com.br') {
|
|
253
|
+
let utmSource = ((_a = getUtmParameter('utm_source')) !== null && _a !== void 0 ? _a : '').toLowerCase();
|
|
254
|
+
let utmCampaign = (_b = getUtmParameter('utm_campaign')) !== null && _b !== void 0 ? _b : '';
|
|
255
|
+
let utmContent = (_c = getUtmParameter('utm_content')) !== null && _c !== void 0 ? _c : '';
|
|
256
|
+
if (!utmSource) {
|
|
257
|
+
const utmsTrack = (yield getCookie('utmsTrack')) || '';
|
|
258
|
+
const cookieUtms = {};
|
|
259
|
+
utmsTrack.split('&').forEach((part) => {
|
|
260
|
+
const eq = part.indexOf('=');
|
|
261
|
+
if (eq === -1)
|
|
262
|
+
return;
|
|
263
|
+
cookieUtms[part.substring(0, eq)] = part.substring(eq + 1);
|
|
264
|
+
});
|
|
265
|
+
utmSource = (cookieUtms['utm_source'] || '').toLowerCase();
|
|
266
|
+
utmCampaign = cookieUtms['utm_campaign'] || '';
|
|
267
|
+
utmContent = cookieUtms['utm_content'] || '';
|
|
268
|
+
}
|
|
269
|
+
const blockedSources = ['fb', 'ig', 'th', 'an', 'msg', 'facebook', 'facebookads'];
|
|
270
|
+
const hasNumericId = (val) => {
|
|
271
|
+
var _a;
|
|
272
|
+
if (!val)
|
|
273
|
+
return false;
|
|
274
|
+
const lastPart = val.indexOf('|') !== -1 ? (_a = val.split('|').pop()) !== null && _a !== void 0 ? _a : '' : val;
|
|
275
|
+
return /^\d+$/.test(lastPart);
|
|
276
|
+
};
|
|
277
|
+
if (blockedSources.indexOf(utmSource) !== -1 &&
|
|
278
|
+
hasNumericId(utmCampaign) &&
|
|
279
|
+
!hasNumericId(utmContent)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
241
284
|
const fbp = (yield getFbp()) || (yield getCookie('_fbp')) || "";
|
|
242
285
|
const fbc = (yield getFbc()) || (yield getCookie('_fbc')) || "";
|
|
243
286
|
const fbclid = getUtmParameter('fbclid') || (yield getCookie('_fbclid')) || "";
|
|
244
287
|
const gaId = (yield getCookie('_ga')) || "";
|
|
245
288
|
const localeStr = typeof navigator !== "undefined" ? navigator.language.replace('-', '_') : '';
|
|
246
|
-
const utmTerm = (
|
|
247
|
-
const queryParams = (
|
|
289
|
+
const utmTerm = (_d = getUtmParameter('utm_term')) !== null && _d !== void 0 ? _d : '';
|
|
290
|
+
const queryParams = (_m = (_k = (_j = (_h = (_g = (_f = (_e = self === null || self === void 0 ? void 0 : self.Shopify) === null || _e === void 0 ? void 0 : _e.init) === null || _f === void 0 ? void 0 : _f.context) === null || _g === void 0 ? void 0 : _g.document) === null || _h === void 0 ? void 0 : _h.location) === null || _j === void 0 ? void 0 : _j.search) !== null && _k !== void 0 ? _k : (_l = window === null || window === void 0 ? void 0 : window.location) === null || _l === void 0 ? void 0 : _l.search) !== null && _m !== void 0 ? _m : '';
|
|
248
291
|
let timezone = '';
|
|
249
292
|
try {
|
|
250
293
|
if (typeof navigator !== "undefined") {
|
|
@@ -266,7 +309,7 @@ const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void
|
|
|
266
309
|
else if (platform === 'magazord') {
|
|
267
310
|
cartToken = (customAliases === null || customAliases === void 0 ? void 0 : customAliases.email) || '';
|
|
268
311
|
}
|
|
269
|
-
else if (platform === 'yampi' || platform === 'woocommerce') {
|
|
312
|
+
else if (platform === 'yampi' || platform === 'woocommerce' || platform === 'loja_yampi') {
|
|
270
313
|
cartToken = (customAliases === null || customAliases === void 0 ? void 0 : customAliases.transaction_id) || (customAliases === null || customAliases === void 0 ? void 0 : customAliases.cart_token) || '';
|
|
271
314
|
}
|
|
272
315
|
else if (platform === 'uappi' || platform === 'bagy' || platform === 'wake' || platform === 'wbuy') {
|
|
@@ -293,9 +336,9 @@ const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void
|
|
|
293
336
|
isReload = (navEntry === null || navEntry === void 0 ? void 0 : navEntry.type) === 'reload';
|
|
294
337
|
}
|
|
295
338
|
catch (e) {
|
|
296
|
-
isReload = ((
|
|
339
|
+
isReload = ((_o = performance === null || performance === void 0 ? void 0 : performance.navigation) === null || _o === void 0 ? void 0 : _o.type) === 1;
|
|
297
340
|
}
|
|
298
|
-
let referrer = (
|
|
341
|
+
let referrer = (_t = (_s = (_r = (_q = (_p = self === null || self === void 0 ? void 0 : self.Shopify) === null || _p === void 0 ? void 0 : _p.init) === null || _q === void 0 ? void 0 : _q.context) === null || _r === void 0 ? void 0 : _r.document) === null || _s === void 0 ? void 0 : _s.referrer) !== null && _t !== void 0 ? _t : document === null || document === void 0 ? void 0 : document.referrer;
|
|
299
342
|
if ((window === null || window === void 0 ? void 0 : window.pageViewFired) || isReload) {
|
|
300
343
|
referrer = '';
|
|
301
344
|
}
|
|
@@ -303,16 +346,16 @@ const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void
|
|
|
303
346
|
var eventData = {
|
|
304
347
|
id: yield getUniqueId(),
|
|
305
348
|
referrer: referrer,
|
|
306
|
-
path: (
|
|
307
|
-
utm_source: (
|
|
308
|
-
utm_medium: (
|
|
309
|
-
utm_campaign: (
|
|
349
|
+
path: (_1 = (_z = (_y = (_x = (_w = (_v = (_u = self === null || self === void 0 ? void 0 : self.Shopify) === null || _u === void 0 ? void 0 : _u.init) === null || _v === void 0 ? void 0 : _v.context) === null || _w === void 0 ? void 0 : _w.document) === null || _x === void 0 ? void 0 : _x.location) === null || _y === void 0 ? void 0 : _y.pathname) !== null && _z !== void 0 ? _z : (_0 = window === null || window === void 0 ? void 0 : window.location) === null || _0 === void 0 ? void 0 : _0.pathname) !== null && _1 !== void 0 ? _1 : '',
|
|
350
|
+
utm_source: (_2 = getUtmParameter('utm_source')) !== null && _2 !== void 0 ? _2 : '',
|
|
351
|
+
utm_medium: (_3 = getUtmParameter('utm_medium')) !== null && _3 !== void 0 ? _3 : '',
|
|
352
|
+
utm_campaign: (_4 = getUtmParameter('utm_campaign')) !== null && _4 !== void 0 ? _4 : '',
|
|
310
353
|
utm_term: yield getUniqueId(),
|
|
311
|
-
utm_content: (
|
|
312
|
-
sol_source: (
|
|
313
|
-
sol_medium: (
|
|
314
|
-
sol_campaign: (
|
|
315
|
-
sol_content: (
|
|
354
|
+
utm_content: (_5 = getUtmParameter('utm_content')) !== null && _5 !== void 0 ? _5 : '',
|
|
355
|
+
sol_source: (_6 = getUtmParameter('sol_source')) !== null && _6 !== void 0 ? _6 : '',
|
|
356
|
+
sol_medium: (_7 = getUtmParameter('sol_medium')) !== null && _7 !== void 0 ? _7 : '',
|
|
357
|
+
sol_campaign: (_8 = getUtmParameter('sol_campaign')) !== null && _8 !== void 0 ? _8 : '',
|
|
358
|
+
sol_content: (_9 = getUtmParameter('sol_content')) !== null && _9 !== void 0 ? _9 : '',
|
|
316
359
|
fbp: fbp,
|
|
317
360
|
fbc: fbc,
|
|
318
361
|
ga_id: gaId,
|
|
@@ -330,9 +373,9 @@ const TouchpointEvent = (account_id, custom_aliases, platform) => __awaiter(void
|
|
|
330
373
|
shopify_id: account_id,
|
|
331
374
|
current_domain: typeof window !== "undefined" ? window.location.hostname : '',
|
|
332
375
|
cart_token: cartToken,
|
|
333
|
-
email: (
|
|
376
|
+
email: (_10 = (yield custom_aliases)) === null || _10 === void 0 ? void 0 : _10.email,
|
|
334
377
|
};
|
|
335
|
-
yield updateUTMParametersInCookie(eventData);
|
|
378
|
+
yield updateUTMParametersInCookie(eventData, platform);
|
|
336
379
|
eventData.utmsTrack = yield getCookie('utmsTrack');
|
|
337
380
|
return eventData;
|
|
338
381
|
});
|
package/dist/sdk/publish.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const publish: (event_promise: Promise<any
|
|
2
|
-
declare const publish_event: (event_promise: Promise<any
|
|
1
|
+
declare const publish: (event_promise: Promise<any>, urlOverride?: string) => Promise<void>;
|
|
2
|
+
declare const publish_event: (event_promise: Promise<any>, urlOverride?: string) => Promise<void>;
|
|
3
3
|
export { publish, publish_event };
|
package/dist/sdk/publish.js
CHANGED
|
@@ -9,12 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
const BACKEND_URL = "https://webanalytics.solomon.com.br/event?mode=web";
|
|
11
11
|
const EVENTS_URL = "https://pixel.solomon.com.br/event";
|
|
12
|
-
const
|
|
12
|
+
const buildWebanalyticsUrl = (base) => base.replace(/\/+$/, "").replace(/\/event(\?mode=web)?$/, "") + "/event?mode=web";
|
|
13
|
+
const buildPixelUrl = (base) => base.replace(/\/+$/, "").replace(/\/event$/, "") + "/event";
|
|
14
|
+
const publish = (event_promise, urlOverride) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
15
|
var _a;
|
|
14
16
|
const event = yield event_promise;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
if (!event) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const base = urlOverride || ((_a = window.__SOLOMON__) === null || _a === void 0 ? void 0 : _a.webanalyticsUrl);
|
|
21
|
+
const url = base
|
|
22
|
+
? buildWebanalyticsUrl(base)
|
|
23
|
+
: BACKEND_URL + `&event=${event === null || event === void 0 ? void 0 : event.event_type}`;
|
|
18
24
|
try {
|
|
19
25
|
;
|
|
20
26
|
const response = yield fetch(url, {
|
|
@@ -44,11 +50,15 @@ const publish = (event_promise) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
44
50
|
console.error('Erro ao enviar evento:', error);
|
|
45
51
|
}
|
|
46
52
|
});
|
|
47
|
-
const publish_event = (event_promise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const publish_event = (event_promise, urlOverride) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
54
|
var _a;
|
|
49
55
|
const event = yield event_promise;
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
if (!event) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const base = urlOverride || ((_a = window.__SOLOMON__) === null || _a === void 0 ? void 0 : _a.pixelUrl);
|
|
60
|
+
const url = base
|
|
61
|
+
? buildPixelUrl(base)
|
|
52
62
|
: EVENTS_URL;
|
|
53
63
|
try {
|
|
54
64
|
const response = yield fetch(url, {
|
|
@@ -70,9 +70,9 @@ export class SolomonSDK {
|
|
|
70
70
|
}
|
|
71
71
|
if (this.config.useTouchpoint) {
|
|
72
72
|
const touchpointPromise = eventTouchpoint(aliasesPromise, "custom", this.config.companyId);
|
|
73
|
-
yield publish_event(touchpointPromise);
|
|
73
|
+
yield publish_event(touchpointPromise, this.config.pixelUrl);
|
|
74
74
|
}
|
|
75
|
-
yield publish(eventPromise);
|
|
75
|
+
yield publish(eventPromise, this.config.webanalyticsUrl);
|
|
76
76
|
if (this.config.debug) {
|
|
77
77
|
console.log("[SolomonSDK] Event tracked successfully:", event);
|
|
78
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o={d:(e,n)=>{for(var i in n)o.o(n,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},e={};o.d(e,{C:()=>SolomonSDK,A:()=>SolomonSDK});var __awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getCookie=o=>__awaiter(void 0,void 0,void 0,(function*(){if((null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)){const e=yield self.Shopify.browser.cookie.get(o);return e?decodeURIComponent(e):null}{if(!document.cookie||""===document.cookie)return null;const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const i=e[n].trim();if(i.substring(0,o.length+1)===o+"=")return decodeURIComponent(i.substring(o.length+1))}return null}})),getLocalStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){var e;return(null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.browser)?yield self.Shopify.browser.localStorage.getItem(o):localStorage.getItem(o)})),getAllStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){return(yield getLocalStorage(o))||(yield getCookie(o))})),setCookie=(o,e,n,i)=>__awaiter(void 0,void 0,void 0,(function*(){let t="";if(n){const o=new Date;o.setTime(o.getTime()+n),t="; expires="+o.toUTCString()}let d=i;if(!d){d=(()=>{let o="";if("undefined"!=typeof window&&window.location)o=window.location.hostname;else if("undefined"!=typeof globalThis&&globalThis.location)o=globalThis.location.hostname;else if("undefined"!=typeof self&&self.location)o=self.location.hostname;else if("undefined"!=typeof document&&document.location)o=document.location.hostname;else{if("undefined"==typeof document||!document.domain)return"";o=document.domain}if(!o)return"";if("localhost"===o||/^(\d{1,3}\.){3}\d{1,3}$/.test(o))return o;const e=o.split(".");if(e.length<2)return o;const n=["com.br","net.br","org.br","gov.br","edu.br","co.uk","org.uk","ac.uk"];if(e.length>=2){const o=e.slice(-2).join(".");return n.includes(o)?2===e.length?"."+o:3===e.length?"."+e.join("."):"."+e.slice(-3).join("."):2===e.length?"."+e.join("."):"."+e.slice(-2).join(".")}return o})()||void 0}const l=d?"; domain="+d:"",c=encodeURIComponent(e||"").replace(/[^\x20-\x7E]/g,(o=>encodeURIComponent(o))),r=o+"="+c+t+"; path=/; SameSite=None; Secure"+l;(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(r):document.cookie=r})),setAllStorage=(o,e,n)=>__awaiter(void 0,void 0,void 0,(function*(){yield((o,e)=>__awaiter(void 0,void 0,void 0,(function*(){var n;(null===(n=null===self||void 0===self?void 0:self.Shopify)||void 0===n?void 0:n.browser)?yield self.Shopify.browser.localStorage.setItem(o,e):localStorage.setItem(o,e)})))(o,e),yield setCookie(o,e,n)}));const getCompanyId=()=>{var o,e,n,i;return"undefined"!=typeof window&&(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.companyId)?window.__SOLOMON__.companyId:"undefined"!=typeof self&&(null===(e=self.__SOLOMON__)||void 0===e?void 0:e.companyId)?self.__SOLOMON__.companyId:"undefined"!=typeof window&&(null===(n=window.SOLOMON)||void 0===n?void 0:n.companyId)?window.SOLOMON.companyId:"undefined"!=typeof self&&(null===(i=self.SOLOMON)||void 0===i?void 0:i.companyId)?self.SOLOMON.companyId:""},getUtmParameter=o=>{var e,n,i,t,d,l,c,r,u,a;let s=null!==(l=null===(d=null===(t=null===(i=null===(n=null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.init)||void 0===n?void 0:n.context)||void 0===i?void 0:i.document)||void 0===t?void 0:t.location)||void 0===d?void 0:d.search)&&void 0!==l?l:null===(c=null===window||void 0===window?void 0:window.location)||void 0===c?void 0:c.search;const f=null!==(u=null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hash)&&void 0!==u?u:"";let v="";f.includes("?")?v=f.substring(f.indexOf("?")):f.length>1&&f.includes("=")&&(v="?"+f.substring(1));const m=new URLSearchParams(s);if(v){new URLSearchParams(v).forEach(((o,e)=>{m.append(e,o)}))}const p=m.getAll(o);try{const e=getCompanyId();if(e&&"8WX2T4ZJz6JonRNrjhOj"===e){const e=m.get("parceiro");if(e&&"utm_source"===o)return"Influenciador";if(e&&"utm_campaign"===o)return e}}catch(o){}if(0===p.length)return"";if(["utm_campaign","sol_campaign","utm_content","sol_content"].includes(o)&&p.length>1){const o=p.filter((o=>/^\d+$/.test(o)));if(o.length>0){return Math.max(...o.map(Number)).toString()}}return null!==(a=p[0])&&void 0!==a?a:""};var session_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const n="solomon-session-id";const getSessionId=()=>session_awaiter(void 0,void 0,void 0,(function*(){const o=(yield getCookie(n))||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield setCookie(n,o,18e5),o}));var user_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const i="solomon-user-id";const getUserId=()=>user_awaiter(void 0,void 0,void 0,(function*(){const o=(yield getAllStorage(i))||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield setAllStorage(i,o,31536e6),o}));var fbp_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getFbp=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbp")})),getFbc=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbc")}));var legacy_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var t,events_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};!function(o){o.VIEW_PAGE="VIEW_PAGE",o.CONTENT_VIEW="CONTENT_VIEW",o.ADD_TO_CART="ADD_TO_CART",o.INITIATE_CHECKOUT="INITIATE_CHECKOUT",o.ADD_SHIPPING_INFO="ADD_SHIPPING_INFO",o.ADD_CUSTOMER_INFO="ADD_CUSTOMER_INFO",o.ADD_PAYMENT_INFO="ADD_PAYMENT_INFO",o.CHECKOUT_COMPLETED="CHECKOUT_COMPLETED"}(t||(t={}));const getUniqueId=()=>events_awaiter(void 0,void 0,void 0,(function*(){const o="uniqueId",e="uniqueId",n=getUtmParameter("utm_term");let i;const t=/^[a-z0-9]{9}_([0-9]+)$/,d="undefined"!=typeof window&&window.location?window.location.hostname:"undefined"!=typeof self&&(null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.location)?self.Shopify.init.context.document.location.hostname:"";var l,c,r,u;const a=(()=>{var o,e,n,i;return"undefined"!=typeof document&&document.referrer?document.referrer:"undefined"!=typeof self&&(null===(i=null===(n=null===(e=null===(o=null===self||void 0===self?void 0:self.Shopify)||void 0===o?void 0:o.init)||void 0===e?void 0:e.context)||void 0===n?void 0:n.document)||void 0===i?void 0:i.referrer)?self.Shopify.init.context.document.referrer:""})(),s=yield getLocalStorage(o);if(s)i=s;else{const l=yield getCookie(e);l?(i=l,yield setAllStorage(o,i,31536e6)):n&&t.test(n)&&-1!==a.indexOf(d)?(i=n,yield setAllStorage(o,i,31536e6)):(i=Math.random().toString(36).substr(2,9)+"_"+(new Date).getTime(),yield setAllStorage(o,i,31536e6))}return s&&(yield setCookie(e,i,31536e6)),i})),SolomonEvent=(o,e,n,i)=>events_awaiter(void 0,void 0,void 0,(function*(){var t,d,l,c,r,u,a,s,f,v,m,p,y,w,_,h,g,x,O,S,b,I,T;return{company_id:o,event_id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)})),event_time:(new Date).toISOString(),session_id:yield getSessionId(),user_id:yield getUserId(),fbp:yield getFbp(),fbc:yield getFbc(),legacy_id:yield legacy_awaiter(void 0,void 0,void 0,(function*(){return(yield getAllStorage("uniqueId"))||null})),custom_aliases:yield i,event_type:String(e),page_referrer:null!==(r=null===(c=null===(l=null===(d=null===(t=null===self||void 0===self?void 0:self.Shopify)||void 0===t?void 0:t.init)||void 0===d?void 0:d.context)||void 0===l?void 0:l.document)||void 0===c?void 0:c.referrer)&&void 0!==r?r:null===document||void 0===document?void 0:document.referrer,page_path:null!==(y=null!==(m=null===(v=null===(f=null===(s=null===(a=null===(u=null===self||void 0===self?void 0:self.Shopify)||void 0===u?void 0:u.init)||void 0===a?void 0:a.context)||void 0===s?void 0:s.document)||void 0===f?void 0:f.location)||void 0===v?void 0:v.pathname)&&void 0!==m?m:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.pathname)&&void 0!==y?y:"",utm_source:null!==(w=getUtmParameter("utm_source"))&&void 0!==w?w:"",utm_medium:null!==(_=getUtmParameter("utm_medium"))&&void 0!==_?_:"",utm_campaign:null!==(h=getUtmParameter("utm_campaign"))&&void 0!==h?h:"",utm_term:null!==(g=getUtmParameter("utm_term"))&&void 0!==g?g:"",utm_content:null!==(x=getUtmParameter("utm_content"))&&void 0!==x?x:"",sol_source:null!==(O=getUtmParameter("sol_source"))&&void 0!==O?O:"",sol_medium:null!==(S=getUtmParameter("sol_medium"))&&void 0!==S?S:"",sol_campaign:null!==(b=getUtmParameter("sol_campaign"))&&void 0!==b?b:"",sol_content:null!==(I=getUtmParameter("sol_content"))&&void 0!==I?I:"",event_payload:n,voxus_url:null!==(T=localStorage.getItem("analytics:session"))&&void 0!==T?T:""}})),TouchpointEvent=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){var i,t,d,l,c,r,u,a,s,f,v,m,p,y,w,_,h,g,x,O,S,b,I,T,N,E,j,D,P,C,k,A;let M="true"===new URLSearchParams(window.location.search).get("vendedor");if((document.referrer.includes("desk.hyperflow.global")||document.referrer.includes("app.yampi.com")||document.referrer.includes("app.reportana.com"))&&(M=!0),M)return setCookie("is_seller","true",365),void localStorage.setItem("is_seller","true");if("true"===(yield getCookie("is_seller"))||M||"true"===localStorage.getItem("is_seller"))return;const U=(yield getFbp())||(yield getCookie("_fbp"))||"",L=(yield getFbc())||(yield getCookie("_fbc"))||"",R=getUtmParameter("fbclid")||(yield getCookie("_fbclid"))||"",K=(yield getCookie("_ga"))||"",H="undefined"!=typeof navigator?navigator.language.replace("-","_"):"",V=null!==(i=getUtmParameter("utm_term"))&&void 0!==i?i:"",F=null!==(s=null!==(u=null===(r=null===(c=null===(l=null===(d=null===(t=null===self||void 0===self?void 0:self.Shopify)||void 0===t?void 0:t.init)||void 0===d?void 0:d.context)||void 0===l?void 0:l.document)||void 0===c?void 0:c.location)||void 0===r?void 0:r.search)&&void 0!==u?u:null===(a=null===window||void 0===window?void 0:window.location)||void 0===a?void 0:a.search)&&void 0!==s?s:"";let G="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));G=o?o[1]:""}}catch(o){G=""}let W="",z=yield e;W="shoppub"===n?(null==z?void 0:z.customer_id)||"":"shopify"===n||"nuvemshop"===n||"tray"===n||"vtex"===n||"trinio"===n||"magento"===n||"buda"===n||"linx"===n?(null==z?void 0:z.cart_token)||"":"magazord"===n?(null==z?void 0:z.email)||"":"yampi"===n||"woocommerce"===n?(null==z?void 0:z.transaction_id)||(null==z?void 0:z.cart_token)||"":"uappi"===n||"bagy"===n||"wake"===n||"wbuy"===n?(null==z?void 0:z.order_id)||"":"cartpanda"===n?(null==z?void 0:z.cart_token)||"":"b4you"===n?(null==z?void 0:z.cart_token)||(null==z?void 0:z.customer_id)||"":"loja_integrada"===n?(null==z?void 0:z.transaction_id)||"":"custom"===n?(null==z?void 0:z.user_id)||"":(null==z?void 0:z.cart_token)||(null==z?void 0:z.customer_id)||(null==z?void 0:z.email)||"";let J=!1;try{const o=performance.getEntriesByType("navigation")[0];J="reload"===(null==o?void 0:o.type)}catch(o){J=1===(null===(f=null===performance||void 0===performance?void 0:performance.navigation)||void 0===f?void 0:f.type)}let q=null!==(w=null===(y=null===(p=null===(m=null===(v=null===self||void 0===self?void 0:self.Shopify)||void 0===v?void 0:v.init)||void 0===m?void 0:m.context)||void 0===p?void 0:p.document)||void 0===y?void 0:y.referrer)&&void 0!==w?w:null===document||void 0===document?void 0:document.referrer;((null===window||void 0===window?void 0:window.pageViewFired)||J)&&(q=""),window.pageViewFired=!0;var Y={id:yield getUniqueId(),referrer:q,path:null!==(I=null!==(S=null===(O=null===(x=null===(g=null===(h=null===(_=null===self||void 0===self?void 0:self.Shopify)||void 0===_?void 0:_.init)||void 0===h?void 0:h.context)||void 0===g?void 0:g.document)||void 0===x?void 0:x.location)||void 0===O?void 0:O.pathname)&&void 0!==S?S:null===(b=null===window||void 0===window?void 0:window.location)||void 0===b?void 0:b.pathname)&&void 0!==I?I:"",utm_source:null!==(T=getUtmParameter("utm_source"))&&void 0!==T?T:"",utm_medium:null!==(N=getUtmParameter("utm_medium"))&&void 0!==N?N:"",utm_campaign:null!==(E=getUtmParameter("utm_campaign"))&&void 0!==E?E:"",utm_term:yield getUniqueId(),utm_content:null!==(j=getUtmParameter("utm_content"))&&void 0!==j?j:"",sol_source:null!==(D=getUtmParameter("sol_source"))&&void 0!==D?D:"",sol_medium:null!==(P=getUtmParameter("sol_medium"))&&void 0!==P?P:"",sol_campaign:null!==(C=getUtmParameter("sol_campaign"))&&void 0!==C?C:"",sol_content:null!==(k=getUtmParameter("sol_content"))&&void 0!==k?k:"",fbp:U,fbc:L,ga_id:K,fbclid:R,locale:H?H.charAt(0).toUpperCase()+H.slice(1):"",timezone:G,osVersion:"undefined"!=typeof navigator?navigator.appVersion.split(" ")[0]:"",screenWidth:"undefined"!=typeof screen?screen.width:0,screenHeight:"undefined"!=typeof screen?screen.height:0,density:"undefined"!=typeof window?window.devicePixelRatio:1,cpuCores:"undefined"!=typeof navigator?navigator.hardwareConcurrency:0,queryParams:F,debug:"",old_id:V,shopify_id:o,current_domain:"undefined"!=typeof window?window.location.hostname:"",cart_token:W,email:null===(A=yield e)||void 0===A?void 0:A.email};return yield(o=>events_awaiter(void 0,void 0,void 0,(function*(){const e=["utm_source","utm_medium","utm_campaign","utm_content","sol_source","sol_medium","sol_campaign","sol_content"],n={},i=yield getCookie("utmsTrack");i&&i.split("&").forEach((o=>{const e=o.split("=");2===e.length&&(n[e[0]]=e[1])}));const t={utm_source:o.utm_source,utm_medium:o.utm_medium,utm_campaign:o.utm_campaign,utm_content:o.utm_content,sol_source:o.sol_source,sol_medium:o.sol_medium,sol_campaign:o.sol_campaign,sol_content:o.sol_content};let d=!1;for(const o of e)if(t[o]){d=!0;break}let l=!1;const c=o.referrer||"",r=o.current_domain||"";if(c&&r)try{const o=new URL(c),e=(o=>{const e=o.split(".");if(e.length<=2)return o;const n=e.slice(-2).join(".");return["com.br","net.br","org.br","gov.br","edu.br","co.uk","co.jp","co.kr","co.za","co.in","com.au","com.mx","com.ar","com.co"].includes(n)?e.slice(-3).join("."):e.slice(-2).join(".")})(r),n=["mercadopago.com","myshopify.com"],i=o.hostname.includes(e),t=n.some((e=>o.hostname.includes(e)));l=!i&&!t}catch(o){l=!1}let u={};if((d||l)&&"Sz8mKHeQqQcPpUnSyET0"!=getCompanyId()){u.utm_term=o.utm_term;for(const o of e)t[o]&&(u[o]=t[o])}else{for(const o in n)n.hasOwnProperty(o)&&(u[o]=n[o]);o.utm_term&&(u.utm_term=o.utm_term);for(const o of e)t[o]&&(u[o]=t[o])}const a=[];for(const o in u)u.hasOwnProperty(o)&&a.push(o+"="+u[o]);yield setCookie("utmsTrack",a.join("&"),2592e6),yield setCookie("track_utms",a.join("&"),2592e6),yield setCookie("yeverUtmsTrack",a.join("&"),2592e6)})))(Y),Y.utmsTrack=yield getCookie("utmsTrack"),Y})),EventTouchpoint=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield TouchpointEvent(n||("undefined"!=typeof window&&(null===(i=window.__SOLOMON__)||void 0===i?void 0:i.accountId)?window.__SOLOMON__.accountId:"undefined"!=typeof self&&(null===(t=self.__SOLOMON__)||void 0===t?void 0:t.accountId)?self.__SOLOMON__.accountId:"undefined"!=typeof window&&(null===(d=window.SOLOMON)||void 0===d?void 0:d.accountId)?window.SOLOMON.accountId:"undefined"!=typeof self&&(null===(l=self.SOLOMON)||void 0===l?void 0:l.accountId)?self.SOLOMON.accountId:""),o,e);var i,t,d,l}));var publish_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var client_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK] initialized",o)}track(o,e,n){return client_awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK] Tracking event:",o,e);const i=n?Promise.resolve(n):void 0;try{let l;switch(o){case"VIEW_PAGE":{const o="undefined"!=typeof window?window.location.href:"";l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.VIEW_PAGE,o,e)})))({url:o,path:"undefined"!=typeof window?window.location.pathname:void 0},i,this.config.companyId);break}case"CONTENT_VIEW":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CONTENT_VIEW,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_TO_CART":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_TO_CART,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"INITIATE_CHECKOUT":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.INITIATE_CHECKOUT,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_SHIPPING_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_SHIPPING_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_CUSTOMER_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_CUSTOMER_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_PAYMENT_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_PAYMENT_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"CHECKOUT_COMPLETED":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CHECKOUT_COMPLETED,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;default:l=SolomonEvent(this.config.companyId,o,Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i)}if((this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==n?void 0:n.user_id)){const o=yield l;o.user_id=n.user_id,l=Promise.resolve(o)}if(this.config.useTouchpoint){const o=EventTouchpoint(i,"custom",this.config.companyId);yield(d=o,publish_awaiter(void 0,void 0,void 0,(function*(){var o;const e=yield d,n=(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.pixelUrl)?window.__SOLOMON__.pixelUrl+"/event":"https://pixel.solomon.com.br/event";try{const o=yield fetch(n,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else console.error("Erro HTTP ao enviar evento:",o.status,o.statusText)}catch(o){console.error("Erro ao enviar evento:",o)}})))}yield(o=>publish_awaiter(void 0,void 0,void 0,(function*(){var e;const n=yield o,i=(null===(e=window.__SOLOMON__)||void 0===e?void 0:e.webanalyticsUrl)?window.__SOLOMON__.webanalyticsUrl+"/event?mode=web":"https://webanalytics.solomon.com.br/event?mode=web";try{const o=yield fetch(i,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else{console.error("[Solomon] Erro HTTP ao enviar evento:",o.status,o.statusText);const e=yield o.text().catch((()=>"Unable to read error response"));console.error("[Solomon] Response error details:",e)}}catch(o){console.error("Erro ao enviar evento:",o)}})))(l),this.config.debug&&console.log("[SolomonSDK] Event tracked successfully:",o)}catch(o){throw console.error("[SolomonSDK] Error tracking event:",o),o}var d}))}}var d=e.C,l=e.A;export{d as SolomonSDK,l as default};
|
|
1
|
+
var o={d:(e,n)=>{for(var i in n)o.o(n,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},e={};o.d(e,{C:()=>SolomonSDK,A:()=>SolomonSDK});var __awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getCookie=o=>__awaiter(void 0,void 0,void 0,(function*(){if((null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)){const e=yield self.Shopify.browser.cookie.get(o);return e?decodeURIComponent(e):null}{if(!document.cookie||""===document.cookie)return null;const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const i=e[n].trim();if(i.substring(0,o.length+1)===o+"=")return decodeURIComponent(i.substring(o.length+1))}return null}})),getLocalStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){var e;return(null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.browser)?yield self.Shopify.browser.localStorage.getItem(o):localStorage.getItem(o)})),getAllStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){return(yield getLocalStorage(o))||(yield getCookie(o))})),setCookie=(o,e,n,i)=>__awaiter(void 0,void 0,void 0,(function*(){let t="";if(n){const o=new Date;o.setTime(o.getTime()+n),t="; expires="+o.toUTCString()}let d=i;if(!d){d=(()=>{let o="";if("undefined"!=typeof window&&window.location)o=window.location.hostname;else if("undefined"!=typeof globalThis&&globalThis.location)o=globalThis.location.hostname;else if("undefined"!=typeof self&&self.location)o=self.location.hostname;else if("undefined"!=typeof document&&document.location)o=document.location.hostname;else{if("undefined"==typeof document||!document.domain)return"";o=document.domain}if(!o)return"";if("localhost"===o||/^(\d{1,3}\.){3}\d{1,3}$/.test(o))return o;const e=o.split(".");if(e.length<2)return o;const n=["com.br","net.br","org.br","gov.br","edu.br","co.uk","org.uk","ac.uk"];if(e.length>=2){const o=e.slice(-2).join(".");return n.includes(o)?2===e.length?"."+o:3===e.length?"."+e.join("."):"."+e.slice(-3).join("."):2===e.length?"."+e.join("."):"."+e.slice(-2).join(".")}return o})()||void 0}const l=d?"; domain="+d:"",c=encodeURIComponent(e||"").replace(/[^\x20-\x7E]/g,(o=>encodeURIComponent(o))),r=o+"="+c+t+"; path=/; SameSite=None; Secure"+l;(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(r):document.cookie=r})),setAllStorage=(o,e,n)=>__awaiter(void 0,void 0,void 0,(function*(){yield((o,e)=>__awaiter(void 0,void 0,void 0,(function*(){var n;(null===(n=null===self||void 0===self?void 0:self.Shopify)||void 0===n?void 0:n.browser)?yield self.Shopify.browser.localStorage.setItem(o,e):localStorage.setItem(o,e)})))(o,e),yield setCookie(o,e,n)}));const getCompanyId=()=>{var o,e,n,i;return"undefined"!=typeof window&&(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.companyId)?window.__SOLOMON__.companyId:"undefined"!=typeof self&&(null===(e=self.__SOLOMON__)||void 0===e?void 0:e.companyId)?self.__SOLOMON__.companyId:"undefined"!=typeof window&&(null===(n=window.SOLOMON)||void 0===n?void 0:n.companyId)?window.SOLOMON.companyId:"undefined"!=typeof self&&(null===(i=self.SOLOMON)||void 0===i?void 0:i.companyId)?self.SOLOMON.companyId:""},getUtmParameter=o=>{var e,n,i,t,d,l,c,r,u,s;let a=null!==(l=null===(d=null===(t=null===(i=null===(n=null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.init)||void 0===n?void 0:n.context)||void 0===i?void 0:i.document)||void 0===t?void 0:t.location)||void 0===d?void 0:d.search)&&void 0!==l?l:null===(c=null===window||void 0===window?void 0:window.location)||void 0===c?void 0:c.search;const f=null!==(u=null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hash)&&void 0!==u?u:"";let v="";f.includes("?")?v=f.substring(f.indexOf("?")):f.length>1&&f.includes("=")&&(v="?"+f.substring(1));const m=new URLSearchParams(a);if(v){new URLSearchParams(v).forEach(((o,e)=>{m.append(e,o)}))}const p=m.getAll(o).filter((o=>!o.includes('"')));try{const e=getCompanyId();if(e&&"8WX2T4ZJz6JonRNrjhOj"===e){const e=m.get("parceiro");if(e&&"utm_source"===o)return"Influenciador";if(e&&"utm_campaign"===o)return e}}catch(o){}if(0===p.length)return"";if(["utm_campaign","sol_campaign","utm_content","sol_content"].includes(o)&&p.length>1){const o=p.filter((o=>/^\d+$/.test(o)));if(o.length>0){return Math.max(...o.map(Number)).toString()}}return null!==(s=p[0])&&void 0!==s?s:""};var persistentId_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};function getPersistentId(o,e,n){return persistentId_awaiter(this,void 0,void 0,(function*(){const i="undefined"!=typeof self?self:"undefined"!=typeof window?window:globalThis,t=Promise.resolve(i[o]).catch((()=>{})).then((o=>persistentId_awaiter(this,void 0,void 0,(function*(){const i=o||(yield e())||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield n(i),i}))));return i[o]=t,t}))}const n="solomon-session-id",i="solomon-user-id";var fbp_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getFbp=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbp")})),getFbc=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbc")}));var legacy_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var t,events_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};!function(o){o.VIEW_PAGE="VIEW_PAGE",o.CONTENT_VIEW="CONTENT_VIEW",o.ADD_TO_CART="ADD_TO_CART",o.INITIATE_CHECKOUT="INITIATE_CHECKOUT",o.ADD_SHIPPING_INFO="ADD_SHIPPING_INFO",o.ADD_CUSTOMER_INFO="ADD_CUSTOMER_INFO",o.ADD_PAYMENT_INFO="ADD_PAYMENT_INFO",o.CHECKOUT_COMPLETED="CHECKOUT_COMPLETED"}(t||(t={}));const getUniqueId=()=>events_awaiter(void 0,void 0,void 0,(function*(){const o="uniqueId",e="uniqueId",n=getUtmParameter("utm_term");let i;const t=/^[a-z0-9]{9}_([0-9]+)$/,d="undefined"!=typeof window&&window.location?window.location.hostname:"undefined"!=typeof self&&(null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.location)?self.Shopify.init.context.document.location.hostname:"";var l,c,r,u;const s=(()=>{var o,e,n,i;return"undefined"!=typeof document&&document.referrer?document.referrer:"undefined"!=typeof self&&(null===(i=null===(n=null===(e=null===(o=null===self||void 0===self?void 0:self.Shopify)||void 0===o?void 0:o.init)||void 0===e?void 0:e.context)||void 0===n?void 0:n.document)||void 0===i?void 0:i.referrer)?self.Shopify.init.context.document.referrer:""})(),a=yield getLocalStorage(o);if(a)i=a;else{const l=yield getCookie(e);l?(i=l,yield setAllStorage(o,i,31536e6)):n&&t.test(n)&&-1!==s.indexOf(d)?(i=n,yield setAllStorage(o,i,31536e6)):(i=Math.random().toString(36).substr(2,9)+"_"+(new Date).getTime(),yield setAllStorage(o,i,31536e6))}return a&&(yield setCookie(e,i,31536e6)),i})),SolomonEvent=(o,e,t,d)=>events_awaiter(void 0,void 0,void 0,(function*(){var l,c,r,u,s,a,f,v,m,p,y,w,_,h,g,O,x,S,b,I,T,N,E;return{company_id:o,event_id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)})),event_time:(new Date).toISOString(),session_id:yield getPersistentId("__SOLOMON_SESSION_ID_LOCK__",(()=>getCookie(n)),(o=>setCookie(n,o,18e5))),user_id:yield getPersistentId("__SOLOMON_USER_ID_LOCK__",(()=>getAllStorage(i)),(o=>setAllStorage(i,o,31536e6))),fbp:yield getFbp(),fbc:yield getFbc(),legacy_id:yield legacy_awaiter(void 0,void 0,void 0,(function*(){return(yield getAllStorage("uniqueId"))||null})),custom_aliases:yield d,event_type:String(e),page_referrer:null!==(s=null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.referrer)&&void 0!==s?s:null===document||void 0===document?void 0:document.referrer,page_path:null!==(_=null!==(y=null===(p=null===(m=null===(v=null===(f=null===(a=null===self||void 0===self?void 0:self.Shopify)||void 0===a?void 0:a.init)||void 0===f?void 0:f.context)||void 0===v?void 0:v.document)||void 0===m?void 0:m.location)||void 0===p?void 0:p.pathname)&&void 0!==y?y:null===(w=null===window||void 0===window?void 0:window.location)||void 0===w?void 0:w.pathname)&&void 0!==_?_:"",utm_source:null!==(h=getUtmParameter("utm_source"))&&void 0!==h?h:"",utm_medium:null!==(g=getUtmParameter("utm_medium"))&&void 0!==g?g:"",utm_campaign:null!==(O=getUtmParameter("utm_campaign"))&&void 0!==O?O:"",utm_term:null!==(x=getUtmParameter("utm_term"))&&void 0!==x?x:"",utm_content:null!==(S=getUtmParameter("utm_content"))&&void 0!==S?S:"",sol_source:null!==(b=getUtmParameter("sol_source"))&&void 0!==b?b:"",sol_medium:null!==(I=getUtmParameter("sol_medium"))&&void 0!==I?I:"",sol_campaign:null!==(T=getUtmParameter("sol_campaign"))&&void 0!==T?T:"",sol_content:null!==(N=getUtmParameter("sol_content"))&&void 0!==N?N:"",event_payload:t,voxus_url:null!==(E=localStorage.getItem("analytics:session"))&&void 0!==E?E:""}})),updateUTMParametersInCookie=(o,e)=>events_awaiter(void 0,void 0,void 0,(function*(){const n=["utm_source","utm_medium","utm_campaign","utm_content","sol_source","sol_medium","sol_campaign","sol_content"],i={},t=yield getCookie("utmsTrack");t&&t.split("&").forEach((o=>{const e=o.split("=");2===e.length&&(i[e[0]]=e[1])}));const d={utm_source:o.utm_source,utm_medium:o.utm_medium,utm_campaign:o.utm_campaign,utm_content:o.utm_content,sol_source:o.sol_source,sol_medium:o.sol_medium,sol_campaign:o.sol_campaign,sol_content:o.sol_content};let l=!1;for(const o of n)if(d[o]){l=!0;break}let c=!1;const r=o.referrer||"",u=o.current_domain||"";if(r&&u)try{const o=new URL(r),e=(o=>{const e=o.split(".");if(e.length<=2)return o;const n=e.slice(-2).join(".");return["com.br","net.br","org.br","gov.br","edu.br","co.uk","co.jp","co.kr","co.za","co.in","com.au","com.mx","com.ar","com.co"].includes(n)?e.slice(-3).join("."):e.slice(-2).join(".")})(u),n=["mercadopago.com","myshopify.com"],i=o.hostname.includes(e),t=n.some((e=>o.hostname.includes(e)));c=!i&&!t}catch(o){c=!1}let s={};const a=["FAtB0BRB4u4QFa5ghBEF","Dk7jRvNPfRfqRuTfdEg1","2JzSzSPMTOSHMElSuyZb"].includes(getCompanyId())?o.old_id:o.utm_term;if((l||c)&&"Sz8mKHeQqQcPpUnSyET0"!=getCompanyId()){a&&(s.utm_term=a);for(const o of n)d[o]&&(s[o]=d[o])}else{for(const o in i)i.hasOwnProperty(o)&&(s[o]=i[o]);a&&(s.utm_term=a);for(const o of n)d[o]&&(s[o]=d[o])}const f=[];for(const o in s)s.hasOwnProperty(o)&&f.push(o+"="+s[o]);var v,m;"yampi"===e?yield(v=s,m=30,__awaiter(void 0,void 0,void 0,(function*(){const o=[];for(const e in v){if(!Object.prototype.hasOwnProperty.call(v,e))continue;const n=v[e];null!=n&&""!==n&&o.push(e+"="+encodeURIComponent(n))}const e=o.join("&"),n=new Date;n.setTime(n.getTime()+24*m*60*60*1e3);const i="utmsTrack="+e+"; expires="+n.toUTCString()+"; path=/; SameSite=Lax";(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(i):document.cookie=i}))):yield setCookie("utmsTrack",f.join("&"),2592e6),yield setCookie("track_utms",f.join("&"),2592e6),yield setCookie("yeverUtmsTrack",f.join("&"),2592e6)})),EventTouchpoint=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){var i,t,d,l,c,r,u,s,a,f,v,m,p,y,w,_,h,g,O,x,S,b,I,T,N,E,j,D,P,k,C,A,M,L,U;let R="true"===new URLSearchParams(window.location.search).get("vendedor");if((document.referrer.includes("desk.hyperflow.global")||document.referrer.includes("app.yampi.com")||document.referrer.includes("app.reportana.com"))&&(R=!0),R)return setCookie("is_seller","true",365),void localStorage.setItem("is_seller","true");if("true"===(yield getCookie("is_seller"))||R||"true"===localStorage.getItem("is_seller"))return;if("lojasdufins"===o&&"seguro.lojasdufins.com.br"===("undefined"!=typeof window?window.location.hostname:"")){let o=(null!==(i=getUtmParameter("utm_source"))&&void 0!==i?i:"").toLowerCase(),e=null!==(t=getUtmParameter("utm_campaign"))&&void 0!==t?t:"",n=null!==(d=getUtmParameter("utm_content"))&&void 0!==d?d:"";if(!o){const i=(yield getCookie("utmsTrack"))||"",t={};i.split("&").forEach((o=>{const e=o.indexOf("=");-1!==e&&(t[o.substring(0,e)]=o.substring(e+1))})),o=(t.utm_source||"").toLowerCase(),e=t.utm_campaign||"",n=t.utm_content||""}const hasNumericId=o=>{var e;if(!o)return!1;const n=-1!==o.indexOf("|")?null!==(e=o.split("|").pop())&&void 0!==e?e:"":o;return/^\d+$/.test(n)};if(-1!==["fb","ig","th","an","msg","facebook","facebookads"].indexOf(o)&&hasNumericId(e)&&!hasNumericId(n))return}const K=(yield getFbp())||(yield getCookie("_fbp"))||"",F=(yield getFbc())||(yield getCookie("_fbc"))||"",H=getUtmParameter("fbclid")||(yield getCookie("_fbclid"))||"",V=(yield getCookie("_ga"))||"",G="undefined"!=typeof navigator?navigator.language.replace("-","_"):"",W=null!==(l=getUtmParameter("utm_term"))&&void 0!==l?l:"",z=null!==(m=null!==(f=null===(a=null===(s=null===(u=null===(r=null===(c=null===self||void 0===self?void 0:self.Shopify)||void 0===c?void 0:c.init)||void 0===r?void 0:r.context)||void 0===u?void 0:u.document)||void 0===s?void 0:s.location)||void 0===a?void 0:a.search)&&void 0!==f?f:null===(v=null===window||void 0===window?void 0:window.location)||void 0===v?void 0:v.search)&&void 0!==m?m:"";let $="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));$=o?o[1]:""}}catch(o){$=""}let J="",q=yield e;J="shoppub"===n?(null==q?void 0:q.customer_id)||"":"shopify"===n||"nuvemshop"===n||"tray"===n||"vtex"===n||"trinio"===n||"magento"===n||"buda"===n||"linx"===n?(null==q?void 0:q.cart_token)||"":"magazord"===n?(null==q?void 0:q.email)||"":"yampi"===n||"woocommerce"===n||"loja_yampi"===n?(null==q?void 0:q.transaction_id)||(null==q?void 0:q.cart_token)||"":"uappi"===n||"bagy"===n||"wake"===n||"wbuy"===n?(null==q?void 0:q.order_id)||"":"cartpanda"===n?(null==q?void 0:q.cart_token)||"":"b4you"===n?(null==q?void 0:q.cart_token)||(null==q?void 0:q.customer_id)||"":"loja_integrada"===n?(null==q?void 0:q.transaction_id)||"":"custom"===n?(null==q?void 0:q.user_id)||"":(null==q?void 0:q.cart_token)||(null==q?void 0:q.customer_id)||(null==q?void 0:q.email)||"";let B=!1;try{const o=performance.getEntriesByType("navigation")[0];B="reload"===(null==o?void 0:o.type)}catch(o){B=1===(null===(p=null===performance||void 0===performance?void 0:performance.navigation)||void 0===p?void 0:p.type)}let Y=null!==(g=null===(h=null===(_=null===(w=null===(y=null===self||void 0===self?void 0:self.Shopify)||void 0===y?void 0:y.init)||void 0===w?void 0:w.context)||void 0===_?void 0:_.document)||void 0===h?void 0:h.referrer)&&void 0!==g?g:null===document||void 0===document?void 0:document.referrer;((null===window||void 0===window?void 0:window.pageViewFired)||B)&&(Y=""),window.pageViewFired=!0;var Q={id:yield getUniqueId(),referrer:Y,path:null!==(E=null!==(T=null===(I=null===(b=null===(S=null===(x=null===(O=null===self||void 0===self?void 0:self.Shopify)||void 0===O?void 0:O.init)||void 0===x?void 0:x.context)||void 0===S?void 0:S.document)||void 0===b?void 0:b.location)||void 0===I?void 0:I.pathname)&&void 0!==T?T:null===(N=null===window||void 0===window?void 0:window.location)||void 0===N?void 0:N.pathname)&&void 0!==E?E:"",utm_source:null!==(j=getUtmParameter("utm_source"))&&void 0!==j?j:"",utm_medium:null!==(D=getUtmParameter("utm_medium"))&&void 0!==D?D:"",utm_campaign:null!==(P=getUtmParameter("utm_campaign"))&&void 0!==P?P:"",utm_term:yield getUniqueId(),utm_content:null!==(k=getUtmParameter("utm_content"))&&void 0!==k?k:"",sol_source:null!==(C=getUtmParameter("sol_source"))&&void 0!==C?C:"",sol_medium:null!==(A=getUtmParameter("sol_medium"))&&void 0!==A?A:"",sol_campaign:null!==(M=getUtmParameter("sol_campaign"))&&void 0!==M?M:"",sol_content:null!==(L=getUtmParameter("sol_content"))&&void 0!==L?L:"",fbp:K,fbc:F,ga_id:V,fbclid:H,locale:G?G.charAt(0).toUpperCase()+G.slice(1):"",timezone:$,osVersion:"undefined"!=typeof navigator?navigator.appVersion.split(" ")[0]:"",screenWidth:"undefined"!=typeof screen?screen.width:0,screenHeight:"undefined"!=typeof screen?screen.height:0,density:"undefined"!=typeof window?window.devicePixelRatio:1,cpuCores:"undefined"!=typeof navigator?navigator.hardwareConcurrency:0,queryParams:z,debug:"",old_id:W,shopify_id:o,current_domain:"undefined"!=typeof window?window.location.hostname:"",cart_token:J,email:null===(U=yield e)||void 0===U?void 0:U.email};return yield updateUTMParametersInCookie(Q,n),Q.utmsTrack=yield getCookie("utmsTrack"),Q})))(n||("undefined"!=typeof window&&(null===(i=window.__SOLOMON__)||void 0===i?void 0:i.accountId)?window.__SOLOMON__.accountId:"undefined"!=typeof self&&(null===(t=self.__SOLOMON__)||void 0===t?void 0:t.accountId)?self.__SOLOMON__.accountId:"undefined"!=typeof window&&(null===(d=window.SOLOMON)||void 0===d?void 0:d.accountId)?window.SOLOMON.accountId:"undefined"!=typeof self&&(null===(l=self.SOLOMON)||void 0===l?void 0:l.accountId)?self.SOLOMON.accountId:""),o,e);var i,t,d,l}));var publish_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var client_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK] initialized",o)}track(o,e,n){return client_awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK] Tracking event:",o,e);const i=n?Promise.resolve(n):void 0;try{let c;switch(o){case"VIEW_PAGE":{const o="undefined"!=typeof window?window.location.href:"";c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.VIEW_PAGE,o,e)})))({url:o,path:"undefined"!=typeof window?window.location.pathname:void 0},i,this.config.companyId);break}case"CONTENT_VIEW":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CONTENT_VIEW,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_TO_CART":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_TO_CART,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"INITIATE_CHECKOUT":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.INITIATE_CHECKOUT,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_SHIPPING_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_SHIPPING_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_CUSTOMER_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_CUSTOMER_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_PAYMENT_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_PAYMENT_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"CHECKOUT_COMPLETED":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CHECKOUT_COMPLETED,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;default:c=SolomonEvent(this.config.companyId,o,Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i)}if((this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==n?void 0:n.user_id)){const o=yield c;o.user_id=n.user_id,c=Promise.resolve(o)}if(this.config.useTouchpoint){const o=EventTouchpoint(i,"custom",this.config.companyId);yield(d=o,l=this.config.pixelUrl,publish_awaiter(void 0,void 0,void 0,(function*(){var o;const e=yield d;if(!e)return;const n=l||(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.pixelUrl),i=n?(o=>o.replace(/\/+$/,"").replace(/\/event$/,"")+"/event")(n):"https://pixel.solomon.com.br/event";try{const o=yield fetch(i,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else console.error("Erro HTTP ao enviar evento:",o.status,o.statusText)}catch(o){console.error("Erro ao enviar evento:",o)}})))}yield((o,e)=>publish_awaiter(void 0,void 0,void 0,(function*(){var n;const i=yield o;if(!i)return;const t=e||(null===(n=window.__SOLOMON__)||void 0===n?void 0:n.webanalyticsUrl),d=t?(o=>o.replace(/\/+$/,"").replace(/\/event(\?mode=web)?$/,"")+"/event?mode=web")(t):`https://webanalytics.solomon.com.br/event?mode=web&event=${null==i?void 0:i.event_type}`;try{const o=yield fetch(d,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else{console.error("[Solomon] Erro HTTP ao enviar evento:",o.status,o.statusText);const e=yield o.text().catch((()=>"Unable to read error response"));console.error("[Solomon] Response error details:",e)}}catch(o){console.error("Erro ao enviar evento:",o)}})))(c,this.config.webanalyticsUrl),this.config.debug&&console.log("[SolomonSDK] Event tracked successfully:",o)}catch(o){throw console.error("[SolomonSDK] Error tracking event:",o),o}var d,l}))}}var d=e.C,l=e.A;export{d as SolomonSDK,l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(o,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SolomonSDK=e():o.SolomonSDK=e()}(this,(()=>(()=>{"use strict";var o={d:(e,n)=>{for(var i in n)o.o(n,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},e={};o.r(e),o.d(e,{SolomonSDK:()=>SolomonSDK,default:()=>SolomonSDK});var __awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getCookie=o=>__awaiter(void 0,void 0,void 0,(function*(){if((null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)){const e=yield self.Shopify.browser.cookie.get(o);return e?decodeURIComponent(e):null}{if(!document.cookie||""===document.cookie)return null;const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const i=e[n].trim();if(i.substring(0,o.length+1)===o+"=")return decodeURIComponent(i.substring(o.length+1))}return null}})),getLocalStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){var e;return(null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.browser)?yield self.Shopify.browser.localStorage.getItem(o):localStorage.getItem(o)})),getAllStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){return(yield getLocalStorage(o))||(yield getCookie(o))})),setCookie=(o,e,n,i)=>__awaiter(void 0,void 0,void 0,(function*(){let t="";if(n){const o=new Date;o.setTime(o.getTime()+n),t="; expires="+o.toUTCString()}let d=i;if(!d){d=(()=>{let o="";if("undefined"!=typeof window&&window.location)o=window.location.hostname;else if("undefined"!=typeof globalThis&&globalThis.location)o=globalThis.location.hostname;else if("undefined"!=typeof self&&self.location)o=self.location.hostname;else if("undefined"!=typeof document&&document.location)o=document.location.hostname;else{if("undefined"==typeof document||!document.domain)return"";o=document.domain}if(!o)return"";if("localhost"===o||/^(\d{1,3}\.){3}\d{1,3}$/.test(o))return o;const e=o.split(".");if(e.length<2)return o;const n=["com.br","net.br","org.br","gov.br","edu.br","co.uk","org.uk","ac.uk"];if(e.length>=2){const o=e.slice(-2).join(".");return n.includes(o)?2===e.length?"."+o:3===e.length?"."+e.join("."):"."+e.slice(-3).join("."):2===e.length?"."+e.join("."):"."+e.slice(-2).join(".")}return o})()||void 0}const l=d?"; domain="+d:"",c=encodeURIComponent(e||"").replace(/[^\x20-\x7E]/g,(o=>encodeURIComponent(o))),r=o+"="+c+t+"; path=/; SameSite=None; Secure"+l;(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(r):document.cookie=r})),setAllStorage=(o,e,n)=>__awaiter(void 0,void 0,void 0,(function*(){yield((o,e)=>__awaiter(void 0,void 0,void 0,(function*(){var n;(null===(n=null===self||void 0===self?void 0:self.Shopify)||void 0===n?void 0:n.browser)?yield self.Shopify.browser.localStorage.setItem(o,e):localStorage.setItem(o,e)})))(o,e),yield setCookie(o,e,n)}));const getCompanyId=()=>{var o,e,n,i;return"undefined"!=typeof window&&(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.companyId)?window.__SOLOMON__.companyId:"undefined"!=typeof self&&(null===(e=self.__SOLOMON__)||void 0===e?void 0:e.companyId)?self.__SOLOMON__.companyId:"undefined"!=typeof window&&(null===(n=window.SOLOMON)||void 0===n?void 0:n.companyId)?window.SOLOMON.companyId:"undefined"!=typeof self&&(null===(i=self.SOLOMON)||void 0===i?void 0:i.companyId)?self.SOLOMON.companyId:""},getUtmParameter=o=>{var e,n,i,t,d,l,c,r,u,a;let s=null!==(l=null===(d=null===(t=null===(i=null===(n=null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.init)||void 0===n?void 0:n.context)||void 0===i?void 0:i.document)||void 0===t?void 0:t.location)||void 0===d?void 0:d.search)&&void 0!==l?l:null===(c=null===window||void 0===window?void 0:window.location)||void 0===c?void 0:c.search;const f=null!==(u=null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hash)&&void 0!==u?u:"";let v="";f.includes("?")?v=f.substring(f.indexOf("?")):f.length>1&&f.includes("=")&&(v="?"+f.substring(1));const m=new URLSearchParams(s);if(v){new URLSearchParams(v).forEach(((o,e)=>{m.append(e,o)}))}const p=m.getAll(o);try{const e=getCompanyId();if(e&&"8WX2T4ZJz6JonRNrjhOj"===e){const e=m.get("parceiro");if(e&&"utm_source"===o)return"Influenciador";if(e&&"utm_campaign"===o)return e}}catch(o){}if(0===p.length)return"";if(["utm_campaign","sol_campaign","utm_content","sol_content"].includes(o)&&p.length>1){const o=p.filter((o=>/^\d+$/.test(o)));if(o.length>0){return Math.max(...o.map(Number)).toString()}}return null!==(a=p[0])&&void 0!==a?a:""};var session_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const n="solomon-session-id";const getSessionId=()=>session_awaiter(void 0,void 0,void 0,(function*(){const o=(yield getCookie(n))||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield setCookie(n,o,18e5),o}));var user_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const i="solomon-user-id";const getUserId=()=>user_awaiter(void 0,void 0,void 0,(function*(){const o=(yield getAllStorage(i))||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield setAllStorage(i,o,31536e6),o}));var fbp_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getFbp=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbp")})),getFbc=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbc")}));var legacy_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var t,events_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};!function(o){o.VIEW_PAGE="VIEW_PAGE",o.CONTENT_VIEW="CONTENT_VIEW",o.ADD_TO_CART="ADD_TO_CART",o.INITIATE_CHECKOUT="INITIATE_CHECKOUT",o.ADD_SHIPPING_INFO="ADD_SHIPPING_INFO",o.ADD_CUSTOMER_INFO="ADD_CUSTOMER_INFO",o.ADD_PAYMENT_INFO="ADD_PAYMENT_INFO",o.CHECKOUT_COMPLETED="CHECKOUT_COMPLETED"}(t||(t={}));const getUniqueId=()=>events_awaiter(void 0,void 0,void 0,(function*(){const o="uniqueId",e="uniqueId",n=getUtmParameter("utm_term");let i;const t=/^[a-z0-9]{9}_([0-9]+)$/,d="undefined"!=typeof window&&window.location?window.location.hostname:"undefined"!=typeof self&&(null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.location)?self.Shopify.init.context.document.location.hostname:"";var l,c,r,u;const a=(()=>{var o,e,n,i;return"undefined"!=typeof document&&document.referrer?document.referrer:"undefined"!=typeof self&&(null===(i=null===(n=null===(e=null===(o=null===self||void 0===self?void 0:self.Shopify)||void 0===o?void 0:o.init)||void 0===e?void 0:e.context)||void 0===n?void 0:n.document)||void 0===i?void 0:i.referrer)?self.Shopify.init.context.document.referrer:""})(),s=yield getLocalStorage(o);if(s)i=s;else{const l=yield getCookie(e);l?(i=l,yield setAllStorage(o,i,31536e6)):n&&t.test(n)&&-1!==a.indexOf(d)?(i=n,yield setAllStorage(o,i,31536e6)):(i=Math.random().toString(36).substr(2,9)+"_"+(new Date).getTime(),yield setAllStorage(o,i,31536e6))}return s&&(yield setCookie(e,i,31536e6)),i})),SolomonEvent=(o,e,n,i)=>events_awaiter(void 0,void 0,void 0,(function*(){var t,d,l,c,r,u,a,s,f,v,m,p,y,w,_,h,g,x,O,S,b,I,T;return{company_id:o,event_id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)})),event_time:(new Date).toISOString(),session_id:yield getSessionId(),user_id:yield getUserId(),fbp:yield getFbp(),fbc:yield getFbc(),legacy_id:yield legacy_awaiter(void 0,void 0,void 0,(function*(){return(yield getAllStorage("uniqueId"))||null})),custom_aliases:yield i,event_type:String(e),page_referrer:null!==(r=null===(c=null===(l=null===(d=null===(t=null===self||void 0===self?void 0:self.Shopify)||void 0===t?void 0:t.init)||void 0===d?void 0:d.context)||void 0===l?void 0:l.document)||void 0===c?void 0:c.referrer)&&void 0!==r?r:null===document||void 0===document?void 0:document.referrer,page_path:null!==(y=null!==(m=null===(v=null===(f=null===(s=null===(a=null===(u=null===self||void 0===self?void 0:self.Shopify)||void 0===u?void 0:u.init)||void 0===a?void 0:a.context)||void 0===s?void 0:s.document)||void 0===f?void 0:f.location)||void 0===v?void 0:v.pathname)&&void 0!==m?m:null===(p=null===window||void 0===window?void 0:window.location)||void 0===p?void 0:p.pathname)&&void 0!==y?y:"",utm_source:null!==(w=getUtmParameter("utm_source"))&&void 0!==w?w:"",utm_medium:null!==(_=getUtmParameter("utm_medium"))&&void 0!==_?_:"",utm_campaign:null!==(h=getUtmParameter("utm_campaign"))&&void 0!==h?h:"",utm_term:null!==(g=getUtmParameter("utm_term"))&&void 0!==g?g:"",utm_content:null!==(x=getUtmParameter("utm_content"))&&void 0!==x?x:"",sol_source:null!==(O=getUtmParameter("sol_source"))&&void 0!==O?O:"",sol_medium:null!==(S=getUtmParameter("sol_medium"))&&void 0!==S?S:"",sol_campaign:null!==(b=getUtmParameter("sol_campaign"))&&void 0!==b?b:"",sol_content:null!==(I=getUtmParameter("sol_content"))&&void 0!==I?I:"",event_payload:n,voxus_url:null!==(T=localStorage.getItem("analytics:session"))&&void 0!==T?T:""}})),TouchpointEvent=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){var i,t,d,l,c,r,u,a,s,f,v,m,p,y,w,_,h,g,x,O,S,b,I,T,N,j,E,D,P,k,C,A;let M="true"===new URLSearchParams(window.location.search).get("vendedor");if((document.referrer.includes("desk.hyperflow.global")||document.referrer.includes("app.yampi.com")||document.referrer.includes("app.reportana.com"))&&(M=!0),M)return setCookie("is_seller","true",365),void localStorage.setItem("is_seller","true");if("true"===(yield getCookie("is_seller"))||M||"true"===localStorage.getItem("is_seller"))return;const U=(yield getFbp())||(yield getCookie("_fbp"))||"",L=(yield getFbc())||(yield getCookie("_fbc"))||"",R=getUtmParameter("fbclid")||(yield getCookie("_fbclid"))||"",K=(yield getCookie("_ga"))||"",H="undefined"!=typeof navigator?navigator.language.replace("-","_"):"",V=null!==(i=getUtmParameter("utm_term"))&&void 0!==i?i:"",F=null!==(s=null!==(u=null===(r=null===(c=null===(l=null===(d=null===(t=null===self||void 0===self?void 0:self.Shopify)||void 0===t?void 0:t.init)||void 0===d?void 0:d.context)||void 0===l?void 0:l.document)||void 0===c?void 0:c.location)||void 0===r?void 0:r.search)&&void 0!==u?u:null===(a=null===window||void 0===window?void 0:window.location)||void 0===a?void 0:a.search)&&void 0!==s?s:"";let G="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));G=o?o[1]:""}}catch(o){G=""}let W="",z=yield e;W="shoppub"===n?(null==z?void 0:z.customer_id)||"":"shopify"===n||"nuvemshop"===n||"tray"===n||"vtex"===n||"trinio"===n||"magento"===n||"buda"===n||"linx"===n?(null==z?void 0:z.cart_token)||"":"magazord"===n?(null==z?void 0:z.email)||"":"yampi"===n||"woocommerce"===n?(null==z?void 0:z.transaction_id)||(null==z?void 0:z.cart_token)||"":"uappi"===n||"bagy"===n||"wake"===n||"wbuy"===n?(null==z?void 0:z.order_id)||"":"cartpanda"===n?(null==z?void 0:z.cart_token)||"":"b4you"===n?(null==z?void 0:z.cart_token)||(null==z?void 0:z.customer_id)||"":"loja_integrada"===n?(null==z?void 0:z.transaction_id)||"":"custom"===n?(null==z?void 0:z.user_id)||"":(null==z?void 0:z.cart_token)||(null==z?void 0:z.customer_id)||(null==z?void 0:z.email)||"";let J=!1;try{const o=performance.getEntriesByType("navigation")[0];J="reload"===(null==o?void 0:o.type)}catch(o){J=1===(null===(f=null===performance||void 0===performance?void 0:performance.navigation)||void 0===f?void 0:f.type)}let q=null!==(w=null===(y=null===(p=null===(m=null===(v=null===self||void 0===self?void 0:self.Shopify)||void 0===v?void 0:v.init)||void 0===m?void 0:m.context)||void 0===p?void 0:p.document)||void 0===y?void 0:y.referrer)&&void 0!==w?w:null===document||void 0===document?void 0:document.referrer;((null===window||void 0===window?void 0:window.pageViewFired)||J)&&(q=""),window.pageViewFired=!0;var Y={id:yield getUniqueId(),referrer:q,path:null!==(I=null!==(S=null===(O=null===(x=null===(g=null===(h=null===(_=null===self||void 0===self?void 0:self.Shopify)||void 0===_?void 0:_.init)||void 0===h?void 0:h.context)||void 0===g?void 0:g.document)||void 0===x?void 0:x.location)||void 0===O?void 0:O.pathname)&&void 0!==S?S:null===(b=null===window||void 0===window?void 0:window.location)||void 0===b?void 0:b.pathname)&&void 0!==I?I:"",utm_source:null!==(T=getUtmParameter("utm_source"))&&void 0!==T?T:"",utm_medium:null!==(N=getUtmParameter("utm_medium"))&&void 0!==N?N:"",utm_campaign:null!==(j=getUtmParameter("utm_campaign"))&&void 0!==j?j:"",utm_term:yield getUniqueId(),utm_content:null!==(E=getUtmParameter("utm_content"))&&void 0!==E?E:"",sol_source:null!==(D=getUtmParameter("sol_source"))&&void 0!==D?D:"",sol_medium:null!==(P=getUtmParameter("sol_medium"))&&void 0!==P?P:"",sol_campaign:null!==(k=getUtmParameter("sol_campaign"))&&void 0!==k?k:"",sol_content:null!==(C=getUtmParameter("sol_content"))&&void 0!==C?C:"",fbp:U,fbc:L,ga_id:K,fbclid:R,locale:H?H.charAt(0).toUpperCase()+H.slice(1):"",timezone:G,osVersion:"undefined"!=typeof navigator?navigator.appVersion.split(" ")[0]:"",screenWidth:"undefined"!=typeof screen?screen.width:0,screenHeight:"undefined"!=typeof screen?screen.height:0,density:"undefined"!=typeof window?window.devicePixelRatio:1,cpuCores:"undefined"!=typeof navigator?navigator.hardwareConcurrency:0,queryParams:F,debug:"",old_id:V,shopify_id:o,current_domain:"undefined"!=typeof window?window.location.hostname:"",cart_token:W,email:null===(A=yield e)||void 0===A?void 0:A.email};return yield(o=>events_awaiter(void 0,void 0,void 0,(function*(){const e=["utm_source","utm_medium","utm_campaign","utm_content","sol_source","sol_medium","sol_campaign","sol_content"],n={},i=yield getCookie("utmsTrack");i&&i.split("&").forEach((o=>{const e=o.split("=");2===e.length&&(n[e[0]]=e[1])}));const t={utm_source:o.utm_source,utm_medium:o.utm_medium,utm_campaign:o.utm_campaign,utm_content:o.utm_content,sol_source:o.sol_source,sol_medium:o.sol_medium,sol_campaign:o.sol_campaign,sol_content:o.sol_content};let d=!1;for(const o of e)if(t[o]){d=!0;break}let l=!1;const c=o.referrer||"",r=o.current_domain||"";if(c&&r)try{const o=new URL(c),e=(o=>{const e=o.split(".");if(e.length<=2)return o;const n=e.slice(-2).join(".");return["com.br","net.br","org.br","gov.br","edu.br","co.uk","co.jp","co.kr","co.za","co.in","com.au","com.mx","com.ar","com.co"].includes(n)?e.slice(-3).join("."):e.slice(-2).join(".")})(r),n=["mercadopago.com","myshopify.com"],i=o.hostname.includes(e),t=n.some((e=>o.hostname.includes(e)));l=!i&&!t}catch(o){l=!1}let u={};if((d||l)&&"Sz8mKHeQqQcPpUnSyET0"!=getCompanyId()){u.utm_term=o.utm_term;for(const o of e)t[o]&&(u[o]=t[o])}else{for(const o in n)n.hasOwnProperty(o)&&(u[o]=n[o]);o.utm_term&&(u.utm_term=o.utm_term);for(const o of e)t[o]&&(u[o]=t[o])}const a=[];for(const o in u)u.hasOwnProperty(o)&&a.push(o+"="+u[o]);yield setCookie("utmsTrack",a.join("&"),2592e6),yield setCookie("track_utms",a.join("&"),2592e6),yield setCookie("yeverUtmsTrack",a.join("&"),2592e6)})))(Y),Y.utmsTrack=yield getCookie("utmsTrack"),Y})),EventTouchpoint=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield TouchpointEvent(n||("undefined"!=typeof window&&(null===(i=window.__SOLOMON__)||void 0===i?void 0:i.accountId)?window.__SOLOMON__.accountId:"undefined"!=typeof self&&(null===(t=self.__SOLOMON__)||void 0===t?void 0:t.accountId)?self.__SOLOMON__.accountId:"undefined"!=typeof window&&(null===(d=window.SOLOMON)||void 0===d?void 0:d.accountId)?window.SOLOMON.accountId:"undefined"!=typeof self&&(null===(l=self.SOLOMON)||void 0===l?void 0:l.accountId)?self.SOLOMON.accountId:""),o,e);var i,t,d,l}));var publish_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var client_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK] initialized",o)}track(o,e,n){return client_awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK] Tracking event:",o,e);const i=n?Promise.resolve(n):void 0;try{let l;switch(o){case"VIEW_PAGE":{const o="undefined"!=typeof window?window.location.href:"";l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.VIEW_PAGE,o,e)})))({url:o,path:"undefined"!=typeof window?window.location.pathname:void 0},i,this.config.companyId);break}case"CONTENT_VIEW":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CONTENT_VIEW,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_TO_CART":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_TO_CART,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"INITIATE_CHECKOUT":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.INITIATE_CHECKOUT,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_SHIPPING_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_SHIPPING_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_CUSTOMER_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_CUSTOMER_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_PAYMENT_INFO":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_PAYMENT_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"CHECKOUT_COMPLETED":l=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CHECKOUT_COMPLETED,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;default:l=SolomonEvent(this.config.companyId,o,Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i)}if((this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==n?void 0:n.user_id)){const o=yield l;o.user_id=n.user_id,l=Promise.resolve(o)}if(this.config.useTouchpoint){const o=EventTouchpoint(i,"custom",this.config.companyId);yield(d=o,publish_awaiter(void 0,void 0,void 0,(function*(){var o;const e=yield d,n=(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.pixelUrl)?window.__SOLOMON__.pixelUrl+"/event":"https://pixel.solomon.com.br/event";try{const o=yield fetch(n,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else console.error("Erro HTTP ao enviar evento:",o.status,o.statusText)}catch(o){console.error("Erro ao enviar evento:",o)}})))}yield(o=>publish_awaiter(void 0,void 0,void 0,(function*(){var e;const n=yield o,i=(null===(e=window.__SOLOMON__)||void 0===e?void 0:e.webanalyticsUrl)?window.__SOLOMON__.webanalyticsUrl+"/event?mode=web":"https://webanalytics.solomon.com.br/event?mode=web";try{const o=yield fetch(i,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(n)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else{console.error("[Solomon] Erro HTTP ao enviar evento:",o.status,o.statusText);const e=yield o.text().catch((()=>"Unable to read error response"));console.error("[Solomon] Response error details:",e)}}catch(o){console.error("Erro ao enviar evento:",o)}})))(l),this.config.debug&&console.log("[SolomonSDK] Event tracked successfully:",o)}catch(o){throw console.error("[SolomonSDK] Error tracking event:",o),o}var d}))}}return e})()));
|
|
1
|
+
!function(o,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SolomonSDK=e():o.SolomonSDK=e()}(this,(()=>(()=>{"use strict";var o={d:(e,n)=>{for(var i in n)o.o(n,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},e={};o.r(e),o.d(e,{SolomonSDK:()=>SolomonSDK,default:()=>SolomonSDK});var __awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getCookie=o=>__awaiter(void 0,void 0,void 0,(function*(){if((null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)){const e=yield self.Shopify.browser.cookie.get(o);return e?decodeURIComponent(e):null}{if(!document.cookie||""===document.cookie)return null;const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const i=e[n].trim();if(i.substring(0,o.length+1)===o+"=")return decodeURIComponent(i.substring(o.length+1))}return null}})),getLocalStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){var e;return(null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.browser)?yield self.Shopify.browser.localStorage.getItem(o):localStorage.getItem(o)})),getAllStorage=o=>__awaiter(void 0,void 0,void 0,(function*(){return(yield getLocalStorage(o))||(yield getCookie(o))})),setCookie=(o,e,n,i)=>__awaiter(void 0,void 0,void 0,(function*(){let t="";if(n){const o=new Date;o.setTime(o.getTime()+n),t="; expires="+o.toUTCString()}let d=i;if(!d){d=(()=>{let o="";if("undefined"!=typeof window&&window.location)o=window.location.hostname;else if("undefined"!=typeof globalThis&&globalThis.location)o=globalThis.location.hostname;else if("undefined"!=typeof self&&self.location)o=self.location.hostname;else if("undefined"!=typeof document&&document.location)o=document.location.hostname;else{if("undefined"==typeof document||!document.domain)return"";o=document.domain}if(!o)return"";if("localhost"===o||/^(\d{1,3}\.){3}\d{1,3}$/.test(o))return o;const e=o.split(".");if(e.length<2)return o;const n=["com.br","net.br","org.br","gov.br","edu.br","co.uk","org.uk","ac.uk"];if(e.length>=2){const o=e.slice(-2).join(".");return n.includes(o)?2===e.length?"."+o:3===e.length?"."+e.join("."):"."+e.slice(-3).join("."):2===e.length?"."+e.join("."):"."+e.slice(-2).join(".")}return o})()||void 0}const l=d?"; domain="+d:"",c=encodeURIComponent(e||"").replace(/[^\x20-\x7E]/g,(o=>encodeURIComponent(o))),r=o+"="+c+t+"; path=/; SameSite=None; Secure"+l;(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(r):document.cookie=r})),setAllStorage=(o,e,n)=>__awaiter(void 0,void 0,void 0,(function*(){yield((o,e)=>__awaiter(void 0,void 0,void 0,(function*(){var n;(null===(n=null===self||void 0===self?void 0:self.Shopify)||void 0===n?void 0:n.browser)?yield self.Shopify.browser.localStorage.setItem(o,e):localStorage.setItem(o,e)})))(o,e),yield setCookie(o,e,n)}));const getCompanyId=()=>{var o,e,n,i;return"undefined"!=typeof window&&(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.companyId)?window.__SOLOMON__.companyId:"undefined"!=typeof self&&(null===(e=self.__SOLOMON__)||void 0===e?void 0:e.companyId)?self.__SOLOMON__.companyId:"undefined"!=typeof window&&(null===(n=window.SOLOMON)||void 0===n?void 0:n.companyId)?window.SOLOMON.companyId:"undefined"!=typeof self&&(null===(i=self.SOLOMON)||void 0===i?void 0:i.companyId)?self.SOLOMON.companyId:""},getUtmParameter=o=>{var e,n,i,t,d,l,c,r,u,s;let a=null!==(l=null===(d=null===(t=null===(i=null===(n=null===(e=null===self||void 0===self?void 0:self.Shopify)||void 0===e?void 0:e.init)||void 0===n?void 0:n.context)||void 0===i?void 0:i.document)||void 0===t?void 0:t.location)||void 0===d?void 0:d.search)&&void 0!==l?l:null===(c=null===window||void 0===window?void 0:window.location)||void 0===c?void 0:c.search;const f=null!==(u=null===(r=null===window||void 0===window?void 0:window.location)||void 0===r?void 0:r.hash)&&void 0!==u?u:"";let v="";f.includes("?")?v=f.substring(f.indexOf("?")):f.length>1&&f.includes("=")&&(v="?"+f.substring(1));const m=new URLSearchParams(a);if(v){new URLSearchParams(v).forEach(((o,e)=>{m.append(e,o)}))}const p=m.getAll(o).filter((o=>!o.includes('"')));try{const e=getCompanyId();if(e&&"8WX2T4ZJz6JonRNrjhOj"===e){const e=m.get("parceiro");if(e&&"utm_source"===o)return"Influenciador";if(e&&"utm_campaign"===o)return e}}catch(o){}if(0===p.length)return"";if(["utm_campaign","sol_campaign","utm_content","sol_content"].includes(o)&&p.length>1){const o=p.filter((o=>/^\d+$/.test(o)));if(o.length>0){return Math.max(...o.map(Number)).toString()}}return null!==(s=p[0])&&void 0!==s?s:""};var persistentId_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};function getPersistentId(o,e,n){return persistentId_awaiter(this,void 0,void 0,(function*(){const i="undefined"!=typeof self?self:"undefined"!=typeof window?window:globalThis,t=Promise.resolve(i[o]).catch((()=>{})).then((o=>persistentId_awaiter(this,void 0,void 0,(function*(){const i=o||(yield e())||"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)}));return yield n(i),i}))));return i[o]=t,t}))}const n="solomon-session-id",i="solomon-user-id";var fbp_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};const getFbp=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbp")})),getFbc=()=>fbp_awaiter(void 0,void 0,void 0,(function*(){return yield getCookie("_fbc")}));var legacy_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var t,events_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};!function(o){o.VIEW_PAGE="VIEW_PAGE",o.CONTENT_VIEW="CONTENT_VIEW",o.ADD_TO_CART="ADD_TO_CART",o.INITIATE_CHECKOUT="INITIATE_CHECKOUT",o.ADD_SHIPPING_INFO="ADD_SHIPPING_INFO",o.ADD_CUSTOMER_INFO="ADD_CUSTOMER_INFO",o.ADD_PAYMENT_INFO="ADD_PAYMENT_INFO",o.CHECKOUT_COMPLETED="CHECKOUT_COMPLETED"}(t||(t={}));const getUniqueId=()=>events_awaiter(void 0,void 0,void 0,(function*(){const o="uniqueId",e="uniqueId",n=getUtmParameter("utm_term");let i;const t=/^[a-z0-9]{9}_([0-9]+)$/,d="undefined"!=typeof window&&window.location?window.location.hostname:"undefined"!=typeof self&&(null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.location)?self.Shopify.init.context.document.location.hostname:"";var l,c,r,u;const s=(()=>{var o,e,n,i;return"undefined"!=typeof document&&document.referrer?document.referrer:"undefined"!=typeof self&&(null===(i=null===(n=null===(e=null===(o=null===self||void 0===self?void 0:self.Shopify)||void 0===o?void 0:o.init)||void 0===e?void 0:e.context)||void 0===n?void 0:n.document)||void 0===i?void 0:i.referrer)?self.Shopify.init.context.document.referrer:""})(),a=yield getLocalStorage(o);if(a)i=a;else{const l=yield getCookie(e);l?(i=l,yield setAllStorage(o,i,31536e6)):n&&t.test(n)&&-1!==s.indexOf(d)?(i=n,yield setAllStorage(o,i,31536e6)):(i=Math.random().toString(36).substr(2,9)+"_"+(new Date).getTime(),yield setAllStorage(o,i,31536e6))}return a&&(yield setCookie(e,i,31536e6)),i})),SolomonEvent=(o,e,t,d)=>events_awaiter(void 0,void 0,void 0,(function*(){var l,c,r,u,s,a,f,v,m,p,y,w,_,h,g,O,S,x,b,I,T,N,E;return{company_id:o,event_id:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(o=>{const e=15&crypto.getRandomValues(new Uint8Array(1))[0];return("x"===o?e:3&e|8).toString(16)})),event_time:(new Date).toISOString(),session_id:yield getPersistentId("__SOLOMON_SESSION_ID_LOCK__",(()=>getCookie(n)),(o=>setCookie(n,o,18e5))),user_id:yield getPersistentId("__SOLOMON_USER_ID_LOCK__",(()=>getAllStorage(i)),(o=>setAllStorage(i,o,31536e6))),fbp:yield getFbp(),fbc:yield getFbc(),legacy_id:yield legacy_awaiter(void 0,void 0,void 0,(function*(){return(yield getAllStorage("uniqueId"))||null})),custom_aliases:yield d,event_type:String(e),page_referrer:null!==(s=null===(u=null===(r=null===(c=null===(l=null===self||void 0===self?void 0:self.Shopify)||void 0===l?void 0:l.init)||void 0===c?void 0:c.context)||void 0===r?void 0:r.document)||void 0===u?void 0:u.referrer)&&void 0!==s?s:null===document||void 0===document?void 0:document.referrer,page_path:null!==(_=null!==(y=null===(p=null===(m=null===(v=null===(f=null===(a=null===self||void 0===self?void 0:self.Shopify)||void 0===a?void 0:a.init)||void 0===f?void 0:f.context)||void 0===v?void 0:v.document)||void 0===m?void 0:m.location)||void 0===p?void 0:p.pathname)&&void 0!==y?y:null===(w=null===window||void 0===window?void 0:window.location)||void 0===w?void 0:w.pathname)&&void 0!==_?_:"",utm_source:null!==(h=getUtmParameter("utm_source"))&&void 0!==h?h:"",utm_medium:null!==(g=getUtmParameter("utm_medium"))&&void 0!==g?g:"",utm_campaign:null!==(O=getUtmParameter("utm_campaign"))&&void 0!==O?O:"",utm_term:null!==(S=getUtmParameter("utm_term"))&&void 0!==S?S:"",utm_content:null!==(x=getUtmParameter("utm_content"))&&void 0!==x?x:"",sol_source:null!==(b=getUtmParameter("sol_source"))&&void 0!==b?b:"",sol_medium:null!==(I=getUtmParameter("sol_medium"))&&void 0!==I?I:"",sol_campaign:null!==(T=getUtmParameter("sol_campaign"))&&void 0!==T?T:"",sol_content:null!==(N=getUtmParameter("sol_content"))&&void 0!==N?N:"",event_payload:t,voxus_url:null!==(E=localStorage.getItem("analytics:session"))&&void 0!==E?E:""}})),updateUTMParametersInCookie=(o,e)=>events_awaiter(void 0,void 0,void 0,(function*(){const n=["utm_source","utm_medium","utm_campaign","utm_content","sol_source","sol_medium","sol_campaign","sol_content"],i={},t=yield getCookie("utmsTrack");t&&t.split("&").forEach((o=>{const e=o.split("=");2===e.length&&(i[e[0]]=e[1])}));const d={utm_source:o.utm_source,utm_medium:o.utm_medium,utm_campaign:o.utm_campaign,utm_content:o.utm_content,sol_source:o.sol_source,sol_medium:o.sol_medium,sol_campaign:o.sol_campaign,sol_content:o.sol_content};let l=!1;for(const o of n)if(d[o]){l=!0;break}let c=!1;const r=o.referrer||"",u=o.current_domain||"";if(r&&u)try{const o=new URL(r),e=(o=>{const e=o.split(".");if(e.length<=2)return o;const n=e.slice(-2).join(".");return["com.br","net.br","org.br","gov.br","edu.br","co.uk","co.jp","co.kr","co.za","co.in","com.au","com.mx","com.ar","com.co"].includes(n)?e.slice(-3).join("."):e.slice(-2).join(".")})(u),n=["mercadopago.com","myshopify.com"],i=o.hostname.includes(e),t=n.some((e=>o.hostname.includes(e)));c=!i&&!t}catch(o){c=!1}let s={};const a=["FAtB0BRB4u4QFa5ghBEF","Dk7jRvNPfRfqRuTfdEg1","2JzSzSPMTOSHMElSuyZb"].includes(getCompanyId())?o.old_id:o.utm_term;if((l||c)&&"Sz8mKHeQqQcPpUnSyET0"!=getCompanyId()){a&&(s.utm_term=a);for(const o of n)d[o]&&(s[o]=d[o])}else{for(const o in i)i.hasOwnProperty(o)&&(s[o]=i[o]);a&&(s.utm_term=a);for(const o of n)d[o]&&(s[o]=d[o])}const f=[];for(const o in s)s.hasOwnProperty(o)&&f.push(o+"="+s[o]);var v,m;"yampi"===e?yield(v=s,m=30,__awaiter(void 0,void 0,void 0,(function*(){const o=[];for(const e in v){if(!Object.prototype.hasOwnProperty.call(v,e))continue;const n=v[e];null!=n&&""!==n&&o.push(e+"="+encodeURIComponent(n))}const e=o.join("&"),n=new Date;n.setTime(n.getTime()+24*m*60*60*1e3);const i="utmsTrack="+e+"; expires="+n.toUTCString()+"; path=/; SameSite=Lax";(null===self||void 0===self?void 0:self.Shopify)&&(null===self||void 0===self?void 0:self.Shopify.browser)?yield self.Shopify.browser.cookie.set(i):document.cookie=i}))):yield setCookie("utmsTrack",f.join("&"),2592e6),yield setCookie("track_utms",f.join("&"),2592e6),yield setCookie("yeverUtmsTrack",f.join("&"),2592e6)})),EventTouchpoint=(o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){var i,t,d,l,c,r,u,s,a,f,v,m,p,y,w,_,h,g,O,S,x,b,I,T,N,E,j,D,P,k,C,A,M,L,U;let R="true"===new URLSearchParams(window.location.search).get("vendedor");if((document.referrer.includes("desk.hyperflow.global")||document.referrer.includes("app.yampi.com")||document.referrer.includes("app.reportana.com"))&&(R=!0),R)return setCookie("is_seller","true",365),void localStorage.setItem("is_seller","true");if("true"===(yield getCookie("is_seller"))||R||"true"===localStorage.getItem("is_seller"))return;if("lojasdufins"===o&&"seguro.lojasdufins.com.br"===("undefined"!=typeof window?window.location.hostname:"")){let o=(null!==(i=getUtmParameter("utm_source"))&&void 0!==i?i:"").toLowerCase(),e=null!==(t=getUtmParameter("utm_campaign"))&&void 0!==t?t:"",n=null!==(d=getUtmParameter("utm_content"))&&void 0!==d?d:"";if(!o){const i=(yield getCookie("utmsTrack"))||"",t={};i.split("&").forEach((o=>{const e=o.indexOf("=");-1!==e&&(t[o.substring(0,e)]=o.substring(e+1))})),o=(t.utm_source||"").toLowerCase(),e=t.utm_campaign||"",n=t.utm_content||""}const hasNumericId=o=>{var e;if(!o)return!1;const n=-1!==o.indexOf("|")?null!==(e=o.split("|").pop())&&void 0!==e?e:"":o;return/^\d+$/.test(n)};if(-1!==["fb","ig","th","an","msg","facebook","facebookads"].indexOf(o)&&hasNumericId(e)&&!hasNumericId(n))return}const K=(yield getFbp())||(yield getCookie("_fbp"))||"",F=(yield getFbc())||(yield getCookie("_fbc"))||"",H=getUtmParameter("fbclid")||(yield getCookie("_fbclid"))||"",V=(yield getCookie("_ga"))||"",G="undefined"!=typeof navigator?navigator.language.replace("-","_"):"",W=null!==(l=getUtmParameter("utm_term"))&&void 0!==l?l:"",z=null!==(m=null!==(f=null===(a=null===(s=null===(u=null===(r=null===(c=null===self||void 0===self?void 0:self.Shopify)||void 0===c?void 0:c.init)||void 0===r?void 0:r.context)||void 0===u?void 0:u.document)||void 0===s?void 0:s.location)||void 0===a?void 0:a.search)&&void 0!==f?f:null===(v=null===window||void 0===window?void 0:window.location)||void 0===v?void 0:v.search)&&void 0!==m?m:"";let $="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));$=o?o[1]:""}}catch(o){$=""}let J="",q=yield e;J="shoppub"===n?(null==q?void 0:q.customer_id)||"":"shopify"===n||"nuvemshop"===n||"tray"===n||"vtex"===n||"trinio"===n||"magento"===n||"buda"===n||"linx"===n?(null==q?void 0:q.cart_token)||"":"magazord"===n?(null==q?void 0:q.email)||"":"yampi"===n||"woocommerce"===n||"loja_yampi"===n?(null==q?void 0:q.transaction_id)||(null==q?void 0:q.cart_token)||"":"uappi"===n||"bagy"===n||"wake"===n||"wbuy"===n?(null==q?void 0:q.order_id)||"":"cartpanda"===n?(null==q?void 0:q.cart_token)||"":"b4you"===n?(null==q?void 0:q.cart_token)||(null==q?void 0:q.customer_id)||"":"loja_integrada"===n?(null==q?void 0:q.transaction_id)||"":"custom"===n?(null==q?void 0:q.user_id)||"":(null==q?void 0:q.cart_token)||(null==q?void 0:q.customer_id)||(null==q?void 0:q.email)||"";let B=!1;try{const o=performance.getEntriesByType("navigation")[0];B="reload"===(null==o?void 0:o.type)}catch(o){B=1===(null===(p=null===performance||void 0===performance?void 0:performance.navigation)||void 0===p?void 0:p.type)}let Y=null!==(g=null===(h=null===(_=null===(w=null===(y=null===self||void 0===self?void 0:self.Shopify)||void 0===y?void 0:y.init)||void 0===w?void 0:w.context)||void 0===_?void 0:_.document)||void 0===h?void 0:h.referrer)&&void 0!==g?g:null===document||void 0===document?void 0:document.referrer;((null===window||void 0===window?void 0:window.pageViewFired)||B)&&(Y=""),window.pageViewFired=!0;var Q={id:yield getUniqueId(),referrer:Y,path:null!==(E=null!==(T=null===(I=null===(b=null===(x=null===(S=null===(O=null===self||void 0===self?void 0:self.Shopify)||void 0===O?void 0:O.init)||void 0===S?void 0:S.context)||void 0===x?void 0:x.document)||void 0===b?void 0:b.location)||void 0===I?void 0:I.pathname)&&void 0!==T?T:null===(N=null===window||void 0===window?void 0:window.location)||void 0===N?void 0:N.pathname)&&void 0!==E?E:"",utm_source:null!==(j=getUtmParameter("utm_source"))&&void 0!==j?j:"",utm_medium:null!==(D=getUtmParameter("utm_medium"))&&void 0!==D?D:"",utm_campaign:null!==(P=getUtmParameter("utm_campaign"))&&void 0!==P?P:"",utm_term:yield getUniqueId(),utm_content:null!==(k=getUtmParameter("utm_content"))&&void 0!==k?k:"",sol_source:null!==(C=getUtmParameter("sol_source"))&&void 0!==C?C:"",sol_medium:null!==(A=getUtmParameter("sol_medium"))&&void 0!==A?A:"",sol_campaign:null!==(M=getUtmParameter("sol_campaign"))&&void 0!==M?M:"",sol_content:null!==(L=getUtmParameter("sol_content"))&&void 0!==L?L:"",fbp:K,fbc:F,ga_id:V,fbclid:H,locale:G?G.charAt(0).toUpperCase()+G.slice(1):"",timezone:$,osVersion:"undefined"!=typeof navigator?navigator.appVersion.split(" ")[0]:"",screenWidth:"undefined"!=typeof screen?screen.width:0,screenHeight:"undefined"!=typeof screen?screen.height:0,density:"undefined"!=typeof window?window.devicePixelRatio:1,cpuCores:"undefined"!=typeof navigator?navigator.hardwareConcurrency:0,queryParams:z,debug:"",old_id:W,shopify_id:o,current_domain:"undefined"!=typeof window?window.location.hostname:"",cart_token:J,email:null===(U=yield e)||void 0===U?void 0:U.email};return yield updateUTMParametersInCookie(Q,n),Q.utmsTrack=yield getCookie("utmsTrack"),Q})))(n||("undefined"!=typeof window&&(null===(i=window.__SOLOMON__)||void 0===i?void 0:i.accountId)?window.__SOLOMON__.accountId:"undefined"!=typeof self&&(null===(t=self.__SOLOMON__)||void 0===t?void 0:t.accountId)?self.__SOLOMON__.accountId:"undefined"!=typeof window&&(null===(d=window.SOLOMON)||void 0===d?void 0:d.accountId)?window.SOLOMON.accountId:"undefined"!=typeof self&&(null===(l=self.SOLOMON)||void 0===l?void 0:l.accountId)?self.SOLOMON.accountId:""),o,e);var i,t,d,l}));var publish_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};var client_awaiter=function(o,e,n,i){return new(n||(n=Promise))((function(t,d){function fulfilled(o){try{step(i.next(o))}catch(o){d(o)}}function rejected(o){try{step(i.throw(o))}catch(o){d(o)}}function step(o){var e;o.done?t(o.value):(e=o.value,e instanceof n?e:new n((function(o){o(e)}))).then(fulfilled,rejected)}step((i=i.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK] initialized",o)}track(o,e,n){return client_awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK] Tracking event:",o,e);const i=n?Promise.resolve(n):void 0;try{let c;switch(o){case"VIEW_PAGE":{const o="undefined"!=typeof window?window.location.href:"";c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.VIEW_PAGE,o,e)})))({url:o,path:"undefined"!=typeof window?window.location.pathname:void 0},i,this.config.companyId);break}case"CONTENT_VIEW":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CONTENT_VIEW,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_TO_CART":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_TO_CART,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"INITIATE_CHECKOUT":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.INITIATE_CHECKOUT,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_SHIPPING_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_SHIPPING_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_CUSTOMER_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_CUSTOMER_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"ADD_PAYMENT_INFO":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.ADD_PAYMENT_INFO,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;case"CHECKOUT_COMPLETED":c=((o,e,n)=>events_awaiter(void 0,void 0,void 0,(function*(){return yield SolomonEvent(n||getCompanyId(),t.CHECKOUT_COMPLETED,o,e)})))(Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i,this.config.companyId);break;default:c=SolomonEvent(this.config.companyId,o,Object.assign(Object.assign({},e),{url:"undefined"!=typeof window?window.location.href:void 0,path:"undefined"!=typeof window?window.location.pathname:void 0}),i)}if((this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==n?void 0:n.user_id)){const o=yield c;o.user_id=n.user_id,c=Promise.resolve(o)}if(this.config.useTouchpoint){const o=EventTouchpoint(i,"custom",this.config.companyId);yield(d=o,l=this.config.pixelUrl,publish_awaiter(void 0,void 0,void 0,(function*(){var o;const e=yield d;if(!e)return;const n=l||(null===(o=window.__SOLOMON__)||void 0===o?void 0:o.pixelUrl),i=n?(o=>o.replace(/\/+$/,"").replace(/\/event$/,"")+"/event")(n):"https://pixel.solomon.com.br/event";try{const o=yield fetch(i,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else console.error("Erro HTTP ao enviar evento:",o.status,o.statusText)}catch(o){console.error("Erro ao enviar evento:",o)}})))}yield((o,e)=>publish_awaiter(void 0,void 0,void 0,(function*(){var n;const i=yield o;if(!i)return;const t=e||(null===(n=window.__SOLOMON__)||void 0===n?void 0:n.webanalyticsUrl),d=t?(o=>o.replace(/\/+$/,"").replace(/\/event(\?mode=web)?$/,"")+"/event?mode=web")(t):`https://webanalytics.solomon.com.br/event?mode=web&event=${null==i?void 0:i.event_type}`;try{const o=yield fetch(d,{method:"POST",mode:"cors",credentials:"omit",headers:{"content-type":"application/json"},body:JSON.stringify(i)});if(o.ok){const e=yield o.text();e&&JSON.parse(e)}else{console.error("[Solomon] Erro HTTP ao enviar evento:",o.status,o.statusText);const e=yield o.text().catch((()=>"Unable to read error response"));console.error("[Solomon] Response error details:",e)}}catch(o){console.error("Erro ao enviar evento:",o)}})))(c,this.config.webanalyticsUrl),this.config.debug&&console.log("[SolomonSDK] Event tracked successfully:",o)}catch(o){throw console.error("[SolomonSDK] Error tracking event:",o),o}var d,l}))}}return e})()));
|
package/dist/sdk/utils.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ declare const getLocalStorage: (name: string) => Promise<string | null>;
|
|
|
3
3
|
declare const getAllStorage: (name: string) => Promise<string | null>;
|
|
4
4
|
declare const getMainDomain: () => string;
|
|
5
5
|
declare const setCookie: (name: string, value: string, duration?: number, domain?: string) => Promise<void>;
|
|
6
|
+
declare const setUtmsTrackCookie: (params: Record<string, string>, durationDays: number) => Promise<void>;
|
|
6
7
|
declare const setAllStorage: (name: string, value: string, duration?: number) => Promise<void>;
|
|
7
8
|
declare function formatPhone(phone: string): string;
|
|
8
9
|
declare const getCompanyId: () => string;
|
|
9
10
|
declare const getUtmParameter: (parameter: string) => string;
|
|
10
11
|
declare const generator: () => string;
|
|
11
|
-
export { getCookie, setCookie, generator, getMainDomain, getLocalStorage, getAllStorage, setAllStorage, formatPhone, getCompanyId, getUtmParameter };
|
|
12
|
+
export { getCookie, setCookie, setUtmsTrackCookie, generator, getMainDomain, getLocalStorage, getAllStorage, setAllStorage, formatPhone, getCompanyId, getUtmParameter };
|
package/dist/sdk/utils.js
CHANGED
|
@@ -121,6 +121,29 @@ const setCookie = (name, value, duration, domain) => __awaiter(void 0, void 0, v
|
|
|
121
121
|
document.cookie = cookie;
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
+
const setUtmsTrackCookie = (params, durationDays) => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
const parts = [];
|
|
126
|
+
for (const k in params) {
|
|
127
|
+
if (!Object.prototype.hasOwnProperty.call(params, k))
|
|
128
|
+
continue;
|
|
129
|
+
const v = params[k];
|
|
130
|
+
if (v === undefined || v === null || v === '')
|
|
131
|
+
continue;
|
|
132
|
+
parts.push(k + '=' + encodeURIComponent(v));
|
|
133
|
+
}
|
|
134
|
+
const value = parts.join('&');
|
|
135
|
+
const date = new Date();
|
|
136
|
+
date.setTime(date.getTime() + durationDays * 24 * 60 * 60 * 1000);
|
|
137
|
+
const cookie = 'utmsTrack=' + value
|
|
138
|
+
+ '; expires=' + date.toUTCString()
|
|
139
|
+
+ '; path=/; SameSite=Lax';
|
|
140
|
+
if ((self === null || self === void 0 ? void 0 : self.Shopify) && (self === null || self === void 0 ? void 0 : self.Shopify.browser)) {
|
|
141
|
+
yield self.Shopify.browser.cookie.set(cookie);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
document.cookie = cookie;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
124
147
|
const setLocalStorage = (name, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
148
|
var _a;
|
|
126
149
|
if ((_a = self === null || self === void 0 ? void 0 : self.Shopify) === null || _a === void 0 ? void 0 : _a.browser) {
|
|
@@ -174,7 +197,7 @@ const getUtmParameter = (parameter) => {
|
|
|
174
197
|
urlParams.append(key, value);
|
|
175
198
|
});
|
|
176
199
|
}
|
|
177
|
-
const values = urlParams.getAll(parameter);
|
|
200
|
+
const values = urlParams.getAll(parameter).filter(value => !value.includes('"'));
|
|
178
201
|
try {
|
|
179
202
|
const company_id = getCompanyId();
|
|
180
203
|
if (company_id && company_id === '8WX2T4ZJz6JonRNrjhOj') {
|
|
@@ -205,4 +228,4 @@ const getUtmParameter = (parameter) => {
|
|
|
205
228
|
const generator = () => {
|
|
206
229
|
return Math.random().toString(36).slice(2, 11) + "_" + new Date().getTime();
|
|
207
230
|
};
|
|
208
|
-
export { getCookie, setCookie, generator, getMainDomain, getLocalStorage, getAllStorage, setAllStorage, formatPhone, getCompanyId, getUtmParameter };
|
|
231
|
+
export { getCookie, setCookie, setUtmsTrackCookie, generator, getMainDomain, getLocalStorage, getAllStorage, setAllStorage, formatPhone, getCompanyId, getUtmParameter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solomon-tech/webanalytics-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Solomon WebAnalytics SDK — browser and Node.js event tracking",
|
|
5
5
|
"main": "./dist/sdk/solomon-sdk.esm.min.js",
|
|
6
6
|
"types": "./dist/sdk/sdk/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"build:shopify": "webpack --env platform=shopify",
|
|
27
27
|
"build:shopify-web": "webpack --env platform=shopify-web",
|
|
28
28
|
"build:yampi": "webpack --env platform=yampi",
|
|
29
|
+
"build:loja_yampi": "webpack --env platform=loja_yampi",
|
|
29
30
|
"build:nuvemshop": "webpack --env platform=nuvemshop",
|
|
30
31
|
"build:magazord": "webpack --env platform=magazord",
|
|
31
32
|
"build:vtex": "webpack --env platform=vtex",
|
|
@@ -45,6 +46,8 @@
|
|
|
45
46
|
"build:b4you": "webpack --env platform=b4you",
|
|
46
47
|
"build:linx": "webpack --env platform=linx",
|
|
47
48
|
"build:loja_integrada": "webpack --env platform=loja_integrada",
|
|
49
|
+
"build:olist": "webpack --env platform=olist",
|
|
50
|
+
"build:irroba": "webpack --env platform=irroba",
|
|
48
51
|
"build:sdk": "webpack --config webpack.sdk.config.js && npm run build:sdk:types",
|
|
49
52
|
"build:sdk:npm": "webpack --config webpack.sdk.npm.config.js && webpack --config webpack.sdk.node.config.js && webpack --config webpack.sdk.node.cjs.config.js && npm run build:sdk:types && npm run build:sdk:cleanup",
|
|
50
53
|
"build:sdk:cleanup": "rm -f dist/sdk/types.d.ts dist/sdk/types.js",
|