@salla.sa/analytics 2.14.582 → 2.14.584

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./chunks/extra-context-3SkJXnof.js"),e=require("@jitsu/js"),i={get(t,e=null){const i="undefined"!=typeof window?window.initialData:null;if(!i||"object"!=typeof i)return e;let s=i;for(const i of t.split(".")){if(null==s||"object"!=typeof s||!(i in s))return e;s=s[i]}return void 0!==s?s:e}};const s="s-session-id";let n=null;function r(t){return`${t}_${i.get("store.id")}`}var o={SESSION_STORAGE_KEY:s,SESSION_TTL_MINUTES:30,resolve:()=>(n||(n=function(t,e=null){try{const i=localStorage.getItem(r(t));if(!i)return e;const s=JSON.parse(i);return s&&"object"==typeof s?(new Date).getTime()>s.expiry?(localStorage.removeItem(r(t)),e):s.value:e}catch(t){return e}}(s)||t.generateSessionId()),function(t,e,i=30){try{const s=(new Date).getTime()+60*i*1e3;localStorage.setItem(r(t),JSON.stringify({value:e,expiry:s}))}catch(t){}}(s,n),n)};class a{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u;return{event:"Checkout Started",properties:{checkout_id:null==(t=window.initialData)||null==(t=t.cart)?void 0:t.id,order_id:(null==(e=this.transaction)||null==(e=e.order_id)?void 0:e.toString())||"",cart_id:(null==(i=this.transaction)||null==(i=i.cart_id)?void 0:i.toString())||"",affiliation:(null==(s=this.transaction)?void 0:s.affiliation)||"",value:(null==(n=this.transaction)?void 0:n.value)||0,revenue:(null==(r=this.transaction)?void 0:r.revenue)||0,shipping:(null==(o=this.transaction)?void 0:o.shipping)||0,tax:(null==(a=this.transaction)?void 0:a.tax)||0,discount:(null==(d=this.transaction)?void 0:d.discount)||0,coupon:(null==(c=this.transaction)?void 0:c.coupon)||"",currency:(null==(l=this.transaction)?void 0:l.currency)||"",products:((null==(u=this.transaction)?void 0:u.products)||[]).map(t=>{var e;return{product_id:(null==t||null==(e=t.product_id)?void 0:e.toString())||"",sku:(null==t?void 0:t.sku)||"",name:(null==t?void 0:t.name)||"",price:(null==t?void 0:t.price)||0,quantity:(null==t?void 0:t.quantity)||0,category:(null==t?void 0:t.category)||"",url:(null==t?void 0:t.url)||"",image_url:(null==t?void 0:t.image_url)||""}})}}}}class d{constructor(t){this.transaction=t}toSegment(){return{event:"Payment Info Entered",properties:{order_id:this.transaction.order_id,payment_method:this.transaction.payment_method,checkout_id:this.transaction.checkout_id}}}}class c{constructor(t){this.details=t||{}}toSegment(){var e;return{event:"Checkout Step Viewed",properties:t._extends({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:null!=(e=this.details.payment_method)?e:""},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class l{constructor(t){this.details=t||{}}toSegment(){return{event:"Checkout Step Completed",properties:t._extends({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:this.details.payment_method},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class u{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Entered",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,value:this.transaction.value,currency:this.transaction.currency}}}}class h{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class p{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,reason:this.transaction.reason}}}}class m{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class _{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u,h,p,m,_,v,y;return{event:"Address Added",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{local:null==(o=this.transaction.address)?void 0:o.local,street:null==(a=this.transaction.address)?void 0:a.street,postal_code:null==(d=this.transaction.address)?void 0:d.postal_code,short_address:null==(c=this.transaction.address)?void 0:c.short_address,region:{id:null==(l=this.transaction.address)||null==(l=l.region)?void 0:l.id,name:null==(u=this.transaction.address)||null==(u=u.region)?void 0:u.name},city:{id:null==(h=this.transaction.address)||null==(h=h.city)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.city)?void 0:p.name},country:{id:null==(m=this.transaction.address)||null==(m=m.country)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.country)?void 0:_.name},district:{id:null==(v=this.transaction.address)||null==(v=v.district)?void 0:v.id,name:null==(y=this.transaction.address)||null==(y=y.district)?void 0:y.name}}}}}}class v{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u,h,p,m,_,v,y;return{event:"Address Updated",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{local:null==(o=this.transaction.address)?void 0:o.local,street:null==(a=this.transaction.address)?void 0:a.street,postal_code:null==(d=this.transaction.address)?void 0:d.postal_code,short_address:null==(c=this.transaction.address)?void 0:c.short_address,region:{id:null==(l=this.transaction.address)||null==(l=l.region)?void 0:l.id,name:null==(u=this.transaction.address)||null==(u=u.region)?void 0:u.name},city:{id:null==(h=this.transaction.address)||null==(h=h.city)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.city)?void 0:p.name},country:{id:null==(m=this.transaction.address)||null==(m=m.country)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.country)?void 0:_.name},district:{id:null==(v=this.transaction.address)||null==(v=v.district)?void 0:v.id,name:null==(y=this.transaction.address)||null==(y=y.district)?void 0:y.name}}}}}}class y{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a;return{event:"Map Clicked",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{lat:null==(o=this.transaction.address)?void 0:o.lat,lng:null==(a=this.transaction.address)?void 0:a.lng}}}}}class g{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Submitted",properties:{checkout_id:this.details.checkout_id||i.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,is_order_free:this.details.is_order_free,cart_total:this.details.cart_total||i.get("cart.total_in_customer_currency",0),shipping_method:this.details.shipping_method,has_partial_payment:this.details.has_partial_payment||!1}}}}const k=/\b(?:\d[ -]?){13,19}\b/g,f=/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,S=t=>t?String(t).replace(k,"[REDACTED]").replace(f,"[REDACTED]").slice(0,500):"",C=t=>t&&"object"==typeof t?Object.keys(t).map(e=>{const i=Array.isArray(t[e])?t[e][0]:t[e],s=i&&"object"==typeof i?i.message||JSON.stringify(i):i;return{field:e,message:S(s)}}):[];class x{constructor(t){this.details=t||{}}toSegment(){const t=this.details.error_fields||{},e=t&&"object"==typeof t?Object.keys(t):[];return{event:"Payment Failed",properties:{checkout_id:this.details.checkout_id||i.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,error_code:this.details.error_code,error_type:this.details.error_type,error_message:S(this.details.error_message),http_status:this.details.http_status,error_fields:e,field_errors:C(t)}}}}class w{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Succeeded",properties:{checkout_id:this.details.checkout_id||i.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,response_status:this.details.response_status,has_redirect:this.details.has_redirect||!1,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||i.get("cart.total_in_customer_currency",0)}}}}class E{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Pending",properties:{checkout_id:this.details.checkout_id||i.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||i.get("cart.total_in_customer_currency",0)}}}}class P{constructor(t){this.details=t||{}}toSegment(){return{event:"Gift Card Redeemed",properties:t.mapGiftCardRedeemedFields({source:"checkout",customer_id:i.get("customer.id"),store_id:i.get("store.id")},this.details)}}}var T=new class{constructor(){this.events={"Checkout Started":a,"Payment Info Entered":d,"Checkout Step Viewed":c,"Checkout Step Completed":l,"Coupon Entered":u,"Coupon Applied":h,"Coupon Denied":p,"Coupon Removed":m,"Address Added":_,"Address Updated":v,"Map Clicked":y,"Payment Submitted":g,"Payment Failed":x,"Payment Succeeded":w,"Payment Pending":E,"Gift Card Redeemed":P}}transform(t,e){const i=this.events[t];if(!i)return null;try{const t=new i(e).toSegment();return null!=t&&t.properties&&null!=e&&e.checkout_type&&(t.properties.checkout_type=e.checkout_type),t}catch(t){return console.error("Failed to transform event:",t),null}}};exports.SessionService=o,exports.default=class{constructor(){this.history=[],this.customTrackers=[],this.context={},this.events=[],this._sessionId=null,this.mappedEvents={"payment::method_updated":"Payment Info Entered","checkout::step_viewed":"Checkout Step Viewed","checkout::step_completed":"Checkout Step Completed","coupon::applied":"Coupon Applied","coupon::denied":"Coupon Denied","coupon::entered":"Coupon Entered","coupon::removed":"Coupon Removed","address::added":"Address Added","address::updated":"Address Updated","map::clicked":"Map Clicked","payment::submitted":"Payment Submitted","payment::failed":"Payment Failed","payment::succeeded":"Payment Succeeded","payment::pending":"Payment Pending","giftcard::redeemed":"Gift Card Redeemed"};const t=i.get("config.jitsu",{}),s=i.get("store.url",null),{host:n,key:r}=t||{};this.analytics=null,n&&r&&(this.analytics=e.jitsuAnalytics({host:this.getAnalyticsHost(s),writeKey:r,cookieCapture:this.captureCookies()}),this.events=i.get("config.jitsu.events",[]),i.get("config.jitsu.context.extra",{})&&this.setExtraContext(i.get("config.jitsu.context.extra",{})),this.initSessionId(),this.setSignedInCustomerTraits(),this.page())}setSignedInCustomerTraits(){const t=i.get("customer");t&&t.id&&this.setTraits(t)}setTraits(t){t&&this.setContext("traits",t)}initSessionId(){this._sessionId=o.resolve(),this.setContext("session_id",this._sessionId)}captureCookies(){return t.captureSallaCookies()}getAnalyticsHost(e){var i;return t.resolveAnalyticsHost(e,{documentOrigin:"undefined"!=typeof window?null==(i=window.location)?void 0:i.origin:null,log:console.log})}trackSallaEvent(t){var e;if("customer::identified"===t.type)return this.setTraits(t.detail);const i=null!=(e=this.mappedEvents[t.type])?e:t.type;if(this.analytics&&this.events.includes(i))try{if(!i)return;const e=T.transform(i,t.detail);e&&this.track(e.event,e.properties)}catch(t){console.log(t)}}track(t,e={}){return this.analytics?(e=this.finalPayload(e),this.analytics.track(t,e).then(i=>(this.pushEventToCustomTrackers("track",t,e),i)).then(()=>{this.history.push({action:"track",eventName:t,payload:e})}).catch(t=>Promise.reject(t))):Promise.resolve()}page(t={}){if(!this.analytics)return Promise.resolve();const e=this.finalPayload(t);return this.analytics.page(e).then(t=>(this.pushEventToCustomTrackers("page",e),t)).then(()=>{this.history.push({action:"page",payload:e})}).catch(t=>Promise.reject(t))}finalPayload(e={}){var s;let n={session_id:o.resolve(),cart_id:i.get("cart.id")||e.cart_id||e.checkout_id||null,requires_shipping:Boolean(i.get("cart.requires_shipping",!1))};return this.setContext("version",i.get("config.jitsu.version",1)),this.setContext("store_id",i.get("config.store.id")),n.session_id&&this.setContext("session_id",n.session_id),e.event_id=e.event_id||t.generateSessionId(),t._extends({},n,e,{session_id:e.session_id||n.session_id,cart_id:e.cart_id||n.cart_id,requires_shipping:null!=(s=e.requires_shipping)?s:n.requires_shipping})}registerTracker(e){t.isValidTracker(e,this.customTrackers,console.log)&&(this.customTrackers.push(e),t.replayHistory(e,this.history))}pushEventToCustomTrackers(e,i,s={}){return t.pushEventToTrackers(this.customTrackers,e,i,s,console.log)}setContext(t,e){var i;null==(i=this.analytics)||i.setContextProperty(t,e),this.context[t]=e}setExtraContext(e){t.applyExtraContext((t,e)=>this.setContext(t,e),e,console.log)}},exports.initialData=i,exports.sanitizeErrorMessage=S,exports.sanitizeFieldErrors=C;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./chunks/extra-context-3SkJXnof.js"),e=require("@jitsu/js"),s={get(t,e=null){const s="undefined"!=typeof window?window.initialData:null;if(!s||"object"!=typeof s)return e;let i=s;for(const s of t.split(".")){if(null==i||"object"!=typeof i||!(s in i))return e;i=i[s]}return void 0!==i?i:e}};const i="s-session-id";let n=null;function r(t){return`${t}_${s.get("store.id")}`}var o={SESSION_STORAGE_KEY:i,SESSION_TTL_MINUTES:30,resolve:()=>(n||(n=function(t,e=null){try{const s=localStorage.getItem(r(t));if(!s)return e;const i=JSON.parse(s);return i&&"object"==typeof i?(new Date).getTime()>i.expiry?(localStorage.removeItem(r(t)),e):i.value:e}catch(t){return e}}(i)||t.generateSessionId()),function(t,e,s=30){try{const i=(new Date).getTime()+60*s*1e3;localStorage.setItem(r(t),JSON.stringify({value:e,expiry:i}))}catch(t){}}(i,n),n)};class a{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,l,c,u;return{event:"Checkout Started",properties:{checkout_id:null==(t=window.initialData)||null==(t=t.cart)?void 0:t.id,order_id:(null==(e=this.transaction)||null==(e=e.order_id)?void 0:e.toString())||"",cart_id:(null==(s=this.transaction)||null==(s=s.cart_id)?void 0:s.toString())||"",affiliation:(null==(i=this.transaction)?void 0:i.affiliation)||"",value:(null==(n=this.transaction)?void 0:n.value)||0,revenue:(null==(r=this.transaction)?void 0:r.revenue)||0,shipping:(null==(o=this.transaction)?void 0:o.shipping)||0,tax:(null==(a=this.transaction)?void 0:a.tax)||0,discount:(null==(d=this.transaction)?void 0:d.discount)||0,coupon:(null==(l=this.transaction)?void 0:l.coupon)||"",currency:(null==(c=this.transaction)?void 0:c.currency)||"",products:((null==(u=this.transaction)?void 0:u.products)||[]).map(t=>{var e;return{product_id:(null==t||null==(e=t.product_id)?void 0:e.toString())||"",sku:(null==t?void 0:t.sku)||"",name:(null==t?void 0:t.name)||"",price:(null==t?void 0:t.price)||0,quantity:(null==t?void 0:t.quantity)||0,category:(null==t?void 0:t.category)||"",url:(null==t?void 0:t.url)||"",image_url:(null==t?void 0:t.image_url)||""}})}}}}class d{constructor(t){this.transaction=t}toSegment(){return{event:"Payment Info Entered",properties:{order_id:this.transaction.order_id,payment_method:this.transaction.payment_method,checkout_id:this.transaction.checkout_id}}}}class l{constructor(t){this.details=t||{}}toSegment(){var e;return{event:"Checkout Step Viewed",properties:t._extends({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:null!=(e=this.details.payment_method)?e:""},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}const c=/\b(?:\d[ -]?){13,19}\b/g,u=/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,h=t=>t?String(t).replace(c,"[REDACTED]").replace(u,"[REDACTED]").slice(0,500):"",p=t=>t&&"object"==typeof t?Object.keys(t).map(e=>{const s=Array.isArray(t[e])?t[e][0]:t[e],i=s&&"object"==typeof s?s.message||JSON.stringify(s):s;return{field:e,message:h(i)}}):[];class _{constructor(t){this.details=t||{}}toSegment(){var e,s,i,n;const r=this.details.error||{},o=r.fields||{},a=Object.keys(o);return{event:"Checkout Step Completed",properties:t._extends({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:this.details.payment_method,success:null==(e=this.details.success)||e,error_code:null!=(s=r.code)?s:null,error_type:null!=(i=r.type)?i:null,error_message:h(r.message),http_status:null!=(n=r.status)?n:null,error_fields:a,field_errors:p(o)},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class m{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Entered",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,value:this.transaction.value,currency:this.transaction.currency}}}}class y{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class v{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,reason:this.transaction.reason}}}}class g{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class f{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,l,c,u,_,m,y,v,g,f,k,S,C,x,w,E;const P=this.transaction.error||{},T=P.fields||{},b=Object.keys(T),j=null==(t=this.transaction.address)?void 0:t.lat,A=null==(e=this.transaction.address)?void 0:e.lng,I=Boolean(j)||Boolean(A);return{event:"Address Added",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(s=this.transaction.customer)?void 0:s.id,name:(null==(i=this.transaction.customer)?void 0:i.first_name)+" "+(null==(n=this.transaction.customer)?void 0:n.last_name),mobile:null==(r=this.transaction.customer)?void 0:r.mobile,email:null==(o=this.transaction.customer)?void 0:o.email,gender:null==(a=this.transaction.customer)?void 0:a.gender},address:{local:null==(d=this.transaction.address)?void 0:d.local,street:null==(l=this.transaction.address)?void 0:l.street,postal_code:null==(c=this.transaction.address)?void 0:c.postal_code,short_address:null==(u=this.transaction.address)?void 0:u.short_address,region:{id:null==(_=this.transaction.address)||null==(_=_.region)?void 0:_.id,name:null==(m=this.transaction.address)||null==(m=m.region)?void 0:m.name},city:{id:null==(y=this.transaction.address)||null==(y=y.city)?void 0:y.id,name:null==(v=this.transaction.address)||null==(v=v.city)?void 0:v.name},country:{id:null==(g=this.transaction.address)||null==(g=g.country)?void 0:g.id,name:null==(f=this.transaction.address)||null==(f=f.country)?void 0:f.name},district:{id:null==(k=this.transaction.address)||null==(k=k.district)?void 0:k.id,name:null==(S=this.transaction.address)||null==(S=S.district)?void 0:S.name},lat:I&&null!=j?j:null,lng:I&&null!=A?A:null},success:null==(C=this.transaction.success)||C,error_code:null!=(x=P.code)?x:null,error_type:null!=(w=P.type)?w:null,error_message:h(P.message),http_status:null!=(E=P.status)?E:null,error_fields:b,field_errors:p(T)}}}}class k{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,l,c,u,_,m,y,v,g,f,k,S,C,x,w,E;const P=this.transaction.error||{},T=P.fields||{},b=Object.keys(T),j=null==(t=this.transaction.address)?void 0:t.lat,A=null==(e=this.transaction.address)?void 0:e.lng,I=Boolean(j)||Boolean(A);return{event:"Address Updated",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(s=this.transaction.customer)?void 0:s.id,name:(null==(i=this.transaction.customer)?void 0:i.first_name)+" "+(null==(n=this.transaction.customer)?void 0:n.last_name),mobile:null==(r=this.transaction.customer)?void 0:r.mobile,email:null==(o=this.transaction.customer)?void 0:o.email,gender:null==(a=this.transaction.customer)?void 0:a.gender},address:{local:null==(d=this.transaction.address)?void 0:d.local,street:null==(l=this.transaction.address)?void 0:l.street,postal_code:null==(c=this.transaction.address)?void 0:c.postal_code,short_address:null==(u=this.transaction.address)?void 0:u.short_address,region:{id:null==(_=this.transaction.address)||null==(_=_.region)?void 0:_.id,name:null==(m=this.transaction.address)||null==(m=m.region)?void 0:m.name},city:{id:null==(y=this.transaction.address)||null==(y=y.city)?void 0:y.id,name:null==(v=this.transaction.address)||null==(v=v.city)?void 0:v.name},country:{id:null==(g=this.transaction.address)||null==(g=g.country)?void 0:g.id,name:null==(f=this.transaction.address)||null==(f=f.country)?void 0:f.name},district:{id:null==(k=this.transaction.address)||null==(k=k.district)?void 0:k.id,name:null==(S=this.transaction.address)||null==(S=S.district)?void 0:S.name},lat:I&&null!=j?j:null,lng:I&&null!=A?A:null},success:null==(C=this.transaction.success)||C,error_code:null!=(x=P.code)?x:null,error_type:null!=(w=P.type)?w:null,error_message:h(P.message),http_status:null!=(E=P.status)?E:null,error_fields:b,field_errors:p(T)}}}}class S{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,l,c,u;const _=this.transaction.error||{},m=_.fields||{},y=Object.keys(m);return{event:"Map Clicked",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(s=this.transaction.customer)?void 0:s.last_name),mobile:null==(i=this.transaction.customer)?void 0:i.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{lat:null==(o=this.transaction.address)?void 0:o.lat,lng:null==(a=this.transaction.address)?void 0:a.lng},success:null==(d=this.transaction.success)||d,error_code:null!=(l=_.code)?l:null,error_type:null!=(c=_.type)?c:null,error_message:h(_.message),http_status:null!=(u=_.status)?u:null,error_fields:y,field_errors:p(m)}}}}class C{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Submitted",properties:{checkout_id:this.details.checkout_id||s.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,is_order_free:this.details.is_order_free,cart_total:this.details.cart_total||s.get("cart.total_in_customer_currency",0),shipping_method:this.details.shipping_method,has_partial_payment:this.details.has_partial_payment||!1}}}}class x{constructor(t){this.details=t||{}}toSegment(){const t=this.details.error_fields||{},e=t&&"object"==typeof t?Object.keys(t):[];return{event:"Payment Failed",properties:{checkout_id:this.details.checkout_id||s.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,error_code:this.details.error_code,error_type:this.details.error_type,error_message:h(this.details.error_message),http_status:this.details.http_status,error_fields:e,field_errors:p(t)}}}}class w{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Succeeded",properties:{checkout_id:this.details.checkout_id||s.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,response_status:this.details.response_status,has_redirect:this.details.has_redirect||!1,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||s.get("cart.total_in_customer_currency",0)}}}}class E{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Pending",properties:{checkout_id:this.details.checkout_id||s.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||s.get("cart.total_in_customer_currency",0)}}}}class P{constructor(t){this.details=t||{}}toSegment(){return{event:"Gift Card Redeemed",properties:t.mapGiftCardRedeemedFields({source:"checkout",customer_id:s.get("customer.id"),store_id:s.get("store.id")},this.details)}}}var T=new class{constructor(){this.events={"Checkout Started":a,"Payment Info Entered":d,"Checkout Step Viewed":l,"Checkout Step Completed":_,"Coupon Entered":m,"Coupon Applied":y,"Coupon Denied":v,"Coupon Removed":g,"Address Added":f,"Address Updated":k,"Map Clicked":S,"Payment Submitted":C,"Payment Failed":x,"Payment Succeeded":w,"Payment Pending":E,"Gift Card Redeemed":P}}transform(t,e){const s=this.events[t];if(!s)return null;try{const t=new s(e).toSegment();return null!=t&&t.properties&&null!=e&&e.checkout_type&&(t.properties.checkout_type=e.checkout_type),t}catch(t){return console.error("Failed to transform event:",t),null}}};exports.SessionService=o,exports.default=class{constructor(){this.history=[],this.customTrackers=[],this.context={},this.events=[],this._sessionId=null,this.mappedEvents={"payment::method_updated":"Payment Info Entered","checkout::step_viewed":"Checkout Step Viewed","checkout::step_completed":"Checkout Step Completed","coupon::applied":"Coupon Applied","coupon::denied":"Coupon Denied","coupon::entered":"Coupon Entered","coupon::removed":"Coupon Removed","address::added":"Address Added","address::updated":"Address Updated","map::clicked":"Map Clicked","payment::submitted":"Payment Submitted","payment::failed":"Payment Failed","payment::succeeded":"Payment Succeeded","payment::pending":"Payment Pending","giftcard::redeemed":"Gift Card Redeemed"};const t=s.get("config.jitsu",{}),i=s.get("store.url",null),{host:n,key:r}=t||{};this.analytics=null,n&&r&&(this.analytics=e.jitsuAnalytics({host:this.getAnalyticsHost(i),writeKey:r,cookieCapture:this.captureCookies()}),this.events=s.get("config.jitsu.events",[]),s.get("config.jitsu.context.extra",{})&&this.setExtraContext(s.get("config.jitsu.context.extra",{})),this.initSessionId(),this.setSignedInCustomerTraits(),this.page())}setSignedInCustomerTraits(){const t=s.get("customer");t&&t.id&&this.setTraits(t)}setTraits(t){t&&this.setContext("traits",t)}initSessionId(){this._sessionId=o.resolve(),this.setContext("session_id",this._sessionId)}captureCookies(){return t.captureSallaCookies()}getAnalyticsHost(e){var s;return t.resolveAnalyticsHost(e,{documentOrigin:"undefined"!=typeof window?null==(s=window.location)?void 0:s.origin:null,log:console.log})}trackSallaEvent(t){var e;if("customer::identified"===t.type)return this.setTraits(t.detail);const s=null!=(e=this.mappedEvents[t.type])?e:t.type;if(this.analytics&&this.events.includes(s))try{if(!s)return;const e=T.transform(s,t.detail);e&&this.track(e.event,e.properties)}catch(t){console.log(t)}}track(t,e={}){return this.analytics?(e=this.finalPayload(e),this.analytics.track(t,e).then(s=>(this.pushEventToCustomTrackers("track",t,e),s)).then(()=>{this.history.push({action:"track",eventName:t,payload:e})}).catch(t=>Promise.reject(t))):Promise.resolve()}page(t={}){if(!this.analytics)return Promise.resolve();const e=this.finalPayload(t);return this.analytics.page(e).then(t=>(this.pushEventToCustomTrackers("page",e),t)).then(()=>{this.history.push({action:"page",payload:e})}).catch(t=>Promise.reject(t))}finalPayload(e={}){var i;let n={session_id:o.resolve(),cart_id:s.get("cart.id")||e.cart_id||e.checkout_id||null,requires_shipping:Boolean(s.get("cart.requires_shipping",!1))};return this.setContext("version",s.get("config.jitsu.version",1)),this.setContext("store_id",s.get("config.store.id")),n.session_id&&this.setContext("session_id",n.session_id),e.event_id=e.event_id||t.generateSessionId(),t._extends({},n,e,{session_id:e.session_id||n.session_id,cart_id:e.cart_id||n.cart_id,requires_shipping:null!=(i=e.requires_shipping)?i:n.requires_shipping})}registerTracker(e){t.isValidTracker(e,this.customTrackers,console.log)&&(this.customTrackers.push(e),t.replayHistory(e,this.history))}pushEventToCustomTrackers(e,s,i={}){return t.pushEventToTrackers(this.customTrackers,e,s,i,console.log)}setContext(t,e){var s;null==(s=this.analytics)||s.setContextProperty(t,e),this.context[t]=e}setExtraContext(e){t.applyExtraContext((t,e)=>this.setContext(t,e),e,console.log)}},exports.initialData=s,exports.sanitizeErrorMessage=h,exports.sanitizeFieldErrors=p;
2
2
  //# sourceMappingURL=checkout.js.map
@@ -1,2 +1,2 @@
1
- import{g as t,_ as e,m as i,c as s,b as n,i as r,r as o,p as a,a as d}from"./chunks/extra-context-DqOdk-SV.js";import{jitsuAnalytics as c}from"@jitsu/js";var l={get(t,e=null){const i="undefined"!=typeof window?window.initialData:null;if(!i||"object"!=typeof i)return e;let s=i;for(const i of t.split(".")){if(null==s||"object"!=typeof s||!(i in s))return e;s=s[i]}return void 0!==s?s:e}};const u="s-session-id";let h=null;function p(t){return`${t}_${l.get("store.id")}`}var m={SESSION_STORAGE_KEY:u,SESSION_TTL_MINUTES:30,resolve:()=>(h||(h=function(t,e=null){try{const i=localStorage.getItem(p(t));if(!i)return e;const s=JSON.parse(i);return s&&"object"==typeof s?(new Date).getTime()>s.expiry?(localStorage.removeItem(p(t)),e):s.value:e}catch(t){return e}}(u)||t()),function(t,e,i=30){try{const s=(new Date).getTime()+60*i*1e3;localStorage.setItem(p(t),JSON.stringify({value:e,expiry:s}))}catch(t){}}(u,h),h)};class _{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u;return{event:"Checkout Started",properties:{checkout_id:null==(t=window.initialData)||null==(t=t.cart)?void 0:t.id,order_id:(null==(e=this.transaction)||null==(e=e.order_id)?void 0:e.toString())||"",cart_id:(null==(i=this.transaction)||null==(i=i.cart_id)?void 0:i.toString())||"",affiliation:(null==(s=this.transaction)?void 0:s.affiliation)||"",value:(null==(n=this.transaction)?void 0:n.value)||0,revenue:(null==(r=this.transaction)?void 0:r.revenue)||0,shipping:(null==(o=this.transaction)?void 0:o.shipping)||0,tax:(null==(a=this.transaction)?void 0:a.tax)||0,discount:(null==(d=this.transaction)?void 0:d.discount)||0,coupon:(null==(c=this.transaction)?void 0:c.coupon)||"",currency:(null==(l=this.transaction)?void 0:l.currency)||"",products:((null==(u=this.transaction)?void 0:u.products)||[]).map(t=>{var e;return{product_id:(null==t||null==(e=t.product_id)?void 0:e.toString())||"",sku:(null==t?void 0:t.sku)||"",name:(null==t?void 0:t.name)||"",price:(null==t?void 0:t.price)||0,quantity:(null==t?void 0:t.quantity)||0,category:(null==t?void 0:t.category)||"",url:(null==t?void 0:t.url)||"",image_url:(null==t?void 0:t.image_url)||""}})}}}}class v{constructor(t){this.transaction=t}toSegment(){return{event:"Payment Info Entered",properties:{order_id:this.transaction.order_id,payment_method:this.transaction.payment_method,checkout_id:this.transaction.checkout_id}}}}class y{constructor(t){this.details=t||{}}toSegment(){var t;return{event:"Checkout Step Viewed",properties:e({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:null!=(t=this.details.payment_method)?t:""},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class g{constructor(t){this.details=t||{}}toSegment(){return{event:"Checkout Step Completed",properties:e({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:this.details.payment_method},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class f{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Entered",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,value:this.transaction.value,currency:this.transaction.currency}}}}class k{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class S{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,reason:this.transaction.reason}}}}class C{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class w{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u,h,p,m,_,v,y;return{event:"Address Added",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{local:null==(o=this.transaction.address)?void 0:o.local,street:null==(a=this.transaction.address)?void 0:a.street,postal_code:null==(d=this.transaction.address)?void 0:d.postal_code,short_address:null==(c=this.transaction.address)?void 0:c.short_address,region:{id:null==(l=this.transaction.address)||null==(l=l.region)?void 0:l.id,name:null==(u=this.transaction.address)||null==(u=u.region)?void 0:u.name},city:{id:null==(h=this.transaction.address)||null==(h=h.city)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.city)?void 0:p.name},country:{id:null==(m=this.transaction.address)||null==(m=m.country)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.country)?void 0:_.name},district:{id:null==(v=this.transaction.address)||null==(v=v.district)?void 0:v.id,name:null==(y=this.transaction.address)||null==(y=y.district)?void 0:y.name}}}}}}class P{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a,d,c,l,u,h,p,m,_,v,y;return{event:"Address Updated",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{local:null==(o=this.transaction.address)?void 0:o.local,street:null==(a=this.transaction.address)?void 0:a.street,postal_code:null==(d=this.transaction.address)?void 0:d.postal_code,short_address:null==(c=this.transaction.address)?void 0:c.short_address,region:{id:null==(l=this.transaction.address)||null==(l=l.region)?void 0:l.id,name:null==(u=this.transaction.address)||null==(u=u.region)?void 0:u.name},city:{id:null==(h=this.transaction.address)||null==(h=h.city)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.city)?void 0:p.name},country:{id:null==(m=this.transaction.address)||null==(m=m.country)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.country)?void 0:_.name},district:{id:null==(v=this.transaction.address)||null==(v=v.district)?void 0:v.id,name:null==(y=this.transaction.address)||null==(y=y.district)?void 0:y.name}}}}}}class x{constructor(t){this.transaction=t}toSegment(){var t,e,i,s,n,r,o,a;return{event:"Map Clicked",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(i=this.transaction.customer)?void 0:i.last_name),mobile:null==(s=this.transaction.customer)?void 0:s.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{lat:null==(o=this.transaction.address)?void 0:o.lat,lng:null==(a=this.transaction.address)?void 0:a.lng}}}}}class T{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Submitted",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,is_order_free:this.details.is_order_free,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0),shipping_method:this.details.shipping_method,has_partial_payment:this.details.has_partial_payment||!1}}}}const E=/\b(?:\d[ -]?){13,19}\b/g,b=/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,A=t=>t?String(t).replace(E,"[REDACTED]").replace(b,"[REDACTED]").slice(0,500):"",j=t=>t&&"object"==typeof t?Object.keys(t).map(e=>{const i=Array.isArray(t[e])?t[e][0]:t[e],s=i&&"object"==typeof i?i.message||JSON.stringify(i):i;return{field:e,message:A(s)}}):[];class I{constructor(t){this.details=t||{}}toSegment(){const t=this.details.error_fields||{},e=t&&"object"==typeof t?Object.keys(t):[];return{event:"Payment Failed",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,error_code:this.details.error_code,error_type:this.details.error_type,error_message:A(this.details.error_message),http_status:this.details.http_status,error_fields:e,field_errors:j(t)}}}}class D{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Succeeded",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,response_status:this.details.response_status,has_redirect:this.details.has_redirect||!1,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0)}}}}class O{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Pending",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0)}}}}class R{constructor(t){this.details=t||{}}toSegment(){return{event:"Gift Card Redeemed",properties:i({source:"checkout",customer_id:l.get("customer.id"),store_id:l.get("store.id")},this.details)}}}var q=new class{constructor(){this.events={"Checkout Started":_,"Payment Info Entered":v,"Checkout Step Viewed":y,"Checkout Step Completed":g,"Coupon Entered":f,"Coupon Applied":k,"Coupon Denied":S,"Coupon Removed":C,"Address Added":w,"Address Updated":P,"Map Clicked":x,"Payment Submitted":T,"Payment Failed":I,"Payment Succeeded":D,"Payment Pending":O,"Gift Card Redeemed":R}}transform(t,e){const i=this.events[t];if(!i)return null;try{const t=new i(e).toSegment();return null!=t&&t.properties&&null!=e&&e.checkout_type&&(t.properties.checkout_type=e.checkout_type),t}catch(t){return console.error("Failed to transform event:",t),null}}};class N{constructor(){this.history=[],this.customTrackers=[],this.context={},this.events=[],this._sessionId=null,this.mappedEvents={"payment::method_updated":"Payment Info Entered","checkout::step_viewed":"Checkout Step Viewed","checkout::step_completed":"Checkout Step Completed","coupon::applied":"Coupon Applied","coupon::denied":"Coupon Denied","coupon::entered":"Coupon Entered","coupon::removed":"Coupon Removed","address::added":"Address Added","address::updated":"Address Updated","map::clicked":"Map Clicked","payment::submitted":"Payment Submitted","payment::failed":"Payment Failed","payment::succeeded":"Payment Succeeded","payment::pending":"Payment Pending","giftcard::redeemed":"Gift Card Redeemed"};const t=l.get("config.jitsu",{}),e=l.get("store.url",null),{host:i,key:s}=t||{};this.analytics=null,i&&s&&(this.analytics=c({host:this.getAnalyticsHost(e),writeKey:s,cookieCapture:this.captureCookies()}),this.events=l.get("config.jitsu.events",[]),l.get("config.jitsu.context.extra",{})&&this.setExtraContext(l.get("config.jitsu.context.extra",{})),this.initSessionId(),this.setSignedInCustomerTraits(),this.page())}setSignedInCustomerTraits(){const t=l.get("customer");t&&t.id&&this.setTraits(t)}setTraits(t){t&&this.setContext("traits",t)}initSessionId(){this._sessionId=m.resolve(),this.setContext("session_id",this._sessionId)}captureCookies(){return s()}getAnalyticsHost(t){var e;return n(t,{documentOrigin:"undefined"!=typeof window?null==(e=window.location)?void 0:e.origin:null,log:console.log})}trackSallaEvent(t){var e;if("customer::identified"===t.type)return this.setTraits(t.detail);const i=null!=(e=this.mappedEvents[t.type])?e:t.type;if(this.analytics&&this.events.includes(i))try{if(!i)return;const e=q.transform(i,t.detail);e&&this.track(e.event,e.properties)}catch(t){console.log(t)}}track(t,e={}){return this.analytics?(e=this.finalPayload(e),this.analytics.track(t,e).then(i=>(this.pushEventToCustomTrackers("track",t,e),i)).then(()=>{this.history.push({action:"track",eventName:t,payload:e})}).catch(t=>Promise.reject(t))):Promise.resolve()}page(t={}){if(!this.analytics)return Promise.resolve();const e=this.finalPayload(t);return this.analytics.page(e).then(t=>(this.pushEventToCustomTrackers("page",e),t)).then(()=>{this.history.push({action:"page",payload:e})}).catch(t=>Promise.reject(t))}finalPayload(i={}){var s;let n={session_id:m.resolve(),cart_id:l.get("cart.id")||i.cart_id||i.checkout_id||null,requires_shipping:Boolean(l.get("cart.requires_shipping",!1))};return this.setContext("version",l.get("config.jitsu.version",1)),this.setContext("store_id",l.get("config.store.id")),n.session_id&&this.setContext("session_id",n.session_id),i.event_id=i.event_id||t(),e({},n,i,{session_id:i.session_id||n.session_id,cart_id:i.cart_id||n.cart_id,requires_shipping:null!=(s=i.requires_shipping)?s:n.requires_shipping})}registerTracker(t){r(t,this.customTrackers,console.log)&&(this.customTrackers.push(t),o(t,this.history))}pushEventToCustomTrackers(t,e,i={}){return a(this.customTrackers,t,e,i,console.log)}setContext(t,e){var i;null==(i=this.analytics)||i.setContextProperty(t,e),this.context[t]=e}setExtraContext(t){d((t,e)=>this.setContext(t,e),t,console.log)}}export{m as SessionService,N as default,l as initialData,A as sanitizeErrorMessage,j as sanitizeFieldErrors};
1
+ import{g as t,_ as e,m as s,c as i,b as n,i as r,r as o,p as a,a as d}from"./chunks/extra-context-DqOdk-SV.js";import{jitsuAnalytics as c}from"@jitsu/js";var l={get(t,e=null){const s="undefined"!=typeof window?window.initialData:null;if(!s||"object"!=typeof s)return e;let i=s;for(const s of t.split(".")){if(null==i||"object"!=typeof i||!(s in i))return e;i=i[s]}return void 0!==i?i:e}};const u="s-session-id";let h=null;function p(t){return`${t}_${l.get("store.id")}`}var m={SESSION_STORAGE_KEY:u,SESSION_TTL_MINUTES:30,resolve:()=>(h||(h=function(t,e=null){try{const s=localStorage.getItem(p(t));if(!s)return e;const i=JSON.parse(s);return i&&"object"==typeof i?(new Date).getTime()>i.expiry?(localStorage.removeItem(p(t)),e):i.value:e}catch(t){return e}}(u)||t()),function(t,e,s=30){try{const i=(new Date).getTime()+60*s*1e3;localStorage.setItem(p(t),JSON.stringify({value:e,expiry:i}))}catch(t){}}(u,h),h)};class _{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,c,l,u;return{event:"Checkout Started",properties:{checkout_id:null==(t=window.initialData)||null==(t=t.cart)?void 0:t.id,order_id:(null==(e=this.transaction)||null==(e=e.order_id)?void 0:e.toString())||"",cart_id:(null==(s=this.transaction)||null==(s=s.cart_id)?void 0:s.toString())||"",affiliation:(null==(i=this.transaction)?void 0:i.affiliation)||"",value:(null==(n=this.transaction)?void 0:n.value)||0,revenue:(null==(r=this.transaction)?void 0:r.revenue)||0,shipping:(null==(o=this.transaction)?void 0:o.shipping)||0,tax:(null==(a=this.transaction)?void 0:a.tax)||0,discount:(null==(d=this.transaction)?void 0:d.discount)||0,coupon:(null==(c=this.transaction)?void 0:c.coupon)||"",currency:(null==(l=this.transaction)?void 0:l.currency)||"",products:((null==(u=this.transaction)?void 0:u.products)||[]).map(t=>{var e;return{product_id:(null==t||null==(e=t.product_id)?void 0:e.toString())||"",sku:(null==t?void 0:t.sku)||"",name:(null==t?void 0:t.name)||"",price:(null==t?void 0:t.price)||0,quantity:(null==t?void 0:t.quantity)||0,category:(null==t?void 0:t.category)||"",url:(null==t?void 0:t.url)||"",image_url:(null==t?void 0:t.image_url)||""}})}}}}class y{constructor(t){this.transaction=t}toSegment(){return{event:"Payment Info Entered",properties:{order_id:this.transaction.order_id,payment_method:this.transaction.payment_method,checkout_id:this.transaction.checkout_id}}}}class v{constructor(t){this.details=t||{}}toSegment(){var t;return{event:"Checkout Step Viewed",properties:e({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:null!=(t=this.details.payment_method)?t:""},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}const g=/\b(?:\d[ -]?){13,19}\b/g,f=/[\w.+-]+@[\w-]+(\.[\w-]+)+/g,k=t=>t?String(t).replace(g,"[REDACTED]").replace(f,"[REDACTED]").slice(0,500):"",S=t=>t&&"object"==typeof t?Object.keys(t).map(e=>{const s=Array.isArray(t[e])?t[e][0]:t[e],i=s&&"object"==typeof s?s.message||JSON.stringify(s):s;return{field:e,message:k(i)}}):[];class C{constructor(t){this.details=t||{}}toSegment(){var t,s,i,n;const r=this.details.error||{},o=r.fields||{},a=Object.keys(o);return{event:"Checkout Step Completed",properties:e({checkout_id:this.details.checkout_id,step:this.details.step,shipping_method:this.details.shipping_method,payment_method:this.details.payment_method,success:null==(t=this.details.success)||t,error_code:null!=(s=r.code)?s:null,error_type:null!=(i=r.type)?i:null,error_message:k(r.message),http_status:null!=(n=r.status)?n:null,error_fields:a,field_errors:S(o)},this.details.payment_methods?{payment_methods:this.details.payment_methods}:{})}}}class w{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Entered",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,value:this.transaction.value,currency:this.transaction.currency}}}}class P{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Applied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class b{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Denied",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,reason:this.transaction.reason}}}}class x{constructor(t){this.transaction=t}toSegment(){return{event:"Coupon Removed",properties:{cart_id:this.transaction.cart_id,order_id:this.transaction.order_id,coupon_id:this.transaction.coupon_id,coupon_name:this.transaction.coupon_name,discount:this.transaction.discount,currency:this.transaction.currency}}}}class T{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,c,l,u,h,p,m,_,y,v,g,f,C,w,P,b;const x=this.transaction.error||{},T=x.fields||{},E=Object.keys(T),j=null==(t=this.transaction.address)?void 0:t.lat,A=null==(e=this.transaction.address)?void 0:e.lng,I=Boolean(j)||Boolean(A);return{event:"Address Added",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(s=this.transaction.customer)?void 0:s.id,name:(null==(i=this.transaction.customer)?void 0:i.first_name)+" "+(null==(n=this.transaction.customer)?void 0:n.last_name),mobile:null==(r=this.transaction.customer)?void 0:r.mobile,email:null==(o=this.transaction.customer)?void 0:o.email,gender:null==(a=this.transaction.customer)?void 0:a.gender},address:{local:null==(d=this.transaction.address)?void 0:d.local,street:null==(c=this.transaction.address)?void 0:c.street,postal_code:null==(l=this.transaction.address)?void 0:l.postal_code,short_address:null==(u=this.transaction.address)?void 0:u.short_address,region:{id:null==(h=this.transaction.address)||null==(h=h.region)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.region)?void 0:p.name},city:{id:null==(m=this.transaction.address)||null==(m=m.city)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.city)?void 0:_.name},country:{id:null==(y=this.transaction.address)||null==(y=y.country)?void 0:y.id,name:null==(v=this.transaction.address)||null==(v=v.country)?void 0:v.name},district:{id:null==(g=this.transaction.address)||null==(g=g.district)?void 0:g.id,name:null==(f=this.transaction.address)||null==(f=f.district)?void 0:f.name},lat:I&&null!=j?j:null,lng:I&&null!=A?A:null},success:null==(C=this.transaction.success)||C,error_code:null!=(w=x.code)?w:null,error_type:null!=(P=x.type)?P:null,error_message:k(x.message),http_status:null!=(b=x.status)?b:null,error_fields:E,field_errors:S(T)}}}}class E{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,c,l,u,h,p,m,_,y,v,g,f,C,w,P,b;const x=this.transaction.error||{},T=x.fields||{},E=Object.keys(T),j=null==(t=this.transaction.address)?void 0:t.lat,A=null==(e=this.transaction.address)?void 0:e.lng,I=Boolean(j)||Boolean(A);return{event:"Address Updated",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(s=this.transaction.customer)?void 0:s.id,name:(null==(i=this.transaction.customer)?void 0:i.first_name)+" "+(null==(n=this.transaction.customer)?void 0:n.last_name),mobile:null==(r=this.transaction.customer)?void 0:r.mobile,email:null==(o=this.transaction.customer)?void 0:o.email,gender:null==(a=this.transaction.customer)?void 0:a.gender},address:{local:null==(d=this.transaction.address)?void 0:d.local,street:null==(c=this.transaction.address)?void 0:c.street,postal_code:null==(l=this.transaction.address)?void 0:l.postal_code,short_address:null==(u=this.transaction.address)?void 0:u.short_address,region:{id:null==(h=this.transaction.address)||null==(h=h.region)?void 0:h.id,name:null==(p=this.transaction.address)||null==(p=p.region)?void 0:p.name},city:{id:null==(m=this.transaction.address)||null==(m=m.city)?void 0:m.id,name:null==(_=this.transaction.address)||null==(_=_.city)?void 0:_.name},country:{id:null==(y=this.transaction.address)||null==(y=y.country)?void 0:y.id,name:null==(v=this.transaction.address)||null==(v=v.country)?void 0:v.name},district:{id:null==(g=this.transaction.address)||null==(g=g.district)?void 0:g.id,name:null==(f=this.transaction.address)||null==(f=f.district)?void 0:f.name},lat:I&&null!=j?j:null,lng:I&&null!=A?A:null},success:null==(C=this.transaction.success)||C,error_code:null!=(w=x.code)?w:null,error_type:null!=(P=x.type)?P:null,error_message:k(x.message),http_status:null!=(b=x.status)?b:null,error_fields:E,field_errors:S(T)}}}}class j{constructor(t){this.transaction=t}toSegment(){var t,e,s,i,n,r,o,a,d,c,l,u;const h=this.transaction.error||{},p=h.fields||{},m=Object.keys(p);return{event:"Map Clicked",properties:{checkout_id:this.transaction.cart_id,order_id:this.transaction.order_id,cart_id:this.transaction.cart_id,customer:{id:null==(t=this.transaction.customer)?void 0:t.id,name:(null==(e=this.transaction.customer)?void 0:e.first_name)+" "+(null==(s=this.transaction.customer)?void 0:s.last_name),mobile:null==(i=this.transaction.customer)?void 0:i.mobile,email:null==(n=this.transaction.customer)?void 0:n.email,gender:null==(r=this.transaction.customer)?void 0:r.gender},address:{lat:null==(o=this.transaction.address)?void 0:o.lat,lng:null==(a=this.transaction.address)?void 0:a.lng},success:null==(d=this.transaction.success)||d,error_code:null!=(c=h.code)?c:null,error_type:null!=(l=h.type)?l:null,error_message:k(h.message),http_status:null!=(u=h.status)?u:null,error_fields:m,field_errors:S(p)}}}}class A{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Submitted",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,is_order_free:this.details.is_order_free,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0),shipping_method:this.details.shipping_method,has_partial_payment:this.details.has_partial_payment||!1}}}}class I{constructor(t){this.details=t||{}}toSegment(){const t=this.details.error_fields||{},e=t&&"object"==typeof t?Object.keys(t):[];return{event:"Payment Failed",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,error_code:this.details.error_code,error_type:this.details.error_type,error_message:k(this.details.error_message),http_status:this.details.http_status,error_fields:e,field_errors:S(t)}}}}class O{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Succeeded",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,response_status:this.details.response_status,has_redirect:this.details.has_redirect||!1,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0)}}}}class D{constructor(t){this.details=t||{}}toSegment(){return{event:"Payment Pending",properties:{checkout_id:this.details.checkout_id||l.get("cart.id"),payment_method:this.details.payment_method,gateway:this.details.gateway,redirect_url:this.details.redirect_url||null,order_id:this.details.order_id||null,cart_total:this.details.cart_total||l.get("cart.total_in_customer_currency",0)}}}}class R{constructor(t){this.details=t||{}}toSegment(){return{event:"Gift Card Redeemed",properties:s({source:"checkout",customer_id:l.get("customer.id"),store_id:l.get("store.id")},this.details)}}}var q=new class{constructor(){this.events={"Checkout Started":_,"Payment Info Entered":y,"Checkout Step Viewed":v,"Checkout Step Completed":C,"Coupon Entered":w,"Coupon Applied":P,"Coupon Denied":b,"Coupon Removed":x,"Address Added":T,"Address Updated":E,"Map Clicked":j,"Payment Submitted":A,"Payment Failed":I,"Payment Succeeded":O,"Payment Pending":D,"Gift Card Redeemed":R}}transform(t,e){const s=this.events[t];if(!s)return null;try{const t=new s(e).toSegment();return null!=t&&t.properties&&null!=e&&e.checkout_type&&(t.properties.checkout_type=e.checkout_type),t}catch(t){return console.error("Failed to transform event:",t),null}}};class N{constructor(){this.history=[],this.customTrackers=[],this.context={},this.events=[],this._sessionId=null,this.mappedEvents={"payment::method_updated":"Payment Info Entered","checkout::step_viewed":"Checkout Step Viewed","checkout::step_completed":"Checkout Step Completed","coupon::applied":"Coupon Applied","coupon::denied":"Coupon Denied","coupon::entered":"Coupon Entered","coupon::removed":"Coupon Removed","address::added":"Address Added","address::updated":"Address Updated","map::clicked":"Map Clicked","payment::submitted":"Payment Submitted","payment::failed":"Payment Failed","payment::succeeded":"Payment Succeeded","payment::pending":"Payment Pending","giftcard::redeemed":"Gift Card Redeemed"};const t=l.get("config.jitsu",{}),e=l.get("store.url",null),{host:s,key:i}=t||{};this.analytics=null,s&&i&&(this.analytics=c({host:this.getAnalyticsHost(e),writeKey:i,cookieCapture:this.captureCookies()}),this.events=l.get("config.jitsu.events",[]),l.get("config.jitsu.context.extra",{})&&this.setExtraContext(l.get("config.jitsu.context.extra",{})),this.initSessionId(),this.setSignedInCustomerTraits(),this.page())}setSignedInCustomerTraits(){const t=l.get("customer");t&&t.id&&this.setTraits(t)}setTraits(t){t&&this.setContext("traits",t)}initSessionId(){this._sessionId=m.resolve(),this.setContext("session_id",this._sessionId)}captureCookies(){return i()}getAnalyticsHost(t){var e;return n(t,{documentOrigin:"undefined"!=typeof window?null==(e=window.location)?void 0:e.origin:null,log:console.log})}trackSallaEvent(t){var e;if("customer::identified"===t.type)return this.setTraits(t.detail);const s=null!=(e=this.mappedEvents[t.type])?e:t.type;if(this.analytics&&this.events.includes(s))try{if(!s)return;const e=q.transform(s,t.detail);e&&this.track(e.event,e.properties)}catch(t){console.log(t)}}track(t,e={}){return this.analytics?(e=this.finalPayload(e),this.analytics.track(t,e).then(s=>(this.pushEventToCustomTrackers("track",t,e),s)).then(()=>{this.history.push({action:"track",eventName:t,payload:e})}).catch(t=>Promise.reject(t))):Promise.resolve()}page(t={}){if(!this.analytics)return Promise.resolve();const e=this.finalPayload(t);return this.analytics.page(e).then(t=>(this.pushEventToCustomTrackers("page",e),t)).then(()=>{this.history.push({action:"page",payload:e})}).catch(t=>Promise.reject(t))}finalPayload(s={}){var i;let n={session_id:m.resolve(),cart_id:l.get("cart.id")||s.cart_id||s.checkout_id||null,requires_shipping:Boolean(l.get("cart.requires_shipping",!1))};return this.setContext("version",l.get("config.jitsu.version",1)),this.setContext("store_id",l.get("config.store.id")),n.session_id&&this.setContext("session_id",n.session_id),s.event_id=s.event_id||t(),e({},n,s,{session_id:s.session_id||n.session_id,cart_id:s.cart_id||n.cart_id,requires_shipping:null!=(i=s.requires_shipping)?i:n.requires_shipping})}registerTracker(t){r(t,this.customTrackers,console.log)&&(this.customTrackers.push(t),o(t,this.history))}pushEventToCustomTrackers(t,e,s={}){return a(this.customTrackers,t,e,s,console.log)}setContext(t,e){var s;null==(s=this.analytics)||s.setContextProperty(t,e),this.context[t]=e}setExtraContext(t){d((t,e)=>this.setContext(t,e),t,console.log)}}export{m as SessionService,N as default,l as initialData,k as sanitizeErrorMessage,S as sanitizeFieldErrors};
2
2
  //# sourceMappingURL=checkout.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/analytics",
3
- "version": "2.14.582",
3
+ "version": "2.14.584",
4
4
  "description": "Salla unified analytics: Jitsu engine, event transformers and trackers for storefront (twilight) and checkout",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -63,5 +63,5 @@
63
63
  "rollup-plugin-exclude-dependencies-from-bundle": "^1.1.24",
64
64
  "rollup-plugin-version-injector": "^1.3.3"
65
65
  },
66
- "gitHead": "3d2a21f32a2b2959d8da6c9e77d9a664a6df044e"
66
+ "gitHead": "958ab6babf292ec83d68d423904d3e38f7e6bae9"
67
67
  }
@@ -1,9 +1,21 @@
1
+ import { sanitizeErrorMessage, sanitizeFieldErrors } from './sanitizers.js';
2
+
1
3
  export default class AddressAdded {
2
4
  constructor(details) {
3
5
  this.transaction = details;
4
6
  }
5
7
 
6
8
  toSegment() {
9
+ const error = this.transaction.error || {};
10
+ const errorFields = error.fields || {};
11
+ const fieldNames = Object.keys(errorFields);
12
+ // Backend casts a missing coordinate pair to (float) 0,0 — treat that
13
+ // pair as absent, but don't null out a real 0 on one axis alone (e.g.
14
+ // an address on the equator or prime meridian).
15
+ const lat = this.transaction.address?.lat;
16
+ const lng = this.transaction.address?.lng;
17
+ const hasCoordinates = Boolean(lat) || Boolean(lng);
18
+
7
19
  return {
8
20
  event: 'Address Added',
9
21
  properties: {
@@ -37,10 +49,18 @@ export default class AddressAdded {
37
49
  district: {
38
50
  id: this.transaction.address?.district?.id,
39
51
  name: this.transaction.address?.district?.name
40
- }
41
- }
52
+ },
53
+ lat: hasCoordinates ? lat ?? null : null,
54
+ lng: hasCoordinates ? lng ?? null : null,
55
+ },
56
+ success: this.transaction.success ?? true,
57
+ error_code: error.code ?? null,
58
+ error_type: error.type ?? null,
59
+ error_message: sanitizeErrorMessage(error.message),
60
+ http_status: error.status ?? null,
61
+ error_fields: fieldNames,
62
+ field_errors: sanitizeFieldErrors(errorFields),
42
63
  }
43
64
  };
44
65
  }
45
66
  }
46
-
@@ -1,9 +1,21 @@
1
+ import { sanitizeErrorMessage, sanitizeFieldErrors } from './sanitizers.js';
2
+
1
3
  export default class AddressUpdated {
2
4
  constructor(details) {
3
5
  this.transaction = details;
4
6
  }
5
7
 
6
8
  toSegment() {
9
+ const error = this.transaction.error || {};
10
+ const errorFields = error.fields || {};
11
+ const fieldNames = Object.keys(errorFields);
12
+ // Backend casts a missing coordinate pair to (float) 0,0 — treat that
13
+ // pair as absent, but don't null out a real 0 on one axis alone (e.g.
14
+ // an address on the equator or prime meridian).
15
+ const lat = this.transaction.address?.lat;
16
+ const lng = this.transaction.address?.lng;
17
+ const hasCoordinates = Boolean(lat) || Boolean(lng);
18
+
7
19
  return {
8
20
  event: 'Address Updated',
9
21
  properties: {
@@ -37,10 +49,18 @@ export default class AddressUpdated {
37
49
  district: {
38
50
  id: this.transaction.address?.district?.id,
39
51
  name: this.transaction.address?.district?.name
40
- }
41
- }
52
+ },
53
+ lat: hasCoordinates ? lat ?? null : null,
54
+ lng: hasCoordinates ? lng ?? null : null,
55
+ },
56
+ success: this.transaction.success ?? true,
57
+ error_code: error.code ?? null,
58
+ error_type: error.type ?? null,
59
+ error_message: sanitizeErrorMessage(error.message),
60
+ http_status: error.status ?? null,
61
+ error_fields: fieldNames,
62
+ field_errors: sanitizeFieldErrors(errorFields),
42
63
  }
43
64
  };
44
65
  }
45
66
  }
46
-
@@ -1,9 +1,15 @@
1
+ import { sanitizeErrorMessage, sanitizeFieldErrors } from './sanitizers.js';
2
+
1
3
  export default class CheckoutStepCompleted {
2
4
  constructor(details) {
3
5
  this.details = details || {};
4
6
  }
5
-
7
+
6
8
  toSegment() {
9
+ const error = this.details.error || {};
10
+ const errorFields = error.fields || {};
11
+ const fieldNames = Object.keys(errorFields);
12
+
7
13
  return {
8
14
  event: 'Checkout Step Completed',
9
15
  properties: {
@@ -11,6 +17,13 @@ export default class CheckoutStepCompleted {
11
17
  step: this.details.step,
12
18
  shipping_method: this.details.shipping_method,
13
19
  payment_method: this.details.payment_method,
20
+ success: this.details.success ?? true,
21
+ error_code: error.code ?? null,
22
+ error_type: error.type ?? null,
23
+ error_message: sanitizeErrorMessage(error.message),
24
+ http_status: error.status ?? null,
25
+ error_fields: fieldNames,
26
+ field_errors: sanitizeFieldErrors(errorFields),
14
27
  ...(this.details.payment_methods
15
28
  ? { payment_methods: this.details.payment_methods }
16
29
  : {}),
@@ -18,4 +31,3 @@ export default class CheckoutStepCompleted {
18
31
  };
19
32
  }
20
33
  }
21
-
@@ -1,9 +1,15 @@
1
+ import { sanitizeErrorMessage, sanitizeFieldErrors } from './sanitizers.js';
2
+
1
3
  export default class MapClicked {
2
4
  constructor(details) {
3
5
  this.transaction = details;
4
6
  }
5
7
 
6
8
  toSegment() {
9
+ const error = this.transaction.error || {};
10
+ const errorFields = error.fields || {};
11
+ const fieldNames = Object.keys(errorFields);
12
+
7
13
  return {
8
14
  event: 'Map Clicked',
9
15
  properties: {
@@ -20,7 +26,14 @@ export default class MapClicked {
20
26
  address : {
21
27
  lat : this.transaction.address?.lat,
22
28
  lng : this.transaction.address?.lng,
23
- }
29
+ },
30
+ success: this.transaction.success ?? true,
31
+ error_code: error.code ?? null,
32
+ error_type: error.type ?? null,
33
+ error_message: sanitizeErrorMessage(error.message),
34
+ http_status: error.status ?? null,
35
+ error_fields: fieldNames,
36
+ field_errors: sanitizeFieldErrors(errorFields),
24
37
  }
25
38
  }
26
39
  }