@solomon-tech/webanalytics-sdk 1.0.2 → 1.0.5
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/sdk/core/client.js +1 -1
- package/dist/sdk/sdk/node/client.d.ts +5 -0
- package/dist/sdk/sdk/node/client.js +80 -15
- package/dist/sdk/sdk/node/index.d.ts +1 -1
- package/dist/sdk/solomon-sdk.esm.min.js +1 -1
- package/dist/sdk/solomon-sdk.min.js +1 -1
- package/dist/sdk/solomon-sdk.node.esm.min.js +1 -1
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ export class SolomonSDK {
|
|
|
63
63
|
eventPromise = SolomonEventFn(this.config.companyId, event, Object.assign(Object.assign({}, payload), { url: typeof window !== "undefined" ? window.location.href : undefined, path: typeof window !== "undefined" ? window.location.pathname : undefined }), aliasesPromise);
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
|
-
if (this.config.identifyByAlias && (aliases === null || aliases === void 0 ? void 0 : aliases.user_id)) {
|
|
66
|
+
if ((this.config.identifyByAlias || this.config.companyId === 'G6fGRIcYL8qJ06SukNdV') && (aliases === null || aliases === void 0 ? void 0 : aliases.user_id)) {
|
|
67
67
|
const event = yield eventPromise;
|
|
68
68
|
event.user_id = aliases.user_id;
|
|
69
69
|
eventPromise = Promise.resolve(event);
|
|
@@ -3,10 +3,15 @@ import type { CustomAliases } from "../core/types";
|
|
|
3
3
|
export interface NodeSDKConfig {
|
|
4
4
|
companyId: string;
|
|
5
5
|
debug?: boolean;
|
|
6
|
+
identifyByAlias?: boolean;
|
|
7
|
+
useTouchpoint?: boolean;
|
|
6
8
|
webanalyticsUrl?: string;
|
|
9
|
+
pixelUrl?: string;
|
|
10
|
+
userAgent?: string;
|
|
7
11
|
}
|
|
8
12
|
export declare class SolomonSDK {
|
|
9
13
|
private config;
|
|
10
14
|
constructor(config: NodeSDKConfig);
|
|
11
15
|
track<E extends SolomonEvent>(event: E, payload?: SolomonPayload<E>, aliases?: CustomAliases): Promise<void>;
|
|
16
|
+
private buildTouchpointEvent;
|
|
12
17
|
}
|
|
@@ -8,12 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { randomUUID } from "crypto";
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_WEBANALYTICS_URL = "https://webanalytics.solomon.com.br/event?mode=web";
|
|
12
|
+
const DEFAULT_PIXEL_URL = "https://pixel.solomon.com.br/event";
|
|
13
|
+
const DEFAULT_USER_AGENT = "Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.5)";
|
|
14
|
+
const BRENDI_COMPANY_ID = "G6fGRIcYL8qJ06SukNdV";
|
|
15
|
+
const DUMMY_SESSION_ID = "00000000-0000-4000-8000-000000000000";
|
|
12
16
|
export class SolomonSDK {
|
|
13
17
|
constructor(config) {
|
|
14
18
|
this.config = config;
|
|
15
19
|
if (this.config.debug) {
|
|
16
|
-
console.log("[SolomonSDK:Node] initialized",
|
|
20
|
+
console.log("[SolomonSDK:Node] initialized", {
|
|
21
|
+
companyId: config.companyId,
|
|
22
|
+
useTouchpoint: config.useTouchpoint,
|
|
23
|
+
});
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
track(event, payload, aliases) {
|
|
@@ -21,12 +28,17 @@ export class SolomonSDK {
|
|
|
21
28
|
if (this.config.debug) {
|
|
22
29
|
console.log("[SolomonSDK:Node] Tracking event:", event, payload);
|
|
23
30
|
}
|
|
31
|
+
const identifyByAlias = this.config.identifyByAlias || this.config.companyId === BRENDI_COMPANY_ID;
|
|
32
|
+
const userId = (identifyByAlias && (aliases === null || aliases === void 0 ? void 0 : aliases.user_id)) ? aliases.user_id : randomUUID();
|
|
24
33
|
const eventData = {
|
|
25
34
|
company_id: this.config.companyId,
|
|
26
35
|
event_id: randomUUID(),
|
|
27
36
|
event_time: new Date().toISOString(),
|
|
28
|
-
session_id:
|
|
29
|
-
user_id:
|
|
37
|
+
session_id: DUMMY_SESSION_ID,
|
|
38
|
+
user_id: userId,
|
|
39
|
+
fbp: "",
|
|
40
|
+
fbc: "",
|
|
41
|
+
legacy_id: "",
|
|
30
42
|
custom_aliases: {
|
|
31
43
|
user_id: (aliases === null || aliases === void 0 ? void 0 : aliases.user_id) || "",
|
|
32
44
|
email: (aliases === null || aliases === void 0 ? void 0 : aliases.email) || "",
|
|
@@ -48,21 +60,39 @@ export class SolomonSDK {
|
|
|
48
60
|
sol_campaign: "",
|
|
49
61
|
sol_content: "",
|
|
50
62
|
event_payload: payload || {},
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
voxus_url: "",
|
|
64
|
+
};
|
|
65
|
+
const webanalyticsUrl = this.config.webanalyticsUrl || DEFAULT_WEBANALYTICS_URL;
|
|
66
|
+
const pixelUrl = this.config.pixelUrl || DEFAULT_PIXEL_URL;
|
|
67
|
+
const headers = {
|
|
68
|
+
"Content-Type": "application/json",
|
|
69
|
+
"User-Agent": this.config.userAgent || DEFAULT_USER_AGENT,
|
|
53
70
|
};
|
|
54
|
-
const url = this.config.webanalyticsUrl || DEFAULT_URL;
|
|
55
71
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
const promises = [
|
|
73
|
+
fetch(webanalyticsUrl, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers,
|
|
76
|
+
body: JSON.stringify(eventData),
|
|
77
|
+
}),
|
|
78
|
+
];
|
|
79
|
+
if (this.config.useTouchpoint) {
|
|
80
|
+
const touchpointData = this.buildTouchpointEvent(userId);
|
|
81
|
+
promises.push(fetch(pixelUrl, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers,
|
|
84
|
+
body: JSON.stringify(touchpointData),
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
const responses = yield Promise.all(promises);
|
|
88
|
+
if (!responses[0].ok) {
|
|
89
|
+
throw new Error(`Event HTTP ${responses[0].status}: ${yield responses[0].text()}`);
|
|
90
|
+
}
|
|
91
|
+
if (responses[1] && !responses[1].ok) {
|
|
92
|
+
console.error(`[SolomonSDK:Node] Touchpoint HTTP ${responses[1].status}: ${yield responses[1].text()}`);
|
|
63
93
|
}
|
|
64
94
|
if (this.config.debug) {
|
|
65
|
-
console.log("[SolomonSDK:Node] Event sent:", event);
|
|
95
|
+
console.log("[SolomonSDK:Node] Event sent:", event, this.config.useTouchpoint ? "(+ touchpoint)" : "");
|
|
66
96
|
}
|
|
67
97
|
}
|
|
68
98
|
catch (error) {
|
|
@@ -71,4 +101,39 @@ export class SolomonSDK {
|
|
|
71
101
|
}
|
|
72
102
|
});
|
|
73
103
|
}
|
|
104
|
+
buildTouchpointEvent(userId) {
|
|
105
|
+
return {
|
|
106
|
+
id: userId,
|
|
107
|
+
referrer: "",
|
|
108
|
+
path: "",
|
|
109
|
+
utm_source: "",
|
|
110
|
+
utm_medium: "",
|
|
111
|
+
utm_campaign: "",
|
|
112
|
+
utm_term: userId,
|
|
113
|
+
utm_content: "",
|
|
114
|
+
sol_source: "",
|
|
115
|
+
sol_medium: "",
|
|
116
|
+
sol_campaign: "",
|
|
117
|
+
sol_content: "",
|
|
118
|
+
fbp: "",
|
|
119
|
+
fbc: "",
|
|
120
|
+
ga_id: "",
|
|
121
|
+
fbclid: "",
|
|
122
|
+
locale: "",
|
|
123
|
+
timezone: "",
|
|
124
|
+
osVersion: "",
|
|
125
|
+
screenWidth: 0,
|
|
126
|
+
screenHeight: 0,
|
|
127
|
+
density: 1,
|
|
128
|
+
cpuCores: 0,
|
|
129
|
+
queryParams: "",
|
|
130
|
+
debug: "",
|
|
131
|
+
old_id: "",
|
|
132
|
+
shopify_id: this.config.companyId,
|
|
133
|
+
current_domain: "",
|
|
134
|
+
cart_token: userId,
|
|
135
|
+
email: "",
|
|
136
|
+
utmsTrack: "",
|
|
137
|
+
};
|
|
138
|
+
}
|
|
74
139
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SolomonSDK } from "./client";
|
|
2
2
|
export type { NodeSDKConfig } from "./client";
|
|
3
3
|
export type { SolomonEvent, SolomonPayload } from "../core/events";
|
|
4
|
-
export type { CustomAliases } from "../core/types";
|
|
4
|
+
export type { CustomAliases, Product } from "../core/types";
|
|
5
5
|
export { SolomonSDK as default } from "./client";
|
|
@@ -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 W="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));W=o?o[1]:""}}catch(o){W=""}let G="",z=yield e;G="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:W,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:G,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&&(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,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 +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 W="";try{if("undefined"!=typeof navigator){const o=/.*\s(.+)/.exec((new Date).toLocaleDateString(navigator.language,{timeZoneName:"short"}));W=o?o[1]:""}}catch(o){W=""}let G="",z=yield e;G="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:W,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:G,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&&(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,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 +1 @@
|
|
|
1
|
-
import{createRequire as o}from"node:module";var e={d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},t={};e.d(t,{C:()=>SolomonSDK,A:()=>SolomonSDK});const n=o(import.meta.url)("crypto");var __awaiter=function(o,e,t,n){return new(t||(t=Promise))((function(i,r){function fulfilled(o){try{step(n.next(o))}catch(o){r(o)}}function rejected(o){try{step(n.throw(o))}catch(o){r(o)}}function step(o){var e;o.done?i(o.value):(e=o.value,e instanceof t?e:new t((function(o){o(e)}))).then(fulfilled,rejected)}step((n=n.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK:Node] initialized",o)}track(o,e,t){return __awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK:Node] Tracking event:",o,e);const i=
|
|
1
|
+
import{createRequire as o}from"node:module";var e={d:(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)},t={};e.d(t,{C:()=>SolomonSDK,A:()=>SolomonSDK});const n=o(import.meta.url)("crypto");var __awaiter=function(o,e,t,n){return new(t||(t=Promise))((function(i,r){function fulfilled(o){try{step(n.next(o))}catch(o){r(o)}}function rejected(o){try{step(n.throw(o))}catch(o){r(o)}}function step(o){var e;o.done?i(o.value):(e=o.value,e instanceof t?e:new t((function(o){o(e)}))).then(fulfilled,rejected)}step((n=n.apply(o,e||[])).next())}))};class SolomonSDK{constructor(o){this.config=o,this.config.debug&&console.log("[SolomonSDK:Node] initialized",{companyId:o.companyId,useTouchpoint:o.useTouchpoint})}track(o,e,t){return __awaiter(this,void 0,void 0,(function*(){this.config.debug&&console.log("[SolomonSDK:Node] Tracking event:",o,e);const i=(this.config.identifyByAlias||"G6fGRIcYL8qJ06SukNdV"===this.config.companyId)&&(null==t?void 0:t.user_id)?t.user_id:(0,n.randomUUID)(),r={company_id:this.config.companyId,event_id:(0,n.randomUUID)(),event_time:(new Date).toISOString(),session_id:"00000000-0000-4000-8000-000000000000",user_id:i,fbp:"",fbc:"",legacy_id:"",custom_aliases:{user_id:(null==t?void 0:t.user_id)||"",email:(null==t?void 0:t.email)||"",phone:(null==t?void 0:t.phone)||"",customer_id:(null==t?void 0:t.customer_id)||"",cart_token:(null==t?void 0:t.cart_token)||"",order_id:(null==t?void 0:t.order_id)||""},event_type:o,page_referrer:"",page_path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",event_payload:e||{},voxus_url:""},c=this.config.webanalyticsUrl||"https://webanalytics.solomon.com.br/event?mode=web",s=this.config.pixelUrl||"https://pixel.solomon.com.br/event",l={"Content-Type":"application/json","User-Agent":this.config.userAgent||"Mozilla/5.0 (compatible; SolomonSDK-Node/1.0.5)"};try{const e=[fetch(c,{method:"POST",headers:l,body:JSON.stringify(r)})];if(this.config.useTouchpoint){const o=this.buildTouchpointEvent(i);e.push(fetch(s,{method:"POST",headers:l,body:JSON.stringify(o)}))}const t=yield Promise.all(e);if(!t[0].ok)throw new Error(`Event HTTP ${t[0].status}: ${yield t[0].text()}`);t[1]&&!t[1].ok&&console.error(`[SolomonSDK:Node] Touchpoint HTTP ${t[1].status}: ${yield t[1].text()}`),this.config.debug&&console.log("[SolomonSDK:Node] Event sent:",o,this.config.useTouchpoint?"(+ touchpoint)":"")}catch(o){throw console.error("[SolomonSDK:Node] Error sending event:",o),o}}))}buildTouchpointEvent(o){return{id:o,referrer:"",path:"",utm_source:"",utm_medium:"",utm_campaign:"",utm_term:o,utm_content:"",sol_source:"",sol_medium:"",sol_campaign:"",sol_content:"",fbp:"",fbc:"",ga_id:"",fbclid:"",locale:"",timezone:"",osVersion:"",screenWidth:0,screenHeight:0,density:1,cpuCores:0,queryParams:"",debug:"",old_id:"",shopify_id:this.config.companyId,current_domain:"",cart_token:o,email:"",utmsTrack:""}}}var i=t.C,r=t.A;export{i as SolomonSDK,r as default};
|
package/package.json
CHANGED