@traqio/web 0.2.1 → 0.2.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/build/index.cjs +126 -32
- package/build/index.cjs.map +3 -3
- package/build/index.js +126 -32
- package/build/index.js.map +3 -3
- package/build/traqio.min.js +1 -1
- package/build/traqio.min.js.map +3 -3
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -362,13 +362,72 @@ var require_adRevenue = __commonJS({
|
|
|
362
362
|
"../sdk-core/build/adRevenue.js"(exports) {
|
|
363
363
|
"use strict";
|
|
364
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;
|
|
365
|
+
exports.CAPACITOR_ADMOB_PAID_EVENTS = exports.MAX_RN_MIN_VERSION = exports.MAX_RN_REVENUE_EVENTS = exports.GMA_MIN_VERSION = exports.GMA_FULLSCREEN_CHANNELS = exports.AdRevenueGate = void 0;
|
|
366
366
|
exports.fromGoogleMobileAdsPaid = fromGoogleMobileAdsPaid;
|
|
367
367
|
exports.fromGoogleMobileAdsChannel = fromGoogleMobileAdsChannel;
|
|
368
368
|
exports.fromGoogleMobileAdsNativeAd = fromGoogleMobileAdsNativeAd;
|
|
369
369
|
exports.fromMaxAdInfo = fromMaxAdInfo;
|
|
370
370
|
exports.fromCapacitorAdMob = fromCapacitorAdMob;
|
|
371
371
|
exports.watchReactNativeAds = watchReactNativeAds;
|
|
372
|
+
function covers(c) {
|
|
373
|
+
return Array.isArray(c) ? c.length > 0 : c === true;
|
|
374
|
+
}
|
|
375
|
+
var AdRevenueGate = class {
|
|
376
|
+
constructor(warn = (m) => console.warn(m)) {
|
|
377
|
+
this.warn = warn;
|
|
378
|
+
this.coverage = {};
|
|
379
|
+
this.warned = /* @__PURE__ */ new Set();
|
|
380
|
+
this.seen = /* @__PURE__ */ new WeakSet();
|
|
381
|
+
}
|
|
382
|
+
arm(coverage) {
|
|
383
|
+
this.coverage = { ...coverage };
|
|
384
|
+
}
|
|
385
|
+
/** Does the automatic capture own this network (any format)? */
|
|
386
|
+
captures(network) {
|
|
387
|
+
return covers(this.coverage[network]);
|
|
388
|
+
}
|
|
389
|
+
/** Does the automatic capture own this format of the network? */
|
|
390
|
+
capturesFormat(network, format) {
|
|
391
|
+
const c = this.coverage[network];
|
|
392
|
+
if (c === true)
|
|
393
|
+
return true;
|
|
394
|
+
return Array.isArray(c) && format !== void 0 && c.includes(format);
|
|
395
|
+
}
|
|
396
|
+
/** A public manual tracker: allowed only for a network nothing captures. */
|
|
397
|
+
manual(network, call) {
|
|
398
|
+
if (!this.captures(network))
|
|
399
|
+
return true;
|
|
400
|
+
this.warnOnce(`manual:${network}`, `[traqio] adRevenue.${network} is on: manual ${call}() ignored \u2014 Traqio already captures this network, remove the call.`);
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
/** A one-line helper: allowed for the formats the watcher does not capture, once per event. */
|
|
404
|
+
helper(network, format, raw, call) {
|
|
405
|
+
if (this.capturesFormat(network, format)) {
|
|
406
|
+
this.warnOnce(`helper:${network}:${format}`, `[traqio] adRevenue.${network} already captures ${format} ads: ${call} ignored for them, keep it on the formats it is documented for.`);
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
return this.first(raw);
|
|
410
|
+
}
|
|
411
|
+
/** True the first time this event object is seen (non-objects always pass). */
|
|
412
|
+
first(raw) {
|
|
413
|
+
if (!raw || typeof raw !== "object")
|
|
414
|
+
return true;
|
|
415
|
+
if (this.seen.has(raw))
|
|
416
|
+
return false;
|
|
417
|
+
this.seen.add(raw);
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
warnOnce(key, message) {
|
|
421
|
+
if (this.warned.has(key))
|
|
422
|
+
return;
|
|
423
|
+
this.warned.add(key);
|
|
424
|
+
try {
|
|
425
|
+
this.warn(message);
|
|
426
|
+
} catch {
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
exports.AdRevenueGate = AdRevenueGate;
|
|
372
431
|
var PRECISION_BY_INDEX = ["unknown", "estimated", "publisher_provided", "precise"];
|
|
373
432
|
function precisionOf(raw) {
|
|
374
433
|
var _a;
|
|
@@ -481,38 +540,49 @@ var require_adRevenue = __commonJS({
|
|
|
481
540
|
return (_e = rn.NativeModules) == null ? void 0 : _e[name];
|
|
482
541
|
}
|
|
483
542
|
}
|
|
543
|
+
var MAX_RN_FULLSCREEN_FORMATS = ["interstitial", "rewarded", "rewarded_interstitial", "app_open"];
|
|
484
544
|
function watchReactNativeAds(want, sink, rn) {
|
|
485
545
|
var _a, _b, _c, _d;
|
|
486
546
|
if (!rn) {
|
|
487
547
|
try {
|
|
488
548
|
rn = (init_empty(), __toCommonJS(empty_exports));
|
|
489
549
|
} catch {
|
|
490
|
-
return () => void 0;
|
|
550
|
+
return { coverage: {}, stop: () => void 0 };
|
|
491
551
|
}
|
|
492
552
|
}
|
|
493
553
|
const subs = [];
|
|
494
|
-
const
|
|
554
|
+
const coverage = {};
|
|
555
|
+
const guard = (parse, deliver, rawOf = (e) => e) => (e) => {
|
|
495
556
|
try {
|
|
496
557
|
const v = parse(e);
|
|
497
558
|
if (v)
|
|
498
|
-
deliver(v);
|
|
559
|
+
deliver(v, rawOf(e));
|
|
499
560
|
} catch {
|
|
500
561
|
}
|
|
501
562
|
};
|
|
563
|
+
const paidData = (e) => {
|
|
564
|
+
var _a2, _b2;
|
|
565
|
+
return (_b2 = record((_a2 = record(e)) == null ? void 0 : _a2.body)) == null ? void 0 : _b2.data;
|
|
566
|
+
};
|
|
502
567
|
if (want.admob) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
568
|
+
coverage.admob = [];
|
|
569
|
+
for (const [channel, format] of Object.entries(exports.GMA_FULLSCREEN_CHANNELS)) {
|
|
570
|
+
const sub = (_a = rn.DeviceEventEmitter) == null ? void 0 : _a.addListener(channel, guard((e) => fromGoogleMobileAdsChannel(channel, e), sink.admob, paidData));
|
|
571
|
+
if (sub) {
|
|
506
572
|
subs.push(sub);
|
|
573
|
+
coverage.admob.push(format);
|
|
574
|
+
}
|
|
507
575
|
}
|
|
508
576
|
const nativeAds = nativeModule(rn, "RNGoogleMobileAdsNativeModule");
|
|
509
577
|
const onNative = guard(fromGoogleMobileAdsNativeAd, sink.admob);
|
|
510
578
|
try {
|
|
511
579
|
if (nativeAds && typeof nativeAds.onAdEvent === "function") {
|
|
512
580
|
subs.push(nativeAds.onAdEvent(onNative));
|
|
581
|
+
coverage.admob.push("native");
|
|
513
582
|
} else if (nativeAds && rn.NativeEventEmitter) {
|
|
514
583
|
const emitter = new rn.NativeEventEmitter(((_b = rn.Platform) == null ? void 0 : _b.OS) === "ios" ? nativeAds : void 0);
|
|
515
584
|
subs.push(emitter.addListener("RNGMANativeAdEvent", onNative));
|
|
585
|
+
coverage.admob.push("native");
|
|
516
586
|
}
|
|
517
587
|
} catch {
|
|
518
588
|
}
|
|
@@ -532,15 +602,19 @@ var require_adRevenue = __commonJS({
|
|
|
532
602
|
const emitter = new rn.NativeEventEmitter(max);
|
|
533
603
|
for (const name of names)
|
|
534
604
|
subs.push(emitter.addListener(name, guard(fromMaxAdInfo, sink.applovinMax)));
|
|
605
|
+
coverage.applovinMax = [...MAX_RN_FULLSCREEN_FORMATS];
|
|
535
606
|
} catch {
|
|
536
607
|
}
|
|
537
608
|
}
|
|
538
609
|
}
|
|
539
|
-
return
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
610
|
+
return {
|
|
611
|
+
coverage,
|
|
612
|
+
stop: () => {
|
|
613
|
+
for (const s of subs.splice(0)) {
|
|
614
|
+
try {
|
|
615
|
+
s.remove();
|
|
616
|
+
} catch {
|
|
617
|
+
}
|
|
544
618
|
}
|
|
545
619
|
}
|
|
546
620
|
};
|
|
@@ -553,7 +627,7 @@ var require_build = __commonJS({
|
|
|
553
627
|
"../sdk-core/build/index.js"(exports) {
|
|
554
628
|
"use strict";
|
|
555
629
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
630
|
+
exports.Traqio = exports.Client = exports.AdRevenueGate = 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;
|
|
557
631
|
exports.normalizeAdvertisingId = normalizeAdvertisingId;
|
|
558
632
|
exports.fromMaxAd = fromMaxAd;
|
|
559
633
|
exports.detectDebug = detectDebug;
|
|
@@ -562,7 +636,7 @@ var require_build = __commonJS({
|
|
|
562
636
|
var adservices_1 = require_adservices();
|
|
563
637
|
var deeplink_1 = require_deeplink();
|
|
564
638
|
var adRevenue_1 = require_adRevenue();
|
|
565
|
-
exports.SDK_VERSION = "0.
|
|
639
|
+
exports.SDK_VERSION = "0.5.0";
|
|
566
640
|
var skan_2 = require_skan();
|
|
567
641
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
568
642
|
return skan_2.Skan;
|
|
@@ -612,6 +686,9 @@ var require_build = __commonJS({
|
|
|
612
686
|
Object.defineProperty(exports, "watchReactNativeAds", { enumerable: true, get: function() {
|
|
613
687
|
return adRevenue_2.watchReactNativeAds;
|
|
614
688
|
} });
|
|
689
|
+
Object.defineProperty(exports, "AdRevenueGate", { enumerable: true, get: function() {
|
|
690
|
+
return adRevenue_2.AdRevenueGate;
|
|
691
|
+
} });
|
|
615
692
|
var INSTALL_SENT_KEY = "traq_install_sent";
|
|
616
693
|
var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
|
|
617
694
|
var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
|
|
@@ -709,6 +786,7 @@ var require_build = __commonJS({
|
|
|
709
786
|
constructor() {
|
|
710
787
|
this.queue = [];
|
|
711
788
|
this.adQueue = [];
|
|
789
|
+
this.adGate = new adRevenue_1.AdRevenueGate();
|
|
712
790
|
this.adBatchId = null;
|
|
713
791
|
this.context = { sdkVersion: exports.SDK_VERSION };
|
|
714
792
|
this.referrer = null;
|
|
@@ -725,9 +803,10 @@ var require_build = __commonJS({
|
|
|
725
803
|
this.debug = false;
|
|
726
804
|
this.maxRevenuePaid = (adInfo) => {
|
|
727
805
|
try {
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
806
|
+
const max = (0, adRevenue_1.fromMaxAdInfo)(adInfo);
|
|
807
|
+
const ad = max && fromMaxAd(max);
|
|
808
|
+
if (ad && this.adGate.helper("applovinMax", ad.adFormat, adInfo, "Traqio.maxRevenuePaid"))
|
|
809
|
+
this.queueAdRevenue(ad, "applovin_max", "auto");
|
|
731
810
|
} catch {
|
|
732
811
|
}
|
|
733
812
|
};
|
|
@@ -770,19 +849,24 @@ var require_build = __commonJS({
|
|
|
770
849
|
}
|
|
771
850
|
// `InitOptions.adRevenue`: hand the ad SDKs' own paid events to the trackers.
|
|
772
851
|
wireAdRevenue() {
|
|
773
|
-
var _a;
|
|
852
|
+
var _a, _b;
|
|
774
853
|
const want = this.opts.adRevenue;
|
|
775
854
|
if (!want || this.isWeb || !(want.admob || want.applovinMax))
|
|
776
855
|
return;
|
|
777
856
|
const sink = {
|
|
778
|
-
admob: (ad) =>
|
|
779
|
-
|
|
857
|
+
admob: (ad, raw) => {
|
|
858
|
+
if (this.adGate.first(raw))
|
|
859
|
+
this.queueAdRevenue(ad, "admob", "auto");
|
|
860
|
+
},
|
|
861
|
+
applovinMax: (ad, raw) => {
|
|
862
|
+
const converted = fromMaxAd(ad);
|
|
863
|
+
if (converted && this.adGate.first(raw))
|
|
864
|
+
this.queueAdRevenue(converted, "applovin_max", "auto");
|
|
865
|
+
}
|
|
780
866
|
};
|
|
781
867
|
try {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
else
|
|
785
|
-
(0, adRevenue_1.watchReactNativeAds)(want, sink);
|
|
868
|
+
const coverage = ((_a = this.opts.native) == null ? void 0 : _a.watchAdRevenue) ? (_b = this.opts.native.watchAdRevenue(want, sink)) != null ? _b : want : (0, adRevenue_1.watchReactNativeAds)(want, sink).coverage;
|
|
869
|
+
this.adGate.arm(coverage);
|
|
786
870
|
} catch {
|
|
787
871
|
}
|
|
788
872
|
}
|
|
@@ -817,9 +901,14 @@ var require_build = __commonJS({
|
|
|
817
901
|
*
|
|
818
902
|
* Impressions are batched and sent to /ingest/ad-revenue, where they are matched
|
|
819
903
|
* to this install and become the ad half of ROAS.
|
|
904
|
+
*
|
|
905
|
+
* Ignored (one warning) once `adRevenue: { admob: true }` captures AdMob: the
|
|
906
|
+
* impression is already counted.
|
|
820
907
|
*/
|
|
821
908
|
trackAdRevenue(ad) {
|
|
822
|
-
this.
|
|
909
|
+
if (!this.adGate.manual("admob", "trackAdRevenue"))
|
|
910
|
+
return;
|
|
911
|
+
this.queueAdRevenue(ad, "admob", "manual");
|
|
823
912
|
}
|
|
824
913
|
/**
|
|
825
914
|
* Report one AppLovin MAX impression's revenue. Call it from MAX's callback:
|
|
@@ -831,12 +920,15 @@ var require_build = __commonJS({
|
|
|
831
920
|
* }); }
|
|
832
921
|
*
|
|
833
922
|
* Same batching, same endpoint and same ROAS numerator as AdMob, filed under
|
|
834
|
-
* the `applovin_max` source.
|
|
923
|
+
* the `applovin_max` source. Ignored (one warning) once
|
|
924
|
+
* `adRevenue: { applovinMax: true }` captures MAX.
|
|
835
925
|
*/
|
|
836
926
|
trackMaxAdRevenue(ad) {
|
|
927
|
+
if (!this.adGate.manual("applovinMax", "trackMaxAdRevenue"))
|
|
928
|
+
return;
|
|
837
929
|
const converted = fromMaxAd(ad);
|
|
838
930
|
if (converted)
|
|
839
|
-
this.queueAdRevenue(converted, "applovin_max");
|
|
931
|
+
this.queueAdRevenue(converted, "applovin_max", "manual");
|
|
840
932
|
}
|
|
841
933
|
/**
|
|
842
934
|
* The one line for an ad that reports through its own callback — a
|
|
@@ -847,25 +939,27 @@ var require_build = __commonJS({
|
|
|
847
939
|
* ad.addAdEventListener(AdEventType.PAID, Traqio.admobPaid(AD_UNIT_ID, "rewarded"))
|
|
848
940
|
*
|
|
849
941
|
* Reads the library's PAID payload (`value` in currency units, or v17's exact
|
|
850
|
-
* `valueMicros`) and reports it as AdMob revenue.
|
|
942
|
+
* `valueMicros`) and reports it as AdMob revenue. With `adRevenue: { admob: true }`
|
|
943
|
+
* it only counts the formats the capture does not reach (banners): on a
|
|
944
|
+
* full-screen or native ad it is ignored, so the impression is never doubled.
|
|
851
945
|
*/
|
|
852
946
|
admobPaid(adUnitId, adFormat = "banner") {
|
|
853
947
|
return (event) => {
|
|
854
948
|
try {
|
|
855
949
|
const ad = (0, adRevenue_1.fromGoogleMobileAdsPaid)(event, { adUnitId, adFormat });
|
|
856
|
-
if (ad)
|
|
857
|
-
this.
|
|
950
|
+
if (ad && this.adGate.helper("admob", adFormat, event, "Traqio.admobPaid()"))
|
|
951
|
+
this.queueAdRevenue(ad, "admob", "auto");
|
|
858
952
|
} catch {
|
|
859
953
|
}
|
|
860
954
|
};
|
|
861
955
|
}
|
|
862
|
-
queueAdRevenue(ad, source) {
|
|
956
|
+
queueAdRevenue(ad, source, origin) {
|
|
863
957
|
var _a;
|
|
864
958
|
if (!this.started || this.erased)
|
|
865
959
|
return;
|
|
866
960
|
if (!(ad.valueMicros >= 0) || !ad.currency)
|
|
867
961
|
return;
|
|
868
|
-
this.adQueue.push({ ...ad, source, impressionId: uuid(), ts: (_a = ad.ts) != null ? _a : Math.floor(Date.now() / 1e3) });
|
|
962
|
+
this.adQueue.push({ ...ad, source, origin, impressionId: uuid(), ts: (_a = ad.ts) != null ? _a : Math.floor(Date.now() / 1e3) });
|
|
869
963
|
this.skan.addRevenue(ad.valueMicros / 1e6);
|
|
870
964
|
if (this.adQueue.length > MAX_AD_QUEUE)
|
|
871
965
|
this.adQueue.splice(0, this.adQueue.length - MAX_AD_QUEUE);
|