@aranova/tracking-next 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.d.mts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +299 -125
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -125
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs.map +1 -1
- package/dist/{phone-utils-BVUDHwo4.d.mts → phone-utils-CcU5mwzc.d.mts} +26 -1
- package/dist/{phone-utils-BVUDHwo4.d.ts → phone-utils-CcU5mwzc.d.ts} +26 -1
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
AdPlatformTracking: () => AdPlatformTracking,
|
|
33
34
|
AranovaApiError: () => AranovaApiError,
|
|
34
35
|
ConsentBanner: () => ConsentBanner,
|
|
35
36
|
DEFAULT_PHONE_COUNTRY: () => DEFAULT_PHONE_COUNTRY,
|
|
@@ -85,62 +86,134 @@ function buildConsentPayload(state) {
|
|
|
85
86
|
}
|
|
86
87
|
function getConsentState() {
|
|
87
88
|
if (typeof window === "undefined") return "pending";
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
try {
|
|
90
|
+
const storedState = window.localStorage.getItem(CONSENT_STATE_KEY);
|
|
91
|
+
if (storedState === "granted" || storedState === "denied") return storedState;
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
90
94
|
return "pending";
|
|
91
95
|
}
|
|
92
96
|
function setConsentState(state) {
|
|
93
97
|
if (typeof window === "undefined") return;
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
try {
|
|
99
|
+
window.localStorage.setItem(CONSENT_STATE_KEY, state);
|
|
100
|
+
window.localStorage.setItem(CONSENT_TIMESTAMP_KEY, (/* @__PURE__ */ new Date()).toISOString());
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
96
103
|
if (typeof window.gtag === "function")
|
|
97
104
|
window.gtag("consent", "update", buildConsentPayload(state));
|
|
105
|
+
if (typeof window.fbq === "function")
|
|
106
|
+
window.fbq("consent", state === "granted" ? "grant" : "revoke");
|
|
98
107
|
}
|
|
99
108
|
function resetConsent() {
|
|
100
109
|
if (typeof window === "undefined") return;
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
try {
|
|
111
|
+
window.localStorage.removeItem(CONSENT_STATE_KEY);
|
|
112
|
+
window.localStorage.removeItem(CONSENT_TIMESTAMP_KEY);
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
103
115
|
}
|
|
104
116
|
|
|
105
|
-
// ../tracking-core/src/
|
|
106
|
-
|
|
117
|
+
// ../tracking-core/src/tracking.ts
|
|
118
|
+
var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
|
|
119
|
+
var TRACKING_PARAM_KEYS = [
|
|
120
|
+
"gclid",
|
|
121
|
+
"fbclid",
|
|
122
|
+
"utm_source",
|
|
123
|
+
"utm_medium",
|
|
124
|
+
"utm_campaign",
|
|
125
|
+
"utm_term",
|
|
126
|
+
"utm_content"
|
|
127
|
+
];
|
|
128
|
+
function createEmptyTrackingParams() {
|
|
107
129
|
return {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
active_gtag_ids: input.activeGtagIds ?? null
|
|
130
|
+
gclid: null,
|
|
131
|
+
fbclid: null,
|
|
132
|
+
utm_source: null,
|
|
133
|
+
utm_medium: null,
|
|
134
|
+
utm_campaign: null,
|
|
135
|
+
utm_term: null,
|
|
136
|
+
utm_content: null
|
|
116
137
|
};
|
|
117
138
|
}
|
|
118
|
-
function
|
|
119
|
-
return
|
|
120
|
-
session_id: input.sessionId,
|
|
121
|
-
visitor_id: input.visitorId ?? null,
|
|
122
|
-
gclid: trackingParams.gclid,
|
|
123
|
-
fbclid: trackingParams.fbclid,
|
|
124
|
-
utm_source: trackingParams.utm_source,
|
|
125
|
-
utm_medium: trackingParams.utm_medium,
|
|
126
|
-
utm_campaign: trackingParams.utm_campaign,
|
|
127
|
-
utm_term: trackingParams.utm_term,
|
|
128
|
-
utm_content: trackingParams.utm_content,
|
|
129
|
-
first_page: input.firstPage ?? null,
|
|
130
|
-
consent_state: input.consentState ?? null,
|
|
131
|
-
context
|
|
132
|
-
};
|
|
139
|
+
function normalizeTrackingCookieValue(value) {
|
|
140
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
133
141
|
}
|
|
134
|
-
function
|
|
135
|
-
return {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
function getTrackingParamsFromCookieReader(readCookie) {
|
|
143
|
+
return TRACKING_PARAM_KEYS.reduce((params, key) => {
|
|
144
|
+
params[key] = normalizeTrackingCookieValue(readCookie(key));
|
|
145
|
+
return params;
|
|
146
|
+
}, createEmptyTrackingParams());
|
|
147
|
+
}
|
|
148
|
+
function getTrackingQueryValues(searchParams) {
|
|
149
|
+
return TRACKING_PARAM_KEYS.reduce((params, key) => {
|
|
150
|
+
const value = searchParams.get(key);
|
|
151
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
152
|
+
params[key] = value;
|
|
153
|
+
}
|
|
154
|
+
return params;
|
|
155
|
+
}, {});
|
|
156
|
+
}
|
|
157
|
+
var FALLBACK_STORAGE_PREFIX = "_aranova_track_";
|
|
158
|
+
function fallbackKey(name) {
|
|
159
|
+
return `${FALLBACK_STORAGE_PREFIX}${name}`;
|
|
160
|
+
}
|
|
161
|
+
function persistCookieValue(name, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
162
|
+
const encoded = encodeURIComponent(value);
|
|
163
|
+
if (typeof document !== "undefined") {
|
|
164
|
+
try {
|
|
165
|
+
document.cookie = `${name}=${encoded}; Max-Age=${maxAgeSeconds}; Path=/; SameSite=Lax`;
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (typeof window !== "undefined") {
|
|
170
|
+
try {
|
|
171
|
+
window.localStorage.setItem(fallbackKey(name), encoded);
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function readCookieValue(name) {
|
|
177
|
+
if (typeof document !== "undefined") {
|
|
178
|
+
const cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
179
|
+
const match = cookies.find((cookie) => cookie.startsWith(`${name}=`));
|
|
180
|
+
if (match) {
|
|
181
|
+
const [, rawValue = ""] = match.split("=");
|
|
182
|
+
return normalizeTrackingCookieValue(decodeURIComponent(rawValue));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (typeof window !== "undefined") {
|
|
186
|
+
try {
|
|
187
|
+
const stored = window.localStorage.getItem(fallbackKey(name));
|
|
188
|
+
if (stored) return normalizeTrackingCookieValue(decodeURIComponent(stored));
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
function getCookieValueFromDocument(key) {
|
|
195
|
+
return readCookieValue(key);
|
|
196
|
+
}
|
|
197
|
+
function setTrackingCookie(key, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
198
|
+
persistCookieValue(key, value, maxAgeSeconds);
|
|
199
|
+
}
|
|
200
|
+
function mergeTrackingParams(primary, fallback) {
|
|
201
|
+
return TRACKING_PARAM_KEYS.reduce((merged, key) => {
|
|
202
|
+
merged[key] = primary[key] ?? fallback[key];
|
|
203
|
+
return merged;
|
|
204
|
+
}, createEmptyTrackingParams());
|
|
205
|
+
}
|
|
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;
|
|
212
|
+
}
|
|
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);
|
|
144
217
|
}
|
|
145
218
|
|
|
146
219
|
// ../tracking-core/src/gtag.ts
|
|
@@ -174,15 +247,17 @@ gtag('config', '${gtagId}');
|
|
|
174
247
|
}
|
|
175
248
|
function createConsentRestoreScript() {
|
|
176
249
|
return `
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
window.gtag('
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
250
|
+
try {
|
|
251
|
+
var consentState = window.localStorage.getItem('consent_state');
|
|
252
|
+
if (window.gtag && (consentState === 'granted' || consentState === 'denied')) {
|
|
253
|
+
window.gtag('consent', 'update', {
|
|
254
|
+
ad_storage: consentState,
|
|
255
|
+
ad_user_data: consentState,
|
|
256
|
+
ad_personalization: consentState,
|
|
257
|
+
analytics_storage: consentState,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
} catch (e) {}
|
|
186
261
|
`.trim();
|
|
187
262
|
}
|
|
188
263
|
function createGtagInitScriptMulti(gtagIds) {
|
|
@@ -197,70 +272,120 @@ ${configs}
|
|
|
197
272
|
`.trim();
|
|
198
273
|
}
|
|
199
274
|
|
|
200
|
-
// ../tracking-core/src/
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
function
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
-
}
|
|
275
|
+
// ../tracking-core/src/fbq.ts
|
|
276
|
+
var FB_EVENTS_SCRIPT_HOST = "https://connect.facebook.net/en_US/fbevents.js";
|
|
277
|
+
var FBC_COOKIE = "_fbc";
|
|
278
|
+
var FBP_COOKIE = "_fbp";
|
|
279
|
+
var META_PIXEL_ID_PATTERN = /^\d{15,16}$/;
|
|
280
|
+
function isValidMetaPixelId(id) {
|
|
281
|
+
return META_PIXEL_ID_PATTERN.test(id);
|
|
282
|
+
}
|
|
283
|
+
function computeFbSubdomainIndex(hostname) {
|
|
284
|
+
const labels = hostname.split(".").filter(Boolean);
|
|
285
|
+
return Math.max(0, labels.length - 1);
|
|
286
|
+
}
|
|
287
|
+
function buildFbc(fbclid, now, hostname) {
|
|
288
|
+
const host = hostname ?? (typeof window === "undefined" ? "" : window.location.hostname);
|
|
289
|
+
return `fb.${computeFbSubdomainIndex(host)}.${now}.${fbclid}`;
|
|
290
|
+
}
|
|
291
|
+
function getFbcCookie() {
|
|
292
|
+
return readCookieValue(FBC_COOKIE);
|
|
293
|
+
}
|
|
294
|
+
function getFbpCookie() {
|
|
295
|
+
return readCookieValue(FBP_COOKIE);
|
|
296
|
+
}
|
|
297
|
+
function readFbclidFromUrl() {
|
|
298
|
+
if (typeof window === "undefined") return null;
|
|
299
|
+
try {
|
|
300
|
+
const value = new URL(window.location.href).searchParams.get("fbclid");
|
|
301
|
+
return value && value.trim().length > 0 ? value : null;
|
|
302
|
+
} catch {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
230
305
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return params;
|
|
238
|
-
}, {});
|
|
306
|
+
function captureFbc(now = typeof Date === "undefined" ? 0 : Date.now()) {
|
|
307
|
+
if (typeof window === "undefined") return;
|
|
308
|
+
if (getFbcCookie()) return;
|
|
309
|
+
const fbclid = readFbclidFromUrl() ?? readCookieValue("fbclid");
|
|
310
|
+
if (!fbclid) return;
|
|
311
|
+
persistCookieValue(FBC_COOKIE, buildFbc(fbclid, now), TRACKING_COOKIE_MAX_AGE_SECONDS);
|
|
239
312
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
313
|
+
function fbqStubScript() {
|
|
314
|
+
return `
|
|
315
|
+
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
|
316
|
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
|
|
317
|
+
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
|
|
318
|
+
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
|
|
319
|
+
document,'script','${FB_EVENTS_SCRIPT_HOST}');`.trim();
|
|
320
|
+
}
|
|
321
|
+
function createMetaConsentDefaultScript() {
|
|
322
|
+
return `${fbqStubScript()}
|
|
323
|
+
fbq('consent', 'revoke');`;
|
|
324
|
+
}
|
|
325
|
+
function createMetaPixelInitScript(pixelId) {
|
|
326
|
+
if (!isValidMetaPixelId(pixelId)) return "";
|
|
327
|
+
return `fbq('init', '${pixelId}');
|
|
328
|
+
fbq('track', 'PageView');`;
|
|
329
|
+
}
|
|
330
|
+
function createMetaPixelInitScriptMulti(pixelIds) {
|
|
331
|
+
const inits = pixelIds.filter(isValidMetaPixelId).map((id) => `fbq('init', '${id}');`);
|
|
332
|
+
if (inits.length === 0) return "";
|
|
333
|
+
return `${inits.join("\n")}
|
|
334
|
+
fbq('track', 'PageView');`;
|
|
335
|
+
}
|
|
336
|
+
function createMetaConsentRestoreScript() {
|
|
337
|
+
return `
|
|
338
|
+
try {
|
|
339
|
+
var consentState = window.localStorage.getItem('consent_state');
|
|
340
|
+
if (window.fbq && (consentState === 'granted' || consentState === 'denied')) {
|
|
341
|
+
window.fbq('consent', consentState === 'granted' ? 'grant' : 'revoke');
|
|
342
|
+
}
|
|
343
|
+
} catch (e) {}`.trim();
|
|
247
344
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
345
|
+
|
|
346
|
+
// ../tracking-core/src/payloads.ts
|
|
347
|
+
function createTrackingClientContext(surface, input = {}) {
|
|
348
|
+
return {
|
|
349
|
+
surface,
|
|
350
|
+
sdk_version: input.sdkVersion ?? null,
|
|
351
|
+
package_name: input.packageName ?? null,
|
|
352
|
+
site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
|
|
353
|
+
page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
|
|
354
|
+
referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
|
|
355
|
+
environment: input.environment ?? "production",
|
|
356
|
+
active_gtag_ids: input.activeGtagIds ?? null
|
|
357
|
+
};
|
|
252
358
|
}
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
359
|
+
function createTrackingSessionUpsertPayload(trackingParams, input, context) {
|
|
360
|
+
return {
|
|
361
|
+
session_id: input.sessionId,
|
|
362
|
+
visitor_id: input.visitorId ?? null,
|
|
363
|
+
gclid: trackingParams.gclid,
|
|
364
|
+
fbclid: trackingParams.fbclid,
|
|
365
|
+
fbc: getFbcCookie(),
|
|
366
|
+
fbp: getFbpCookie(),
|
|
367
|
+
utm_source: trackingParams.utm_source,
|
|
368
|
+
utm_medium: trackingParams.utm_medium,
|
|
369
|
+
utm_campaign: trackingParams.utm_campaign,
|
|
370
|
+
utm_term: trackingParams.utm_term,
|
|
371
|
+
utm_content: trackingParams.utm_content,
|
|
372
|
+
first_page: input.firstPage ?? null,
|
|
373
|
+
consent_state: input.consentState ?? null,
|
|
374
|
+
context
|
|
375
|
+
};
|
|
259
376
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
377
|
+
function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
378
|
+
return {
|
|
379
|
+
session_id: input.sessionId,
|
|
380
|
+
event_type: input.eventType,
|
|
381
|
+
gclid: trackingParams.gclid,
|
|
382
|
+
fbclid: trackingParams.fbclid,
|
|
383
|
+
fbc: getFbcCookie(),
|
|
384
|
+
fbp: getFbpCookie(),
|
|
385
|
+
page_url: input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href),
|
|
386
|
+
metadata: input.metadata ?? null,
|
|
387
|
+
context
|
|
388
|
+
};
|
|
264
389
|
}
|
|
265
390
|
|
|
266
391
|
// ../tracking-core/src/session.ts
|
|
@@ -553,11 +678,22 @@ function createTrackingClient(config) {
|
|
|
553
678
|
let queue = [];
|
|
554
679
|
let flushTimer = null;
|
|
555
680
|
let firstPage = null;
|
|
681
|
+
let initialParams = createEmptyTrackingParams();
|
|
556
682
|
let destroyed = false;
|
|
557
683
|
const visitorId = getVisitorId();
|
|
558
684
|
const initialSession = getOrRotateSessionId();
|
|
559
685
|
let sessionId = initialSession.id;
|
|
560
|
-
if (typeof window !== "undefined")
|
|
686
|
+
if (typeof window !== "undefined") {
|
|
687
|
+
firstPage = window.location.href;
|
|
688
|
+
try {
|
|
689
|
+
initialParams = captureTrackingParamsFromLocation();
|
|
690
|
+
} catch {
|
|
691
|
+
}
|
|
692
|
+
try {
|
|
693
|
+
captureFbc();
|
|
694
|
+
} catch {
|
|
695
|
+
}
|
|
696
|
+
}
|
|
561
697
|
function enqueueHeartbeat() {
|
|
562
698
|
const metadata = buildHeartbeatMetadata(
|
|
563
699
|
config.surface,
|
|
@@ -582,7 +718,7 @@ function createTrackingClient(config) {
|
|
|
582
718
|
enqueueHeartbeat();
|
|
583
719
|
}
|
|
584
720
|
sessionId = rotated.id;
|
|
585
|
-
const params = readTrackingParams();
|
|
721
|
+
const params = mergeTrackingParams(readTrackingParams(), initialParams);
|
|
586
722
|
const context = buildContext(
|
|
587
723
|
config.surface,
|
|
588
724
|
sdkVersion,
|
|
@@ -595,6 +731,8 @@ function createTrackingClient(config) {
|
|
|
595
731
|
visitor_id: visitorId,
|
|
596
732
|
gclid: params.gclid,
|
|
597
733
|
fbclid: params.fbclid,
|
|
734
|
+
fbc: getFbcCookie(),
|
|
735
|
+
fbp: getFbpCookie(),
|
|
598
736
|
utm_source: params.utm_source,
|
|
599
737
|
utm_medium: params.utm_medium,
|
|
600
738
|
utm_campaign: params.utm_campaign,
|
|
@@ -1713,26 +1851,61 @@ var ANIMATION_KEYFRAMES = `
|
|
|
1713
1851
|
}
|
|
1714
1852
|
`;
|
|
1715
1853
|
|
|
1716
|
-
// src/
|
|
1854
|
+
// src/AdPlatformTracking.tsx
|
|
1717
1855
|
var import_script = __toESM(require("next/script"));
|
|
1718
1856
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1857
|
+
function AdPlatformTracking({
|
|
1858
|
+
gtagId,
|
|
1859
|
+
gtagIds,
|
|
1860
|
+
metaPixelId,
|
|
1861
|
+
metaPixelIds
|
|
1862
|
+
}) {
|
|
1863
|
+
const gtagAll = gtagIds ? Object.values(gtagIds).filter((id) => id != null) : gtagId ? [gtagId] : [];
|
|
1864
|
+
const metaAll = metaPixelIds ? Object.values(metaPixelIds).filter((id) => id != null) : metaPixelId ? [metaPixelId] : [];
|
|
1865
|
+
const gtagLoaderId = gtagAll[0];
|
|
1866
|
+
const gtagInitScript = gtagAll.length === 1 ? createGtagInitScript(gtagAll[0]) : createGtagInitScriptMulti(gtagAll);
|
|
1867
|
+
const metaInitScript = metaAll.length === 1 ? createMetaPixelInitScript(metaAll[0]) : createMetaPixelInitScriptMulti(metaAll);
|
|
1868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1869
|
+
gtagLoaderId ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "consent-default", strategy: "beforeInteractive", children: createConsentDefaultScript() }),
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1872
|
+
import_script.default,
|
|
1873
|
+
{
|
|
1874
|
+
src: `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(gtagLoaderId)}`,
|
|
1875
|
+
strategy: "afterInteractive"
|
|
1876
|
+
}
|
|
1877
|
+
),
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "gtag-init", strategy: "afterInteractive", children: gtagInitScript }),
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "consent-restore", strategy: "afterInteractive", children: createConsentRestoreScript() })
|
|
1880
|
+
] }) : null,
|
|
1881
|
+
metaAll.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1882
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "meta-pixel-base", strategy: "afterInteractive", children: createMetaConsentDefaultScript() }),
|
|
1883
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "meta-pixel-init", strategy: "afterInteractive", children: metaInitScript }),
|
|
1884
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_script.default, { id: "meta-pixel-consent-restore", strategy: "afterInteractive", children: createMetaConsentRestoreScript() })
|
|
1885
|
+
] }) : null
|
|
1886
|
+
] });
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
// src/GoogleAdsTracking.tsx
|
|
1890
|
+
var import_script2 = __toESM(require("next/script"));
|
|
1891
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1719
1892
|
function GoogleAdsTracking(props) {
|
|
1720
1893
|
const { gtagId, gtagIds } = props;
|
|
1721
1894
|
const allIds = gtagIds ? Object.values(gtagIds).filter((id) => id != null) : gtagId ? [gtagId] : [];
|
|
1722
1895
|
if (allIds.length === 0) return null;
|
|
1723
1896
|
const loaderId = allIds[0];
|
|
1724
1897
|
const initScript = allIds.length === 1 ? createGtagInitScript(loaderId) : createGtagInitScriptMulti(allIds);
|
|
1725
|
-
return /* @__PURE__ */ (0,
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1727
|
-
/* @__PURE__ */ (0,
|
|
1728
|
-
|
|
1898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1899
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_script2.default, { id: "consent-default", strategy: "beforeInteractive", children: createConsentDefaultScript() }),
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1901
|
+
import_script2.default,
|
|
1729
1902
|
{
|
|
1730
1903
|
src: `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(loaderId)}`,
|
|
1731
1904
|
strategy: "afterInteractive"
|
|
1732
1905
|
}
|
|
1733
1906
|
),
|
|
1734
|
-
/* @__PURE__ */ (0,
|
|
1735
|
-
/* @__PURE__ */ (0,
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_script2.default, { id: "gtag-init", strategy: "afterInteractive", children: initScript }),
|
|
1908
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_script2.default, { id: "consent-restore", strategy: "afterInteractive", children: createConsentRestoreScript() })
|
|
1736
1909
|
] });
|
|
1737
1910
|
}
|
|
1738
1911
|
|
|
@@ -1740,14 +1913,14 @@ function GoogleAdsTracking(props) {
|
|
|
1740
1913
|
var import_navigation = require("next/navigation");
|
|
1741
1914
|
|
|
1742
1915
|
// package.json
|
|
1743
|
-
var version = "0.
|
|
1916
|
+
var version = "0.13.0";
|
|
1744
1917
|
|
|
1745
1918
|
// src/factory.tsx
|
|
1746
1919
|
var import_react4 = require("react");
|
|
1747
1920
|
|
|
1748
1921
|
// ../tracking-core/src/phone-react.tsx
|
|
1749
1922
|
var import_react3 = require("react");
|
|
1750
|
-
var
|
|
1923
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1751
1924
|
var _phoneConfigContext;
|
|
1752
1925
|
function phoneConfigContext() {
|
|
1753
1926
|
return _phoneConfigContext ?? (_phoneConfigContext = (0, import_react3.createContext)(null));
|
|
@@ -1757,7 +1930,7 @@ function PhoneConfigProvider({
|
|
|
1757
1930
|
children
|
|
1758
1931
|
}) {
|
|
1759
1932
|
const Ctx = phoneConfigContext();
|
|
1760
|
-
return /* @__PURE__ */ (0,
|
|
1933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Ctx.Provider, { value, children });
|
|
1761
1934
|
}
|
|
1762
1935
|
function usePhoneConfig() {
|
|
1763
1936
|
const ctx = (0, import_react3.useContext)(phoneConfigContext());
|
|
@@ -1817,7 +1990,7 @@ var PhoneField = (0, import_react3.forwardRef)(function PhoneField2({ country, v
|
|
|
1817
1990
|
onChange?.(event);
|
|
1818
1991
|
};
|
|
1819
1992
|
const shown = isControlled ? formatPhoneAsTyped(value, resolvedCountry) : internal;
|
|
1820
|
-
return /* @__PURE__ */ (0,
|
|
1993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1821
1994
|
"input",
|
|
1822
1995
|
{
|
|
1823
1996
|
...rest,
|
|
@@ -1832,7 +2005,7 @@ var PhoneField = (0, import_react3.forwardRef)(function PhoneField2({ country, v
|
|
|
1832
2005
|
});
|
|
1833
2006
|
|
|
1834
2007
|
// src/factory.tsx
|
|
1835
|
-
var
|
|
2008
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1836
2009
|
function createTracking(options) {
|
|
1837
2010
|
const { apiKey, endpoint, triggers, environment, gtagIds, debug, phone } = options;
|
|
1838
2011
|
if (!apiKey || !endpoint) {
|
|
@@ -1850,7 +2023,7 @@ function createTracking(options) {
|
|
|
1850
2023
|
getVisitorId: () => ""
|
|
1851
2024
|
};
|
|
1852
2025
|
return {
|
|
1853
|
-
TrackingProvider: ({ children }) => /* @__PURE__ */ (0,
|
|
2026
|
+
TrackingProvider: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PhoneConfigProvider, { value: phone ?? null, children }),
|
|
1854
2027
|
useTracking: () => noopClient
|
|
1855
2028
|
};
|
|
1856
2029
|
}
|
|
@@ -2019,7 +2192,7 @@ function createTracking(options) {
|
|
|
2019
2192
|
}
|
|
2020
2193
|
};
|
|
2021
2194
|
}, []);
|
|
2022
|
-
return /* @__PURE__ */ (0,
|
|
2195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TrackingContext.Provider, { value: client, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PhoneConfigProvider, { value: phone ?? null, children }) });
|
|
2023
2196
|
}
|
|
2024
2197
|
function useTracking() {
|
|
2025
2198
|
const client = (0, import_react4.useContext)(TrackingContext);
|
|
@@ -2034,6 +2207,7 @@ function createTracking(options) {
|
|
|
2034
2207
|
}
|
|
2035
2208
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2036
2209
|
0 && (module.exports = {
|
|
2210
|
+
AdPlatformTracking,
|
|
2037
2211
|
AranovaApiError,
|
|
2038
2212
|
ConsentBanner,
|
|
2039
2213
|
DEFAULT_PHONE_COUNTRY,
|