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.d.cts CHANGED
@@ -183,22 +183,13 @@ declare global {
183
183
  gtag: (...args: any[]) => void;
184
184
  }
185
185
  }
186
- /**
187
- * Injects the GA4 script tag into the document head.
188
- * Should be called once on page load when analytics is configured.
189
- */
190
- declare function injectGA4Script(measurementId: string): void;
191
186
  /**
192
187
  * Generic event tracking - works with any configured analytics provider.
193
188
  * Currently routes to GA4, can be extended for other providers.
194
189
  */
195
- declare function trackEvent(eventName: string, params?: Record<string, any>): void;
196
- /**
197
- * Check if analytics is ready.
198
- */
199
- declare function isAnalyticsReady(): boolean;
190
+ declare function track(eventName: string, params?: Record<string, any>): void;
200
191
 
201
- declare const SDK_VERSION = "0.3.168";
192
+ declare const SDK_VERSION = "0.4.14";
202
193
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
203
194
  interface ApiConfig {
204
195
  httpClient: any;
@@ -362,6 +353,9 @@ declare function createArkySDK(config: HttpClientConfig & {
362
353
  getSubscribers(params: GetAudienceSubscribersParams, options?: RequestOptions): Promise<any>;
363
354
  revokeSubscription(params: RevokeAudienceSubscriptionParams, options?: RequestOptions): Promise<any>;
364
355
  };
356
+ analytics: {
357
+ track: typeof track;
358
+ };
365
359
  setBusinessId: (businessId: string) => void;
366
360
  getBusinessId: () => string;
367
361
  setMarket: (market: string) => void;
@@ -409,9 +403,7 @@ declare function createArkySDK(config: HttpClientConfig & {
409
403
  validateKey: typeof validateKey;
410
404
  toKey: typeof toKey;
411
405
  nameToKey: typeof nameToKey;
412
- injectGA4Script: typeof injectGA4Script;
413
- trackEvent: typeof trackEvent;
414
- isAnalyticsReady: typeof isAnalyticsReady;
406
+ track: typeof track;
415
407
  };
416
408
  }>;
417
409
 
package/dist/index.d.ts CHANGED
@@ -183,22 +183,13 @@ declare global {
183
183
  gtag: (...args: any[]) => void;
184
184
  }
185
185
  }
186
- /**
187
- * Injects the GA4 script tag into the document head.
188
- * Should be called once on page load when analytics is configured.
189
- */
190
- declare function injectGA4Script(measurementId: string): void;
191
186
  /**
192
187
  * Generic event tracking - works with any configured analytics provider.
193
188
  * Currently routes to GA4, can be extended for other providers.
194
189
  */
195
- declare function trackEvent(eventName: string, params?: Record<string, any>): void;
196
- /**
197
- * Check if analytics is ready.
198
- */
199
- declare function isAnalyticsReady(): boolean;
190
+ declare function track(eventName: string, params?: Record<string, any>): void;
200
191
 
201
- declare const SDK_VERSION = "0.3.168";
192
+ declare const SDK_VERSION = "0.4.14";
202
193
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
203
194
  interface ApiConfig {
204
195
  httpClient: any;
@@ -362,6 +353,9 @@ declare function createArkySDK(config: HttpClientConfig & {
362
353
  getSubscribers(params: GetAudienceSubscribersParams, options?: RequestOptions): Promise<any>;
363
354
  revokeSubscription(params: RevokeAudienceSubscriptionParams, options?: RequestOptions): Promise<any>;
364
355
  };
356
+ analytics: {
357
+ track: typeof track;
358
+ };
365
359
  setBusinessId: (businessId: string) => void;
366
360
  getBusinessId: () => string;
367
361
  setMarket: (market: string) => void;
@@ -409,9 +403,7 @@ declare function createArkySDK(config: HttpClientConfig & {
409
403
  validateKey: typeof validateKey;
410
404
  toKey: typeof toKey;
411
405
  nameToKey: typeof nameToKey;
412
- injectGA4Script: typeof injectGA4Script;
413
- trackEvent: typeof trackEvent;
414
- isAnalyticsReady: typeof isAnalyticsReady;
406
+ track: typeof track;
415
407
  };
416
408
  }>;
417
409
 
package/dist/index.js CHANGED
@@ -1855,19 +1855,15 @@ function injectGA4Script(measurementId) {
1855
1855
  script.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
1856
1856
  document.head.appendChild(script);
1857
1857
  }
1858
- function trackEvent(eventName, params) {
1858
+ function track(eventName, params) {
1859
1859
  if (typeof window === "undefined") return;
1860
1860
  if (window.gtag) {
1861
1861
  window.gtag("event", eventName, params);
1862
1862
  }
1863
1863
  }
1864
- function isAnalyticsReady() {
1865
- if (typeof window === "undefined") return false;
1866
- return typeof window.gtag === "function";
1867
- }
1868
1864
 
1869
1865
  // src/index.ts
1870
- var SDK_VERSION = "0.3.168";
1866
+ var SDK_VERSION = "0.4.14";
1871
1867
  var SUPPORTED_FRAMEWORKS = [
1872
1868
  "astro",
1873
1869
  "react",
@@ -1889,10 +1885,19 @@ async function createArkySDK(config) {
1889
1885
  };
1890
1886
  const accountApi = createAccountApi(apiConfig);
1891
1887
  const authApi = createAuthApi(apiConfig);
1888
+ const businessApi = createBusinessApi(apiConfig);
1889
+ if (typeof window !== "undefined") {
1890
+ businessApi.getBusiness({}).then(({ data: business }) => {
1891
+ if (business?.config?.analytics?.measurementId) {
1892
+ injectGA4Script(business.config.analytics.measurementId);
1893
+ }
1894
+ }).catch(() => {
1895
+ });
1896
+ }
1892
1897
  const sdk = {
1893
1898
  auth: authApi,
1894
1899
  account: accountApi,
1895
- business: createBusinessApi(apiConfig),
1900
+ business: businessApi,
1896
1901
  media: createMediaApi(apiConfig),
1897
1902
  notification: createNotificationApi(apiConfig),
1898
1903
  promoCode: createPromoCodeApi(apiConfig),
@@ -1904,6 +1909,9 @@ async function createArkySDK(config) {
1904
1909
  network: createNetworkApi(apiConfig),
1905
1910
  workflow: createWorkflowApi(apiConfig),
1906
1911
  audience: createAudienceApi(apiConfig),
1912
+ analytics: {
1913
+ track
1914
+ },
1907
1915
  setBusinessId: (businessId) => {
1908
1916
  apiConfig.businessId = businessId;
1909
1917
  },
@@ -1961,9 +1969,7 @@ async function createArkySDK(config) {
1961
1969
  toKey,
1962
1970
  nameToKey,
1963
1971
  // Analytics utilities
1964
- injectGA4Script,
1965
- trackEvent,
1966
- isAnalyticsReady
1972
+ track
1967
1973
  }
1968
1974
  };
1969
1975
  return sdk;