arky-sdk 0.4.11 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -89
- package/dist/index.d.ts +31 -89
- package/dist/index.js +11 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1857,50 +1857,15 @@ function injectGA4Script(measurementId) {
|
|
|
1857
1857
|
script.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
|
|
1858
1858
|
document.head.appendChild(script);
|
|
1859
1859
|
}
|
|
1860
|
-
function
|
|
1861
|
-
if (typeof window === "undefined"
|
|
1862
|
-
window.gtag
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
trackGA4Event("purchase", {
|
|
1866
|
-
transaction_id: params.transactionId,
|
|
1867
|
-
value: params.value,
|
|
1868
|
-
currency: params.currency,
|
|
1869
|
-
items: params.items,
|
|
1870
|
-
tax: params.tax,
|
|
1871
|
-
shipping: params.shipping
|
|
1872
|
-
});
|
|
1873
|
-
}
|
|
1874
|
-
function trackAddToCart(params) {
|
|
1875
|
-
trackGA4Event("add_to_cart", {
|
|
1876
|
-
currency: params.currency,
|
|
1877
|
-
value: params.value,
|
|
1878
|
-
items: params.items
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1881
|
-
function trackRemoveFromCart(params) {
|
|
1882
|
-
trackGA4Event("remove_from_cart", {
|
|
1883
|
-
currency: params.currency,
|
|
1884
|
-
value: params.value,
|
|
1885
|
-
items: params.items
|
|
1886
|
-
});
|
|
1887
|
-
}
|
|
1888
|
-
function trackBeginCheckout(params) {
|
|
1889
|
-
trackGA4Event("begin_checkout", {
|
|
1890
|
-
currency: params.currency,
|
|
1891
|
-
value: params.value,
|
|
1892
|
-
items: params.items
|
|
1893
|
-
});
|
|
1894
|
-
}
|
|
1895
|
-
function trackViewItem(params) {
|
|
1896
|
-
trackGA4Event("view_item", {
|
|
1897
|
-
currency: params.currency,
|
|
1898
|
-
value: params.value,
|
|
1899
|
-
items: params.items
|
|
1900
|
-
});
|
|
1860
|
+
function trackEvent(eventName, params) {
|
|
1861
|
+
if (typeof window === "undefined") return;
|
|
1862
|
+
if (window.gtag) {
|
|
1863
|
+
window.gtag("event", eventName, params);
|
|
1864
|
+
}
|
|
1901
1865
|
}
|
|
1902
|
-
function
|
|
1903
|
-
|
|
1866
|
+
function isAnalyticsReady() {
|
|
1867
|
+
if (typeof window === "undefined") return false;
|
|
1868
|
+
return typeof window.gtag === "function";
|
|
1904
1869
|
}
|
|
1905
1870
|
|
|
1906
1871
|
// src/index.ts
|
|
@@ -1926,21 +1891,10 @@ async function createArkySDK(config) {
|
|
|
1926
1891
|
};
|
|
1927
1892
|
const accountApi = createAccountApi(apiConfig);
|
|
1928
1893
|
const authApi = createAuthApi(apiConfig);
|
|
1929
|
-
const businessApi = createBusinessApi(apiConfig);
|
|
1930
|
-
if (typeof window !== "undefined") {
|
|
1931
|
-
try {
|
|
1932
|
-
const business = await businessApi.getBusiness({ id: config.businessId });
|
|
1933
|
-
const measurementId = business?.configs?.analytics?.measurementId;
|
|
1934
|
-
if (measurementId) {
|
|
1935
|
-
injectGA4Script(measurementId);
|
|
1936
|
-
}
|
|
1937
|
-
} catch (e) {
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
1894
|
const sdk = {
|
|
1941
1895
|
auth: authApi,
|
|
1942
1896
|
account: accountApi,
|
|
1943
|
-
business:
|
|
1897
|
+
business: createBusinessApi(apiConfig),
|
|
1944
1898
|
media: createMediaApi(apiConfig),
|
|
1945
1899
|
notification: createNotificationApi(apiConfig),
|
|
1946
1900
|
promoCode: createPromoCodeApi(apiConfig),
|
|
@@ -2010,13 +1964,8 @@ async function createArkySDK(config) {
|
|
|
2010
1964
|
nameToKey,
|
|
2011
1965
|
// Analytics utilities
|
|
2012
1966
|
injectGA4Script,
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
trackAddToCart,
|
|
2016
|
-
trackRemoveFromCart,
|
|
2017
|
-
trackBeginCheckout,
|
|
2018
|
-
trackViewItem,
|
|
2019
|
-
isGA4Ready
|
|
1967
|
+
trackEvent,
|
|
1968
|
+
isAnalyticsReady
|
|
2020
1969
|
}
|
|
2021
1970
|
};
|
|
2022
1971
|
return sdk;
|