@solomon-tech/webanalytics-sdk 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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);
@@ -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})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solomon-tech/webanalytics-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Solomon WebAnalytics SDK — browser and Node.js event tracking",
5
5
  "main": "./dist/sdk/solomon-sdk.esm.min.js",
6
6
  "types": "./dist/sdk/sdk/index.d.ts",