@aranova/tracking-next 0.7.0 → 0.7.2
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{types-D0Vm9WRC.d.mts → types-BPJLgMsG.d.mts} +8 -2
- package/dist/{types-D0Vm9WRC.d.ts → types-BPJLgMsG.d.ts} +8 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, G as GtagEnvironmentMap } from './types-
|
|
2
|
-
export { f as TrackingInitConfig } from './types-
|
|
1
|
+
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, G as GtagEnvironmentMap } from './types-BPJLgMsG.mjs';
|
|
2
|
+
export { f as TrackingInitConfig } from './types-BPJLgMsG.mjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as src from 'src';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -28,7 +28,7 @@ interface TrackingContextInput {
|
|
|
28
28
|
referrer?: string | null;
|
|
29
29
|
sdkVersion?: string | null;
|
|
30
30
|
siteOrigin?: string | null;
|
|
31
|
-
environment?: TrackingEnvironment
|
|
31
|
+
environment?: TrackingEnvironment;
|
|
32
32
|
activeGtagIds?: Record<string, string> | null;
|
|
33
33
|
}
|
|
34
34
|
interface TrackingEventInput {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, G as GtagEnvironmentMap } from './types-
|
|
2
|
-
export { f as TrackingInitConfig } from './types-
|
|
1
|
+
import { C as ConsentState, T as TrackingInstallSurface, a as TrackingEnvironment, b as TrackingClientContext, c as TrackingParams, d as TrackingEventCreatePayload, e as TrackingSessionUpsertPayload, G as GtagEnvironmentMap } from './types-BPJLgMsG.js';
|
|
2
|
+
export { f as TrackingInitConfig } from './types-BPJLgMsG.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as src from 'src';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -28,7 +28,7 @@ interface TrackingContextInput {
|
|
|
28
28
|
referrer?: string | null;
|
|
29
29
|
sdkVersion?: string | null;
|
|
30
30
|
siteOrigin?: string | null;
|
|
31
|
-
environment?: TrackingEnvironment
|
|
31
|
+
environment?: TrackingEnvironment;
|
|
32
32
|
activeGtagIds?: Record<string, string> | null;
|
|
33
33
|
}
|
|
34
34
|
interface TrackingEventInput {
|
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ function createTrackingClientContext(surface, input = {}) {
|
|
|
83
83
|
site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
|
|
84
84
|
page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
|
|
85
85
|
referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
|
|
86
|
-
environment: input.environment ??
|
|
86
|
+
environment: input.environment ?? "production",
|
|
87
87
|
active_gtag_ids: input.activeGtagIds ?? null
|
|
88
88
|
};
|
|
89
89
|
}
|
|
@@ -445,6 +445,10 @@ var DEFAULT_FLUSH_INTERVAL_MS = 2e3;
|
|
|
445
445
|
var DEFAULT_MAX_QUEUE_SIZE = 10;
|
|
446
446
|
var HARD_MAX_BATCH = 50;
|
|
447
447
|
var API_KEY_HEADER = "X-Aranova-Api-Key";
|
|
448
|
+
var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
|
|
449
|
+
var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
450
|
+
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
451
|
+
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
448
452
|
function buildContext(surface, sdkVersion, packageName, environment, activeGtagIds) {
|
|
449
453
|
return {
|
|
450
454
|
surface,
|
|
@@ -473,7 +477,7 @@ function consentSnapshot() {
|
|
|
473
477
|
return null;
|
|
474
478
|
}
|
|
475
479
|
}
|
|
476
|
-
async function postWithFetch(url, body, apiKey, keepalive) {
|
|
480
|
+
async function postWithFetch(url, body, apiKey, identity, keepalive) {
|
|
477
481
|
if (typeof fetch !== "function")
|
|
478
482
|
return;
|
|
479
483
|
try {
|
|
@@ -481,7 +485,11 @@ async function postWithFetch(url, body, apiKey, keepalive) {
|
|
|
481
485
|
method: "POST",
|
|
482
486
|
headers: {
|
|
483
487
|
"Content-Type": "application/json",
|
|
484
|
-
[API_KEY_HEADER]: apiKey
|
|
488
|
+
[API_KEY_HEADER]: apiKey,
|
|
489
|
+
[SDK_VERSION_HEADER]: identity.sdkVersion,
|
|
490
|
+
[SDK_PACKAGE_HEADER]: identity.packageName,
|
|
491
|
+
[SDK_SURFACE_HEADER]: identity.surface,
|
|
492
|
+
[SDK_ENVIRONMENT_HEADER]: identity.environment
|
|
485
493
|
},
|
|
486
494
|
body,
|
|
487
495
|
keepalive,
|
|
@@ -514,10 +522,16 @@ function createTrackingClient(config) {
|
|
|
514
522
|
const maxQueueSize = Math.min(config.maxQueueSize ?? DEFAULT_MAX_QUEUE_SIZE, HARD_MAX_BATCH);
|
|
515
523
|
const sdkVersion = config.sdkVersion ?? null;
|
|
516
524
|
const packageName = config.packageName ?? null;
|
|
517
|
-
const environment = config.environment ??
|
|
525
|
+
const environment = config.environment ?? "production";
|
|
518
526
|
const activeGtagIds = config.activeGtagIds ?? null;
|
|
519
527
|
const endpointBase = config.endpoint.replace(/\/$/, "");
|
|
520
528
|
const eventsUrl = `${endpointBase}/events`;
|
|
529
|
+
const identityHeaders = {
|
|
530
|
+
sdkVersion: sdkVersion ?? "",
|
|
531
|
+
packageName: packageName ?? "",
|
|
532
|
+
surface: config.surface,
|
|
533
|
+
environment
|
|
534
|
+
};
|
|
521
535
|
let queue = [];
|
|
522
536
|
let flushTimer = null;
|
|
523
537
|
let firstPage = null;
|
|
@@ -593,7 +607,7 @@ function createTrackingClient(config) {
|
|
|
593
607
|
events
|
|
594
608
|
};
|
|
595
609
|
const serialized = JSON.stringify(body);
|
|
596
|
-
await postWithFetch(eventsUrl, serialized, config.apiKey, false);
|
|
610
|
+
await postWithFetch(eventsUrl, serialized, config.apiKey, identityHeaders, false);
|
|
597
611
|
}
|
|
598
612
|
function trackEvent(input) {
|
|
599
613
|
if (destroyed)
|
|
@@ -624,7 +638,7 @@ function createTrackingClient(config) {
|
|
|
624
638
|
events
|
|
625
639
|
};
|
|
626
640
|
const serialized = JSON.stringify(body);
|
|
627
|
-
void postWithFetch(eventsUrl, serialized, config.apiKey, true);
|
|
641
|
+
void postWithFetch(eventsUrl, serialized, config.apiKey, identityHeaders, true);
|
|
628
642
|
}
|
|
629
643
|
if (typeof window !== "undefined") {
|
|
630
644
|
window.addEventListener("pagehide", flushOnUnload);
|
|
@@ -1188,7 +1202,7 @@ function GoogleAdsTracking(props) {
|
|
|
1188
1202
|
var import_navigation = require("next/navigation");
|
|
1189
1203
|
|
|
1190
1204
|
// package.json
|
|
1191
|
-
var version = "0.7.
|
|
1205
|
+
var version = "0.7.2";
|
|
1192
1206
|
|
|
1193
1207
|
// src/factory.tsx
|
|
1194
1208
|
var import_react3 = require("react");
|