@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.cjs
CHANGED
|
@@ -367,13 +367,72 @@ var require_adRevenue = __commonJS({
|
|
|
367
367
|
"../sdk-core/build/adRevenue.js"(exports) {
|
|
368
368
|
"use strict";
|
|
369
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;
|
|
370
|
+
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;
|
|
371
371
|
exports.fromGoogleMobileAdsPaid = fromGoogleMobileAdsPaid;
|
|
372
372
|
exports.fromGoogleMobileAdsChannel = fromGoogleMobileAdsChannel;
|
|
373
373
|
exports.fromGoogleMobileAdsNativeAd = fromGoogleMobileAdsNativeAd;
|
|
374
374
|
exports.fromMaxAdInfo = fromMaxAdInfo;
|
|
375
375
|
exports.fromCapacitorAdMob = fromCapacitorAdMob;
|
|
376
376
|
exports.watchReactNativeAds = watchReactNativeAds;
|
|
377
|
+
function covers(c) {
|
|
378
|
+
return Array.isArray(c) ? c.length > 0 : c === true;
|
|
379
|
+
}
|
|
380
|
+
var AdRevenueGate = class {
|
|
381
|
+
constructor(warn = (m) => console.warn(m)) {
|
|
382
|
+
this.warn = warn;
|
|
383
|
+
this.coverage = {};
|
|
384
|
+
this.warned = /* @__PURE__ */ new Set();
|
|
385
|
+
this.seen = /* @__PURE__ */ new WeakSet();
|
|
386
|
+
}
|
|
387
|
+
arm(coverage) {
|
|
388
|
+
this.coverage = { ...coverage };
|
|
389
|
+
}
|
|
390
|
+
/** Does the automatic capture own this network (any format)? */
|
|
391
|
+
captures(network) {
|
|
392
|
+
return covers(this.coverage[network]);
|
|
393
|
+
}
|
|
394
|
+
/** Does the automatic capture own this format of the network? */
|
|
395
|
+
capturesFormat(network, format) {
|
|
396
|
+
const c = this.coverage[network];
|
|
397
|
+
if (c === true)
|
|
398
|
+
return true;
|
|
399
|
+
return Array.isArray(c) && format !== void 0 && c.includes(format);
|
|
400
|
+
}
|
|
401
|
+
/** A public manual tracker: allowed only for a network nothing captures. */
|
|
402
|
+
manual(network, call) {
|
|
403
|
+
if (!this.captures(network))
|
|
404
|
+
return true;
|
|
405
|
+
this.warnOnce(`manual:${network}`, `[traqio] adRevenue.${network} is on: manual ${call}() ignored \u2014 Traqio already captures this network, remove the call.`);
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
/** A one-line helper: allowed for the formats the watcher does not capture, once per event. */
|
|
409
|
+
helper(network, format, raw, call) {
|
|
410
|
+
if (this.capturesFormat(network, format)) {
|
|
411
|
+
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.`);
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
return this.first(raw);
|
|
415
|
+
}
|
|
416
|
+
/** True the first time this event object is seen (non-objects always pass). */
|
|
417
|
+
first(raw) {
|
|
418
|
+
if (!raw || typeof raw !== "object")
|
|
419
|
+
return true;
|
|
420
|
+
if (this.seen.has(raw))
|
|
421
|
+
return false;
|
|
422
|
+
this.seen.add(raw);
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
warnOnce(key, message) {
|
|
426
|
+
if (this.warned.has(key))
|
|
427
|
+
return;
|
|
428
|
+
this.warned.add(key);
|
|
429
|
+
try {
|
|
430
|
+
this.warn(message);
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
exports.AdRevenueGate = AdRevenueGate;
|
|
377
436
|
var PRECISION_BY_INDEX = ["unknown", "estimated", "publisher_provided", "precise"];
|
|
378
437
|
function precisionOf(raw) {
|
|
379
438
|
var _a;
|
|
@@ -486,38 +545,49 @@ var require_adRevenue = __commonJS({
|
|
|
486
545
|
return (_e = rn.NativeModules) == null ? void 0 : _e[name];
|
|
487
546
|
}
|
|
488
547
|
}
|
|
548
|
+
var MAX_RN_FULLSCREEN_FORMATS = ["interstitial", "rewarded", "rewarded_interstitial", "app_open"];
|
|
489
549
|
function watchReactNativeAds(want, sink, rn) {
|
|
490
550
|
var _a, _b, _c, _d;
|
|
491
551
|
if (!rn) {
|
|
492
552
|
try {
|
|
493
553
|
rn = (init_empty(), __toCommonJS(empty_exports));
|
|
494
554
|
} catch {
|
|
495
|
-
return () => void 0;
|
|
555
|
+
return { coverage: {}, stop: () => void 0 };
|
|
496
556
|
}
|
|
497
557
|
}
|
|
498
558
|
const subs = [];
|
|
499
|
-
const
|
|
559
|
+
const coverage = {};
|
|
560
|
+
const guard = (parse, deliver, rawOf = (e) => e) => (e) => {
|
|
500
561
|
try {
|
|
501
562
|
const v = parse(e);
|
|
502
563
|
if (v)
|
|
503
|
-
deliver(v);
|
|
564
|
+
deliver(v, rawOf(e));
|
|
504
565
|
} catch {
|
|
505
566
|
}
|
|
506
567
|
};
|
|
568
|
+
const paidData = (e) => {
|
|
569
|
+
var _a2, _b2;
|
|
570
|
+
return (_b2 = record((_a2 = record(e)) == null ? void 0 : _a2.body)) == null ? void 0 : _b2.data;
|
|
571
|
+
};
|
|
507
572
|
if (want.admob) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
573
|
+
coverage.admob = [];
|
|
574
|
+
for (const [channel, format] of Object.entries(exports.GMA_FULLSCREEN_CHANNELS)) {
|
|
575
|
+
const sub = (_a = rn.DeviceEventEmitter) == null ? void 0 : _a.addListener(channel, guard((e) => fromGoogleMobileAdsChannel(channel, e), sink.admob, paidData));
|
|
576
|
+
if (sub) {
|
|
511
577
|
subs.push(sub);
|
|
578
|
+
coverage.admob.push(format);
|
|
579
|
+
}
|
|
512
580
|
}
|
|
513
581
|
const nativeAds = nativeModule(rn, "RNGoogleMobileAdsNativeModule");
|
|
514
582
|
const onNative = guard(fromGoogleMobileAdsNativeAd, sink.admob);
|
|
515
583
|
try {
|
|
516
584
|
if (nativeAds && typeof nativeAds.onAdEvent === "function") {
|
|
517
585
|
subs.push(nativeAds.onAdEvent(onNative));
|
|
586
|
+
coverage.admob.push("native");
|
|
518
587
|
} else if (nativeAds && rn.NativeEventEmitter) {
|
|
519
588
|
const emitter = new rn.NativeEventEmitter(((_b = rn.Platform) == null ? void 0 : _b.OS) === "ios" ? nativeAds : void 0);
|
|
520
589
|
subs.push(emitter.addListener("RNGMANativeAdEvent", onNative));
|
|
590
|
+
coverage.admob.push("native");
|
|
521
591
|
}
|
|
522
592
|
} catch {
|
|
523
593
|
}
|
|
@@ -537,15 +607,19 @@ var require_adRevenue = __commonJS({
|
|
|
537
607
|
const emitter = new rn.NativeEventEmitter(max);
|
|
538
608
|
for (const name of names)
|
|
539
609
|
subs.push(emitter.addListener(name, guard(fromMaxAdInfo, sink.applovinMax)));
|
|
610
|
+
coverage.applovinMax = [...MAX_RN_FULLSCREEN_FORMATS];
|
|
540
611
|
} catch {
|
|
541
612
|
}
|
|
542
613
|
}
|
|
543
614
|
}
|
|
544
|
-
return
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
615
|
+
return {
|
|
616
|
+
coverage,
|
|
617
|
+
stop: () => {
|
|
618
|
+
for (const s of subs.splice(0)) {
|
|
619
|
+
try {
|
|
620
|
+
s.remove();
|
|
621
|
+
} catch {
|
|
622
|
+
}
|
|
549
623
|
}
|
|
550
624
|
}
|
|
551
625
|
};
|
|
@@ -558,7 +632,7 @@ var require_build = __commonJS({
|
|
|
558
632
|
"../sdk-core/build/index.js"(exports) {
|
|
559
633
|
"use strict";
|
|
560
634
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
635
|
+
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;
|
|
562
636
|
exports.normalizeAdvertisingId = normalizeAdvertisingId;
|
|
563
637
|
exports.fromMaxAd = fromMaxAd;
|
|
564
638
|
exports.detectDebug = detectDebug;
|
|
@@ -567,7 +641,7 @@ var require_build = __commonJS({
|
|
|
567
641
|
var adservices_1 = require_adservices();
|
|
568
642
|
var deeplink_1 = require_deeplink();
|
|
569
643
|
var adRevenue_1 = require_adRevenue();
|
|
570
|
-
exports.SDK_VERSION = "0.
|
|
644
|
+
exports.SDK_VERSION = "0.5.0";
|
|
571
645
|
var skan_2 = require_skan();
|
|
572
646
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
573
647
|
return skan_2.Skan;
|
|
@@ -617,6 +691,9 @@ var require_build = __commonJS({
|
|
|
617
691
|
Object.defineProperty(exports, "watchReactNativeAds", { enumerable: true, get: function() {
|
|
618
692
|
return adRevenue_2.watchReactNativeAds;
|
|
619
693
|
} });
|
|
694
|
+
Object.defineProperty(exports, "AdRevenueGate", { enumerable: true, get: function() {
|
|
695
|
+
return adRevenue_2.AdRevenueGate;
|
|
696
|
+
} });
|
|
620
697
|
var INSTALL_SENT_KEY = "traq_install_sent";
|
|
621
698
|
var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
|
|
622
699
|
var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
|
|
@@ -714,6 +791,7 @@ var require_build = __commonJS({
|
|
|
714
791
|
constructor() {
|
|
715
792
|
this.queue = [];
|
|
716
793
|
this.adQueue = [];
|
|
794
|
+
this.adGate = new adRevenue_1.AdRevenueGate();
|
|
717
795
|
this.adBatchId = null;
|
|
718
796
|
this.context = { sdkVersion: exports.SDK_VERSION };
|
|
719
797
|
this.referrer = null;
|
|
@@ -730,9 +808,10 @@ var require_build = __commonJS({
|
|
|
730
808
|
this.debug = false;
|
|
731
809
|
this.maxRevenuePaid = (adInfo) => {
|
|
732
810
|
try {
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
|
|
811
|
+
const max = (0, adRevenue_1.fromMaxAdInfo)(adInfo);
|
|
812
|
+
const ad = max && fromMaxAd(max);
|
|
813
|
+
if (ad && this.adGate.helper("applovinMax", ad.adFormat, adInfo, "Traqio.maxRevenuePaid"))
|
|
814
|
+
this.queueAdRevenue(ad, "applovin_max", "auto");
|
|
736
815
|
} catch {
|
|
737
816
|
}
|
|
738
817
|
};
|
|
@@ -775,19 +854,24 @@ var require_build = __commonJS({
|
|
|
775
854
|
}
|
|
776
855
|
// `InitOptions.adRevenue`: hand the ad SDKs' own paid events to the trackers.
|
|
777
856
|
wireAdRevenue() {
|
|
778
|
-
var _a;
|
|
857
|
+
var _a, _b;
|
|
779
858
|
const want = this.opts.adRevenue;
|
|
780
859
|
if (!want || this.isWeb || !(want.admob || want.applovinMax))
|
|
781
860
|
return;
|
|
782
861
|
const sink = {
|
|
783
|
-
admob: (ad) =>
|
|
784
|
-
|
|
862
|
+
admob: (ad, raw) => {
|
|
863
|
+
if (this.adGate.first(raw))
|
|
864
|
+
this.queueAdRevenue(ad, "admob", "auto");
|
|
865
|
+
},
|
|
866
|
+
applovinMax: (ad, raw) => {
|
|
867
|
+
const converted = fromMaxAd(ad);
|
|
868
|
+
if (converted && this.adGate.first(raw))
|
|
869
|
+
this.queueAdRevenue(converted, "applovin_max", "auto");
|
|
870
|
+
}
|
|
785
871
|
};
|
|
786
872
|
try {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
else
|
|
790
|
-
(0, adRevenue_1.watchReactNativeAds)(want, sink);
|
|
873
|
+
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;
|
|
874
|
+
this.adGate.arm(coverage);
|
|
791
875
|
} catch {
|
|
792
876
|
}
|
|
793
877
|
}
|
|
@@ -822,9 +906,14 @@ var require_build = __commonJS({
|
|
|
822
906
|
*
|
|
823
907
|
* Impressions are batched and sent to /ingest/ad-revenue, where they are matched
|
|
824
908
|
* to this install and become the ad half of ROAS.
|
|
909
|
+
*
|
|
910
|
+
* Ignored (one warning) once `adRevenue: { admob: true }` captures AdMob: the
|
|
911
|
+
* impression is already counted.
|
|
825
912
|
*/
|
|
826
913
|
trackAdRevenue(ad) {
|
|
827
|
-
this.
|
|
914
|
+
if (!this.adGate.manual("admob", "trackAdRevenue"))
|
|
915
|
+
return;
|
|
916
|
+
this.queueAdRevenue(ad, "admob", "manual");
|
|
828
917
|
}
|
|
829
918
|
/**
|
|
830
919
|
* Report one AppLovin MAX impression's revenue. Call it from MAX's callback:
|
|
@@ -836,12 +925,15 @@ var require_build = __commonJS({
|
|
|
836
925
|
* }); }
|
|
837
926
|
*
|
|
838
927
|
* Same batching, same endpoint and same ROAS numerator as AdMob, filed under
|
|
839
|
-
* the `applovin_max` source.
|
|
928
|
+
* the `applovin_max` source. Ignored (one warning) once
|
|
929
|
+
* `adRevenue: { applovinMax: true }` captures MAX.
|
|
840
930
|
*/
|
|
841
931
|
trackMaxAdRevenue(ad) {
|
|
932
|
+
if (!this.adGate.manual("applovinMax", "trackMaxAdRevenue"))
|
|
933
|
+
return;
|
|
842
934
|
const converted = fromMaxAd(ad);
|
|
843
935
|
if (converted)
|
|
844
|
-
this.queueAdRevenue(converted, "applovin_max");
|
|
936
|
+
this.queueAdRevenue(converted, "applovin_max", "manual");
|
|
845
937
|
}
|
|
846
938
|
/**
|
|
847
939
|
* The one line for an ad that reports through its own callback — a
|
|
@@ -852,25 +944,27 @@ var require_build = __commonJS({
|
|
|
852
944
|
* ad.addAdEventListener(AdEventType.PAID, Traqio.admobPaid(AD_UNIT_ID, "rewarded"))
|
|
853
945
|
*
|
|
854
946
|
* Reads the library's PAID payload (`value` in currency units, or v17's exact
|
|
855
|
-
* `valueMicros`) and reports it as AdMob revenue.
|
|
947
|
+
* `valueMicros`) and reports it as AdMob revenue. With `adRevenue: { admob: true }`
|
|
948
|
+
* it only counts the formats the capture does not reach (banners): on a
|
|
949
|
+
* full-screen or native ad it is ignored, so the impression is never doubled.
|
|
856
950
|
*/
|
|
857
951
|
admobPaid(adUnitId, adFormat = "banner") {
|
|
858
952
|
return (event) => {
|
|
859
953
|
try {
|
|
860
954
|
const ad = (0, adRevenue_1.fromGoogleMobileAdsPaid)(event, { adUnitId, adFormat });
|
|
861
|
-
if (ad)
|
|
862
|
-
this.
|
|
955
|
+
if (ad && this.adGate.helper("admob", adFormat, event, "Traqio.admobPaid()"))
|
|
956
|
+
this.queueAdRevenue(ad, "admob", "auto");
|
|
863
957
|
} catch {
|
|
864
958
|
}
|
|
865
959
|
};
|
|
866
960
|
}
|
|
867
|
-
queueAdRevenue(ad, source) {
|
|
961
|
+
queueAdRevenue(ad, source, origin) {
|
|
868
962
|
var _a;
|
|
869
963
|
if (!this.started || this.erased)
|
|
870
964
|
return;
|
|
871
965
|
if (!(ad.valueMicros >= 0) || !ad.currency)
|
|
872
966
|
return;
|
|
873
|
-
this.adQueue.push({ ...ad, source, impressionId: uuid(), ts: (_a = ad.ts) != null ? _a : Math.floor(Date.now() / 1e3) });
|
|
967
|
+
this.adQueue.push({ ...ad, source, origin, impressionId: uuid(), ts: (_a = ad.ts) != null ? _a : Math.floor(Date.now() / 1e3) });
|
|
874
968
|
this.skan.addRevenue(ad.valueMicros / 1e6);
|
|
875
969
|
if (this.adQueue.length > MAX_AD_QUEUE)
|
|
876
970
|
this.adQueue.splice(0, this.adQueue.length - MAX_AD_QUEUE);
|