@aranova/tracking-react 0.7.1 → 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.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -465,6 +465,10 @@ var DEFAULT_FLUSH_INTERVAL_MS = 2e3;
|
|
|
465
465
|
var DEFAULT_MAX_QUEUE_SIZE = 10;
|
|
466
466
|
var HARD_MAX_BATCH = 50;
|
|
467
467
|
var API_KEY_HEADER = "X-Aranova-Api-Key";
|
|
468
|
+
var SDK_VERSION_HEADER = "X-Aranova-Sdk-Version";
|
|
469
|
+
var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
470
|
+
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
471
|
+
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
468
472
|
function buildContext(surface, sdkVersion, packageName, environment, activeGtagIds) {
|
|
469
473
|
return {
|
|
470
474
|
surface,
|
|
@@ -493,7 +497,7 @@ function consentSnapshot() {
|
|
|
493
497
|
return null;
|
|
494
498
|
}
|
|
495
499
|
}
|
|
496
|
-
async function postWithFetch(url, body, apiKey, keepalive) {
|
|
500
|
+
async function postWithFetch(url, body, apiKey, identity, keepalive) {
|
|
497
501
|
if (typeof fetch !== "function")
|
|
498
502
|
return;
|
|
499
503
|
try {
|
|
@@ -501,7 +505,11 @@ async function postWithFetch(url, body, apiKey, keepalive) {
|
|
|
501
505
|
method: "POST",
|
|
502
506
|
headers: {
|
|
503
507
|
"Content-Type": "application/json",
|
|
504
|
-
[API_KEY_HEADER]: apiKey
|
|
508
|
+
[API_KEY_HEADER]: apiKey,
|
|
509
|
+
[SDK_VERSION_HEADER]: identity.sdkVersion,
|
|
510
|
+
[SDK_PACKAGE_HEADER]: identity.packageName,
|
|
511
|
+
[SDK_SURFACE_HEADER]: identity.surface,
|
|
512
|
+
[SDK_ENVIRONMENT_HEADER]: identity.environment
|
|
505
513
|
},
|
|
506
514
|
body,
|
|
507
515
|
keepalive,
|
|
@@ -538,6 +546,12 @@ function createTrackingClient(config) {
|
|
|
538
546
|
const activeGtagIds = config.activeGtagIds ?? null;
|
|
539
547
|
const endpointBase = config.endpoint.replace(/\/$/, "");
|
|
540
548
|
const eventsUrl = `${endpointBase}/events`;
|
|
549
|
+
const identityHeaders = {
|
|
550
|
+
sdkVersion: sdkVersion ?? "",
|
|
551
|
+
packageName: packageName ?? "",
|
|
552
|
+
surface: config.surface,
|
|
553
|
+
environment
|
|
554
|
+
};
|
|
541
555
|
let queue = [];
|
|
542
556
|
let flushTimer = null;
|
|
543
557
|
let firstPage = null;
|
|
@@ -613,7 +627,7 @@ function createTrackingClient(config) {
|
|
|
613
627
|
events
|
|
614
628
|
};
|
|
615
629
|
const serialized = JSON.stringify(body);
|
|
616
|
-
await postWithFetch(eventsUrl, serialized, config.apiKey, false);
|
|
630
|
+
await postWithFetch(eventsUrl, serialized, config.apiKey, identityHeaders, false);
|
|
617
631
|
}
|
|
618
632
|
function trackEvent(input) {
|
|
619
633
|
if (destroyed)
|
|
@@ -644,7 +658,7 @@ function createTrackingClient(config) {
|
|
|
644
658
|
events
|
|
645
659
|
};
|
|
646
660
|
const serialized = JSON.stringify(body);
|
|
647
|
-
void postWithFetch(eventsUrl, serialized, config.apiKey, true);
|
|
661
|
+
void postWithFetch(eventsUrl, serialized, config.apiKey, identityHeaders, true);
|
|
648
662
|
}
|
|
649
663
|
if (typeof window !== "undefined") {
|
|
650
664
|
window.addEventListener("pagehide", flushOnUnload);
|
|
@@ -1342,7 +1356,7 @@ import {
|
|
|
1342
1356
|
} from "react";
|
|
1343
1357
|
|
|
1344
1358
|
// package.json
|
|
1345
|
-
var version = "0.7.
|
|
1359
|
+
var version = "0.7.2";
|
|
1346
1360
|
|
|
1347
1361
|
// src/factory.tsx
|
|
1348
1362
|
import { jsx as jsx2 } from "react/jsx-runtime";
|