@ikas/storefront 0.0.83 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/analytics/analytics.d.ts +9 -28
- package/build/analytics/facebookPixel.d.ts +11 -0
- package/build/analytics/googleTagManager.d.ts +170 -0
- package/build/index.es.js +355 -199
- package/build/index.js +355 -199
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -19707,6 +19707,144 @@ function debounce(func, wait, options) {
|
|
|
19707
19707
|
|
|
19708
19708
|
var debounce_1 = debounce;
|
|
19709
19709
|
|
|
19710
|
+
var isServer = typeof window === "undefined";
|
|
19711
|
+
var FacebookPixel = /** @class */ (function () {
|
|
19712
|
+
function FacebookPixel() {
|
|
19713
|
+
mobx.makeAutoObservable(this);
|
|
19714
|
+
}
|
|
19715
|
+
FacebookPixel.productView = function (productDetail) {
|
|
19716
|
+
try {
|
|
19717
|
+
!isServer &&
|
|
19718
|
+
window.fbq &&
|
|
19719
|
+
window.fbq("track", "ViewContent", productToFBPItem(productDetail));
|
|
19720
|
+
return;
|
|
19721
|
+
}
|
|
19722
|
+
catch (err) {
|
|
19723
|
+
console.error(err);
|
|
19724
|
+
}
|
|
19725
|
+
};
|
|
19726
|
+
FacebookPixel.addToCart = function (item, quantity) {
|
|
19727
|
+
try {
|
|
19728
|
+
!isServer &&
|
|
19729
|
+
window.fbq &&
|
|
19730
|
+
window.fbq("track", "AddToCart", item instanceof IkasProductDetail
|
|
19731
|
+
? productToFBPItem(item, quantity)
|
|
19732
|
+
: orderLineItemToFBPItem(item, quantity));
|
|
19733
|
+
return;
|
|
19734
|
+
}
|
|
19735
|
+
catch (err) {
|
|
19736
|
+
console.error(err);
|
|
19737
|
+
}
|
|
19738
|
+
};
|
|
19739
|
+
FacebookPixel.beginCheckout = function (checkout) {
|
|
19740
|
+
try {
|
|
19741
|
+
!isServer &&
|
|
19742
|
+
window.fbq &&
|
|
19743
|
+
window.fbq("track", "InitiateCheckout", beginCheckoutFBPItem(checkout));
|
|
19744
|
+
return;
|
|
19745
|
+
}
|
|
19746
|
+
catch (err) {
|
|
19747
|
+
console.error(err);
|
|
19748
|
+
}
|
|
19749
|
+
};
|
|
19750
|
+
FacebookPixel.purchase = function (checkout, orderId) {
|
|
19751
|
+
try {
|
|
19752
|
+
!isServer &&
|
|
19753
|
+
window.fbq &&
|
|
19754
|
+
window.fbq("track", "Purchase", beginCheckoutFBPItem(checkout));
|
|
19755
|
+
return;
|
|
19756
|
+
}
|
|
19757
|
+
catch (err) {
|
|
19758
|
+
console.error(err);
|
|
19759
|
+
}
|
|
19760
|
+
};
|
|
19761
|
+
FacebookPixel.addToWishlist = function (id) {
|
|
19762
|
+
try {
|
|
19763
|
+
!isServer &&
|
|
19764
|
+
window.fbq &&
|
|
19765
|
+
window.fbq("track", "AddToWishlist", {
|
|
19766
|
+
content_ids: [id],
|
|
19767
|
+
});
|
|
19768
|
+
return;
|
|
19769
|
+
}
|
|
19770
|
+
catch (err) {
|
|
19771
|
+
console.error(err);
|
|
19772
|
+
}
|
|
19773
|
+
};
|
|
19774
|
+
FacebookPixel.search = function (searchKeyword) {
|
|
19775
|
+
try {
|
|
19776
|
+
!isServer &&
|
|
19777
|
+
window.fbq &&
|
|
19778
|
+
window.fbq("track", "Search", {
|
|
19779
|
+
search_string: searchKeyword,
|
|
19780
|
+
});
|
|
19781
|
+
return;
|
|
19782
|
+
}
|
|
19783
|
+
catch (err) {
|
|
19784
|
+
console.error(err);
|
|
19785
|
+
}
|
|
19786
|
+
};
|
|
19787
|
+
FacebookPixel.completeRegistration = function () {
|
|
19788
|
+
try {
|
|
19789
|
+
!isServer &&
|
|
19790
|
+
window.fbq &&
|
|
19791
|
+
window.fbq("track", "CompleteRegistration", {
|
|
19792
|
+
status: true,
|
|
19793
|
+
});
|
|
19794
|
+
return;
|
|
19795
|
+
}
|
|
19796
|
+
catch (err) {
|
|
19797
|
+
console.error(err);
|
|
19798
|
+
}
|
|
19799
|
+
};
|
|
19800
|
+
return FacebookPixel;
|
|
19801
|
+
}());
|
|
19802
|
+
function productToFBPItem(productDetail, quantity) {
|
|
19803
|
+
if (quantity === void 0) { quantity = 1; }
|
|
19804
|
+
return {
|
|
19805
|
+
content_name: productDetail.product.name,
|
|
19806
|
+
content_category: productDetail.product.categories.length > 0
|
|
19807
|
+
? productDetail.product.categories[0].path
|
|
19808
|
+
.map(function (category) { return category.name; })
|
|
19809
|
+
.join(" > ")
|
|
19810
|
+
: "",
|
|
19811
|
+
content_ids: [productDetail.selectedVariant.id],
|
|
19812
|
+
content_type: "product",
|
|
19813
|
+
value: productDetail.selectedVariant.price.finalPrice,
|
|
19814
|
+
currency: productDetail.selectedVariant.price.currency === ""
|
|
19815
|
+
? "TRY"
|
|
19816
|
+
: productDetail.selectedVariant.price.currency,
|
|
19817
|
+
num_items: quantity,
|
|
19818
|
+
};
|
|
19819
|
+
}
|
|
19820
|
+
function beginCheckoutFBPItem(checkout) {
|
|
19821
|
+
var _a, _b, _c, _d;
|
|
19822
|
+
var contentIds = [];
|
|
19823
|
+
var contents = [];
|
|
19824
|
+
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
19825
|
+
contentIds.push(item.id);
|
|
19826
|
+
contents.push({ id: item.id, quantity: item.quantity });
|
|
19827
|
+
});
|
|
19828
|
+
return {
|
|
19829
|
+
contents: contents,
|
|
19830
|
+
content_category: "",
|
|
19831
|
+
content_ids: contentIds,
|
|
19832
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
19833
|
+
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
19834
|
+
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
19835
|
+
};
|
|
19836
|
+
}
|
|
19837
|
+
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
19838
|
+
return {
|
|
19839
|
+
content_name: orderLineItem.variant.name,
|
|
19840
|
+
content_category: "",
|
|
19841
|
+
content_ids: [orderLineItem.variant.id],
|
|
19842
|
+
content_type: "product",
|
|
19843
|
+
value: orderLineItem.finalPrice,
|
|
19844
|
+
currency: orderLineItem.currencyCode,
|
|
19845
|
+
};
|
|
19846
|
+
}
|
|
19847
|
+
|
|
19710
19848
|
var IkasPaymentMethodType;
|
|
19711
19849
|
(function (IkasPaymentMethodType) {
|
|
19712
19850
|
IkasPaymentMethodType["BUY_ONLINE_PAY_AT_STORE"] = "BUY_ONLINE_PAY_AT_STORE";
|
|
@@ -19718,7 +19856,7 @@ var IkasPaymentMethodType;
|
|
|
19718
19856
|
IkasPaymentMethodType["OTHER"] = "OTHER";
|
|
19719
19857
|
})(IkasPaymentMethodType || (IkasPaymentMethodType = {}));
|
|
19720
19858
|
|
|
19721
|
-
var isServer = typeof localStorage === "undefined";
|
|
19859
|
+
var isServer$1 = typeof localStorage === "undefined";
|
|
19722
19860
|
var LS_TOKEN_KEY = "customerToken";
|
|
19723
19861
|
var LS_TOKEN_EXPIRY = "customerTokenExpiry";
|
|
19724
19862
|
var LS_CUSTOMER_KEY = "customer";
|
|
@@ -19987,7 +20125,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
19987
20125
|
return __generator(this, function (_a) {
|
|
19988
20126
|
switch (_a.label) {
|
|
19989
20127
|
case 0:
|
|
19990
|
-
if (isServer || !this.token)
|
|
20128
|
+
if (isServer$1 || !this.token)
|
|
19991
20129
|
return [2 /*return*/];
|
|
19992
20130
|
return [4 /*yield*/, IkasCustomerAPI.getCustomer()];
|
|
19993
20131
|
case 1:
|
|
@@ -20018,13 +20156,13 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20018
20156
|
});
|
|
20019
20157
|
};
|
|
20020
20158
|
IkasCustomerStore.prototype.setCustomer = function (customer) {
|
|
20021
|
-
if (!isServer) {
|
|
20159
|
+
if (!isServer$1) {
|
|
20022
20160
|
localStorage.setItem(LS_CUSTOMER_KEY, JSON.stringify(customer));
|
|
20023
20161
|
}
|
|
20024
20162
|
this.customer = new IkasCustomer(customer);
|
|
20025
20163
|
};
|
|
20026
20164
|
IkasCustomerStore.prototype.loadCustomer = function () {
|
|
20027
|
-
if (isServer)
|
|
20165
|
+
if (isServer$1)
|
|
20028
20166
|
return;
|
|
20029
20167
|
try {
|
|
20030
20168
|
var customerStr = localStorage.getItem(LS_CUSTOMER_KEY);
|
|
@@ -20035,7 +20173,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20035
20173
|
catch (err) { }
|
|
20036
20174
|
};
|
|
20037
20175
|
IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
|
|
20038
|
-
if (isServer)
|
|
20176
|
+
if (isServer$1)
|
|
20039
20177
|
return;
|
|
20040
20178
|
this.token = token;
|
|
20041
20179
|
this.tokenExpiry = tokenExpiry;
|
|
@@ -20044,7 +20182,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20044
20182
|
apollo.setCustomerToken(token);
|
|
20045
20183
|
};
|
|
20046
20184
|
IkasCustomerStore.prototype.loadToken = function () {
|
|
20047
|
-
if (isServer)
|
|
20185
|
+
if (isServer$1)
|
|
20048
20186
|
return;
|
|
20049
20187
|
var token = localStorage.getItem(LS_TOKEN_KEY);
|
|
20050
20188
|
var tokenExpiry = localStorage.getItem(LS_TOKEN_EXPIRY);
|
|
@@ -20108,7 +20246,7 @@ var NUMBER_ONLY_REGEX = /^\d+$/;
|
|
|
20108
20246
|
var MAX_CARD_NUMBER_LENGTH = 16;
|
|
20109
20247
|
var MAX_CVC_LENGTH = 4;
|
|
20110
20248
|
var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
|
|
20111
|
-
var isServer$
|
|
20249
|
+
var isServer$2 = typeof localStorage === "undefined";
|
|
20112
20250
|
var CheckoutViewModel = /** @class */ (function () {
|
|
20113
20251
|
function CheckoutViewModel(checkout, queryParams, router) {
|
|
20114
20252
|
var _this = this;
|
|
@@ -20660,7 +20798,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
20660
20798
|
_this.cardData.installmentCount = count;
|
|
20661
20799
|
};
|
|
20662
20800
|
this.changeStep = function (step) {
|
|
20663
|
-
if (!isServer$
|
|
20801
|
+
if (!isServer$2) {
|
|
20664
20802
|
window.location.href = "/checkout/" + _this.checkout.id + "?step=" + step;
|
|
20665
20803
|
// this.router.push(`/checkout/${this.checkout.id}?step=${step}`);
|
|
20666
20804
|
}
|
|
@@ -20821,185 +20959,129 @@ var ErrorType;
|
|
|
20821
20959
|
ErrorType[ErrorType["NO_SHIPPING_ERROR"] = 4] = "NO_SHIPPING_ERROR";
|
|
20822
20960
|
})(ErrorType || (ErrorType = {}));
|
|
20823
20961
|
|
|
20824
|
-
var
|
|
20825
|
-
var
|
|
20826
|
-
|
|
20827
|
-
function Analytics() {
|
|
20962
|
+
var isServer$3 = typeof window === "undefined";
|
|
20963
|
+
var GoogleTagManager = /** @class */ (function () {
|
|
20964
|
+
function GoogleTagManager() {
|
|
20828
20965
|
mobx.makeAutoObservable(this);
|
|
20829
20966
|
}
|
|
20830
|
-
|
|
20967
|
+
GoogleTagManager.pageView = function (url) {
|
|
20831
20968
|
try {
|
|
20832
20969
|
var event_1 = {
|
|
20833
20970
|
event: "page-view",
|
|
20834
20971
|
page: url,
|
|
20835
20972
|
};
|
|
20836
20973
|
//@ts-ignore
|
|
20837
|
-
!isServer$
|
|
20974
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_1);
|
|
20838
20975
|
return event_1;
|
|
20839
20976
|
}
|
|
20840
20977
|
catch (err) {
|
|
20841
20978
|
console.error(err);
|
|
20842
20979
|
}
|
|
20843
20980
|
};
|
|
20844
|
-
|
|
20845
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20846
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20847
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20848
|
-
var event = {};
|
|
20981
|
+
GoogleTagManager.productView = function (productDetail) {
|
|
20849
20982
|
try {
|
|
20850
|
-
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
}
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
ecommerce: {
|
|
20860
|
-
items: [productToGTMItem(productDetail)],
|
|
20861
|
-
},
|
|
20862
|
-
};
|
|
20863
|
-
//@ts-ignore
|
|
20864
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20865
|
-
}
|
|
20866
|
-
return event;
|
|
20983
|
+
var event_2 = {
|
|
20984
|
+
event: "view_item",
|
|
20985
|
+
ecommerce: {
|
|
20986
|
+
items: [productToGTMItem(productDetail)],
|
|
20987
|
+
},
|
|
20988
|
+
};
|
|
20989
|
+
//@ts-ignore
|
|
20990
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_2);
|
|
20991
|
+
return event_2;
|
|
20867
20992
|
}
|
|
20868
20993
|
catch (err) {
|
|
20869
20994
|
console.error(err);
|
|
20870
20995
|
}
|
|
20871
20996
|
};
|
|
20872
|
-
|
|
20873
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20874
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20875
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20876
|
-
var event = {};
|
|
20997
|
+
GoogleTagManager.addToCart = function (item, quantity) {
|
|
20877
20998
|
try {
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20885
|
-
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
|
|
20891
|
-
: orderLineItemToGTMItem(item, quantity),
|
|
20892
|
-
],
|
|
20893
|
-
},
|
|
20894
|
-
};
|
|
20895
|
-
//@ts-ignore
|
|
20896
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20897
|
-
}
|
|
20898
|
-
return event;
|
|
20999
|
+
var event_3 = {
|
|
21000
|
+
event: "add_to_cart",
|
|
21001
|
+
ecommerce: {
|
|
21002
|
+
items: [
|
|
21003
|
+
item instanceof IkasProductDetail
|
|
21004
|
+
? productToGTMItem(item, quantity)
|
|
21005
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21006
|
+
],
|
|
21007
|
+
},
|
|
21008
|
+
};
|
|
21009
|
+
//@ts-ignore
|
|
21010
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_3);
|
|
21011
|
+
return event_3;
|
|
20899
21012
|
}
|
|
20900
21013
|
catch (err) {
|
|
20901
21014
|
console.error(err);
|
|
20902
21015
|
}
|
|
20903
21016
|
};
|
|
20904
|
-
|
|
20905
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20906
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20907
|
-
serverRuntimeConfig.FBP_ID;
|
|
20908
|
-
var event = {};
|
|
21017
|
+
GoogleTagManager.removeFromCart = function (item, quantity) {
|
|
20909
21018
|
try {
|
|
20910
|
-
|
|
20911
|
-
event
|
|
20912
|
-
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
item
|
|
20916
|
-
|
|
20917
|
-
|
|
20918
|
-
|
|
20919
|
-
|
|
20920
|
-
|
|
20921
|
-
|
|
20922
|
-
|
|
20923
|
-
}
|
|
20924
|
-
return event;
|
|
21019
|
+
var event_4 = {
|
|
21020
|
+
event: "remove_from_cart",
|
|
21021
|
+
ecommerce: {
|
|
21022
|
+
items: [
|
|
21023
|
+
item instanceof IkasProductDetail
|
|
21024
|
+
? productToGTMItem(item, quantity)
|
|
21025
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21026
|
+
],
|
|
21027
|
+
},
|
|
21028
|
+
};
|
|
21029
|
+
//@ts-ignore
|
|
21030
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_4);
|
|
21031
|
+
return event_4;
|
|
20925
21032
|
}
|
|
20926
21033
|
catch (err) {
|
|
20927
21034
|
console.error(err);
|
|
20928
21035
|
}
|
|
20929
21036
|
};
|
|
20930
|
-
|
|
21037
|
+
GoogleTagManager.beginCheckout = function (checkout) {
|
|
20931
21038
|
var _a;
|
|
20932
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20933
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20934
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20935
|
-
var event = {};
|
|
20936
21039
|
try {
|
|
20937
|
-
var
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
|
|
20944
|
-
}
|
|
20945
|
-
|
|
20946
|
-
|
|
20947
|
-
|
|
20948
|
-
ecommerce: {
|
|
20949
|
-
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
20950
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20951
|
-
}),
|
|
20952
|
-
},
|
|
20953
|
-
};
|
|
20954
|
-
//@ts-ignore
|
|
20955
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20956
|
-
}
|
|
20957
|
-
return event;
|
|
21040
|
+
var event_5 = {
|
|
21041
|
+
event: "begin_checkout",
|
|
21042
|
+
ecommerce: {
|
|
21043
|
+
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21044
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21045
|
+
}),
|
|
21046
|
+
},
|
|
21047
|
+
};
|
|
21048
|
+
//@ts-ignore
|
|
21049
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_5);
|
|
21050
|
+
return event_5;
|
|
20958
21051
|
}
|
|
20959
21052
|
catch (err) {
|
|
20960
21053
|
console.error(err);
|
|
20961
21054
|
}
|
|
20962
21055
|
};
|
|
20963
|
-
|
|
21056
|
+
GoogleTagManager.purchase = function (checkout, orderId) {
|
|
20964
21057
|
var _a, _b, _c;
|
|
20965
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20966
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20967
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20968
|
-
var event = {};
|
|
20969
21058
|
try {
|
|
20970
|
-
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
20982
|
-
|
|
20983
|
-
|
|
20984
|
-
shipping: "" + checkout.shippingTotal,
|
|
20985
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
20986
|
-
coupon: checkout.couponCode,
|
|
20987
|
-
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
20988
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20989
|
-
}),
|
|
20990
|
-
},
|
|
21059
|
+
var event_6 = {
|
|
21060
|
+
event: "purchase",
|
|
21061
|
+
ecommerce: {
|
|
21062
|
+
purchase: {
|
|
21063
|
+
transaction_id: orderId,
|
|
21064
|
+
affiliation: window.location.hostname,
|
|
21065
|
+
value: "" + checkout.totalFinalPrice,
|
|
21066
|
+
tax: "" + ((_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.totalTax),
|
|
21067
|
+
shipping: "" + checkout.shippingTotal,
|
|
21068
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
21069
|
+
coupon: checkout.couponCode,
|
|
21070
|
+
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
21071
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21072
|
+
}),
|
|
20991
21073
|
},
|
|
20992
|
-
}
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
|
|
20996
|
-
return
|
|
21074
|
+
},
|
|
21075
|
+
};
|
|
21076
|
+
//@ts-ignore
|
|
21077
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_6);
|
|
21078
|
+
return event_6;
|
|
20997
21079
|
}
|
|
20998
21080
|
catch (err) {
|
|
20999
21081
|
console.error(err);
|
|
21000
21082
|
}
|
|
21001
21083
|
};
|
|
21002
|
-
|
|
21084
|
+
GoogleTagManager.checkoutStep = function (checkout, step) {
|
|
21003
21085
|
var _a;
|
|
21004
21086
|
var eventName = "";
|
|
21005
21087
|
if (step === CheckoutStep.INFO)
|
|
@@ -21011,7 +21093,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21011
21093
|
else if (step === CheckoutStep.SUCCESS)
|
|
21012
21094
|
eventName = "checkout_success";
|
|
21013
21095
|
try {
|
|
21014
|
-
var
|
|
21096
|
+
var event_7 = {
|
|
21015
21097
|
event: eventName,
|
|
21016
21098
|
ecommerce: {
|
|
21017
21099
|
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
@@ -21020,14 +21102,14 @@ var Analytics = /** @class */ (function () {
|
|
|
21020
21102
|
},
|
|
21021
21103
|
};
|
|
21022
21104
|
//@ts-ignore
|
|
21023
|
-
!isServer$
|
|
21024
|
-
return
|
|
21105
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_7);
|
|
21106
|
+
return event_7;
|
|
21025
21107
|
}
|
|
21026
21108
|
catch (err) {
|
|
21027
21109
|
console.error(err);
|
|
21028
21110
|
}
|
|
21029
21111
|
};
|
|
21030
|
-
|
|
21112
|
+
GoogleTagManager.disableHTML = function () {
|
|
21031
21113
|
try {
|
|
21032
21114
|
var data = {
|
|
21033
21115
|
"gtm.blocklist": [
|
|
@@ -21038,19 +21120,19 @@ var Analytics = /** @class */ (function () {
|
|
|
21038
21120
|
],
|
|
21039
21121
|
};
|
|
21040
21122
|
//@ts-ignore
|
|
21041
|
-
!isServer$
|
|
21123
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(data);
|
|
21042
21124
|
}
|
|
21043
21125
|
catch (err) {
|
|
21044
21126
|
console.error(err);
|
|
21045
21127
|
}
|
|
21046
21128
|
};
|
|
21047
|
-
|
|
21129
|
+
GoogleTagManager.addToWishlist = function (id) {
|
|
21048
21130
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21049
21131
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21050
21132
|
var event = {};
|
|
21051
21133
|
try {
|
|
21052
21134
|
if (fbpId) {
|
|
21053
|
-
!isServer$
|
|
21135
|
+
!isServer$3 &&
|
|
21054
21136
|
window.fbq("track", "AddToWishlist", {
|
|
21055
21137
|
content_ids: [id],
|
|
21056
21138
|
});
|
|
@@ -21061,13 +21143,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21061
21143
|
console.error(err);
|
|
21062
21144
|
}
|
|
21063
21145
|
};
|
|
21064
|
-
|
|
21146
|
+
GoogleTagManager.search = function (searchKeyword) {
|
|
21065
21147
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21066
21148
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21067
21149
|
var event = {};
|
|
21068
21150
|
try {
|
|
21069
21151
|
if (fbpId) {
|
|
21070
|
-
!isServer$
|
|
21152
|
+
!isServer$3 &&
|
|
21071
21153
|
window.fbq("track", "Search", {
|
|
21072
21154
|
search_string: searchKeyword,
|
|
21073
21155
|
});
|
|
@@ -21078,13 +21160,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21078
21160
|
console.error(err);
|
|
21079
21161
|
}
|
|
21080
21162
|
};
|
|
21081
|
-
|
|
21163
|
+
GoogleTagManager.completeRegistration = function () {
|
|
21082
21164
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21083
21165
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21084
21166
|
var event = {};
|
|
21085
21167
|
try {
|
|
21086
21168
|
if (fbpId) {
|
|
21087
|
-
!isServer$
|
|
21169
|
+
!isServer$3 &&
|
|
21088
21170
|
window.fbq("track", "CompleteRegistration", {
|
|
21089
21171
|
status: true,
|
|
21090
21172
|
});
|
|
@@ -21095,7 +21177,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21095
21177
|
console.error(err);
|
|
21096
21178
|
}
|
|
21097
21179
|
};
|
|
21098
|
-
return
|
|
21180
|
+
return GoogleTagManager;
|
|
21099
21181
|
}());
|
|
21100
21182
|
function productToGTMItem(productDetail, quantity) {
|
|
21101
21183
|
var _a;
|
|
@@ -21126,51 +21208,6 @@ function productToGTMItem(productDetail, quantity) {
|
|
|
21126
21208
|
quantity: quantity,
|
|
21127
21209
|
};
|
|
21128
21210
|
}
|
|
21129
|
-
function productToFBPItem(productDetail, quantity) {
|
|
21130
|
-
if (quantity === void 0) { quantity = 1; }
|
|
21131
|
-
return {
|
|
21132
|
-
content_name: productDetail.product.name,
|
|
21133
|
-
content_category: productDetail.product.categories.length > 0
|
|
21134
|
-
? productDetail.product.categories[0].path
|
|
21135
|
-
.map(function (category) { return category.name; })
|
|
21136
|
-
.join(" > ")
|
|
21137
|
-
: "",
|
|
21138
|
-
content_ids: [productDetail.selectedVariant.id],
|
|
21139
|
-
content_type: "product",
|
|
21140
|
-
value: productDetail.selectedVariant.price.finalPrice,
|
|
21141
|
-
currency: productDetail.selectedVariant.price.currency === ""
|
|
21142
|
-
? "TRY"
|
|
21143
|
-
: productDetail.selectedVariant.price.currency,
|
|
21144
|
-
num_items: quantity,
|
|
21145
|
-
};
|
|
21146
|
-
}
|
|
21147
|
-
function beginCheckoutFBPItem(checkout) {
|
|
21148
|
-
var _a, _b, _c, _d;
|
|
21149
|
-
var contentIds = [];
|
|
21150
|
-
var contents = [];
|
|
21151
|
-
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21152
|
-
contentIds.push(item.id);
|
|
21153
|
-
contents.push({ id: item.id, quantity: item.quantity });
|
|
21154
|
-
});
|
|
21155
|
-
return {
|
|
21156
|
-
contents: contents,
|
|
21157
|
-
content_category: "",
|
|
21158
|
-
content_ids: contentIds,
|
|
21159
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
21160
|
-
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
21161
|
-
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
21162
|
-
};
|
|
21163
|
-
}
|
|
21164
|
-
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
21165
|
-
return {
|
|
21166
|
-
content_name: orderLineItem.variant.name,
|
|
21167
|
-
content_category: "",
|
|
21168
|
-
content_ids: [orderLineItem.variant.id],
|
|
21169
|
-
content_type: "product",
|
|
21170
|
-
value: orderLineItem.finalPrice,
|
|
21171
|
-
currency: orderLineItem.currencyCode,
|
|
21172
|
-
};
|
|
21173
|
-
}
|
|
21174
21211
|
function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
21175
21212
|
if (quantity === void 0) { quantity = 1; }
|
|
21176
21213
|
return {
|
|
@@ -21192,12 +21229,132 @@ function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
|
21192
21229
|
};
|
|
21193
21230
|
}
|
|
21194
21231
|
|
|
21232
|
+
var LS_BEGIN_CHECKOUT_KEY = "gtmBeginCheckout";
|
|
21233
|
+
var isServer$4 = typeof window === "undefined";
|
|
21234
|
+
var Analytics = /** @class */ (function () {
|
|
21235
|
+
function Analytics() {
|
|
21236
|
+
mobx.makeAutoObservable(this);
|
|
21237
|
+
}
|
|
21238
|
+
Analytics.pageView = function (url) {
|
|
21239
|
+
try {
|
|
21240
|
+
var event_1 = {
|
|
21241
|
+
event: "page-view",
|
|
21242
|
+
page: url,
|
|
21243
|
+
};
|
|
21244
|
+
//@ts-ignore
|
|
21245
|
+
!isServer$4 && window.dataLayer && window.dataLayer.push(event_1);
|
|
21246
|
+
return event_1;
|
|
21247
|
+
}
|
|
21248
|
+
catch (err) {
|
|
21249
|
+
console.error(err);
|
|
21250
|
+
}
|
|
21251
|
+
};
|
|
21252
|
+
Analytics.productView = function (productDetail) {
|
|
21253
|
+
try {
|
|
21254
|
+
FacebookPixel.productView(productDetail);
|
|
21255
|
+
GoogleTagManager.productView(productDetail);
|
|
21256
|
+
return;
|
|
21257
|
+
}
|
|
21258
|
+
catch (err) {
|
|
21259
|
+
console.error(err);
|
|
21260
|
+
}
|
|
21261
|
+
};
|
|
21262
|
+
Analytics.addToCart = function (item, quantity) {
|
|
21263
|
+
try {
|
|
21264
|
+
FacebookPixel.addToCart(item, quantity);
|
|
21265
|
+
GoogleTagManager.addToCart(item, quantity);
|
|
21266
|
+
return;
|
|
21267
|
+
}
|
|
21268
|
+
catch (err) {
|
|
21269
|
+
console.error(err);
|
|
21270
|
+
}
|
|
21271
|
+
};
|
|
21272
|
+
Analytics.removeFromCart = function (item, quantity) {
|
|
21273
|
+
try {
|
|
21274
|
+
GoogleTagManager.removeFromCart(item, quantity);
|
|
21275
|
+
return;
|
|
21276
|
+
}
|
|
21277
|
+
catch (err) {
|
|
21278
|
+
console.error(err);
|
|
21279
|
+
}
|
|
21280
|
+
};
|
|
21281
|
+
Analytics.beginCheckout = function (checkout) {
|
|
21282
|
+
try {
|
|
21283
|
+
var beginCheckout = localStorage.getItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21284
|
+
if (beginCheckout && checkout.id === beginCheckout)
|
|
21285
|
+
return;
|
|
21286
|
+
localStorage.setItem(LS_BEGIN_CHECKOUT_KEY, checkout.id);
|
|
21287
|
+
FacebookPixel.beginCheckout(checkout);
|
|
21288
|
+
GoogleTagManager.beginCheckout(checkout);
|
|
21289
|
+
return;
|
|
21290
|
+
}
|
|
21291
|
+
catch (err) {
|
|
21292
|
+
console.error(err);
|
|
21293
|
+
}
|
|
21294
|
+
};
|
|
21295
|
+
Analytics.purchase = function (checkout, orderId) {
|
|
21296
|
+
try {
|
|
21297
|
+
localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21298
|
+
FacebookPixel.purchase(checkout, orderId);
|
|
21299
|
+
GoogleTagManager.purchase(checkout, orderId);
|
|
21300
|
+
return;
|
|
21301
|
+
}
|
|
21302
|
+
catch (err) {
|
|
21303
|
+
console.error(err);
|
|
21304
|
+
}
|
|
21305
|
+
};
|
|
21306
|
+
Analytics.checkoutStep = function (checkout, step) {
|
|
21307
|
+
try {
|
|
21308
|
+
GoogleTagManager.checkoutStep(checkout, step);
|
|
21309
|
+
return;
|
|
21310
|
+
}
|
|
21311
|
+
catch (err) {
|
|
21312
|
+
console.error(err);
|
|
21313
|
+
}
|
|
21314
|
+
};
|
|
21315
|
+
Analytics.disableHTML = function () {
|
|
21316
|
+
try {
|
|
21317
|
+
GoogleTagManager.disableHTML();
|
|
21318
|
+
}
|
|
21319
|
+
catch (err) {
|
|
21320
|
+
console.error(err);
|
|
21321
|
+
}
|
|
21322
|
+
};
|
|
21323
|
+
Analytics.addToWishlist = function (id) {
|
|
21324
|
+
try {
|
|
21325
|
+
FacebookPixel.addToWishlist(id);
|
|
21326
|
+
return;
|
|
21327
|
+
}
|
|
21328
|
+
catch (err) {
|
|
21329
|
+
console.error(err);
|
|
21330
|
+
}
|
|
21331
|
+
};
|
|
21332
|
+
Analytics.search = function (searchKeyword) {
|
|
21333
|
+
try {
|
|
21334
|
+
FacebookPixel.search(searchKeyword);
|
|
21335
|
+
return;
|
|
21336
|
+
}
|
|
21337
|
+
catch (err) {
|
|
21338
|
+
console.error(err);
|
|
21339
|
+
}
|
|
21340
|
+
};
|
|
21341
|
+
Analytics.completeRegistration = function () {
|
|
21342
|
+
try {
|
|
21343
|
+
FacebookPixel.completeRegistration();
|
|
21344
|
+
return;
|
|
21345
|
+
}
|
|
21346
|
+
catch (err) {
|
|
21347
|
+
console.error(err);
|
|
21348
|
+
}
|
|
21349
|
+
};
|
|
21350
|
+
return Analytics;
|
|
21351
|
+
}());
|
|
21352
|
+
|
|
21195
21353
|
var AnalyticsHead = function (_a) {
|
|
21196
21354
|
var blockHTML = _a.blockHTML;
|
|
21197
21355
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21198
21356
|
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
21199
21357
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21200
|
-
console.log("fbp head", fbpId);
|
|
21201
21358
|
return (React.createElement(React.Fragment, null,
|
|
21202
21359
|
blockHTML && (React.createElement("script", { dangerouslySetInnerHTML: {
|
|
21203
21360
|
__html: "dataLayer = [{'gtm.blocklist': ['html']}];",
|
|
@@ -21213,7 +21370,6 @@ var AnalyticsBody = function () {
|
|
|
21213
21370
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21214
21371
|
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
21215
21372
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21216
|
-
console.log("fbp body", fbpId);
|
|
21217
21373
|
return (React.createElement(React.Fragment, null,
|
|
21218
21374
|
gtmId && (React.createElement("noscript", { dangerouslySetInnerHTML: {
|
|
21219
21375
|
__html: "<iframe src=\"https://www.googletagmanager.com/ns.html?id=" + gtmId + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>",
|