@aranova/tracking-next 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 CHANGED
@@ -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,
@@ -518,6 +526,12 @@ function createTrackingClient(config) {
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.1";
1205
+ var version = "0.7.2";
1192
1206
 
1193
1207
  // src/factory.tsx
1194
1208
  var import_react3 = require("react");