@aranova/tracking-next 0.12.1 → 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 +301 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +300 -127
- 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-dd1tW7sb.d.mts → phone-utils-CcU5mwzc.d.mts} +33 -4
- package/dist/{phone-utils-dd1tW7sb.d.ts → phone-utils-CcU5mwzc.d.ts} +33 -4
- 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.mjs
CHANGED
|
@@ -11,62 +11,134 @@ function buildConsentPayload(state) {
|
|
|
11
11
|
}
|
|
12
12
|
function getConsentState() {
|
|
13
13
|
if (typeof window === "undefined") return "pending";
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
try {
|
|
15
|
+
const storedState = window.localStorage.getItem(CONSENT_STATE_KEY);
|
|
16
|
+
if (storedState === "granted" || storedState === "denied") return storedState;
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
16
19
|
return "pending";
|
|
17
20
|
}
|
|
18
21
|
function setConsentState(state) {
|
|
19
22
|
if (typeof window === "undefined") return;
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
try {
|
|
24
|
+
window.localStorage.setItem(CONSENT_STATE_KEY, state);
|
|
25
|
+
window.localStorage.setItem(CONSENT_TIMESTAMP_KEY, (/* @__PURE__ */ new Date()).toISOString());
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
22
28
|
if (typeof window.gtag === "function")
|
|
23
29
|
window.gtag("consent", "update", buildConsentPayload(state));
|
|
30
|
+
if (typeof window.fbq === "function")
|
|
31
|
+
window.fbq("consent", state === "granted" ? "grant" : "revoke");
|
|
24
32
|
}
|
|
25
33
|
function resetConsent() {
|
|
26
34
|
if (typeof window === "undefined") return;
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
try {
|
|
36
|
+
window.localStorage.removeItem(CONSENT_STATE_KEY);
|
|
37
|
+
window.localStorage.removeItem(CONSENT_TIMESTAMP_KEY);
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
29
40
|
}
|
|
30
41
|
|
|
31
|
-
// ../tracking-core/src/
|
|
32
|
-
|
|
42
|
+
// ../tracking-core/src/tracking.ts
|
|
43
|
+
var TRACKING_COOKIE_MAX_AGE_SECONDS = 7776e3;
|
|
44
|
+
var TRACKING_PARAM_KEYS = [
|
|
45
|
+
"gclid",
|
|
46
|
+
"fbclid",
|
|
47
|
+
"utm_source",
|
|
48
|
+
"utm_medium",
|
|
49
|
+
"utm_campaign",
|
|
50
|
+
"utm_term",
|
|
51
|
+
"utm_content"
|
|
52
|
+
];
|
|
53
|
+
function createEmptyTrackingParams() {
|
|
33
54
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
active_gtag_ids: input.activeGtagIds ?? null
|
|
55
|
+
gclid: null,
|
|
56
|
+
fbclid: null,
|
|
57
|
+
utm_source: null,
|
|
58
|
+
utm_medium: null,
|
|
59
|
+
utm_campaign: null,
|
|
60
|
+
utm_term: null,
|
|
61
|
+
utm_content: null
|
|
42
62
|
};
|
|
43
63
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
46
|
-
session_id: input.sessionId,
|
|
47
|
-
visitor_id: input.visitorId ?? null,
|
|
48
|
-
gclid: trackingParams.gclid,
|
|
49
|
-
fbclid: trackingParams.fbclid,
|
|
50
|
-
utm_source: trackingParams.utm_source,
|
|
51
|
-
utm_medium: trackingParams.utm_medium,
|
|
52
|
-
utm_campaign: trackingParams.utm_campaign,
|
|
53
|
-
utm_term: trackingParams.utm_term,
|
|
54
|
-
utm_content: trackingParams.utm_content,
|
|
55
|
-
first_page: input.firstPage ?? null,
|
|
56
|
-
consent_state: input.consentState ?? null,
|
|
57
|
-
context
|
|
58
|
-
};
|
|
64
|
+
function normalizeTrackingCookieValue(value) {
|
|
65
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
59
66
|
}
|
|
60
|
-
function
|
|
61
|
-
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
function getTrackingParamsFromCookieReader(readCookie) {
|
|
68
|
+
return TRACKING_PARAM_KEYS.reduce((params, key) => {
|
|
69
|
+
params[key] = normalizeTrackingCookieValue(readCookie(key));
|
|
70
|
+
return params;
|
|
71
|
+
}, createEmptyTrackingParams());
|
|
72
|
+
}
|
|
73
|
+
function getTrackingQueryValues(searchParams) {
|
|
74
|
+
return TRACKING_PARAM_KEYS.reduce((params, key) => {
|
|
75
|
+
const value = searchParams.get(key);
|
|
76
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
77
|
+
params[key] = value;
|
|
78
|
+
}
|
|
79
|
+
return params;
|
|
80
|
+
}, {});
|
|
81
|
+
}
|
|
82
|
+
var FALLBACK_STORAGE_PREFIX = "_aranova_track_";
|
|
83
|
+
function fallbackKey(name) {
|
|
84
|
+
return `${FALLBACK_STORAGE_PREFIX}${name}`;
|
|
85
|
+
}
|
|
86
|
+
function persistCookieValue(name, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
87
|
+
const encoded = encodeURIComponent(value);
|
|
88
|
+
if (typeof document !== "undefined") {
|
|
89
|
+
try {
|
|
90
|
+
document.cookie = `${name}=${encoded}; Max-Age=${maxAgeSeconds}; Path=/; SameSite=Lax`;
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (typeof window !== "undefined") {
|
|
95
|
+
try {
|
|
96
|
+
window.localStorage.setItem(fallbackKey(name), encoded);
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function readCookieValue(name) {
|
|
102
|
+
if (typeof document !== "undefined") {
|
|
103
|
+
const cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
104
|
+
const match = cookies.find((cookie) => cookie.startsWith(`${name}=`));
|
|
105
|
+
if (match) {
|
|
106
|
+
const [, rawValue = ""] = match.split("=");
|
|
107
|
+
return normalizeTrackingCookieValue(decodeURIComponent(rawValue));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (typeof window !== "undefined") {
|
|
111
|
+
try {
|
|
112
|
+
const stored = window.localStorage.getItem(fallbackKey(name));
|
|
113
|
+
if (stored) return normalizeTrackingCookieValue(decodeURIComponent(stored));
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function getCookieValueFromDocument(key) {
|
|
120
|
+
return readCookieValue(key);
|
|
121
|
+
}
|
|
122
|
+
function setTrackingCookie(key, value, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
123
|
+
persistCookieValue(key, value, maxAgeSeconds);
|
|
124
|
+
}
|
|
125
|
+
function mergeTrackingParams(primary, fallback) {
|
|
126
|
+
return TRACKING_PARAM_KEYS.reduce((merged, key) => {
|
|
127
|
+
merged[key] = primary[key] ?? fallback[key];
|
|
128
|
+
return merged;
|
|
129
|
+
}, createEmptyTrackingParams());
|
|
130
|
+
}
|
|
131
|
+
function persistTrackingParamsFromSearchParams(searchParams, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
132
|
+
const trackingValues = getTrackingQueryValues(searchParams);
|
|
133
|
+
Object.entries(trackingValues).forEach(([key, value]) => {
|
|
134
|
+
setTrackingCookie(key, value, maxAgeSeconds);
|
|
135
|
+
});
|
|
136
|
+
return trackingValues;
|
|
137
|
+
}
|
|
138
|
+
function captureTrackingParamsFromLocation(url = typeof window === "undefined" ? "" : window.location.href, maxAgeSeconds = TRACKING_COOKIE_MAX_AGE_SECONDS) {
|
|
139
|
+
const resolvedUrl = typeof window === "undefined" ? new URL(url || "https://example.invalid") : new URL(url, window.location.origin);
|
|
140
|
+
persistTrackingParamsFromSearchParams(resolvedUrl.searchParams, maxAgeSeconds);
|
|
141
|
+
return getTrackingParamsFromCookieReader(getCookieValueFromDocument);
|
|
70
142
|
}
|
|
71
143
|
|
|
72
144
|
// ../tracking-core/src/gtag.ts
|
|
@@ -100,15 +172,17 @@ gtag('config', '${gtagId}');
|
|
|
100
172
|
}
|
|
101
173
|
function createConsentRestoreScript() {
|
|
102
174
|
return `
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
window.gtag('
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
175
|
+
try {
|
|
176
|
+
var consentState = window.localStorage.getItem('consent_state');
|
|
177
|
+
if (window.gtag && (consentState === 'granted' || consentState === 'denied')) {
|
|
178
|
+
window.gtag('consent', 'update', {
|
|
179
|
+
ad_storage: consentState,
|
|
180
|
+
ad_user_data: consentState,
|
|
181
|
+
ad_personalization: consentState,
|
|
182
|
+
analytics_storage: consentState,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} catch (e) {}
|
|
112
186
|
`.trim();
|
|
113
187
|
}
|
|
114
188
|
function createGtagInitScriptMulti(gtagIds) {
|
|
@@ -123,70 +197,120 @@ ${configs}
|
|
|
123
197
|
`.trim();
|
|
124
198
|
}
|
|
125
199
|
|
|
126
|
-
// ../tracking-core/src/
|
|
127
|
-
var
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
}
|
|
200
|
+
// ../tracking-core/src/fbq.ts
|
|
201
|
+
var FB_EVENTS_SCRIPT_HOST = "https://connect.facebook.net/en_US/fbevents.js";
|
|
202
|
+
var FBC_COOKIE = "_fbc";
|
|
203
|
+
var FBP_COOKIE = "_fbp";
|
|
204
|
+
var META_PIXEL_ID_PATTERN = /^\d{15,16}$/;
|
|
205
|
+
function isValidMetaPixelId(id) {
|
|
206
|
+
return META_PIXEL_ID_PATTERN.test(id);
|
|
207
|
+
}
|
|
208
|
+
function computeFbSubdomainIndex(hostname) {
|
|
209
|
+
const labels = hostname.split(".").filter(Boolean);
|
|
210
|
+
return Math.max(0, labels.length - 1);
|
|
211
|
+
}
|
|
212
|
+
function buildFbc(fbclid, now, hostname) {
|
|
213
|
+
const host = hostname ?? (typeof window === "undefined" ? "" : window.location.hostname);
|
|
214
|
+
return `fb.${computeFbSubdomainIndex(host)}.${now}.${fbclid}`;
|
|
215
|
+
}
|
|
216
|
+
function getFbcCookie() {
|
|
217
|
+
return readCookieValue(FBC_COOKIE);
|
|
218
|
+
}
|
|
219
|
+
function getFbpCookie() {
|
|
220
|
+
return readCookieValue(FBP_COOKIE);
|
|
221
|
+
}
|
|
222
|
+
function readFbclidFromUrl() {
|
|
223
|
+
if (typeof window === "undefined") return null;
|
|
224
|
+
try {
|
|
225
|
+
const value = new URL(window.location.href).searchParams.get("fbclid");
|
|
226
|
+
return value && value.trim().length > 0 ? value : null;
|
|
227
|
+
} catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
156
230
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return params;
|
|
164
|
-
}, {});
|
|
231
|
+
function captureFbc(now = typeof Date === "undefined" ? 0 : Date.now()) {
|
|
232
|
+
if (typeof window === "undefined") return;
|
|
233
|
+
if (getFbcCookie()) return;
|
|
234
|
+
const fbclid = readFbclidFromUrl() ?? readCookieValue("fbclid");
|
|
235
|
+
if (!fbclid) return;
|
|
236
|
+
persistCookieValue(FBC_COOKIE, buildFbc(fbclid, now), TRACKING_COOKIE_MAX_AGE_SECONDS);
|
|
165
237
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
238
|
+
function fbqStubScript() {
|
|
239
|
+
return `
|
|
240
|
+
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
|
241
|
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
|
|
242
|
+
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
|
|
243
|
+
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
|
|
244
|
+
document,'script','${FB_EVENTS_SCRIPT_HOST}');`.trim();
|
|
245
|
+
}
|
|
246
|
+
function createMetaConsentDefaultScript() {
|
|
247
|
+
return `${fbqStubScript()}
|
|
248
|
+
fbq('consent', 'revoke');`;
|
|
249
|
+
}
|
|
250
|
+
function createMetaPixelInitScript(pixelId) {
|
|
251
|
+
if (!isValidMetaPixelId(pixelId)) return "";
|
|
252
|
+
return `fbq('init', '${pixelId}');
|
|
253
|
+
fbq('track', 'PageView');`;
|
|
254
|
+
}
|
|
255
|
+
function createMetaPixelInitScriptMulti(pixelIds) {
|
|
256
|
+
const inits = pixelIds.filter(isValidMetaPixelId).map((id) => `fbq('init', '${id}');`);
|
|
257
|
+
if (inits.length === 0) return "";
|
|
258
|
+
return `${inits.join("\n")}
|
|
259
|
+
fbq('track', 'PageView');`;
|
|
260
|
+
}
|
|
261
|
+
function createMetaConsentRestoreScript() {
|
|
262
|
+
return `
|
|
263
|
+
try {
|
|
264
|
+
var consentState = window.localStorage.getItem('consent_state');
|
|
265
|
+
if (window.fbq && (consentState === 'granted' || consentState === 'denied')) {
|
|
266
|
+
window.fbq('consent', consentState === 'granted' ? 'grant' : 'revoke');
|
|
267
|
+
}
|
|
268
|
+
} catch (e) {}`.trim();
|
|
173
269
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
270
|
+
|
|
271
|
+
// ../tracking-core/src/payloads.ts
|
|
272
|
+
function createTrackingClientContext(surface, input = {}) {
|
|
273
|
+
return {
|
|
274
|
+
surface,
|
|
275
|
+
sdk_version: input.sdkVersion ?? null,
|
|
276
|
+
package_name: input.packageName ?? null,
|
|
277
|
+
site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
|
|
278
|
+
page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
|
|
279
|
+
referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
|
|
280
|
+
environment: input.environment ?? "production",
|
|
281
|
+
active_gtag_ids: input.activeGtagIds ?? null
|
|
282
|
+
};
|
|
178
283
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
284
|
+
function createTrackingSessionUpsertPayload(trackingParams, input, context) {
|
|
285
|
+
return {
|
|
286
|
+
session_id: input.sessionId,
|
|
287
|
+
visitor_id: input.visitorId ?? null,
|
|
288
|
+
gclid: trackingParams.gclid,
|
|
289
|
+
fbclid: trackingParams.fbclid,
|
|
290
|
+
fbc: getFbcCookie(),
|
|
291
|
+
fbp: getFbpCookie(),
|
|
292
|
+
utm_source: trackingParams.utm_source,
|
|
293
|
+
utm_medium: trackingParams.utm_medium,
|
|
294
|
+
utm_campaign: trackingParams.utm_campaign,
|
|
295
|
+
utm_term: trackingParams.utm_term,
|
|
296
|
+
utm_content: trackingParams.utm_content,
|
|
297
|
+
first_page: input.firstPage ?? null,
|
|
298
|
+
consent_state: input.consentState ?? null,
|
|
299
|
+
context
|
|
300
|
+
};
|
|
185
301
|
}
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
302
|
+
function createTrackingEventCreatePayload(trackingParams, input, context) {
|
|
303
|
+
return {
|
|
304
|
+
session_id: input.sessionId,
|
|
305
|
+
event_type: input.eventType,
|
|
306
|
+
gclid: trackingParams.gclid,
|
|
307
|
+
fbclid: trackingParams.fbclid,
|
|
308
|
+
fbc: getFbcCookie(),
|
|
309
|
+
fbp: getFbpCookie(),
|
|
310
|
+
page_url: input.pageUrl ?? (typeof window === "undefined" ? null : window.location.href),
|
|
311
|
+
metadata: input.metadata ?? null,
|
|
312
|
+
context
|
|
313
|
+
};
|
|
190
314
|
}
|
|
191
315
|
|
|
192
316
|
// ../tracking-core/src/session.ts
|
|
@@ -479,11 +603,22 @@ function createTrackingClient(config) {
|
|
|
479
603
|
let queue = [];
|
|
480
604
|
let flushTimer = null;
|
|
481
605
|
let firstPage = null;
|
|
606
|
+
let initialParams = createEmptyTrackingParams();
|
|
482
607
|
let destroyed = false;
|
|
483
608
|
const visitorId = getVisitorId();
|
|
484
609
|
const initialSession = getOrRotateSessionId();
|
|
485
610
|
let sessionId = initialSession.id;
|
|
486
|
-
if (typeof window !== "undefined")
|
|
611
|
+
if (typeof window !== "undefined") {
|
|
612
|
+
firstPage = window.location.href;
|
|
613
|
+
try {
|
|
614
|
+
initialParams = captureTrackingParamsFromLocation();
|
|
615
|
+
} catch {
|
|
616
|
+
}
|
|
617
|
+
try {
|
|
618
|
+
captureFbc();
|
|
619
|
+
} catch {
|
|
620
|
+
}
|
|
621
|
+
}
|
|
487
622
|
function enqueueHeartbeat() {
|
|
488
623
|
const metadata = buildHeartbeatMetadata(
|
|
489
624
|
config.surface,
|
|
@@ -508,7 +643,7 @@ function createTrackingClient(config) {
|
|
|
508
643
|
enqueueHeartbeat();
|
|
509
644
|
}
|
|
510
645
|
sessionId = rotated.id;
|
|
511
|
-
const params = readTrackingParams();
|
|
646
|
+
const params = mergeTrackingParams(readTrackingParams(), initialParams);
|
|
512
647
|
const context = buildContext(
|
|
513
648
|
config.surface,
|
|
514
649
|
sdkVersion,
|
|
@@ -521,6 +656,8 @@ function createTrackingClient(config) {
|
|
|
521
656
|
visitor_id: visitorId,
|
|
522
657
|
gclid: params.gclid,
|
|
523
658
|
fbclid: params.fbclid,
|
|
659
|
+
fbc: getFbcCookie(),
|
|
660
|
+
fbp: getFbpCookie(),
|
|
524
661
|
utm_source: params.utm_source,
|
|
525
662
|
utm_medium: params.utm_medium,
|
|
526
663
|
utm_campaign: params.utm_campaign,
|
|
@@ -1639,26 +1776,61 @@ var ANIMATION_KEYFRAMES = `
|
|
|
1639
1776
|
}
|
|
1640
1777
|
`;
|
|
1641
1778
|
|
|
1642
|
-
// src/
|
|
1779
|
+
// src/AdPlatformTracking.tsx
|
|
1643
1780
|
import Script from "next/script";
|
|
1644
1781
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1782
|
+
function AdPlatformTracking({
|
|
1783
|
+
gtagId,
|
|
1784
|
+
gtagIds,
|
|
1785
|
+
metaPixelId,
|
|
1786
|
+
metaPixelIds
|
|
1787
|
+
}) {
|
|
1788
|
+
const gtagAll = gtagIds ? Object.values(gtagIds).filter((id) => id != null) : gtagId ? [gtagId] : [];
|
|
1789
|
+
const metaAll = metaPixelIds ? Object.values(metaPixelIds).filter((id) => id != null) : metaPixelId ? [metaPixelId] : [];
|
|
1790
|
+
const gtagLoaderId = gtagAll[0];
|
|
1791
|
+
const gtagInitScript = gtagAll.length === 1 ? createGtagInitScript(gtagAll[0]) : createGtagInitScriptMulti(gtagAll);
|
|
1792
|
+
const metaInitScript = metaAll.length === 1 ? createMetaPixelInitScript(metaAll[0]) : createMetaPixelInitScriptMulti(metaAll);
|
|
1793
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1794
|
+
gtagLoaderId ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1795
|
+
/* @__PURE__ */ jsx2(Script, { id: "consent-default", strategy: "beforeInteractive", children: createConsentDefaultScript() }),
|
|
1796
|
+
/* @__PURE__ */ jsx2(
|
|
1797
|
+
Script,
|
|
1798
|
+
{
|
|
1799
|
+
src: `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(gtagLoaderId)}`,
|
|
1800
|
+
strategy: "afterInteractive"
|
|
1801
|
+
}
|
|
1802
|
+
),
|
|
1803
|
+
/* @__PURE__ */ jsx2(Script, { id: "gtag-init", strategy: "afterInteractive", children: gtagInitScript }),
|
|
1804
|
+
/* @__PURE__ */ jsx2(Script, { id: "consent-restore", strategy: "afterInteractive", children: createConsentRestoreScript() })
|
|
1805
|
+
] }) : null,
|
|
1806
|
+
metaAll.length > 0 ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1807
|
+
/* @__PURE__ */ jsx2(Script, { id: "meta-pixel-base", strategy: "afterInteractive", children: createMetaConsentDefaultScript() }),
|
|
1808
|
+
/* @__PURE__ */ jsx2(Script, { id: "meta-pixel-init", strategy: "afterInteractive", children: metaInitScript }),
|
|
1809
|
+
/* @__PURE__ */ jsx2(Script, { id: "meta-pixel-consent-restore", strategy: "afterInteractive", children: createMetaConsentRestoreScript() })
|
|
1810
|
+
] }) : null
|
|
1811
|
+
] });
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
// src/GoogleAdsTracking.tsx
|
|
1815
|
+
import Script2 from "next/script";
|
|
1816
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1645
1817
|
function GoogleAdsTracking(props) {
|
|
1646
1818
|
const { gtagId, gtagIds } = props;
|
|
1647
|
-
const allIds = gtagIds ? Object.values(gtagIds) : gtagId ? [gtagId] : [];
|
|
1819
|
+
const allIds = gtagIds ? Object.values(gtagIds).filter((id) => id != null) : gtagId ? [gtagId] : [];
|
|
1648
1820
|
if (allIds.length === 0) return null;
|
|
1649
1821
|
const loaderId = allIds[0];
|
|
1650
|
-
const initScript = allIds.length === 1 ? createGtagInitScript(
|
|
1651
|
-
return /* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1653
|
-
/* @__PURE__ */
|
|
1654
|
-
|
|
1822
|
+
const initScript = allIds.length === 1 ? createGtagInitScript(loaderId) : createGtagInitScriptMulti(allIds);
|
|
1823
|
+
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
1824
|
+
/* @__PURE__ */ jsx3(Script2, { id: "consent-default", strategy: "beforeInteractive", children: createConsentDefaultScript() }),
|
|
1825
|
+
/* @__PURE__ */ jsx3(
|
|
1826
|
+
Script2,
|
|
1655
1827
|
{
|
|
1656
1828
|
src: `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(loaderId)}`,
|
|
1657
1829
|
strategy: "afterInteractive"
|
|
1658
1830
|
}
|
|
1659
1831
|
),
|
|
1660
|
-
/* @__PURE__ */
|
|
1661
|
-
/* @__PURE__ */
|
|
1832
|
+
/* @__PURE__ */ jsx3(Script2, { id: "gtag-init", strategy: "afterInteractive", children: initScript }),
|
|
1833
|
+
/* @__PURE__ */ jsx3(Script2, { id: "consent-restore", strategy: "afterInteractive", children: createConsentRestoreScript() })
|
|
1662
1834
|
] });
|
|
1663
1835
|
}
|
|
1664
1836
|
|
|
@@ -1666,7 +1838,7 @@ function GoogleAdsTracking(props) {
|
|
|
1666
1838
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
1667
1839
|
|
|
1668
1840
|
// package.json
|
|
1669
|
-
var version = "0.
|
|
1841
|
+
var version = "0.13.0";
|
|
1670
1842
|
|
|
1671
1843
|
// src/factory.tsx
|
|
1672
1844
|
import { createContext as createContext2, useContext as useContext2, useEffect as useEffect3, useMemo as useMemo2, useRef } from "react";
|
|
@@ -1680,7 +1852,7 @@ import {
|
|
|
1680
1852
|
useMemo,
|
|
1681
1853
|
useState as useState3
|
|
1682
1854
|
} from "react";
|
|
1683
|
-
import { jsx as
|
|
1855
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1684
1856
|
var _phoneConfigContext;
|
|
1685
1857
|
function phoneConfigContext() {
|
|
1686
1858
|
return _phoneConfigContext ?? (_phoneConfigContext = createContext(null));
|
|
@@ -1690,7 +1862,7 @@ function PhoneConfigProvider({
|
|
|
1690
1862
|
children
|
|
1691
1863
|
}) {
|
|
1692
1864
|
const Ctx = phoneConfigContext();
|
|
1693
|
-
return /* @__PURE__ */
|
|
1865
|
+
return /* @__PURE__ */ jsx4(Ctx.Provider, { value, children });
|
|
1694
1866
|
}
|
|
1695
1867
|
function usePhoneConfig() {
|
|
1696
1868
|
const ctx = useContext(phoneConfigContext());
|
|
@@ -1750,7 +1922,7 @@ var PhoneField = forwardRef(function PhoneField2({ country, value, defaultValue,
|
|
|
1750
1922
|
onChange?.(event);
|
|
1751
1923
|
};
|
|
1752
1924
|
const shown = isControlled ? formatPhoneAsTyped(value, resolvedCountry) : internal;
|
|
1753
|
-
return /* @__PURE__ */
|
|
1925
|
+
return /* @__PURE__ */ jsx4(
|
|
1754
1926
|
"input",
|
|
1755
1927
|
{
|
|
1756
1928
|
...rest,
|
|
@@ -1765,7 +1937,7 @@ var PhoneField = forwardRef(function PhoneField2({ country, value, defaultValue,
|
|
|
1765
1937
|
});
|
|
1766
1938
|
|
|
1767
1939
|
// src/factory.tsx
|
|
1768
|
-
import { jsx as
|
|
1940
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1769
1941
|
function createTracking(options) {
|
|
1770
1942
|
const { apiKey, endpoint, triggers, environment, gtagIds, debug, phone } = options;
|
|
1771
1943
|
if (!apiKey || !endpoint) {
|
|
@@ -1783,7 +1955,7 @@ function createTracking(options) {
|
|
|
1783
1955
|
getVisitorId: () => ""
|
|
1784
1956
|
};
|
|
1785
1957
|
return {
|
|
1786
|
-
TrackingProvider: ({ children }) => /* @__PURE__ */
|
|
1958
|
+
TrackingProvider: ({ children }) => /* @__PURE__ */ jsx5(PhoneConfigProvider, { value: phone ?? null, children }),
|
|
1787
1959
|
useTracking: () => noopClient
|
|
1788
1960
|
};
|
|
1789
1961
|
}
|
|
@@ -1952,7 +2124,7 @@ function createTracking(options) {
|
|
|
1952
2124
|
}
|
|
1953
2125
|
};
|
|
1954
2126
|
}, []);
|
|
1955
|
-
return /* @__PURE__ */
|
|
2127
|
+
return /* @__PURE__ */ jsx5(TrackingContext.Provider, { value: client, children: /* @__PURE__ */ jsx5(PhoneConfigProvider, { value: phone ?? null, children }) });
|
|
1956
2128
|
}
|
|
1957
2129
|
function useTracking() {
|
|
1958
2130
|
const client = useContext2(TrackingContext);
|
|
@@ -1966,6 +2138,7 @@ function createTracking(options) {
|
|
|
1966
2138
|
return { TrackingProvider, useTracking };
|
|
1967
2139
|
}
|
|
1968
2140
|
export {
|
|
2141
|
+
AdPlatformTracking,
|
|
1969
2142
|
AranovaApiError,
|
|
1970
2143
|
ConsentBanner,
|
|
1971
2144
|
DEFAULT_PHONE_COUNTRY,
|