@traqio/web 0.1.3 → 0.2.1

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/README.md CHANGED
@@ -112,6 +112,9 @@ networks.
112
112
  | `waitForConsent` | `false` | Store nothing until `setConsent(true)` |
113
113
  | `trackIdDays` | `30` | How long the trackID is kept after the click |
114
114
  | `cookies` | `true` | `false` = localStorage only, no sharing across subdomains |
115
+ | `debug` | detected | Debug traffic, kept out of every report (see below) |
116
+
117
+ **Debug traffic.** Omitted, `debug` is on for a page served from `localhost`, `127.0.0.1`, `*.localhost`, `*.local` or `file:`, and off everywhere else; `true` forces it (a staging site), `false` counts a local page. `traqio.isDebug` tells which mode is on. Debug traffic shows in the console's **Live events › Debug** view, but it is never counted in a report, attributed, sent to an ad network or a webhook, or billed.
115
118
 
116
119
  ## Requirements
117
120
 
package/build/index.cjs CHANGED
@@ -269,7 +269,8 @@ var require_adservices = __commonJS({
269
269
  sdkKey: opts.sdkKey,
270
270
  token: token.trim(),
271
271
  deviceId: opts.deviceId,
272
- appUserId: opts.userId
272
+ appUserId: opts.userId,
273
+ ...opts.debug ? { debug: true } : {}
273
274
  })
274
275
  });
275
276
  if (!res.ok)
@@ -361,18 +362,212 @@ var init_empty = __esm({
361
362
  }
362
363
  });
363
364
 
365
+ // ../sdk-core/build/adRevenue.js
366
+ var require_adRevenue = __commonJS({
367
+ "../sdk-core/build/adRevenue.js"(exports) {
368
+ "use strict";
369
+ Object.defineProperty(exports, "__esModule", { value: true });
370
+ exports.CAPACITOR_ADMOB_PAID_EVENTS = exports.MAX_RN_MIN_VERSION = exports.MAX_RN_REVENUE_EVENTS = exports.GMA_MIN_VERSION = exports.GMA_FULLSCREEN_CHANNELS = void 0;
371
+ exports.fromGoogleMobileAdsPaid = fromGoogleMobileAdsPaid;
372
+ exports.fromGoogleMobileAdsChannel = fromGoogleMobileAdsChannel;
373
+ exports.fromGoogleMobileAdsNativeAd = fromGoogleMobileAdsNativeAd;
374
+ exports.fromMaxAdInfo = fromMaxAdInfo;
375
+ exports.fromCapacitorAdMob = fromCapacitorAdMob;
376
+ exports.watchReactNativeAds = watchReactNativeAds;
377
+ var PRECISION_BY_INDEX = ["unknown", "estimated", "publisher_provided", "precise"];
378
+ function precisionOf(raw) {
379
+ var _a;
380
+ return typeof raw === "number" ? (_a = PRECISION_BY_INDEX[raw]) != null ? _a : "unknown" : "unknown";
381
+ }
382
+ function text(raw) {
383
+ return typeof raw === "string" && raw.trim() ? raw : void 0;
384
+ }
385
+ function record(raw) {
386
+ return raw && typeof raw === "object" ? raw : void 0;
387
+ }
388
+ function micros(raw) {
389
+ const n = typeof raw === "string" && /^\d+$/.test(raw.trim()) ? Number(raw) : raw;
390
+ return typeof n === "number" && Number.isSafeInteger(n) && n >= 0 ? n : void 0;
391
+ }
392
+ exports.GMA_FULLSCREEN_CHANNELS = {
393
+ rnapp_google_mobile_ads_app_open_event: "app_open",
394
+ rnapp_google_mobile_ads_interstitial_event: "interstitial",
395
+ rnapp_google_mobile_ads_rewarded_event: "rewarded",
396
+ rnapp_google_mobile_ads_rewarded_interstitial_event: "rewarded_interstitial"
397
+ };
398
+ exports.GMA_MIN_VERSION = "12.4.0";
399
+ function fromGoogleMobileAdsPaid(payload, meta = {}) {
400
+ var _a;
401
+ const p = record(payload);
402
+ if (!p)
403
+ return void 0;
404
+ const currency = text(p.currency);
405
+ if (!currency)
406
+ return void 0;
407
+ let valueMicros = micros(p.valueMicros);
408
+ if (valueMicros === void 0) {
409
+ if (!(typeof p.value === "number" && Number.isFinite(p.value) && p.value >= 0))
410
+ return void 0;
411
+ valueMicros = Math.round(p.value * 1e6);
412
+ }
413
+ const loaded = record((_a = record(p.responseInfo)) == null ? void 0 : _a.loadedAdapterResponse);
414
+ return {
415
+ valueMicros,
416
+ currency,
417
+ precision: precisionOf(p.precision),
418
+ adUnitId: meta.adUnitId,
419
+ adFormat: meta.adFormat,
420
+ adSourceName: text(loaded == null ? void 0 : loaded.adSourceName)
421
+ };
422
+ }
423
+ function fromGoogleMobileAdsChannel(channel, event) {
424
+ const e = record(event);
425
+ const body = record(e == null ? void 0 : e.body);
426
+ if (!e || (body == null ? void 0 : body.type) !== "paid")
427
+ return void 0;
428
+ return fromGoogleMobileAdsPaid(body.data, { adUnitId: text(e.adUnitId), adFormat: exports.GMA_FULLSCREEN_CHANNELS[channel] });
429
+ }
430
+ function fromGoogleMobileAdsNativeAd(event) {
431
+ const e = record(event);
432
+ if ((e == null ? void 0 : e.type) !== "paid")
433
+ return void 0;
434
+ return fromGoogleMobileAdsPaid(e, { adFormat: "native" });
435
+ }
436
+ exports.MAX_RN_REVENUE_EVENTS = [
437
+ "OnBannerAdRevenuePaid",
438
+ "OnMRecAdRevenuePaid",
439
+ "OnInterstitialAdRevenuePaid",
440
+ "OnRewardedAdRevenuePaid",
441
+ "OnAppOpenAdRevenuePaid"
442
+ ];
443
+ exports.MAX_RN_MIN_VERSION = "5.0.0";
444
+ function fromMaxAdInfo(info) {
445
+ const i = record(info);
446
+ if (!i || typeof i.revenue !== "number")
447
+ return void 0;
448
+ return {
449
+ revenue: i.revenue,
450
+ revenuePrecision: text(i.revenuePrecision),
451
+ adUnitId: text(i.adUnitId),
452
+ format: text(i.adFormat),
453
+ networkName: text(i.networkName)
454
+ };
455
+ }
456
+ exports.CAPACITOR_ADMOB_PAID_EVENTS = {
457
+ bannerAdPaid: "banner",
458
+ nativeAdPaid: "native",
459
+ interstitialAdImpression: "interstitial",
460
+ onRewardedVideoAdImpression: "rewarded",
461
+ onRewardedInterstitialAdImpression: "rewarded_interstitial",
462
+ appOpenAdImpression: "app_open"
463
+ };
464
+ function fromCapacitorAdMob(event, adFormat) {
465
+ const e = record(event);
466
+ const valueMicros = micros(e == null ? void 0 : e.valueMicros);
467
+ const currency = text(e == null ? void 0 : e.currencyCode);
468
+ if (!e || valueMicros === void 0 || !currency)
469
+ return void 0;
470
+ return {
471
+ valueMicros,
472
+ currency,
473
+ precision: precisionOf(e.precision),
474
+ adUnitId: text(e.adUnitId),
475
+ adFormat,
476
+ // The mediation ADAPTER class here, not the source's display name — still
477
+ // the only thing telling AdMob's own demand from a mediated network.
478
+ adSourceName: text(e.networkName)
479
+ };
480
+ }
481
+ function nativeModule(rn, name) {
482
+ var _a, _b, _c, _d, _e;
483
+ try {
484
+ return (_d = (_b = (_a = rn.TurboModuleRegistry) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a, name)) != null ? _d : (_c = rn.NativeModules) == null ? void 0 : _c[name];
485
+ } catch {
486
+ return (_e = rn.NativeModules) == null ? void 0 : _e[name];
487
+ }
488
+ }
489
+ function watchReactNativeAds(want, sink, rn) {
490
+ var _a, _b, _c, _d;
491
+ if (!rn) {
492
+ try {
493
+ rn = (init_empty(), __toCommonJS(empty_exports));
494
+ } catch {
495
+ return () => void 0;
496
+ }
497
+ }
498
+ const subs = [];
499
+ const guard = (parse, deliver) => (e) => {
500
+ try {
501
+ const v = parse(e);
502
+ if (v)
503
+ deliver(v);
504
+ } catch {
505
+ }
506
+ };
507
+ if (want.admob) {
508
+ for (const channel of Object.keys(exports.GMA_FULLSCREEN_CHANNELS)) {
509
+ const sub = (_a = rn.DeviceEventEmitter) == null ? void 0 : _a.addListener(channel, guard((e) => fromGoogleMobileAdsChannel(channel, e), sink.admob));
510
+ if (sub)
511
+ subs.push(sub);
512
+ }
513
+ const nativeAds = nativeModule(rn, "RNGoogleMobileAdsNativeModule");
514
+ const onNative = guard(fromGoogleMobileAdsNativeAd, sink.admob);
515
+ try {
516
+ if (nativeAds && typeof nativeAds.onAdEvent === "function") {
517
+ subs.push(nativeAds.onAdEvent(onNative));
518
+ } else if (nativeAds && rn.NativeEventEmitter) {
519
+ const emitter = new rn.NativeEventEmitter(((_b = rn.Platform) == null ? void 0 : _b.OS) === "ios" ? nativeAds : void 0);
520
+ subs.push(emitter.addListener("RNGMANativeAdEvent", onNative));
521
+ }
522
+ } catch {
523
+ }
524
+ }
525
+ if (want.applovinMax) {
526
+ const max = nativeModule(rn, "AppLovinMAX");
527
+ if (max && rn.NativeEventEmitter) {
528
+ try {
529
+ let names = [...exports.MAX_RN_REVENUE_EVENTS];
530
+ try {
531
+ const c = (_d = (_c = max.getConstants) == null ? void 0 : _c.call(max)) != null ? _d : {};
532
+ const fromModule = Object.keys(c).filter((k) => /^ON_.*_AD_REVENUE_PAID$/.test(k)).map((k) => c[k]).filter((v) => typeof v === "string");
533
+ if (fromModule.length)
534
+ names = [.../* @__PURE__ */ new Set([...fromModule, ...names])];
535
+ } catch {
536
+ }
537
+ const emitter = new rn.NativeEventEmitter(max);
538
+ for (const name of names)
539
+ subs.push(emitter.addListener(name, guard(fromMaxAdInfo, sink.applovinMax)));
540
+ } catch {
541
+ }
542
+ }
543
+ }
544
+ return () => {
545
+ for (const s of subs.splice(0)) {
546
+ try {
547
+ s.remove();
548
+ } catch {
549
+ }
550
+ }
551
+ };
552
+ }
553
+ }
554
+ });
555
+
364
556
  // ../sdk-core/build/index.js
365
557
  var require_build = __commonJS({
366
558
  "../sdk-core/build/index.js"(exports) {
367
559
  "use strict";
368
560
  Object.defineProperty(exports, "__esModule", { value: true });
369
- exports.Traqio = exports.Client = exports.isTrackingUrl = exports.isOpenUrl = exports.reportAdServicesToken = exports.Skan = exports.SDK_VERSION = void 0;
561
+ exports.Traqio = exports.Client = exports.watchReactNativeAds = exports.fromMaxAdInfo = exports.fromGoogleMobileAdsPaid = exports.fromGoogleMobileAdsNativeAd = exports.fromGoogleMobileAdsChannel = exports.fromCapacitorAdMob = exports.MAX_RN_REVENUE_EVENTS = exports.MAX_RN_MIN_VERSION = exports.GMA_MIN_VERSION = exports.GMA_FULLSCREEN_CHANNELS = exports.CAPACITOR_ADMOB_PAID_EVENTS = exports.isTrackingUrl = exports.isOpenUrl = exports.reportAdServicesToken = exports.Skan = exports.SDK_VERSION = void 0;
370
562
  exports.normalizeAdvertisingId = normalizeAdvertisingId;
371
563
  exports.fromMaxAd = fromMaxAd;
564
+ exports.detectDebug = detectDebug;
565
+ exports.isLocalPage = isLocalPage;
372
566
  var skan_1 = require_skan();
373
567
  var adservices_1 = require_adservices();
374
568
  var deeplink_1 = require_deeplink();
375
- exports.SDK_VERSION = "0.2.0";
569
+ var adRevenue_1 = require_adRevenue();
570
+ exports.SDK_VERSION = "0.4.0";
376
571
  var skan_2 = require_skan();
377
572
  Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
378
573
  return skan_2.Skan;
@@ -388,7 +583,42 @@ var require_build = __commonJS({
388
583
  Object.defineProperty(exports, "isTrackingUrl", { enumerable: true, get: function() {
389
584
  return deeplink_2.isTrackingUrl;
390
585
  } });
586
+ var adRevenue_2 = require_adRevenue();
587
+ Object.defineProperty(exports, "CAPACITOR_ADMOB_PAID_EVENTS", { enumerable: true, get: function() {
588
+ return adRevenue_2.CAPACITOR_ADMOB_PAID_EVENTS;
589
+ } });
590
+ Object.defineProperty(exports, "GMA_FULLSCREEN_CHANNELS", { enumerable: true, get: function() {
591
+ return adRevenue_2.GMA_FULLSCREEN_CHANNELS;
592
+ } });
593
+ Object.defineProperty(exports, "GMA_MIN_VERSION", { enumerable: true, get: function() {
594
+ return adRevenue_2.GMA_MIN_VERSION;
595
+ } });
596
+ Object.defineProperty(exports, "MAX_RN_MIN_VERSION", { enumerable: true, get: function() {
597
+ return adRevenue_2.MAX_RN_MIN_VERSION;
598
+ } });
599
+ Object.defineProperty(exports, "MAX_RN_REVENUE_EVENTS", { enumerable: true, get: function() {
600
+ return adRevenue_2.MAX_RN_REVENUE_EVENTS;
601
+ } });
602
+ Object.defineProperty(exports, "fromCapacitorAdMob", { enumerable: true, get: function() {
603
+ return adRevenue_2.fromCapacitorAdMob;
604
+ } });
605
+ Object.defineProperty(exports, "fromGoogleMobileAdsChannel", { enumerable: true, get: function() {
606
+ return adRevenue_2.fromGoogleMobileAdsChannel;
607
+ } });
608
+ Object.defineProperty(exports, "fromGoogleMobileAdsNativeAd", { enumerable: true, get: function() {
609
+ return adRevenue_2.fromGoogleMobileAdsNativeAd;
610
+ } });
611
+ Object.defineProperty(exports, "fromGoogleMobileAdsPaid", { enumerable: true, get: function() {
612
+ return adRevenue_2.fromGoogleMobileAdsPaid;
613
+ } });
614
+ Object.defineProperty(exports, "fromMaxAdInfo", { enumerable: true, get: function() {
615
+ return adRevenue_2.fromMaxAdInfo;
616
+ } });
617
+ Object.defineProperty(exports, "watchReactNativeAds", { enumerable: true, get: function() {
618
+ return adRevenue_2.watchReactNativeAds;
619
+ } });
391
620
  var INSTALL_SENT_KEY = "traq_install_sent";
621
+ var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
392
622
  var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
393
623
  var REFERRER_KEY = "traq_referrer";
394
624
  var QUEUE_KEY = "traq_queue";
@@ -497,6 +727,19 @@ var require_build = __commonJS({
497
727
  this.undelivered = [];
498
728
  this.deferred = null;
499
729
  this.consent = null;
730
+ this.debug = false;
731
+ this.maxRevenuePaid = (adInfo) => {
732
+ try {
733
+ const ad = (0, adRevenue_1.fromMaxAdInfo)(adInfo);
734
+ if (ad)
735
+ this.trackMaxAdRevenue(ad);
736
+ } catch {
737
+ }
738
+ };
739
+ }
740
+ /** Whether this run is in debug mode — see `InitOptions.debug`. Settled by `init()`. */
741
+ get isDebug() {
742
+ return this.debug;
500
743
  }
501
744
  async init(opts) {
502
745
  var _a;
@@ -507,6 +750,7 @@ var require_build = __commonJS({
507
750
  if (!this.opts.storage) {
508
751
  console.warn("[traqio] no storage available \u2014 pass `storage` to init() or install @react-native-async-storage/async-storage, otherwise the install is re-sent at every launch.");
509
752
  }
753
+ this.debug = await detectDebug(opts);
510
754
  await this.restoreConsent(opts.consent);
511
755
  await this.restoreQueue();
512
756
  await this.restoreAdQueue();
@@ -514,7 +758,7 @@ var require_build = __commonJS({
514
758
  if (await this.restoreErased())
515
759
  return;
516
760
  if (!this.isWeb) {
517
- const freshInstall = Boolean(this.opts.storage) && !await this.opts.storage.getItem(INSTALL_SENT_KEY).catch(() => "1");
761
+ const freshInstall = Boolean(this.opts.storage) && !await this.opts.storage.getItem(this.installSentKey).catch(() => "1");
518
762
  await this.sendInstallOnce();
519
763
  if (this.opts.deepLinking !== false) {
520
764
  this.deferred = this.resolveDeferredOnce(freshInstall).then((link) => link != null ? link : this.retryDeferredWithConsent());
@@ -525,9 +769,28 @@ var require_build = __commonJS({
525
769
  await this.initSkan();
526
770
  await this.initAppleAds();
527
771
  this.wireLifecycle();
772
+ this.wireAdRevenue();
528
773
  if (this.queue.length || this.adQueue.length)
529
774
  this.scheduleFlush(0);
530
775
  }
776
+ // `InitOptions.adRevenue`: hand the ad SDKs' own paid events to the trackers.
777
+ wireAdRevenue() {
778
+ var _a;
779
+ const want = this.opts.adRevenue;
780
+ if (!want || this.isWeb || !(want.admob || want.applovinMax))
781
+ return;
782
+ const sink = {
783
+ admob: (ad) => this.trackAdRevenue(ad),
784
+ applovinMax: (ad) => this.trackMaxAdRevenue(ad)
785
+ };
786
+ try {
787
+ if ((_a = this.opts.native) == null ? void 0 : _a.watchAdRevenue)
788
+ this.opts.native.watchAdRevenue(want, sink);
789
+ else
790
+ (0, adRevenue_1.watchReactNativeAds)(want, sink);
791
+ } catch {
792
+ }
793
+ }
531
794
  track(name, props) {
532
795
  var _a, _b;
533
796
  if (!this.started || this.erased)
@@ -580,6 +843,27 @@ var require_build = __commonJS({
580
843
  if (converted)
581
844
  this.queueAdRevenue(converted, "applovin_max");
582
845
  }
846
+ /**
847
+ * The one line for an ad that reports through its own callback — a
848
+ * react-native-google-mobile-ads `<BannerAd>` (the full-screen formats are
849
+ * captured by `adRevenue: { admob: true }`):
850
+ *
851
+ * <BannerAd unitId={AD_UNIT_ID} size={…} onPaid={Traqio.admobPaid(AD_UNIT_ID)} />
852
+ * ad.addAdEventListener(AdEventType.PAID, Traqio.admobPaid(AD_UNIT_ID, "rewarded"))
853
+ *
854
+ * Reads the library's PAID payload (`value` in currency units, or v17's exact
855
+ * `valueMicros`) and reports it as AdMob revenue.
856
+ */
857
+ admobPaid(adUnitId, adFormat = "banner") {
858
+ return (event) => {
859
+ try {
860
+ const ad = (0, adRevenue_1.fromGoogleMobileAdsPaid)(event, { adUnitId, adFormat });
861
+ if (ad)
862
+ this.trackAdRevenue(ad);
863
+ } catch {
864
+ }
865
+ };
866
+ }
583
867
  queueAdRevenue(ad, source) {
584
868
  var _a;
585
869
  if (!this.started || this.erased)
@@ -777,7 +1061,8 @@ var require_build = __commonJS({
777
1061
  deviceId: this.context.deviceId,
778
1062
  userId: this.opts.userId,
779
1063
  storage: this.opts.storage,
780
- native: { getAttributionToken: () => native.getAttributionToken() }
1064
+ native: { getAttributionToken: () => native.getAttributionToken() },
1065
+ debug: this.debug
781
1066
  });
782
1067
  }
783
1068
  async initSkan() {
@@ -915,6 +1200,13 @@ var require_build = __commonJS({
915
1200
  var _a;
916
1201
  return ((_a = this.opts) == null ? void 0 : _a.platform) === "web";
917
1202
  }
1203
+ get installSentKey() {
1204
+ return this.debug ? INSTALL_SENT_DEBUG_KEY : INSTALL_SENT_KEY;
1205
+ }
1206
+ /** Spread into every body: present only in debug mode, so a release build's payload is unchanged. */
1207
+ debugField() {
1208
+ return this.debug ? { debug: true } : {};
1209
+ }
918
1210
  wireLifecycle() {
919
1211
  const events = {
920
1212
  background: () => this.flush(),
@@ -1126,7 +1418,7 @@ var require_build = __commonJS({
1126
1418
  async sendInstallOnce() {
1127
1419
  var _a, _b;
1128
1420
  const store = this.opts.storage;
1129
- if (store && await store.getItem(INSTALL_SENT_KEY))
1421
+ if (store && await store.getItem(this.installSentKey))
1130
1422
  return;
1131
1423
  const platform = (_b = (_a = this.opts.native) == null ? void 0 : _a.platform) != null ? _b : "android";
1132
1424
  const referrer = await this.readReferrer();
@@ -1147,7 +1439,7 @@ var require_build = __commonJS({
1147
1439
  }
1148
1440
  });
1149
1441
  if (ok)
1150
- await (store == null ? void 0 : store.setItem(INSTALL_SENT_KEY, "1"));
1442
+ await (store == null ? void 0 : store.setItem(this.installSentKey, "1"));
1151
1443
  }
1152
1444
  scheduleFlush(delay = FLUSH_DELAY_MS) {
1153
1445
  if (this.flushTimer)
@@ -1222,7 +1514,7 @@ var require_build = __commonJS({
1222
1514
  const res = await fetch(`${this.opts.endpoint}${path}`, {
1223
1515
  method: "POST",
1224
1516
  headers: { "Content-Type": "application/json" },
1225
- body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body }),
1517
+ body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...this.debugField() }),
1226
1518
  ...this.keepalive()
1227
1519
  });
1228
1520
  return res.ok ? await res.json() : null;
@@ -1267,7 +1559,7 @@ var require_build = __commonJS({
1267
1559
  const res = await fetch(`${this.opts.endpoint}${path}`, {
1268
1560
  method: "POST",
1269
1561
  headers: { "Content-Type": "application/json" },
1270
- body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...consent }),
1562
+ body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...consent, ...this.debugField() }),
1271
1563
  ...this.keepalive()
1272
1564
  });
1273
1565
  if (res.ok)
@@ -1279,6 +1571,28 @@ var require_build = __commonJS({
1279
1571
  }
1280
1572
  };
1281
1573
  exports.Client = Client2;
1574
+ async function detectDebug(opts) {
1575
+ var _a, _b;
1576
+ if (opts.debug !== void 0)
1577
+ return opts.debug;
1578
+ if (opts.platform === "web")
1579
+ return isLocalPage();
1580
+ if (globalThis.__DEV__ === true)
1581
+ return true;
1582
+ try {
1583
+ return await ((_b = (_a = opts.native) == null ? void 0 : _a.isDebugBuild) == null ? void 0 : _b.call(_a)) === true;
1584
+ } catch {
1585
+ return false;
1586
+ }
1587
+ }
1588
+ function isLocalPage(loc = globalThis.location) {
1589
+ if (!loc)
1590
+ return false;
1591
+ if (loc.protocol === "file:")
1592
+ return true;
1593
+ const host = loc.hostname.toLowerCase().replace(/^\[|\]$/g, "");
1594
+ return host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host === "::1" || host === "0.0.0.0" || /^127\.\d+\.\d+\.\d+$/.test(host);
1595
+ }
1282
1596
  exports.Traqio = new Client2();
1283
1597
  }
1284
1598
  });
@@ -1570,12 +1884,17 @@ var TraqioWeb = class {
1570
1884
  platform: "web",
1571
1885
  userId: opts.userId,
1572
1886
  consent,
1887
+ debug: opts.debug,
1573
1888
  lifecycle: ({ background, foreground }) => {
1574
1889
  document.addEventListener("visibilitychange", () => document.visibilityState === "hidden" ? background() : foreground());
1575
1890
  window.addEventListener("pagehide", background);
1576
1891
  }
1577
1892
  });
1578
1893
  }
1894
+ /** Whether this page runs in debug mode — see `WebInitOptions.debug`. Settled by `init()`. */
1895
+ get isDebug() {
1896
+ return this.core.isDebug;
1897
+ }
1579
1898
  /** Record an event — `signup`, `purchase`, `add_to_cart`… Batched, retried, kept across page loads. */
1580
1899
  track(name, props) {
1581
1900
  this.core.track(name, props);