arky-sdk 0.4.13 → 0.4.14
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 +16 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -14
- package/dist/index.d.ts +6 -14
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1857,19 +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
|
|
1860
|
+
function track(eventName, params) {
|
|
1861
1861
|
if (typeof window === "undefined") return;
|
|
1862
1862
|
if (window.gtag) {
|
|
1863
1863
|
window.gtag("event", eventName, params);
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
|
-
function isAnalyticsReady() {
|
|
1867
|
-
if (typeof window === "undefined") return false;
|
|
1868
|
-
return typeof window.gtag === "function";
|
|
1869
|
-
}
|
|
1870
1866
|
|
|
1871
1867
|
// src/index.ts
|
|
1872
|
-
var SDK_VERSION = "0.
|
|
1868
|
+
var SDK_VERSION = "0.4.14";
|
|
1873
1869
|
var SUPPORTED_FRAMEWORKS = [
|
|
1874
1870
|
"astro",
|
|
1875
1871
|
"react",
|
|
@@ -1891,10 +1887,19 @@ async function createArkySDK(config) {
|
|
|
1891
1887
|
};
|
|
1892
1888
|
const accountApi = createAccountApi(apiConfig);
|
|
1893
1889
|
const authApi = createAuthApi(apiConfig);
|
|
1890
|
+
const businessApi = createBusinessApi(apiConfig);
|
|
1891
|
+
if (typeof window !== "undefined") {
|
|
1892
|
+
businessApi.getBusiness({}).then(({ data: business }) => {
|
|
1893
|
+
if (business?.config?.analytics?.measurementId) {
|
|
1894
|
+
injectGA4Script(business.config.analytics.measurementId);
|
|
1895
|
+
}
|
|
1896
|
+
}).catch(() => {
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1894
1899
|
const sdk = {
|
|
1895
1900
|
auth: authApi,
|
|
1896
1901
|
account: accountApi,
|
|
1897
|
-
business:
|
|
1902
|
+
business: businessApi,
|
|
1898
1903
|
media: createMediaApi(apiConfig),
|
|
1899
1904
|
notification: createNotificationApi(apiConfig),
|
|
1900
1905
|
promoCode: createPromoCodeApi(apiConfig),
|
|
@@ -1906,6 +1911,9 @@ async function createArkySDK(config) {
|
|
|
1906
1911
|
network: createNetworkApi(apiConfig),
|
|
1907
1912
|
workflow: createWorkflowApi(apiConfig),
|
|
1908
1913
|
audience: createAudienceApi(apiConfig),
|
|
1914
|
+
analytics: {
|
|
1915
|
+
track
|
|
1916
|
+
},
|
|
1909
1917
|
setBusinessId: (businessId) => {
|
|
1910
1918
|
apiConfig.businessId = businessId;
|
|
1911
1919
|
},
|
|
@@ -1963,9 +1971,7 @@ async function createArkySDK(config) {
|
|
|
1963
1971
|
toKey,
|
|
1964
1972
|
nameToKey,
|
|
1965
1973
|
// Analytics utilities
|
|
1966
|
-
|
|
1967
|
-
trackEvent,
|
|
1968
|
-
isAnalyticsReady
|
|
1974
|
+
track
|
|
1969
1975
|
}
|
|
1970
1976
|
};
|
|
1971
1977
|
return sdk;
|