@aranova/tracking-react 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.mjs CHANGED
@@ -44,7 +44,7 @@ function createTrackingClientContext(surface, input = {}) {
44
44
  site_origin: input.siteOrigin ?? (typeof window === "undefined" ? null : window.location.origin),
45
45
  page_title: input.pageTitle ?? (typeof document === "undefined" ? null : document.title || null),
46
46
  referrer: input.referrer ?? (typeof document === "undefined" ? null : document.referrer || null),
47
- environment: input.environment ?? null,
47
+ environment: input.environment ?? "production",
48
48
  active_gtag_ids: input.activeGtagIds ?? null
49
49
  };
50
50
  }
@@ -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,
@@ -534,10 +542,16 @@ function createTrackingClient(config) {
534
542
  const maxQueueSize = Math.min(config.maxQueueSize ?? DEFAULT_MAX_QUEUE_SIZE, HARD_MAX_BATCH);
535
543
  const sdkVersion = config.sdkVersion ?? null;
536
544
  const packageName = config.packageName ?? null;
537
- const environment = config.environment ?? null;
545
+ const environment = config.environment ?? "production";
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.0";
1359
+ var version = "0.7.2";
1346
1360
 
1347
1361
  // src/factory.tsx
1348
1362
  import { jsx as jsx2 } from "react/jsx-runtime";