@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/build/index.d.ts CHANGED
@@ -25,6 +25,14 @@ export interface WebInitOptions {
25
25
  trackIdDays?: number;
26
26
  /** `false` = never write a cookie, localStorage only (no sharing across subdomains). Default `true`. */
27
27
  cookies?: boolean;
28
+ /**
29
+ * Debug mode. Omitted = on when the page is served from your machine (`localhost`,
30
+ * `127.0.0.1`, `*.localhost`, `*.local`, `file:`), off everywhere else. Debug
31
+ * traffic shows in the console's Live events › Debug view and is never counted,
32
+ * attributed, sent to an ad network or a webhook, or billed. `true` for a staging
33
+ * site, `false` to count a local page.
34
+ */
35
+ debug?: boolean;
28
36
  }
29
37
  /** What `track()` accepts beside the event name. */
30
38
  export interface WebTrackProps {
@@ -51,6 +59,8 @@ export declare class TraqioWeb {
51
59
  * does nothing there.
52
60
  */
53
61
  init(opts: WebInitOptions): Promise<void>;
62
+ /** Whether this page runs in debug mode — see `WebInitOptions.debug`. Settled by `init()`. */
63
+ get isDebug(): boolean;
54
64
  /** Record an event — `signup`, `purchase`, `add_to_cart`… Batched, retried, kept across page loads. */
55
65
  track(name: string, props?: WebTrackProps): void;
56
66
  /** Set the user id once known (after sign-in). */
package/build/index.js CHANGED
@@ -264,7 +264,8 @@ var require_adservices = __commonJS({
264
264
  sdkKey: opts.sdkKey,
265
265
  token: token.trim(),
266
266
  deviceId: opts.deviceId,
267
- appUserId: opts.userId
267
+ appUserId: opts.userId,
268
+ ...opts.debug ? { debug: true } : {}
268
269
  })
269
270
  });
270
271
  if (!res.ok)
@@ -356,18 +357,212 @@ var init_empty = __esm({
356
357
  }
357
358
  });
358
359
 
360
+ // ../sdk-core/build/adRevenue.js
361
+ var require_adRevenue = __commonJS({
362
+ "../sdk-core/build/adRevenue.js"(exports) {
363
+ "use strict";
364
+ Object.defineProperty(exports, "__esModule", { value: true });
365
+ 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;
366
+ exports.fromGoogleMobileAdsPaid = fromGoogleMobileAdsPaid;
367
+ exports.fromGoogleMobileAdsChannel = fromGoogleMobileAdsChannel;
368
+ exports.fromGoogleMobileAdsNativeAd = fromGoogleMobileAdsNativeAd;
369
+ exports.fromMaxAdInfo = fromMaxAdInfo;
370
+ exports.fromCapacitorAdMob = fromCapacitorAdMob;
371
+ exports.watchReactNativeAds = watchReactNativeAds;
372
+ var PRECISION_BY_INDEX = ["unknown", "estimated", "publisher_provided", "precise"];
373
+ function precisionOf(raw) {
374
+ var _a;
375
+ return typeof raw === "number" ? (_a = PRECISION_BY_INDEX[raw]) != null ? _a : "unknown" : "unknown";
376
+ }
377
+ function text(raw) {
378
+ return typeof raw === "string" && raw.trim() ? raw : void 0;
379
+ }
380
+ function record(raw) {
381
+ return raw && typeof raw === "object" ? raw : void 0;
382
+ }
383
+ function micros(raw) {
384
+ const n = typeof raw === "string" && /^\d+$/.test(raw.trim()) ? Number(raw) : raw;
385
+ return typeof n === "number" && Number.isSafeInteger(n) && n >= 0 ? n : void 0;
386
+ }
387
+ exports.GMA_FULLSCREEN_CHANNELS = {
388
+ rnapp_google_mobile_ads_app_open_event: "app_open",
389
+ rnapp_google_mobile_ads_interstitial_event: "interstitial",
390
+ rnapp_google_mobile_ads_rewarded_event: "rewarded",
391
+ rnapp_google_mobile_ads_rewarded_interstitial_event: "rewarded_interstitial"
392
+ };
393
+ exports.GMA_MIN_VERSION = "12.4.0";
394
+ function fromGoogleMobileAdsPaid(payload, meta = {}) {
395
+ var _a;
396
+ const p = record(payload);
397
+ if (!p)
398
+ return void 0;
399
+ const currency = text(p.currency);
400
+ if (!currency)
401
+ return void 0;
402
+ let valueMicros = micros(p.valueMicros);
403
+ if (valueMicros === void 0) {
404
+ if (!(typeof p.value === "number" && Number.isFinite(p.value) && p.value >= 0))
405
+ return void 0;
406
+ valueMicros = Math.round(p.value * 1e6);
407
+ }
408
+ const loaded = record((_a = record(p.responseInfo)) == null ? void 0 : _a.loadedAdapterResponse);
409
+ return {
410
+ valueMicros,
411
+ currency,
412
+ precision: precisionOf(p.precision),
413
+ adUnitId: meta.adUnitId,
414
+ adFormat: meta.adFormat,
415
+ adSourceName: text(loaded == null ? void 0 : loaded.adSourceName)
416
+ };
417
+ }
418
+ function fromGoogleMobileAdsChannel(channel, event) {
419
+ const e = record(event);
420
+ const body = record(e == null ? void 0 : e.body);
421
+ if (!e || (body == null ? void 0 : body.type) !== "paid")
422
+ return void 0;
423
+ return fromGoogleMobileAdsPaid(body.data, { adUnitId: text(e.adUnitId), adFormat: exports.GMA_FULLSCREEN_CHANNELS[channel] });
424
+ }
425
+ function fromGoogleMobileAdsNativeAd(event) {
426
+ const e = record(event);
427
+ if ((e == null ? void 0 : e.type) !== "paid")
428
+ return void 0;
429
+ return fromGoogleMobileAdsPaid(e, { adFormat: "native" });
430
+ }
431
+ exports.MAX_RN_REVENUE_EVENTS = [
432
+ "OnBannerAdRevenuePaid",
433
+ "OnMRecAdRevenuePaid",
434
+ "OnInterstitialAdRevenuePaid",
435
+ "OnRewardedAdRevenuePaid",
436
+ "OnAppOpenAdRevenuePaid"
437
+ ];
438
+ exports.MAX_RN_MIN_VERSION = "5.0.0";
439
+ function fromMaxAdInfo(info) {
440
+ const i = record(info);
441
+ if (!i || typeof i.revenue !== "number")
442
+ return void 0;
443
+ return {
444
+ revenue: i.revenue,
445
+ revenuePrecision: text(i.revenuePrecision),
446
+ adUnitId: text(i.adUnitId),
447
+ format: text(i.adFormat),
448
+ networkName: text(i.networkName)
449
+ };
450
+ }
451
+ exports.CAPACITOR_ADMOB_PAID_EVENTS = {
452
+ bannerAdPaid: "banner",
453
+ nativeAdPaid: "native",
454
+ interstitialAdImpression: "interstitial",
455
+ onRewardedVideoAdImpression: "rewarded",
456
+ onRewardedInterstitialAdImpression: "rewarded_interstitial",
457
+ appOpenAdImpression: "app_open"
458
+ };
459
+ function fromCapacitorAdMob(event, adFormat) {
460
+ const e = record(event);
461
+ const valueMicros = micros(e == null ? void 0 : e.valueMicros);
462
+ const currency = text(e == null ? void 0 : e.currencyCode);
463
+ if (!e || valueMicros === void 0 || !currency)
464
+ return void 0;
465
+ return {
466
+ valueMicros,
467
+ currency,
468
+ precision: precisionOf(e.precision),
469
+ adUnitId: text(e.adUnitId),
470
+ adFormat,
471
+ // The mediation ADAPTER class here, not the source's display name — still
472
+ // the only thing telling AdMob's own demand from a mediated network.
473
+ adSourceName: text(e.networkName)
474
+ };
475
+ }
476
+ function nativeModule(rn, name) {
477
+ var _a, _b, _c, _d, _e;
478
+ try {
479
+ 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];
480
+ } catch {
481
+ return (_e = rn.NativeModules) == null ? void 0 : _e[name];
482
+ }
483
+ }
484
+ function watchReactNativeAds(want, sink, rn) {
485
+ var _a, _b, _c, _d;
486
+ if (!rn) {
487
+ try {
488
+ rn = (init_empty(), __toCommonJS(empty_exports));
489
+ } catch {
490
+ return () => void 0;
491
+ }
492
+ }
493
+ const subs = [];
494
+ const guard = (parse, deliver) => (e) => {
495
+ try {
496
+ const v = parse(e);
497
+ if (v)
498
+ deliver(v);
499
+ } catch {
500
+ }
501
+ };
502
+ if (want.admob) {
503
+ for (const channel of Object.keys(exports.GMA_FULLSCREEN_CHANNELS)) {
504
+ const sub = (_a = rn.DeviceEventEmitter) == null ? void 0 : _a.addListener(channel, guard((e) => fromGoogleMobileAdsChannel(channel, e), sink.admob));
505
+ if (sub)
506
+ subs.push(sub);
507
+ }
508
+ const nativeAds = nativeModule(rn, "RNGoogleMobileAdsNativeModule");
509
+ const onNative = guard(fromGoogleMobileAdsNativeAd, sink.admob);
510
+ try {
511
+ if (nativeAds && typeof nativeAds.onAdEvent === "function") {
512
+ subs.push(nativeAds.onAdEvent(onNative));
513
+ } else if (nativeAds && rn.NativeEventEmitter) {
514
+ const emitter = new rn.NativeEventEmitter(((_b = rn.Platform) == null ? void 0 : _b.OS) === "ios" ? nativeAds : void 0);
515
+ subs.push(emitter.addListener("RNGMANativeAdEvent", onNative));
516
+ }
517
+ } catch {
518
+ }
519
+ }
520
+ if (want.applovinMax) {
521
+ const max = nativeModule(rn, "AppLovinMAX");
522
+ if (max && rn.NativeEventEmitter) {
523
+ try {
524
+ let names = [...exports.MAX_RN_REVENUE_EVENTS];
525
+ try {
526
+ const c = (_d = (_c = max.getConstants) == null ? void 0 : _c.call(max)) != null ? _d : {};
527
+ const fromModule = Object.keys(c).filter((k) => /^ON_.*_AD_REVENUE_PAID$/.test(k)).map((k) => c[k]).filter((v) => typeof v === "string");
528
+ if (fromModule.length)
529
+ names = [.../* @__PURE__ */ new Set([...fromModule, ...names])];
530
+ } catch {
531
+ }
532
+ const emitter = new rn.NativeEventEmitter(max);
533
+ for (const name of names)
534
+ subs.push(emitter.addListener(name, guard(fromMaxAdInfo, sink.applovinMax)));
535
+ } catch {
536
+ }
537
+ }
538
+ }
539
+ return () => {
540
+ for (const s of subs.splice(0)) {
541
+ try {
542
+ s.remove();
543
+ } catch {
544
+ }
545
+ }
546
+ };
547
+ }
548
+ }
549
+ });
550
+
359
551
  // ../sdk-core/build/index.js
360
552
  var require_build = __commonJS({
361
553
  "../sdk-core/build/index.js"(exports) {
362
554
  "use strict";
363
555
  Object.defineProperty(exports, "__esModule", { value: true });
364
- exports.Traqio = exports.Client = exports.isTrackingUrl = exports.isOpenUrl = exports.reportAdServicesToken = exports.Skan = exports.SDK_VERSION = void 0;
556
+ 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;
365
557
  exports.normalizeAdvertisingId = normalizeAdvertisingId;
366
558
  exports.fromMaxAd = fromMaxAd;
559
+ exports.detectDebug = detectDebug;
560
+ exports.isLocalPage = isLocalPage;
367
561
  var skan_1 = require_skan();
368
562
  var adservices_1 = require_adservices();
369
563
  var deeplink_1 = require_deeplink();
370
- exports.SDK_VERSION = "0.2.0";
564
+ var adRevenue_1 = require_adRevenue();
565
+ exports.SDK_VERSION = "0.4.0";
371
566
  var skan_2 = require_skan();
372
567
  Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
373
568
  return skan_2.Skan;
@@ -383,7 +578,42 @@ var require_build = __commonJS({
383
578
  Object.defineProperty(exports, "isTrackingUrl", { enumerable: true, get: function() {
384
579
  return deeplink_2.isTrackingUrl;
385
580
  } });
581
+ var adRevenue_2 = require_adRevenue();
582
+ Object.defineProperty(exports, "CAPACITOR_ADMOB_PAID_EVENTS", { enumerable: true, get: function() {
583
+ return adRevenue_2.CAPACITOR_ADMOB_PAID_EVENTS;
584
+ } });
585
+ Object.defineProperty(exports, "GMA_FULLSCREEN_CHANNELS", { enumerable: true, get: function() {
586
+ return adRevenue_2.GMA_FULLSCREEN_CHANNELS;
587
+ } });
588
+ Object.defineProperty(exports, "GMA_MIN_VERSION", { enumerable: true, get: function() {
589
+ return adRevenue_2.GMA_MIN_VERSION;
590
+ } });
591
+ Object.defineProperty(exports, "MAX_RN_MIN_VERSION", { enumerable: true, get: function() {
592
+ return adRevenue_2.MAX_RN_MIN_VERSION;
593
+ } });
594
+ Object.defineProperty(exports, "MAX_RN_REVENUE_EVENTS", { enumerable: true, get: function() {
595
+ return adRevenue_2.MAX_RN_REVENUE_EVENTS;
596
+ } });
597
+ Object.defineProperty(exports, "fromCapacitorAdMob", { enumerable: true, get: function() {
598
+ return adRevenue_2.fromCapacitorAdMob;
599
+ } });
600
+ Object.defineProperty(exports, "fromGoogleMobileAdsChannel", { enumerable: true, get: function() {
601
+ return adRevenue_2.fromGoogleMobileAdsChannel;
602
+ } });
603
+ Object.defineProperty(exports, "fromGoogleMobileAdsNativeAd", { enumerable: true, get: function() {
604
+ return adRevenue_2.fromGoogleMobileAdsNativeAd;
605
+ } });
606
+ Object.defineProperty(exports, "fromGoogleMobileAdsPaid", { enumerable: true, get: function() {
607
+ return adRevenue_2.fromGoogleMobileAdsPaid;
608
+ } });
609
+ Object.defineProperty(exports, "fromMaxAdInfo", { enumerable: true, get: function() {
610
+ return adRevenue_2.fromMaxAdInfo;
611
+ } });
612
+ Object.defineProperty(exports, "watchReactNativeAds", { enumerable: true, get: function() {
613
+ return adRevenue_2.watchReactNativeAds;
614
+ } });
386
615
  var INSTALL_SENT_KEY = "traq_install_sent";
616
+ var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
387
617
  var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
388
618
  var REFERRER_KEY = "traq_referrer";
389
619
  var QUEUE_KEY = "traq_queue";
@@ -492,6 +722,19 @@ var require_build = __commonJS({
492
722
  this.undelivered = [];
493
723
  this.deferred = null;
494
724
  this.consent = null;
725
+ this.debug = false;
726
+ this.maxRevenuePaid = (adInfo) => {
727
+ try {
728
+ const ad = (0, adRevenue_1.fromMaxAdInfo)(adInfo);
729
+ if (ad)
730
+ this.trackMaxAdRevenue(ad);
731
+ } catch {
732
+ }
733
+ };
734
+ }
735
+ /** Whether this run is in debug mode — see `InitOptions.debug`. Settled by `init()`. */
736
+ get isDebug() {
737
+ return this.debug;
495
738
  }
496
739
  async init(opts) {
497
740
  var _a;
@@ -502,6 +745,7 @@ var require_build = __commonJS({
502
745
  if (!this.opts.storage) {
503
746
  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.");
504
747
  }
748
+ this.debug = await detectDebug(opts);
505
749
  await this.restoreConsent(opts.consent);
506
750
  await this.restoreQueue();
507
751
  await this.restoreAdQueue();
@@ -509,7 +753,7 @@ var require_build = __commonJS({
509
753
  if (await this.restoreErased())
510
754
  return;
511
755
  if (!this.isWeb) {
512
- const freshInstall = Boolean(this.opts.storage) && !await this.opts.storage.getItem(INSTALL_SENT_KEY).catch(() => "1");
756
+ const freshInstall = Boolean(this.opts.storage) && !await this.opts.storage.getItem(this.installSentKey).catch(() => "1");
513
757
  await this.sendInstallOnce();
514
758
  if (this.opts.deepLinking !== false) {
515
759
  this.deferred = this.resolveDeferredOnce(freshInstall).then((link) => link != null ? link : this.retryDeferredWithConsent());
@@ -520,9 +764,28 @@ var require_build = __commonJS({
520
764
  await this.initSkan();
521
765
  await this.initAppleAds();
522
766
  this.wireLifecycle();
767
+ this.wireAdRevenue();
523
768
  if (this.queue.length || this.adQueue.length)
524
769
  this.scheduleFlush(0);
525
770
  }
771
+ // `InitOptions.adRevenue`: hand the ad SDKs' own paid events to the trackers.
772
+ wireAdRevenue() {
773
+ var _a;
774
+ const want = this.opts.adRevenue;
775
+ if (!want || this.isWeb || !(want.admob || want.applovinMax))
776
+ return;
777
+ const sink = {
778
+ admob: (ad) => this.trackAdRevenue(ad),
779
+ applovinMax: (ad) => this.trackMaxAdRevenue(ad)
780
+ };
781
+ try {
782
+ if ((_a = this.opts.native) == null ? void 0 : _a.watchAdRevenue)
783
+ this.opts.native.watchAdRevenue(want, sink);
784
+ else
785
+ (0, adRevenue_1.watchReactNativeAds)(want, sink);
786
+ } catch {
787
+ }
788
+ }
526
789
  track(name, props) {
527
790
  var _a, _b;
528
791
  if (!this.started || this.erased)
@@ -575,6 +838,27 @@ var require_build = __commonJS({
575
838
  if (converted)
576
839
  this.queueAdRevenue(converted, "applovin_max");
577
840
  }
841
+ /**
842
+ * The one line for an ad that reports through its own callback — a
843
+ * react-native-google-mobile-ads `<BannerAd>` (the full-screen formats are
844
+ * captured by `adRevenue: { admob: true }`):
845
+ *
846
+ * <BannerAd unitId={AD_UNIT_ID} size={…} onPaid={Traqio.admobPaid(AD_UNIT_ID)} />
847
+ * ad.addAdEventListener(AdEventType.PAID, Traqio.admobPaid(AD_UNIT_ID, "rewarded"))
848
+ *
849
+ * Reads the library's PAID payload (`value` in currency units, or v17's exact
850
+ * `valueMicros`) and reports it as AdMob revenue.
851
+ */
852
+ admobPaid(adUnitId, adFormat = "banner") {
853
+ return (event) => {
854
+ try {
855
+ const ad = (0, adRevenue_1.fromGoogleMobileAdsPaid)(event, { adUnitId, adFormat });
856
+ if (ad)
857
+ this.trackAdRevenue(ad);
858
+ } catch {
859
+ }
860
+ };
861
+ }
578
862
  queueAdRevenue(ad, source) {
579
863
  var _a;
580
864
  if (!this.started || this.erased)
@@ -772,7 +1056,8 @@ var require_build = __commonJS({
772
1056
  deviceId: this.context.deviceId,
773
1057
  userId: this.opts.userId,
774
1058
  storage: this.opts.storage,
775
- native: { getAttributionToken: () => native.getAttributionToken() }
1059
+ native: { getAttributionToken: () => native.getAttributionToken() },
1060
+ debug: this.debug
776
1061
  });
777
1062
  }
778
1063
  async initSkan() {
@@ -910,6 +1195,13 @@ var require_build = __commonJS({
910
1195
  var _a;
911
1196
  return ((_a = this.opts) == null ? void 0 : _a.platform) === "web";
912
1197
  }
1198
+ get installSentKey() {
1199
+ return this.debug ? INSTALL_SENT_DEBUG_KEY : INSTALL_SENT_KEY;
1200
+ }
1201
+ /** Spread into every body: present only in debug mode, so a release build's payload is unchanged. */
1202
+ debugField() {
1203
+ return this.debug ? { debug: true } : {};
1204
+ }
913
1205
  wireLifecycle() {
914
1206
  const events = {
915
1207
  background: () => this.flush(),
@@ -1121,7 +1413,7 @@ var require_build = __commonJS({
1121
1413
  async sendInstallOnce() {
1122
1414
  var _a, _b;
1123
1415
  const store = this.opts.storage;
1124
- if (store && await store.getItem(INSTALL_SENT_KEY))
1416
+ if (store && await store.getItem(this.installSentKey))
1125
1417
  return;
1126
1418
  const platform = (_b = (_a = this.opts.native) == null ? void 0 : _a.platform) != null ? _b : "android";
1127
1419
  const referrer = await this.readReferrer();
@@ -1142,7 +1434,7 @@ var require_build = __commonJS({
1142
1434
  }
1143
1435
  });
1144
1436
  if (ok)
1145
- await (store == null ? void 0 : store.setItem(INSTALL_SENT_KEY, "1"));
1437
+ await (store == null ? void 0 : store.setItem(this.installSentKey, "1"));
1146
1438
  }
1147
1439
  scheduleFlush(delay = FLUSH_DELAY_MS) {
1148
1440
  if (this.flushTimer)
@@ -1217,7 +1509,7 @@ var require_build = __commonJS({
1217
1509
  const res = await fetch(`${this.opts.endpoint}${path}`, {
1218
1510
  method: "POST",
1219
1511
  headers: { "Content-Type": "application/json" },
1220
- body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body }),
1512
+ body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...this.debugField() }),
1221
1513
  ...this.keepalive()
1222
1514
  });
1223
1515
  return res.ok ? await res.json() : null;
@@ -1262,7 +1554,7 @@ var require_build = __commonJS({
1262
1554
  const res = await fetch(`${this.opts.endpoint}${path}`, {
1263
1555
  method: "POST",
1264
1556
  headers: { "Content-Type": "application/json" },
1265
- body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...consent }),
1557
+ body: JSON.stringify({ sdkKey: this.opts.sdkKey, ...body, ...consent, ...this.debugField() }),
1266
1558
  ...this.keepalive()
1267
1559
  });
1268
1560
  if (res.ok)
@@ -1274,6 +1566,28 @@ var require_build = __commonJS({
1274
1566
  }
1275
1567
  };
1276
1568
  exports.Client = Client2;
1569
+ async function detectDebug(opts) {
1570
+ var _a, _b;
1571
+ if (opts.debug !== void 0)
1572
+ return opts.debug;
1573
+ if (opts.platform === "web")
1574
+ return isLocalPage();
1575
+ if (globalThis.__DEV__ === true)
1576
+ return true;
1577
+ try {
1578
+ return await ((_b = (_a = opts.native) == null ? void 0 : _a.isDebugBuild) == null ? void 0 : _b.call(_a)) === true;
1579
+ } catch {
1580
+ return false;
1581
+ }
1582
+ }
1583
+ function isLocalPage(loc = globalThis.location) {
1584
+ if (!loc)
1585
+ return false;
1586
+ if (loc.protocol === "file:")
1587
+ return true;
1588
+ const host = loc.hostname.toLowerCase().replace(/^\[|\]$/g, "");
1589
+ return host === "localhost" || host.endsWith(".localhost") || host.endsWith(".local") || host === "::1" || host === "0.0.0.0" || /^127\.\d+\.\d+\.\d+$/.test(host);
1590
+ }
1277
1591
  exports.Traqio = new Client2();
1278
1592
  }
1279
1593
  });
@@ -1558,12 +1872,17 @@ var TraqioWeb = class {
1558
1872
  platform: "web",
1559
1873
  userId: opts.userId,
1560
1874
  consent,
1875
+ debug: opts.debug,
1561
1876
  lifecycle: ({ background, foreground }) => {
1562
1877
  document.addEventListener("visibilitychange", () => document.visibilityState === "hidden" ? background() : foreground());
1563
1878
  window.addEventListener("pagehide", background);
1564
1879
  }
1565
1880
  });
1566
1881
  }
1882
+ /** Whether this page runs in debug mode — see `WebInitOptions.debug`. Settled by `init()`. */
1883
+ get isDebug() {
1884
+ return this.core.isDebug;
1885
+ }
1567
1886
  /** Record an event — `signup`, `purchase`, `add_to_cart`… Batched, retried, kept across page loads. */
1568
1887
  track(name, props) {
1569
1888
  this.core.track(name, props);