@ikas/storefront 6.1.0-beta.347 → 6.1.0-beta.349
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 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import{IkasBrand as i}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as s}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as n}from"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as d}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import{IkasStorefrontPopup as c}from"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{FacebookPixel as l}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasEventType as m}from"./events.js";import p from"lodash/cloneDeep";import{tryForEach as v}from"../utils/helper.js";import f from"./ikasV3.js";import{GoogleAnalytics as b}from"./googleAnalytics.js";import{TiktokPixel as h}from"./tiktokPixel.js";import{IkasBaseStore as g}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var j=function(){function j(){o(this)}return j.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=g.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},j.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,i,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,f.checkJourneyId()];case 1:return e.sent(),t=window.location.href,[4,j.getCustomerInfo()];case 2:return o=e.sent(),i=Date.now().toString(),u.pageView(t),l.pageView(t,i),[4,f.pageView(r,i)];case 3:return e.sent(),h.pageView(t),v(j.subscribers,(function(e){e.callback({type:m.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,5];case 4:return s=e.sent(),console.error(s),[3,5];case 5:return[2]}}))}))},j.productView=function(r){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Date.now().toString(),l.productView(r,t),u.productView(r),[4,f.productView(r,t)];case 1:return e.sent(),b.productView(r),h.productView(r),j.subscribers.length&&(o=new d(p(r)),v(j.subscribers,(function(t){t.callback({type:m.PRODUCT_VIEW,data:{productDetail:o}})}))),[3,3];case 2:return i=e.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},j.addToCart=function(t,e,r,o,i){try{if(l.addToCart(t,e,r),u.addToCart(t,e,i),f.addToCart(t,e,o,r),b.addToCart(t,e),h.addToCart(t,e),j.subscribers.length){var a=p(t),n=new s(p(o));v(j.subscribers,(function(t){t.callback({type:m.ADD_TO_CART,data:{item:a,quantity:e,cart:n}})}))}}catch(t){console.error(t)}},j.removeFromCart=function(t,e,r){try{if(u.removeFromCart(t,e),b.removeFromCart(t,e),j.subscribers.length){var o=p(t),i=new s(p(r));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:i}})}))}}catch(t){console.error(t)}},j.beginCheckout=function(t){var e,r,o,i,s,a,d,c,g,y,x;try{var w=localStorage.getItem("gtmBeginCheckout");if(w&&t.id===w)return;localStorage.setItem("gtmBeginCheckout",t.id),l.initAdvancedMatching({em:null===(e=t.customer)||void 0===e?void 0:e.email,fn:(null===(r=t.customer)||void 0===r?void 0:r.firstName)||(null===(o=t.shippingAddress)||void 0===o?void 0:o.firstName),ln:(null===(i=t.customer)||void 0===i?void 0:i.lastName)||(null===(s=t.shippingAddress)||void 0===s?void 0:s.lastName),ph:null===(a=t.shippingAddress)||void 0===a?void 0:a.phone,external_id:t.customerId,ct:null===(c=null===(d=t.shippingAddress)||void 0===d?void 0:d.city)||void 0===c?void 0:c.name,zp:null===(g=t.shippingAddress)||void 0===g?void 0:g.postalCode,country:null===(x=null===(y=t.shippingAddress)||void 0===y?void 0:y.country)||void 0===x?void 0:x.iso2});var C=Date.now().toString();if(l.beginCheckout(t,C),u.beginCheckout(t),f.beginCheckout(t,C),b.beginCheckout(t),h.beginCheckout(t),j.subscribers.length){var k=new n(p(t));v(j.subscribers,(function(t){t.callback({type:m.BEGIN_CHECKOUT,data:{checkout:k}})}))}}catch(t){console.error(t)}},j.purchase=function(t,e){var r,o,i,s,a,d,c,g,y,x,w;try{if(localStorage.removeItem("gtmBeginCheckout"),l.initAdvancedMatching({em:null===(r=t.customer)||void 0===r?void 0:r.email,fn:(null===(o=t.customer)||void 0===o?void 0:o.firstName)||(null===(i=t.shippingAddress)||void 0===i?void 0:i.firstName),ln:(null===(s=t.customer)||void 0===s?void 0:s.lastName)||(null===(a=t.shippingAddress)||void 0===a?void 0:a.lastName),ph:null===(d=t.shippingAddress)||void 0===d?void 0:d.phone,external_id:t.customerId,ct:null===(g=null===(c=t.shippingAddress)||void 0===c?void 0:c.city)||void 0===g?void 0:g.name,zp:null===(y=t.shippingAddress)||void 0===y?void 0:y.postalCode,country:null===(w=null===(x=t.shippingAddress)||void 0===x?void 0:x.country)||void 0===w?void 0:w.iso2}),l.purchase(t,e.id||""),u.purchase(t,t.orderNumber||""),f.orderSuccess(t,e.id||""),b.purchase(t,t.orderNumber||""),h.purchase(t),j.subscribers.length){var C=new n(p(t)),k=p(e);v(j.subscribers,(function(t){t.callback({type:m.COMPLETE_CHECKOUT,data:{checkout:C,transaction:k}})}))}}catch(t){console.error(t)}},j.checkoutStep=function(t,e,r){var o,i,s,a,d,c,h,g,y,x,w;try{l.initAdvancedMatching({em:null===(o=t.customer)||void 0===o?void 0:o.email,fn:(null===(i=t.customer)||void 0===i?void 0:i.firstName)||(null===(s=t.shippingAddress)||void 0===s?void 0:s.firstName),ln:(null===(a=t.customer)||void 0===a?void 0:a.lastName)||(null===(d=t.shippingAddress)||void 0===d?void 0:d.lastName),ph:null===(c=t.shippingAddress)||void 0===c?void 0:c.phone,external_id:t.customerId,ct:null===(g=null===(h=t.shippingAddress)||void 0===h?void 0:h.city)||void 0===g?void 0:g.name,zp:null===(y=t.shippingAddress)||void 0===y?void 0:y.postalCode,country:null===(w=null===(x=t.shippingAddress)||void 0===x?void 0:x.country)||void 0===w?void 0:w.iso2});var C=Date.now().toString();if(u.checkoutStep(t,e,r),f.checkoutStep(t,e),b.checkoutStep(t,e,r),l.checkoutStep(t,e,C),j.subscribers.length){var k=new n(p(t));v(j.subscribers,(function(t){t.callback({type:m.CHECKOUT_STEP,data:{checkout:k,step:e}})}))}}catch(t){console.error(t)}},j.disableHTML=function(){try{u.disableHTML()}catch(t){console.error(t)}},j.addToWishlist=function(t,e){try{var r=Date.now().toString();l.addToWishlist(t,r),h.addToWishlist(t),f.addToWishlist(t,r),b.addToWishlist(t),j.subscribers.length&&v(j.subscribers,(function(r){r.callback({type:e?m.REMOVE_FROM_WISHLIST:m.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},j.search=function(t,e){try{var r=Date.now().toString();l.search(t,r),u.search(t),h.search(t),b.search(t),f.search(t,r,e),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},j.completeRegistration=function(t,e){try{var o=Date.now().toString();l.initAdvancedMatching({em:t.email,fn:t.firstName,ln:t.lastName,ph:t.phone,external_id:t.id}),e||(l.completeRegistration(o),u.completeRegistration(t),h.completeRegistration()),f.customerRegister(o),j.subscribers.length&&v(j.subscribers,(function(o){o.callback({type:m.CUSTOMER_REGISTER,data:r({email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus},e?{attributes:t.attributes}:{})})}))}catch(t){console.error(t)}},j.createEmailSubscripition=function(t){try{l.initAdvancedMatching({em:t}),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},j.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(l.initAdvancedMatching({em:t.email,fn:t.firstName,ln:t.lastName,ph:t.phone,external_id:t.id}),u.customerLogin(t),[4,f.customerLogin()]):[2];case 2:return e.sent(),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.CUSTOMER_LOGIN,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},j.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{u.customerLogout(),j.subscribers.length&&v(j.subscribers,(function(t){t.callback({type:m.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},j.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerVisit(t),[4,f.customerVisit()]):[2];case 2:return e.sent(),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.CUSTOMER_VISIT,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},j.viewCart=function(t){try{if(t){var e=Date.now().toString();if(l.viewCart(t,e),f.viewCart(t,e),b.viewCart(t),u.viewCart(t),j.subscribers.length){var r=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.VIEW_CART,data:{cart:r}})}))}}}catch(t){console.error(t)}},j.viewCategory=function(t,e){try{var r=Date.now().toString();if(l.viewCategory(t,r),u.viewCategory(e,t),f.viewCategory(e,t,r),h.viewCategory(e),j.subscribers.length){var o=new a(p(e));v(j.subscribers,(function(e){e.callback({type:m.VIEW_CATEGORY,data:{categoryPath:t,category:o}})}))}}catch(t){console.error(t)}},j.viewBrand=function(t){try{if(f.viewBrand(t),j.subscribers.length){var e=new i(p(t));v(j.subscribers,(function(t){t.callback({type:m.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},j.viewStorefrontPopup=function(t){try{if(f.viewPopup(t.id),j.subscribers.length){var e=new c(p(t));v(j.subscribers,(function(t){t.callback({type:m.POPUP_VIEW,data:{popup:e}})}))}}catch(t){console.error(t)}},j.viewSearchResults=function(t,e){try{if(j.subscribers.length){var r=p(e).map((function(t){return new d(t)}));v(j.subscribers,(function(e){e.callback({type:m.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},j.viewListing=function(t){try{if(j.subscribers.length){var e=p(t).map((function(t){return new d(t)}));v(j.subscribers,(function(t){t.callback({type:m.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},j.contactForm=function(t){try{var e=Date.now().toString();if(l.contactForm(e),h.contactForm(),f.contactForm(e),j.subscribers.length){var r=p(t);v(j.subscribers,(function(t){t.callback({type:m.CONTACT_FORM,data:{form:r}})}))}}catch(t){console.error(t)}},j.addCouponCode=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.ADD_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},j.removeCouponCode=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},j.removeLoyaltyPoints=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_LOYALTY_POINTS,data:{cart:e}})}))}}catch(t){console.error(t)}},j.subscribers=[],j}();export{j as Analytics};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import{IkasBrand as i}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as s}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as n}from"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as d}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import{IkasStorefrontPopup as c}from"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{FacebookPixel as l}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasEventType as m}from"./events.js";import p from"lodash/cloneDeep";import{tryForEach as v}from"../utils/helper.js";import f from"./ikasV3.js";import{GoogleAnalytics as b}from"./googleAnalytics.js";import{TiktokPixel as h}from"./tiktokPixel.js";import{IkasBaseStore as g}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var j=function(){function j(){o(this)}return j.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=g.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},j.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,i,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,f.checkJourneyId()];case 1:return e.sent(),t=window.location.href,[4,j.getCustomerInfo()];case 2:return o=e.sent(),i=Date.now().toString(),u.pageView(t),l.pageView(t,i),[4,f.pageView(r,i)];case 3:return e.sent(),h.pageView(t),v(j.subscribers,(function(e){e.callback({type:m.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,5];case 4:return s=e.sent(),console.error(s),[3,5];case 5:return[2]}}))}))},j.productView=function(r){return t(this,void 0,void 0,(function(){var t,o,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Date.now().toString(),l.productView(r,t),u.productView(r),[4,f.productView(r,t)];case 1:return e.sent(),b.productView(r),h.productView(r),j.subscribers.length&&(o=new d(p(r)),v(j.subscribers,(function(t){t.callback({type:m.PRODUCT_VIEW,data:{productDetail:o}})}))),[3,3];case 2:return i=e.sent(),console.error(i),[3,3];case 3:return[2]}}))}))},j.addToCart=function(t,e,r,o,i){try{if(l.addToCart(t,e,r),u.addToCart(t,e,i),f.addToCart(t,e,o,r),b.addToCart(t,e),h.addToCart(t,e),j.subscribers.length){var a=p(t),n=new s(p(o));v(j.subscribers,(function(t){t.callback({type:m.ADD_TO_CART,data:{item:a,quantity:e,cart:n}})}))}}catch(t){console.error(t)}},j.removeFromCart=function(t,e,r){try{if(u.removeFromCart(t,e),b.removeFromCart(t,e),j.subscribers.length){var o=p(t),i=new s(p(r));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:i}})}))}}catch(t){console.error(t)}},j.beginCheckout=function(t){var e,r,o,i,s,a,d,c,g,y,x;try{var w=localStorage.getItem("gtmBeginCheckout");if(w&&t.id===w)return;localStorage.setItem("gtmBeginCheckout",t.id),l.initAdvancedMatching({em:null===(e=t.customer)||void 0===e?void 0:e.email,fn:(null===(r=t.customer)||void 0===r?void 0:r.firstName)||(null===(o=t.shippingAddress)||void 0===o?void 0:o.firstName),ln:(null===(i=t.customer)||void 0===i?void 0:i.lastName)||(null===(s=t.shippingAddress)||void 0===s?void 0:s.lastName),ph:null===(a=t.shippingAddress)||void 0===a?void 0:a.phone,external_id:t.customerId,ct:null===(c=null===(d=t.shippingAddress)||void 0===d?void 0:d.city)||void 0===c?void 0:c.name,zp:null===(g=t.shippingAddress)||void 0===g?void 0:g.postalCode,country:null===(x=null===(y=t.shippingAddress)||void 0===y?void 0:y.country)||void 0===x?void 0:x.iso2});var C=Date.now().toString();if(l.beginCheckout(t,C),u.beginCheckout(t),f.beginCheckout(t,C),b.beginCheckout(t),h.beginCheckout(t),j.subscribers.length){var k=new n(p(t));v(j.subscribers,(function(t){t.callback({type:m.BEGIN_CHECKOUT,data:{checkout:k}})}))}}catch(t){console.error(t)}},j.purchase=function(t,e){var r,o,i,s,a,d,c,g,y,x,w;try{if(localStorage.removeItem("gtmBeginCheckout"),l.initAdvancedMatching({em:null===(r=t.customer)||void 0===r?void 0:r.email,fn:(null===(o=t.customer)||void 0===o?void 0:o.firstName)||(null===(i=t.shippingAddress)||void 0===i?void 0:i.firstName),ln:(null===(s=t.customer)||void 0===s?void 0:s.lastName)||(null===(a=t.shippingAddress)||void 0===a?void 0:a.lastName),ph:null===(d=t.shippingAddress)||void 0===d?void 0:d.phone,external_id:t.customerId,ct:null===(g=null===(c=t.shippingAddress)||void 0===c?void 0:c.city)||void 0===g?void 0:g.name,zp:null===(y=t.shippingAddress)||void 0===y?void 0:y.postalCode,country:null===(w=null===(x=t.shippingAddress)||void 0===x?void 0:x.country)||void 0===w?void 0:w.iso2}),l.purchase(t,e.id||""),u.purchase(t,t.orderNumber||""),f.orderSuccess(t,e.id||""),b.purchase(t,t.orderNumber||""),h.purchase(t),j.subscribers.length){var C=new n(p(t)),k=p(e);v(j.subscribers,(function(t){t.callback({type:m.COMPLETE_CHECKOUT,data:{checkout:C,transaction:k}})}))}}catch(t){console.error(t)}},j.checkoutStep=function(t,e,r){var o,i,s,a,d,c,h,g,y,x,w;try{l.initAdvancedMatching({em:null===(o=t.customer)||void 0===o?void 0:o.email,fn:(null===(i=t.customer)||void 0===i?void 0:i.firstName)||(null===(s=t.shippingAddress)||void 0===s?void 0:s.firstName),ln:(null===(a=t.customer)||void 0===a?void 0:a.lastName)||(null===(d=t.shippingAddress)||void 0===d?void 0:d.lastName),ph:null===(c=t.shippingAddress)||void 0===c?void 0:c.phone,external_id:t.customerId,ct:null===(g=null===(h=t.shippingAddress)||void 0===h?void 0:h.city)||void 0===g?void 0:g.name,zp:null===(y=t.shippingAddress)||void 0===y?void 0:y.postalCode,country:null===(w=null===(x=t.shippingAddress)||void 0===x?void 0:x.country)||void 0===w?void 0:w.iso2});var C=Date.now().toString();if(u.checkoutStep(t,e,r),f.checkoutStep(t,e,C),b.checkoutStep(t,e,r),l.checkoutStep(t,e,C),j.subscribers.length){var k=new n(p(t));v(j.subscribers,(function(t){t.callback({type:m.CHECKOUT_STEP,data:{checkout:k,step:e}})}))}}catch(t){console.error(t)}},j.disableHTML=function(){try{u.disableHTML()}catch(t){console.error(t)}},j.addToWishlist=function(t,e){try{var r=Date.now().toString();l.addToWishlist(t,r),h.addToWishlist(t),f.addToWishlist(t,r),b.addToWishlist(t),j.subscribers.length&&v(j.subscribers,(function(r){r.callback({type:e?m.REMOVE_FROM_WISHLIST:m.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},j.search=function(t,e){try{var r=Date.now().toString();l.search(t,r),u.search(t),h.search(t),b.search(t),f.search(t,r,e),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},j.completeRegistration=function(t,e){try{var o=Date.now().toString();l.initAdvancedMatching({em:t.email,fn:t.firstName,ln:t.lastName,ph:t.phone,external_id:t.id}),e||(l.completeRegistration(o),u.completeRegistration(t),h.completeRegistration()),f.customerRegister(o),j.subscribers.length&&v(j.subscribers,(function(o){o.callback({type:m.CUSTOMER_REGISTER,data:r({email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus},e?{attributes:t.attributes}:{})})}))}catch(t){console.error(t)}},j.createEmailSubscripition=function(t){try{l.initAdvancedMatching({em:t}),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},j.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(l.initAdvancedMatching({em:t.email,fn:t.firstName,ln:t.lastName,ph:t.phone,external_id:t.id}),u.customerLogin(t),[4,f.customerLogin()]):[2];case 2:return e.sent(),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.CUSTOMER_LOGIN,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},j.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{u.customerLogout(),j.subscribers.length&&v(j.subscribers,(function(t){t.callback({type:m.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},j.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,j.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerVisit(t),[4,f.customerVisit()]):[2];case 2:return e.sent(),j.subscribers.length&&v(j.subscribers,(function(e){e.callback({type:m.CUSTOMER_VISIT,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},j.viewCart=function(t){try{if(t){var e=Date.now().toString();if(l.viewCart(t,e),f.viewCart(t,e),b.viewCart(t),u.viewCart(t),j.subscribers.length){var r=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.VIEW_CART,data:{cart:r}})}))}}}catch(t){console.error(t)}},j.viewCategory=function(t,e){try{var r=Date.now().toString();if(l.viewCategory(t,r),u.viewCategory(e,t),f.viewCategory(e,t,r),h.viewCategory(e),j.subscribers.length){var o=new a(p(e));v(j.subscribers,(function(e){e.callback({type:m.VIEW_CATEGORY,data:{categoryPath:t,category:o}})}))}}catch(t){console.error(t)}},j.viewBrand=function(t){try{if(f.viewBrand(t),j.subscribers.length){var e=new i(p(t));v(j.subscribers,(function(t){t.callback({type:m.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},j.viewStorefrontPopup=function(t){try{if(f.viewPopup(t.id),j.subscribers.length){var e=new c(p(t));v(j.subscribers,(function(t){t.callback({type:m.POPUP_VIEW,data:{popup:e}})}))}}catch(t){console.error(t)}},j.viewSearchResults=function(t,e){try{if(j.subscribers.length){var r=p(e).map((function(t){return new d(t)}));v(j.subscribers,(function(e){e.callback({type:m.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},j.viewListing=function(t){try{if(j.subscribers.length){var e=p(t).map((function(t){return new d(t)}));v(j.subscribers,(function(t){t.callback({type:m.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},j.contactForm=function(t){try{var e=Date.now().toString();if(l.contactForm(e),h.contactForm(),f.contactForm(e),j.subscribers.length){var r=p(t);v(j.subscribers,(function(t){t.callback({type:m.CONTACT_FORM,data:{form:r}})}))}}catch(t){console.error(t)}},j.addCouponCode=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.ADD_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},j.removeCouponCode=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},j.removeLoyaltyPoints=function(t){try{if(t&&j.subscribers.length){var e=new s(p(t));v(j.subscribers,(function(t){t.callback({type:m.REMOVE_LOYALTY_POINTS,data:{cart:e}})}))}}catch(t){console.error(t)}},j.subscribers=[],j}();export{j as Analytics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{__assign as t}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as e}from"mobx";import{IkasStorefrontConfig as n}from"@ikas/storefront-config";import{CheckoutStep as r}from"../components/checkout/model.js";var o="undefined"==typeof window,i=function(){function i(){e(this)}return Object.defineProperty(i,"fbpId",{get:function(){return n.getFbpId()},enumerable:!1,configurable:!0}),i.pageView=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","PageView",{},{eventID:e}))}catch(t){console.error(t)}},i.productView=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","ViewContent",(n=t,{content_name:n.name,content_category:n.categories.length>0?n.categories[0].path.map((function(t){return t.name})).join(" > "):"",content_ids:[n.selectedVariant.id],content_type:"product",value:n.selectedVariant.price.finalPrice,currency:""===n.selectedVariant.price.currency?"TRY":n.selectedVariant.price.currency}),{eventID:e}))}catch(t){console.error(t)}var n},i.addToCart=function(t,e,n){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","AddToCart",function(t,e){var n,r,o=[];(null===(n=t.variant.categories)||void 0===n?void 0:n.length)&&(null===(r=t.variant.categories[0].categoryPath)||void 0===r||r.map((function(t){return o.push(t.name)}))),t.variant.categories&&t.variant.categories.length>0&&o.push(t.variant.categories[0].name);var i=o.length>0?o.join(" > "):"";return{content_name:t.variant.name,content_category:i,content_ids:[t.variant.id],content_type:"product",value:t.finalPrice,currency:t.currencyCode}}(t),{eventID:n}))}catch(t){console.error(t)}},i.beginCheckout=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","InitiateCheckout",c(t),{eventID:e}))}catch(t){console.error(t)}},i.purchase=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","Purchase",c(t),{eventID:e}))}catch(t){console.error(t)}},i.checkoutStep=function(e,n,i){var a,d,s;if(n===r.SHIPPING&&1!==(null===(a=e.availableShippingMethods)||void 0===a?void 0:a.length)||1===(null===(d=e.availableShippingMethods)||void 0===d?void 0:d.length)&&n===r.PAYMENT)try{!o&&this.fbpId&&window.fbq&&window.fbq("track","AddPaymentInfo",t(t({},c(e)),{shipping_tier:"Ground",coupon:e.couponCode}),{eventID:i})}catch(t){console.error(t)}if(n===r.PAYMENT)try{!o&&this.fbpId&&window.fbq&&window.fbq("track","AddPaymentInfo",t(t({},c(e)),{coupon:e.couponCode,payment_type:null===(s=e.selectedPaymentGateway)||void 0===s?void 0:s.paymentMethodType}),{eventID:i})}catch(t){console.error(t)}},i.addToWishlist=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","AddToWishlist",{content_ids:[t]},{eventID:e}))}catch(t){console.error(t)}},i.search=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","Search",{search_string:t},{eventID:e}))}catch(t){console.error(t)}},i.completeRegistration=function(t){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","CompleteRegistration",{status:!0,value:0,currency:"TRY"},{eventID:t}))}catch(t){console.error(t)}},i.viewCart=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","ViewCart",function(t){var e=[],n=[];return t.items.map((function(t){e.push(t.variant.id||""),n.push({id:t.variant.id,quantity:t.quantity})})),{contents:n,content_type:"product",content_ids:e,currency:t.items[0].currencyCode,value:t.totalPrice,num_items:t.items.length}}(t),{eventID:e}))}catch(t){console.error(t)}},i.viewCategory=function(t,e){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","ViewCategory",{content_name:t},{eventID:e}))}catch(t){console.error(t)}},i.contactForm=function(t){try{return void(!o&&this.fbpId&&window.fbq&&window.fbq("track","ContactForm",{},{eventID:t}))}catch(t){console.error(t)}},i.initAdvancedMatching=function(t){try{if(o||!this.fbpId||!window.fbq)return;var e={};t.em&&(e.em=t.em.toLowerCase().trim()),t.fn&&(e.fn=t.fn.toLowerCase().trim()),t.ln&&(e.ln=t.ln.toLowerCase().trim()),t.ph&&(e.ph=t.ph.replace(/\D/g,"")),t.external_id&&(e.external_id=t.external_id),t.ct&&(e.ct=t.ct.toLowerCase().replace(/\s/g,"")),t.st&&(e.st=t.st.toLowerCase().trim()),t.zp&&(e.zp=t.zp.trim()),t.country&&(e.country=t.country.toLowerCase().trim()),Object.keys(e).length>0&&window.fbq("init",this.fbpId,e)}catch(t){console.error(t)}},i}();function c(t){var e=[],n=[];return t.items.map((function(t){e.push(t.variant.id||""),n.push({id:t.variant.id,quantity:t.quantity})})),{contents:n,content_category:"",content_type:"product",content_ids:e,currency:t.items[0].currencyCode,value:t.totalFinalPrice,num_items:t.items.length}}export{i as FacebookPixel};
|
|
@@ -172,7 +172,7 @@ export default class IkasAnalytics {
|
|
|
172
172
|
static viewCart(cart: IkasCart, eventId: string): Promise<void>;
|
|
173
173
|
static orderSuccess(checkout: IkasCheckout, eventId: string): Promise<void>;
|
|
174
174
|
static beginCheckout(checkout: IkasCheckout, eventId: string): Promise<void>;
|
|
175
|
-
static checkoutStep(checkout: IkasCheckout, step: CheckoutStep): Promise<void>;
|
|
175
|
+
static checkoutStep(checkout: IkasCheckout, step: CheckoutStep, eventId: string): Promise<void>;
|
|
176
176
|
static customerRegister(eventId: string): Promise<void>;
|
|
177
177
|
static customerLogin(): Promise<void>;
|
|
178
178
|
static customerVisit(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as s}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import{IkasThemeJsonPageType as n}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{getCookieValue as o}from"../utils/helper.js";var a,d;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW",t[t.POPUP_VIEW=14]="POPUP_VIEW",t[t.SEARCH=15]="SEARCH",t[t.FAVORITE_PRODUCT=16]="FAVORITE_PRODUCT",t[t.CONTACT_FORM=17]="CONTACT_FORM",t[t.CONTACT_FORM_BACKEND=205]="CONTACT_FORM_BACKEND"}(a||(a={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(d||(d={}));var c=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",u=function(){function u(){}return u.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))]}))}))},u.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},u.createJourneyId=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.createUUID()];case 1:return t=e.sent(),localStorage.setItem(this.JOURNEY_ID_KEY,t),this.journeyId=t,[2]}}))}))},u.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(r=JSON.parse(t)).expiry<Date.now()||r.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=r.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return s=e.sent(),console.error(s),[3,8];case 8:return[2]}}))}))},u.checkJourneyId=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.JOURNEY_ID_KEY))?(this.journeyId=t,[3,3]):[3,1];case 1:return[4,this.createJourneyId()];case 2:e.sent(),e.label=3;case 3:return i.init({journeyId:this.journeyId||""}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},u.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return r=this,[4,this.createUUID()];case 2:r.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return s=e.sent(),console.error(s),[3,5];case 5:return[2]}}))}))},u.refreshJourneyId=function(){localStorage.removeItem(this.JOURNEY_ID_KEY),this.journeyId=void 0,this.checkJourneyId()},u.getPageType=function(t){switch(t){case n.INDEX:return d.INDEX;case n.CATEGORY:return d.CATEGORY;case n.BRAND:return d.BRAND;case n.PRODUCT:return d.PRODUCT;case n.CUSTOM:return d.CUSTOM;case n.ACCOUNT:return d.ACCOUNT;case n.ADDRESSES:return d.ADDRESSES;case n.ORDERS:return d.ORDERS;case n.ORDER_DETAIL:return d.ORDER_DETAIL;case n.LOGIN:return d.LOGIN;case n.REGISTER:return d.REGISTER;case n.FORGOT_PASSWORD:return d.FORGOT_PASSWORD;case n.RECOVER_PASSWORD:return d.RECOVER_PASSWORD;case n.ACTIVATE_CUSTOMER:return d.ACTIVATE_CUSTOMER;case n.CART:return d.CART;case n.FAVORITE_PRODUCTS:return d.FAVORITE_PRODUCTS;case n.SEARCH:return d.SEARCH;case n.NOT_FOUND:return d.NOT_FOUND;case n.BLOG:return d.BLOG;case n.BLOG_INDEX:return d.BLOG_INDEX;case n.BLOG_CATEGORY:return d.BLOG_CATEGORY;case n.CHECKOUT:return d.CHECKOUT}},u.getCustomerData=function(){var t=s.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},u.getCommonEventData=function(){var t=s.getInstance();return{u:window.location.href.includes("checkout")&&document.referrer||window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0,m:{fbp:o("_fbp"),fbc:o("_fbc")}}},u.getOrderLineItem=function(t){return t.orderLineItems.map((function(t){return r(r(r(r({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})}))},u.getCartItem=function(t){return r(r(r(r({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})},u.sendEvents=function(n){var o,a,d,u,m,l,h,E,p;return t(this,void 0,void 0,(function(){var t,v,O;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,(t=s.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),[4,this.checkSessionId()];case 2:return e.sent(),[4,this.checkVisitorId()];case 3:return e.sent(),[4,this.checkJourneyId()];case 4:return e.sent(),v={e:n,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,jid:this.journeyId,vid:this.visitorId,sfrid:i.getStorefrontRoutingId()||"",ud:r(r(r(r({id:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},(null===(a=t.customerStore.customer)||void 0===a?void 0:a.email)?{em:null===(d=t.customerStore.customer)||void 0===d?void 0:d.email}:{}),(null===(u=t.customerStore.customer)||void 0===u?void 0:u.phone)?{ph:null===(m=t.customerStore.customer)||void 0===m?void 0:m.phone}:{}),(null===(l=t.customerStore.customer)||void 0===l?void 0:l.lastName)?{ln:null===(h=t.customerStore.customer)||void 0===h?void 0:h.lastName}:{}),(null===(E=t.customerStore.customer)||void 0===E?void 0:E.firstName)?{fn:null===(p=t.customerStore.customer)||void 0===p?void 0:p.firstName}:{}),v:3},[4,fetch(c,{method:"POST",body:JSON.stringify(v),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 5:return e.sent(),[3,7];case 6:return O=e.sent(),console.error(O),[3,7];case 7:return[2]}}))}))},u.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.SESSION_START,ts:Date.now(),d:r({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.pageView=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.PAGE_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.productView=function(i,s){var n;return t(this,void 0,void 0,(function(){var t,o,d;return e(this,(function(e){switch(e.label){case 0:return t=[],o=[],(null===(n=i.categories)||void 0===n?void 0:n.length)&&i.categories[0].path.forEach((function(e){t.push(e.name),o.push(e.id)})),d={id:s,t:a.PRODUCT_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:r({pr:r({id:i.id,vid:i.selectedVariant.id,cp:t,cid:o,n:i.name,pr:i.selectedVariant.finalPrice},i.selectedVariant.price.currency?{c:i.selectedVariant.price.currency}:{})},i.brand?{br:{id:i.brand.id}}:{})})},[4,this.sendEvents([d])];case 1:return e.sent(),[2]}}))}))},u.addToCart=function(i,s,n,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:o,t:a.ADD_TO_CART,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{crt:{id:n.id,c:n.currencyCode,pr:n.totalFinalPrice,il:this.getOrderLineItem(n)},crtItm:this.getCartItem(i)}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewCart=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.VIEW_CART,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.currencyCode,pr:i.totalFinalPrice,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.orderSuccess=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.ORDER_SUCCESS,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success",p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.beginCheckout=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.BEGIN_CHECKOUT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.checkoutStep=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.CHECKOUT_STEP,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,s:s,p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerRegister=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:i,t:a.CUSTOMER_REGISTER,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.CUSTOMER_LOGIN,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.CUSTOMER_VISIT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.BRAND_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewCategory=function(i,s,n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:n,t:a.CATEGORY_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id,cp:s}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewPopup=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.POPUP_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()},m:{sfpid:i}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.search=function(i,s,n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.SEARCH,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{src:r({s:i},n?{r:n}:{})}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.contactForm=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:i,t:a.CONTACT_FORM,ts:Date.now(),d:r({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.addToWishlist=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.FAVORITE_PRODUCT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{pr:{id:i}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.SESSION_ID_KEY="ikas_session_id",u.VISITOR_ID_KEY="ikas_visitor_id",u.JOURNEY_ID_KEY="ikas_journey_id",u.EXPIRY_LENGTH=18e5,u}();export{u as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{IkasBaseStore as s}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import{IkasThemeJsonPageType as n}from"@ikas/storefront-models";import"mobx";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{getCookieValue as o}from"../utils/helper.js";var a,d;!function(t){t[t.SESSION_START=1]="SESSION_START",t[t.PAGE_VIEW=2]="PAGE_VIEW",t[t.PRODUCT_VIEW=3]="PRODUCT_VIEW",t[t.ADD_TO_CART=4]="ADD_TO_CART",t[t.VIEW_CART=5]="VIEW_CART",t[t.ORDER_SUCCESS=6]="ORDER_SUCCESS",t[t.BEGIN_CHECKOUT=7]="BEGIN_CHECKOUT",t[t.CHECKOUT_STEP=8]="CHECKOUT_STEP",t[t.CUSTOMER_REGISTER=9]="CUSTOMER_REGISTER",t[t.CUSTOMER_VISIT=10]="CUSTOMER_VISIT",t[t.CUSTOMER_LOGIN=11]="CUSTOMER_LOGIN",t[t.BRAND_VIEW=12]="BRAND_VIEW",t[t.CATEGORY_VIEW=13]="CATEGORY_VIEW",t[t.POPUP_VIEW=14]="POPUP_VIEW",t[t.SEARCH=15]="SEARCH",t[t.FAVORITE_PRODUCT=16]="FAVORITE_PRODUCT",t[t.CONTACT_FORM=17]="CONTACT_FORM",t[t.CONTACT_FORM_BACKEND=205]="CONTACT_FORM_BACKEND"}(a||(a={})),function(t){t[t.INDEX=1]="INDEX",t[t.CATEGORY=2]="CATEGORY",t[t.BRAND=3]="BRAND",t[t.PRODUCT=4]="PRODUCT",t[t.CUSTOM=5]="CUSTOM",t[t.ACCOUNT=6]="ACCOUNT",t[t.ADDRESSES=7]="ADDRESSES",t[t.ORDERS=8]="ORDERS",t[t.ORDER_DETAIL=9]="ORDER_DETAIL",t[t.LOGIN=10]="LOGIN",t[t.REGISTER=11]="REGISTER",t[t.FORGOT_PASSWORD=12]="FORGOT_PASSWORD",t[t.RECOVER_PASSWORD=13]="RECOVER_PASSWORD",t[t.CART=14]="CART",t[t.FAVORITE_PRODUCTS=15]="FAVORITE_PRODUCTS",t[t.SEARCH=16]="SEARCH",t[t.NOT_FOUND=17]="NOT_FOUND",t[t.BLOG=18]="BLOG",t[t.BLOG_INDEX=19]="BLOG_INDEX",t[t.BLOG_CATEGORY=20]="BLOG_CATEGORY",t[t.CHECKOUT=21]="CHECKOUT",t[t.ACTIVATE_CUSTOMER=21]="ACTIVATE_CUSTOMER"}(d||(d={}));var c=process.env.NEXT_PUBLIC_ANALYTICS_URL?"".concat(process.env.NEXT_PUBLIC_ANALYTICS_URL,"/sendEventV2"):"https://0.myikas.com/sendEventV2",u=function(){function u(){}return u.createUUID=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))]}))}))},u.createSessionId=function(){return t(this,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),i={},[4,this.createUUID()];case 1:return i.id=e.sent(),i.expiry=Date.now()+this.EXPIRY_LENGTH,t=i,localStorage.setItem(this.SESSION_ID_KEY,JSON.stringify(t)),this.sessionId=t.id,[4,this.sessionStart()];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},u.createJourneyId=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.createUUID()];case 1:return t=e.sent(),localStorage.setItem(this.JOURNEY_ID_KEY,t),this.journeyId=t,[2]}}))}))},u.checkSessionId=function(){return t(this,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),(t=localStorage.getItem(this.SESSION_ID_KEY))?(r=JSON.parse(t)).expiry<Date.now()||r.id.length<=13?[4,this.createSessionId()]:[3,2]:[3,4];case 1:return e.sent(),[3,3];case 2:this.sessionId=r.id,e.label=3;case 3:return[3,6];case 4:return[4,this.createSessionId()];case 5:e.sent(),e.label=6;case 6:return i.init({sessionId:this.sessionId||""}),[3,8];case 7:return s=e.sent(),console.error(s),[3,8];case 8:return[2]}}))}))},u.checkJourneyId=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.JOURNEY_ID_KEY))?(this.journeyId=t,[3,3]):[3,1];case 1:return[4,this.createJourneyId()];case 2:e.sent(),e.label=3;case 3:return i.init({journeyId:this.journeyId||""}),[3,5];case 4:return r=e.sent(),console.error(r),[3,5];case 5:return[2]}}))}))},u.checkVisitorId=function(){return t(this,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),(t=localStorage.getItem(this.VISITOR_ID_KEY))&&t.length>13?(this.visitorId=t,[3,3]):[3,1];case 1:return r=this,[4,this.createUUID()];case 2:r.visitorId=e.sent(),localStorage.setItem(this.VISITOR_ID_KEY,this.visitorId),e.label=3;case 3:return i.init({visitorId:this.visitorId}),[3,5];case 4:return s=e.sent(),console.error(s),[3,5];case 5:return[2]}}))}))},u.refreshJourneyId=function(){localStorage.removeItem(this.JOURNEY_ID_KEY),this.journeyId=void 0,this.checkJourneyId()},u.getPageType=function(t){switch(t){case n.INDEX:return d.INDEX;case n.CATEGORY:return d.CATEGORY;case n.BRAND:return d.BRAND;case n.PRODUCT:return d.PRODUCT;case n.CUSTOM:return d.CUSTOM;case n.ACCOUNT:return d.ACCOUNT;case n.ADDRESSES:return d.ADDRESSES;case n.ORDERS:return d.ORDERS;case n.ORDER_DETAIL:return d.ORDER_DETAIL;case n.LOGIN:return d.LOGIN;case n.REGISTER:return d.REGISTER;case n.FORGOT_PASSWORD:return d.FORGOT_PASSWORD;case n.RECOVER_PASSWORD:return d.RECOVER_PASSWORD;case n.ACTIVATE_CUSTOMER:return d.ACTIVATE_CUSTOMER;case n.CART:return d.CART;case n.FAVORITE_PRODUCTS:return d.FAVORITE_PRODUCTS;case n.SEARCH:return d.SEARCH;case n.NOT_FOUND:return d.NOT_FOUND;case n.BLOG:return d.BLOG;case n.BLOG_INDEX:return d.BLOG_INDEX;case n.BLOG_CATEGORY:return d.BLOG_CATEGORY;case n.CHECKOUT:return d.CHECKOUT}},u.getCustomerData=function(){var t=s.getInstance(),e=t.customerStore.customer;return{id:(null==e?void 0:e.id)||void 0,e:(null==e?void 0:e.email)||void 0,c:t.customerStore.customerConsentGranted}},u.getCommonEventData=function(){var t=s.getInstance();return{u:window.location.href.includes("checkout")&&document.referrer||window.location.href,r:document.referrer,pt:t.currentPageType?this.getPageType(t.currentPageType):void 0,m:{fbp:o("_fbp"),fbc:o("_fbc")}}},u.getOrderLineItem=function(t){return t.orderLineItems.map((function(t){return r(r(r(r({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})}))},u.getCartItem=function(t){return r(r(r(r({},t.variant.productId?{pid:t.variant.productId}:{}),t.variant.id?{vid:t.variant.id}:{}),{c:t.quantity}),t.finalPrice?{p:t.finalPrice}:{})},u.sendEvents=function(n){var o,a,d,u,m,l,h,E,p;return t(this,void 0,void 0,(function(){var t,v,O;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,6,,7]),[4,(t=s.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),[4,this.checkSessionId()];case 2:return e.sent(),[4,this.checkVisitorId()];case 3:return e.sent(),[4,this.checkJourneyId()];case 4:return e.sent(),v={e:n,scid:i.getSalesChannelId(),sfid:i.getStorefrontId(),sid:this.sessionId,jid:this.journeyId,vid:this.visitorId,sfrid:i.getStorefrontRoutingId()||"",ud:r(r(r(r({id:null===(o=t.customerStore.customer)||void 0===o?void 0:o.id},(null===(a=t.customerStore.customer)||void 0===a?void 0:a.email)?{em:null===(d=t.customerStore.customer)||void 0===d?void 0:d.email}:{}),(null===(u=t.customerStore.customer)||void 0===u?void 0:u.phone)?{ph:null===(m=t.customerStore.customer)||void 0===m?void 0:m.phone}:{}),(null===(l=t.customerStore.customer)||void 0===l?void 0:l.lastName)?{ln:null===(h=t.customerStore.customer)||void 0===h?void 0:h.lastName}:{}),(null===(E=t.customerStore.customer)||void 0===E?void 0:E.firstName)?{fn:null===(p=t.customerStore.customer)||void 0===p?void 0:p.firstName}:{}),v:3},[4,fetch(c,{method:"POST",body:JSON.stringify(v),headers:{"Content-Type":"application/json","x-api-key":i.getApiKey()}})];case 5:return e.sent(),[3,7];case 6:return O=e.sent(),console.error(O),[3,7];case 7:return[2]}}))}))},u.sessionStart=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.SESSION_START,ts:Date.now(),d:r({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.pageView=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.PAGE_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{pt:this.getPageType(i)})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.productView=function(i,s){var n;return t(this,void 0,void 0,(function(){var t,o,d;return e(this,(function(e){switch(e.label){case 0:return t=[],o=[],(null===(n=i.categories)||void 0===n?void 0:n.length)&&i.categories[0].path.forEach((function(e){t.push(e.name),o.push(e.id)})),d={id:s,t:a.PRODUCT_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:r({pr:r({id:i.id,vid:i.selectedVariant.id,cp:t,cid:o,n:i.name,pr:i.selectedVariant.finalPrice},i.selectedVariant.price.currency?{c:i.selectedVariant.price.currency}:{})},i.brand?{br:{id:i.brand.id}}:{})})},[4,this.sendEvents([d])];case 1:return e.sent(),[2]}}))}))},u.addToCart=function(i,s,n,o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:o,t:a.ADD_TO_CART,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{crt:{id:n.id,c:n.currencyCode,pr:n.totalFinalPrice,il:this.getOrderLineItem(n)},crtItm:this.getCartItem(i)}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewCart=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.VIEW_CART,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{crt:{id:i.id,c:i.currencyCode,pr:i.totalFinalPrice,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.orderSuccess=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.ORDER_SUCCESS,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,s:"success",p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.beginCheckout=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.BEGIN_CHECKOUT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.checkoutStep=function(i,s,n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:n,t:a.CHECKOUT_STEP,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{chk:{id:i.id,s:s,p:i.totalFinalPrice,c:i.currencyCode,il:this.getOrderLineItem(i)}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerRegister=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:i,t:a.CUSTOMER_REGISTER,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerLogin=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.CUSTOMER_LOGIN,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.customerVisit=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.CUSTOMER_VISIT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewBrand=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.BRAND_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),br:{id:i.id}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewCategory=function(i,s,n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:n,t:a.CATEGORY_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData(),ctg:{id:i.id,cp:s}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.viewPopup=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={t:a.POPUP_VIEW,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{cst:this.getCustomerData()},m:{sfpid:i}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.search=function(i,s,n){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.SEARCH,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{src:r({s:i},n?{r:n}:{})}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.contactForm=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:i,t:a.CONTACT_FORM,ts:Date.now(),d:r({},this.getCommonEventData())},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.addToWishlist=function(i,s){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t={id:s,t:a.FAVORITE_PRODUCT,ts:Date.now(),d:r(r({},this.getCommonEventData()),{d:{pr:{id:i}}})},[4,this.sendEvents([t])];case 1:return e.sent(),[2]}}))}))},u.SESSION_ID_KEY="ikas_session_id",u.VISITOR_ID_KEY="ikas_visitor_id",u.JOURNEY_ID_KEY="ikas_journey_id",u.EXPIRY_LENGTH=18e5,u}();export{u as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.349",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"swiper": "11.0.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
29
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
30
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
26
|
+
"@ikas/storefront-api": "^6.1.0-beta.349",
|
|
27
|
+
"@ikas/storefront-config": "^6.1.0-beta.349",
|
|
28
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.349",
|
|
29
|
+
"@ikas/storefront-models": "^6.1.0-beta.349",
|
|
30
|
+
"@ikas/storefront-providers": "^6.1.0-beta.349",
|
|
31
31
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
32
32
|
"@adyen/adyen-web": "^5.57.0",
|
|
33
33
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
65
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
68
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
69
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
65
|
+
"@ikas/storefront-api": "^6.1.0-beta.349",
|
|
66
|
+
"@ikas/storefront-config": "^6.1.0-beta.349",
|
|
67
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.349",
|
|
68
|
+
"@ikas/storefront-models": "^6.1.0-beta.349",
|
|
69
|
+
"@ikas/storefront-providers": "^6.1.0-beta.349",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|