@aranova/tracking-react 0.12.2 → 0.13.0

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.mjs CHANGED
@@ -17,21 +17,32 @@ function buildConsentPayload(state) {
17
17
  }
18
18
  function getConsentState() {
19
19
  if (typeof window === "undefined") return "pending";
20
- const storedState = window.localStorage.getItem(CONSENT_STATE_KEY);
21
- if (storedState === "granted" || storedState === "denied") return storedState;
20
+ try {
21
+ const storedState = window.localStorage.getItem(CONSENT_STATE_KEY);
22
+ if (storedState === "granted" || storedState === "denied") return storedState;
23
+ } catch {
24
+ }
22
25
  return "pending";
23
26
  }
24
27
  function setConsentState(state) {
25
28
  if (typeof window === "undefined") return;
26
- window.localStorage.setItem(CONSENT_STATE_KEY, state);
27
- window.localStorage.setItem(CONSENT_TIMESTAMP_KEY, (/* @__PURE__ */ new Date()).toISOString());
29
+ try {
30
+ window.localStorage.setItem(CONSENT_STATE_KEY, state);
31
+ window.localStorage.setItem(CONSENT_TIMESTAMP_KEY, (/* @__PURE__ */ new Date()).toISOString());
32
+ } catch {
33
+ }
28
34
  if (typeof window.gtag === "function")
29
35
  window.gtag("consent", "update", buildConsentPayload(state));
36
+ if (typeof window.fbq === "function")
37
+ window.fbq("consent", state === "granted" ? "grant" : "revoke");
30
38
  }
31
39
  function resetConsent() {
32
40
  if (typeof window === "undefined") return;
33
- window.localStorage.removeItem(CONSENT_STATE_KEY);
34
- window.localStorage.removeItem(CONSENT_TIMESTAMP_KEY);
41
+ try {
42
+ window.localStorage.removeItem(CONSENT_STATE_KEY);
43
+ window.localStorage.removeItem(CONSENT_TIMESTAMP_KEY);
44
+ } catch {
45
+ }
35
46
  }
36
47
  function restoreStoredConsent() {
37
48
  const consentState = getConsentState();
@@ -39,45 +50,106 @@ function restoreStoredConsent() {
39
50
  return consentState;
40
51
  }
41
52
 
42
- // ../tracking-core/src/payloads.ts
43
- function createTrackingClientContext(surface, input = {}) {
53
+ // ../tracking-core/src/tracking.ts
54
+ var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
55
+ var TRACKING_PARAM_KEYS = [
56
+ "gclid",
57
+ "fbclid",
58
+ "utm_source",
59
+ "utm_medium",
60
+ "utm_campaign",
61
+ "utm_term",
62
+ "utm_content"
63
+ ];
64
+ function createEmptyTrackingParams() {
44
65
  return {
45
- surface,
46
- sdk_version: input.sdkVersion ?? null,
47
- package_name: input.packageName ?? null,
48
- site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
49
- page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
50
- referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
51
- environment: input.environment ?? "production",
52
- active_gtag_ids: input.activeGtagIds ?? null
66
+ gclid: null,
67
+ fbclid: null,
68
+ utm_source: null,
69
+ utm_medium: null,
70
+ utm_campaign: null,
71
+ utm_term: null,
72
+ utm_content: null
53
73
  };
54
74
  }
55
- function createTrackingSessionUpsertPayload(trackingParams, input, context) {
56
- return {
57
- session_id: input.sessionId,
58
- visitor_id: input.visitorId ?? null,
59
- gclid: trackingParams.gclid,
60
- fbclid: trackingParams.fbclid,
61
- utm_source: trackingParams.utm_source,
62
- utm_medium: trackingParams.utm_medium,
63
- utm_campaign: trackingParams.utm_campaign,
64
- utm_term: trackingParams.utm_term,
65
- utm_content: trackingParams.utm_content,
66
- first_page: input.firstPage ?? null,
67
- consent_state: input.consentState ?? null,
68
- context
69
- };
75
+ function normalizeTrackingCookieValue(value) {
76
+ return typeof value === "string" && value.length > 0 ? value : null;
70
77
  }
71
- function createTrackingEventCreatePayload(trackingParams, input, context) {
72
- return {
73
- session_id: input.sessionId,
74
- event_type: input.eventType,
75
- gclid: trackingParams.gclid,
76
- fbclid: trackingParams.fbclid,
77
- page_url: input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href),
78
- metadata: input.metadata ?? null,
79
- context
80
- };
78
+ function getTrackingParamsFromCookieReader(readCookie) {
79
+ return TRACKING_PARAM_KEYS.reduce((params, key) => {
80
+ params[key] = normalizeTrackingCookieValue(readCookie(key));
81
+ return params;
82
+ }, createEmptyTrackingParams());
83
+ }
84
+ function getTrackingQueryValues(searchParams) {
85
+ return TRACKING_PARAM_KEYS.reduce((params, key) => {
86
+ const value = searchParams.get(key);
87
+ if (typeof value === "string" && value.trim().length > 0) {
88
+ params[key] = value;
89
+ }
90
+ return params;
91
+ }, {});
92
+ }
93
+ var FALLBACK_STORAGE_PREFIX = "_aranova_track_";
94
+ function fallbackKey(name) {
95
+ return `${FALLBACK_STORAGE_PREFIX}${name}`;
96
+ }
97
+ function persistCookieValue(name, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
98
+ const encoded = encodeURIComponent(value);
99
+ if (typeof document !== "undefined") {
100
+ try {
101
+ document.cookie = `${name}=${encoded}; Max-Age=${maxAgeSeconds}; Path=/; SameSite=Lax`;
102
+ } catch {
103
+ }
104
+ }
105
+ if (typeof window !== "undefined") {
106
+ try {
107
+ window.localStorage.setItem(fallbackKey(name), encoded);
108
+ } catch {
109
+ }
110
+ }
111
+ }
112
+ function readCookieValue(name) {
113
+ if (typeof document !== "undefined") {
114
+ const cookies = document.cookie ? document.cookie.split("; ") : [];
115
+ const match = cookies.find((cookie) => cookie.startsWith(`${name}=`));
116
+ if (match) {
117
+ const [, rawValue = ""] = match.split("=");
118
+ return normalizeTrackingCookieValue(decodeURIComponent(rawValue));
119
+ }
120
+ }
121
+ if (typeof window !== "undefined") {
122
+ try {
123
+ const stored = window.localStorage.getItem(fallbackKey(name));
124
+ if (stored) return normalizeTrackingCookieValue(decodeURIComponent(stored));
125
+ } catch {
126
+ }
127
+ }
128
+ return null;
129
+ }
130
+ function getCookieValueFromDocument(key) {
131
+ return readCookieValue(key);
132
+ }
133
+ function setTrackingCookie(key, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
134
+ persistCookieValue(key, value, maxAgeSeconds);
135
+ }
136
+ function mergeTrackingParams(primary, fallback) {
137
+ return TRACKING_PARAM_KEYS.reduce((merged, key) => {
138
+ merged[key] = primary[key] ?? fallback[key];
139
+ return merged;
140
+ }, createEmptyTrackingParams());
141
+ }
142
+ function persistTrackingParamsFromSearchParams(searchParams, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
143
+ const trackingValues = getTrackingQueryValues(searchParams);
144
+ Object.entries(trackingValues).forEach(([key, value]) => {
145
+ setTrackingCookie(key, value, maxAgeSeconds);
146
+ });
147
+ return trackingValues;
148
+ }
149
+ function captureTrackingParamsFromLocation(url = typeof window === "undefined" ? "" : window.location.href, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
150
+ const resolvedUrl = typeof window === "undefined" ? new URL(url || "https://example.invalid") : new URL(url, window.location.origin);
151
+ persistTrackingParamsFromSearchParams(resolvedUrl.searchParams, maxAgeSeconds);
152
+ return getTrackingParamsFromCookieReader(getCookieValueFromDocument);
81
153
  }
82
154
 
83
155
  // ../tracking-core/src/gtag.ts
@@ -150,70 +222,158 @@ function bootstrapMultipleGtags(gtagIds) {
150
222
  restoreStoredConsent();
151
223
  }
152
224
 
153
- // ../tracking-core/src/tracking.ts
154
- var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
155
- var TRACKING_PARAM_KEYS = [
156
- "gclid",
157
- "fbclid",
158
- "utm_source",
159
- "utm_medium",
160
- "utm_campaign",
161
- "utm_term",
162
- "utm_content"
163
- ];
164
- function createEmptyTrackingParams() {
165
- return {
166
- gclid: null,
167
- fbclid: null,
168
- utm_source: null,
169
- utm_medium: null,
170
- utm_campaign: null,
171
- utm_term: null,
172
- utm_content: null
173
- };
225
+ // ../tracking-core/src/fbq.ts
226
+ var FB_EVENTS_SCRIPT_HOST = "https://connect.facebook.net/en_US/fbevents.js";
227
+ var FBC_COOKIE = "_fbc";
228
+ var FBP_COOKIE = "_fbp";
229
+ var META_PIXEL_ID_PATTERN = /^\d{15,16}$/;
230
+ function isValidMetaPixelId(id) {
231
+ return META_PIXEL_ID_PATTERN.test(id);
232
+ }
233
+ function computeFbSubdomainIndex(hostname) {
234
+ const labels = hostname.split(".").filter(Boolean);
235
+ return Math.max(0, labels.length - 1);
236
+ }
237
+ function buildFbc(fbclid, now, hostname) {
238
+ const host = hostname ?? (typeof window === "undefined" ? "" : window.location.hostname);
239
+ return `fb.${computeFbSubdomainIndex(host)}.${now}.${fbclid}`;
240
+ }
241
+ function getFbcCookie() {
242
+ return readCookieValue(FBC_COOKIE);
243
+ }
244
+ function getFbpCookie() {
245
+ return readCookieValue(FBP_COOKIE);
246
+ }
247
+ function readFbclidFromUrl() {
248
+ if (typeof window === "undefined") return null;
249
+ try {
250
+ const value = new URL(window.location.href).searchParams.get("fbclid");
251
+ return value && value.trim().length > 0 ? value : null;
252
+ } catch {
253
+ return null;
254
+ }
174
255
  }
175
- function normalizeTrackingCookieValue(value) {
176
- return typeof value === "string" && value.length > 0 ? value : null;
256
+ function captureFbc(now = typeof Date === "undefined" ? 0 : Date.now()) {
257
+ if (typeof window === "undefined") return;
258
+ if (getFbcCookie()) return;
259
+ const fbclid = readFbclidFromUrl() ?? readCookieValue("fbclid");
260
+ if (!fbclid) return;
261
+ persistCookieValue(FBC_COOKIE, buildFbc(fbclid, now), TRACKING_COOKIE_MAX_AGE_SECONDS);
177
262
  }
178
- function getTrackingParamsFromCookieReader(readCookie) {
179
- return TRACKING_PARAM_KEYS.reduce((params, key) => {
180
- params[key] = normalizeTrackingCookieValue(readCookie(key));
181
- return params;
182
- }, createEmptyTrackingParams());
263
+ function getScriptMarker2(id) {
264
+ return `aranova-${id}`;
183
265
  }
184
- function getTrackingQueryValues(searchParams) {
185
- return TRACKING_PARAM_KEYS.reduce((params, key) => {
186
- const value = searchParams.get(key);
187
- if (typeof value === "string" && value.trim().length > 0) {
188
- params[key] = value;
189
- }
190
- return params;
191
- }, {});
266
+ function ensureFbqFunction() {
267
+ const w = window;
268
+ if (typeof w.fbq === "function") return w.fbq;
269
+ const fbq = function(...args) {
270
+ if (fbq.callMethod) fbq.callMethod.apply(fbq, args);
271
+ else fbq.queue.push(args);
272
+ };
273
+ fbq.push = fbq;
274
+ fbq.loaded = true;
275
+ fbq.version = "2.0";
276
+ fbq.queue = [];
277
+ w.fbq = fbq;
278
+ if (!w._fbq) w._fbq = fbq;
279
+ return fbq;
280
+ }
281
+ function applyDefaultMetaConsentState() {
282
+ ensureFbqFunction()("consent", "revoke");
283
+ }
284
+ function loadFbeventsScript() {
285
+ if (typeof document === "undefined") return;
286
+ const marker = getScriptMarker2("fbq-loader");
287
+ const existing = document.querySelector(
288
+ `script[${TRACKING_SCRIPT_ATTRIBUTE}="${marker}"]`
289
+ );
290
+ if (existing) return;
291
+ const script = document.createElement("script");
292
+ script.async = true;
293
+ script.src = FB_EVENTS_SCRIPT_HOST;
294
+ script.setAttribute(TRACKING_SCRIPT_ATTRIBUTE, marker);
295
+ document.head.append(script);
192
296
  }
193
- function getCookieValueFromDocument(key) {
194
- if (typeof document === "undefined") return null;
195
- const cookies = document.cookie ? document.cookie.split("; ") : [];
196
- const match = cookies.find((cookie) => cookie.startsWith(`${key}=`));
197
- if (!match) return null;
198
- const [, rawValue = ""] = match.split("=");
199
- return normalizeTrackingCookieValue(decodeURIComponent(rawValue));
297
+ function initializeMetaPixel(pixelId) {
298
+ const fbq = ensureFbqFunction();
299
+ fbq("init", pixelId);
300
+ fbq("track", "PageView");
200
301
  }
201
- function setTrackingCookie(key, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
202
- if (typeof document === "undefined") return;
203
- const encodedValue = encodeURIComponent(value);
204
- document.cookie = `${key}=${encodedValue}; Max-Age=${maxAgeSeconds}; Path=/; SameSite=Lax`;
302
+ function restoreMetaConsentState() {
303
+ if (typeof window === "undefined") return;
304
+ const state = getConsentState();
305
+ if (state === "granted") window.fbq?.("consent", "grant");
306
+ else if (state === "denied") window.fbq?.("consent", "revoke");
205
307
  }
206
- function persistTrackingParamsFromSearchParams(searchParams, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
207
- const trackingValues = getTrackingQueryValues(searchParams);
208
- Object.entries(trackingValues).forEach(([key, value]) => {
209
- setTrackingCookie(key, value, maxAgeSeconds);
210
- });
211
- return trackingValues;
308
+ function bootstrapMetaPixel(pixelId) {
309
+ if (typeof window === "undefined" || typeof document === "undefined") return;
310
+ if (!isValidMetaPixelId(pixelId)) return;
311
+ applyDefaultMetaConsentState();
312
+ loadFbeventsScript();
313
+ initializeMetaPixel(pixelId);
314
+ restoreMetaConsentState();
315
+ captureFbc();
316
+ }
317
+ function bootstrapMultiplePixels(pixelIds) {
318
+ if (typeof window === "undefined" || typeof document === "undefined") return;
319
+ const ids = Object.values(pixelIds).filter(
320
+ (id) => typeof id === "string" && isValidMetaPixelId(id)
321
+ );
322
+ if (ids.length === 0) return;
323
+ applyDefaultMetaConsentState();
324
+ loadFbeventsScript();
325
+ const fbq = ensureFbqFunction();
326
+ for (const id of ids) {
327
+ fbq("init", id);
328
+ }
329
+ fbq("track", "PageView");
330
+ restoreMetaConsentState();
331
+ captureFbc();
212
332
  }
213
- function captureTrackingParamsFromLocation(url = typeof window === "undefined" ? "" : window.location.href, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
214
- const resolvedUrl = typeof window === "undefined" ? new URL(url || "https://example.invalid") : new URL(url, window.location.origin);
215
- persistTrackingParamsFromSearchParams(resolvedUrl.searchParams, maxAgeSeconds);
216
- return getTrackingParamsFromCookieReader(getCookieValueFromDocument);
333
+
334
+ // ../tracking-core/src/payloads.ts
335
+ function createTrackingClientContext(surface, input = {}) {
336
+ return {
337
+ surface,
338
+ sdk_version: input.sdkVersion ?? null,
339
+ package_name: input.packageName ?? null,
340
+ site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
341
+ page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
342
+ referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
343
+ environment: input.environment ?? "production",
344
+ active_gtag_ids: input.activeGtagIds ?? null
345
+ };
346
+ }
347
+ function createTrackingSessionUpsertPayload(trackingParams, input, context) {
348
+ return {
349
+ session_id: input.sessionId,
350
+ visitor_id: input.visitorId ?? null,
351
+ gclid: trackingParams.gclid,
352
+ fbclid: trackingParams.fbclid,
353
+ fbc: getFbcCookie(),
354
+ fbp: getFbpCookie(),
355
+ utm_source: trackingParams.utm_source,
356
+ utm_medium: trackingParams.utm_medium,
357
+ utm_campaign: trackingParams.utm_campaign,
358
+ utm_term: trackingParams.utm_term,
359
+ utm_content: trackingParams.utm_content,
360
+ first_page: input.firstPage ?? null,
361
+ consent_state: input.consentState ?? null,
362
+ context
363
+ };
364
+ }
365
+ function createTrackingEventCreatePayload(trackingParams, input, context) {
366
+ return {
367
+ session_id: input.sessionId,
368
+ event_type: input.eventType,
369
+ gclid: trackingParams.gclid,
370
+ fbclid: trackingParams.fbclid,
371
+ fbc: getFbcCookie(),
372
+ fbp: getFbpCookie(),
373
+ page_url: input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href),
374
+ metadata: input.metadata ?? null,
375
+ context
376
+ };
217
377
  }
218
378
 
219
379
  // ../tracking-core/src/session.ts
@@ -544,11 +704,22 @@ function createTrackingClient(config) {
544
704
  let queue = [];
545
705
  let flushTimer = null;
546
706
  let firstPage = null;
707
+ let initialParams = createEmptyTrackingParams();
547
708
  let destroyed = false;
548
709
  const visitorId = getVisitorId();
549
710
  const initialSession = getOrRotateSessionId();
550
711
  let sessionId = initialSession.id;
551
- if (typeof window !== "undefined") firstPage = window.location.href;
712
+ if (typeof window !== "undefined") {
713
+ firstPage = window.location.href;
714
+ try {
715
+ initialParams = captureTrackingParamsFromLocation();
716
+ } catch {
717
+ }
718
+ try {
719
+ captureFbc();
720
+ } catch {
721
+ }
722
+ }
552
723
  function enqueueHeartbeat() {
553
724
  const metadata = buildHeartbeatMetadata(
554
725
  config.surface,
@@ -573,7 +744,7 @@ function createTrackingClient(config) {
573
744
  enqueueHeartbeat();
574
745
  }
575
746
  sessionId = rotated.id;
576
- const params = readTrackingParams();
747
+ const params = mergeTrackingParams(readTrackingParams(), initialParams);
577
748
  const context = buildContext(
578
749
  config.surface,
579
750
  sdkVersion,
@@ -586,6 +757,8 @@ function createTrackingClient(config) {
586
757
  visitor_id: visitorId,
587
758
  gclid: params.gclid,
588
759
  fbclid: params.fbclid,
760
+ fbc: getFbcCookie(),
761
+ fbp: getFbpCookie(),
589
762
  utm_source: params.utm_source,
590
763
  utm_medium: params.utm_medium,
591
764
  utm_campaign: params.utm_campaign,
@@ -1835,11 +2008,19 @@ var ANIMATION_KEYFRAMES = `
1835
2008
  }
1836
2009
  `;
1837
2010
 
1838
- // src/GoogleAdsTracking.tsx
2011
+ // src/AdPlatformTracking.tsx
1839
2012
  import { useEffect as useEffect3, useMemo } from "react";
1840
- function GoogleAdsTracking(props) {
1841
- const { gtagId, gtagIds } = props;
2013
+ function AdPlatformTracking({
2014
+ gtagId,
2015
+ gtagIds,
2016
+ metaPixelId,
2017
+ metaPixelIds
2018
+ }) {
1842
2019
  const gtagIdsKey = useMemo(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
2020
+ const metaPixelIdsKey = useMemo(
2021
+ () => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
2022
+ [metaPixelIds]
2023
+ );
1843
2024
  useEffect3(() => {
1844
2025
  if (gtagIds && Object.keys(gtagIds).length > 0) {
1845
2026
  bootstrapMultipleGtags(gtagIds);
@@ -1847,14 +2028,36 @@ function GoogleAdsTracking(props) {
1847
2028
  bootstrapGoogleAdsTracking(gtagId);
1848
2029
  }
1849
2030
  }, [gtagId, gtagIdsKey]);
2031
+ useEffect3(() => {
2032
+ if (metaPixelIds && Object.keys(metaPixelIds).length > 0) {
2033
+ bootstrapMultiplePixels(metaPixelIds);
2034
+ } else if (metaPixelId) {
2035
+ bootstrapMetaPixel(metaPixelId);
2036
+ }
2037
+ }, [metaPixelId, metaPixelIdsKey]);
2038
+ return null;
2039
+ }
2040
+
2041
+ // src/GoogleAdsTracking.tsx
2042
+ import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
2043
+ function GoogleAdsTracking(props) {
2044
+ const { gtagId, gtagIds } = props;
2045
+ const gtagIdsKey = useMemo2(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
2046
+ useEffect4(() => {
2047
+ if (gtagIds && Object.keys(gtagIds).length > 0) {
2048
+ bootstrapMultipleGtags(gtagIds);
2049
+ } else if (gtagId) {
2050
+ bootstrapGoogleAdsTracking(gtagId);
2051
+ }
2052
+ }, [gtagId, gtagIdsKey]);
1850
2053
  return null;
1851
2054
  }
1852
2055
 
1853
2056
  // src/factory.tsx
1854
- import { createContext as createContext2, useContext as useContext2, useEffect as useEffect4, useMemo as useMemo3 } from "react";
2057
+ import { createContext as createContext2, useContext as useContext2, useEffect as useEffect5, useMemo as useMemo4 } from "react";
1855
2058
 
1856
2059
  // package.json
1857
- var version = "0.12.2";
2060
+ var version = "0.13.0";
1858
2061
 
1859
2062
  // ../tracking-core/src/phone-react.tsx
1860
2063
  import {
@@ -1862,7 +2065,7 @@ import {
1862
2065
  forwardRef,
1863
2066
  useCallback as useCallback2,
1864
2067
  useContext,
1865
- useMemo as useMemo2,
2068
+ useMemo as useMemo3,
1866
2069
  useState as useState3
1867
2070
  } from "react";
1868
2071
  import { jsx as jsx2 } from "react/jsx-runtime";
@@ -1891,7 +2094,7 @@ function usePhoneField(opts = {}) {
1891
2094
  const { onValueChange } = opts;
1892
2095
  const [value, setValue] = useState3(() => formatPhoneAsTyped(opts.defaultValue ?? "", country));
1893
2096
  const [touched, setTouched] = useState3(false);
1894
- const parsed = useMemo2(() => parsePhone(value, country), [value, country]);
2097
+ const parsed = useMemo3(() => parsePhone(value, country), [value, country]);
1895
2098
  const onChange = useCallback2(
1896
2099
  (event) => {
1897
2100
  const next = formatPhoneAsTyped(event.target.value, country);
@@ -1976,11 +2179,17 @@ function createTracking(options) {
1976
2179
  };
1977
2180
  }
1978
2181
  const TrackingContext = createContext2(null);
1979
- function TrackingProvider({ gtagId, gtagIds, children }) {
2182
+ function TrackingProvider({
2183
+ gtagId,
2184
+ gtagIds,
2185
+ metaPixelId,
2186
+ metaPixelIds,
2187
+ children
2188
+ }) {
1980
2189
  const resolvedGtagIds = gtagIds ? Object.fromEntries(
1981
2190
  Object.entries(gtagIds).filter((e) => e[1] != null)
1982
2191
  ) : gtagId ? { default: gtagId } : void 0;
1983
- const client = useMemo3(
2192
+ const client = useMemo4(
1984
2193
  () => createTypedClient(
1985
2194
  getOrCreateTrackingClient({
1986
2195
  apiKey,
@@ -1998,15 +2207,26 @@ function createTracking(options) {
1998
2207
  ),
1999
2208
  []
2000
2209
  );
2001
- const gtagIdsKey = useMemo3(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
2002
- useEffect4(() => {
2210
+ const gtagIdsKey = useMemo4(() => gtagIds ? JSON.stringify(gtagIds) : "", [gtagIds]);
2211
+ useEffect5(() => {
2003
2212
  if (gtagIds && Object.keys(gtagIds).length > 0) {
2004
2213
  bootstrapMultipleGtags(gtagIds);
2005
2214
  } else if (gtagId) {
2006
2215
  bootstrapGoogleAdsTracking(gtagId);
2007
2216
  }
2008
2217
  }, [gtagId, gtagIdsKey]);
2009
- useEffect4(() => {
2218
+ const metaPixelIdsKey = useMemo4(
2219
+ () => metaPixelIds ? JSON.stringify(metaPixelIds) : "",
2220
+ [metaPixelIds]
2221
+ );
2222
+ useEffect5(() => {
2223
+ if (metaPixelIds && Object.keys(metaPixelIds).length > 0) {
2224
+ bootstrapMultiplePixels(metaPixelIds);
2225
+ } else if (metaPixelId) {
2226
+ bootstrapMetaPixel(metaPixelId);
2227
+ }
2228
+ }, [metaPixelId, metaPixelIdsKey]);
2229
+ useEffect5(() => {
2010
2230
  const detachers = [];
2011
2231
  const rawClient = getOrCreateTrackingClient({
2012
2232
  apiKey,
@@ -2060,6 +2280,7 @@ function createTracking(options) {
2060
2280
  return { TrackingProvider, useTracking };
2061
2281
  }
2062
2282
  export {
2283
+ AdPlatformTracking,
2063
2284
  AranovaApiError,
2064
2285
  ConsentBanner,
2065
2286
  DEFAULT_PHONE_COUNTRY,