@traqio/web 0.2.0 → 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 +375 -7
- package/build/index.cjs.map +4 -4
- package/build/index.js +375 -7
- package/build/index.js.map +4 -4
- package/build/traqio.min.js +1 -1
- package/build/traqio.min.js.map +4 -4
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -357,12 +357,277 @@ var init_empty = __esm({
|
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
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 = exports.AdRevenueGate = 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
|
+
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;
|
|
431
|
+
var PRECISION_BY_INDEX = ["unknown", "estimated", "publisher_provided", "precise"];
|
|
432
|
+
function precisionOf(raw) {
|
|
433
|
+
var _a;
|
|
434
|
+
return typeof raw === "number" ? (_a = PRECISION_BY_INDEX[raw]) != null ? _a : "unknown" : "unknown";
|
|
435
|
+
}
|
|
436
|
+
function text(raw) {
|
|
437
|
+
return typeof raw === "string" && raw.trim() ? raw : void 0;
|
|
438
|
+
}
|
|
439
|
+
function record(raw) {
|
|
440
|
+
return raw && typeof raw === "object" ? raw : void 0;
|
|
441
|
+
}
|
|
442
|
+
function micros(raw) {
|
|
443
|
+
const n = typeof raw === "string" && /^\d+$/.test(raw.trim()) ? Number(raw) : raw;
|
|
444
|
+
return typeof n === "number" && Number.isSafeInteger(n) && n >= 0 ? n : void 0;
|
|
445
|
+
}
|
|
446
|
+
exports.GMA_FULLSCREEN_CHANNELS = {
|
|
447
|
+
rnapp_google_mobile_ads_app_open_event: "app_open",
|
|
448
|
+
rnapp_google_mobile_ads_interstitial_event: "interstitial",
|
|
449
|
+
rnapp_google_mobile_ads_rewarded_event: "rewarded",
|
|
450
|
+
rnapp_google_mobile_ads_rewarded_interstitial_event: "rewarded_interstitial"
|
|
451
|
+
};
|
|
452
|
+
exports.GMA_MIN_VERSION = "12.4.0";
|
|
453
|
+
function fromGoogleMobileAdsPaid(payload, meta = {}) {
|
|
454
|
+
var _a;
|
|
455
|
+
const p = record(payload);
|
|
456
|
+
if (!p)
|
|
457
|
+
return void 0;
|
|
458
|
+
const currency = text(p.currency);
|
|
459
|
+
if (!currency)
|
|
460
|
+
return void 0;
|
|
461
|
+
let valueMicros = micros(p.valueMicros);
|
|
462
|
+
if (valueMicros === void 0) {
|
|
463
|
+
if (!(typeof p.value === "number" && Number.isFinite(p.value) && p.value >= 0))
|
|
464
|
+
return void 0;
|
|
465
|
+
valueMicros = Math.round(p.value * 1e6);
|
|
466
|
+
}
|
|
467
|
+
const loaded = record((_a = record(p.responseInfo)) == null ? void 0 : _a.loadedAdapterResponse);
|
|
468
|
+
return {
|
|
469
|
+
valueMicros,
|
|
470
|
+
currency,
|
|
471
|
+
precision: precisionOf(p.precision),
|
|
472
|
+
adUnitId: meta.adUnitId,
|
|
473
|
+
adFormat: meta.adFormat,
|
|
474
|
+
adSourceName: text(loaded == null ? void 0 : loaded.adSourceName)
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function fromGoogleMobileAdsChannel(channel, event) {
|
|
478
|
+
const e = record(event);
|
|
479
|
+
const body = record(e == null ? void 0 : e.body);
|
|
480
|
+
if (!e || (body == null ? void 0 : body.type) !== "paid")
|
|
481
|
+
return void 0;
|
|
482
|
+
return fromGoogleMobileAdsPaid(body.data, { adUnitId: text(e.adUnitId), adFormat: exports.GMA_FULLSCREEN_CHANNELS[channel] });
|
|
483
|
+
}
|
|
484
|
+
function fromGoogleMobileAdsNativeAd(event) {
|
|
485
|
+
const e = record(event);
|
|
486
|
+
if ((e == null ? void 0 : e.type) !== "paid")
|
|
487
|
+
return void 0;
|
|
488
|
+
return fromGoogleMobileAdsPaid(e, { adFormat: "native" });
|
|
489
|
+
}
|
|
490
|
+
exports.MAX_RN_REVENUE_EVENTS = [
|
|
491
|
+
"OnBannerAdRevenuePaid",
|
|
492
|
+
"OnMRecAdRevenuePaid",
|
|
493
|
+
"OnInterstitialAdRevenuePaid",
|
|
494
|
+
"OnRewardedAdRevenuePaid",
|
|
495
|
+
"OnAppOpenAdRevenuePaid"
|
|
496
|
+
];
|
|
497
|
+
exports.MAX_RN_MIN_VERSION = "5.0.0";
|
|
498
|
+
function fromMaxAdInfo(info) {
|
|
499
|
+
const i = record(info);
|
|
500
|
+
if (!i || typeof i.revenue !== "number")
|
|
501
|
+
return void 0;
|
|
502
|
+
return {
|
|
503
|
+
revenue: i.revenue,
|
|
504
|
+
revenuePrecision: text(i.revenuePrecision),
|
|
505
|
+
adUnitId: text(i.adUnitId),
|
|
506
|
+
format: text(i.adFormat),
|
|
507
|
+
networkName: text(i.networkName)
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
exports.CAPACITOR_ADMOB_PAID_EVENTS = {
|
|
511
|
+
bannerAdPaid: "banner",
|
|
512
|
+
nativeAdPaid: "native",
|
|
513
|
+
interstitialAdImpression: "interstitial",
|
|
514
|
+
onRewardedVideoAdImpression: "rewarded",
|
|
515
|
+
onRewardedInterstitialAdImpression: "rewarded_interstitial",
|
|
516
|
+
appOpenAdImpression: "app_open"
|
|
517
|
+
};
|
|
518
|
+
function fromCapacitorAdMob(event, adFormat) {
|
|
519
|
+
const e = record(event);
|
|
520
|
+
const valueMicros = micros(e == null ? void 0 : e.valueMicros);
|
|
521
|
+
const currency = text(e == null ? void 0 : e.currencyCode);
|
|
522
|
+
if (!e || valueMicros === void 0 || !currency)
|
|
523
|
+
return void 0;
|
|
524
|
+
return {
|
|
525
|
+
valueMicros,
|
|
526
|
+
currency,
|
|
527
|
+
precision: precisionOf(e.precision),
|
|
528
|
+
adUnitId: text(e.adUnitId),
|
|
529
|
+
adFormat,
|
|
530
|
+
// The mediation ADAPTER class here, not the source's display name — still
|
|
531
|
+
// the only thing telling AdMob's own demand from a mediated network.
|
|
532
|
+
adSourceName: text(e.networkName)
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function nativeModule(rn, name) {
|
|
536
|
+
var _a, _b, _c, _d, _e;
|
|
537
|
+
try {
|
|
538
|
+
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];
|
|
539
|
+
} catch {
|
|
540
|
+
return (_e = rn.NativeModules) == null ? void 0 : _e[name];
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
var MAX_RN_FULLSCREEN_FORMATS = ["interstitial", "rewarded", "rewarded_interstitial", "app_open"];
|
|
544
|
+
function watchReactNativeAds(want, sink, rn) {
|
|
545
|
+
var _a, _b, _c, _d;
|
|
546
|
+
if (!rn) {
|
|
547
|
+
try {
|
|
548
|
+
rn = (init_empty(), __toCommonJS(empty_exports));
|
|
549
|
+
} catch {
|
|
550
|
+
return { coverage: {}, stop: () => void 0 };
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const subs = [];
|
|
554
|
+
const coverage = {};
|
|
555
|
+
const guard = (parse, deliver, rawOf = (e) => e) => (e) => {
|
|
556
|
+
try {
|
|
557
|
+
const v = parse(e);
|
|
558
|
+
if (v)
|
|
559
|
+
deliver(v, rawOf(e));
|
|
560
|
+
} catch {
|
|
561
|
+
}
|
|
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
|
+
};
|
|
567
|
+
if (want.admob) {
|
|
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) {
|
|
572
|
+
subs.push(sub);
|
|
573
|
+
coverage.admob.push(format);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
const nativeAds = nativeModule(rn, "RNGoogleMobileAdsNativeModule");
|
|
577
|
+
const onNative = guard(fromGoogleMobileAdsNativeAd, sink.admob);
|
|
578
|
+
try {
|
|
579
|
+
if (nativeAds && typeof nativeAds.onAdEvent === "function") {
|
|
580
|
+
subs.push(nativeAds.onAdEvent(onNative));
|
|
581
|
+
coverage.admob.push("native");
|
|
582
|
+
} else if (nativeAds && rn.NativeEventEmitter) {
|
|
583
|
+
const emitter = new rn.NativeEventEmitter(((_b = rn.Platform) == null ? void 0 : _b.OS) === "ios" ? nativeAds : void 0);
|
|
584
|
+
subs.push(emitter.addListener("RNGMANativeAdEvent", onNative));
|
|
585
|
+
coverage.admob.push("native");
|
|
586
|
+
}
|
|
587
|
+
} catch {
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (want.applovinMax) {
|
|
591
|
+
const max = nativeModule(rn, "AppLovinMAX");
|
|
592
|
+
if (max && rn.NativeEventEmitter) {
|
|
593
|
+
try {
|
|
594
|
+
let names = [...exports.MAX_RN_REVENUE_EVENTS];
|
|
595
|
+
try {
|
|
596
|
+
const c = (_d = (_c = max.getConstants) == null ? void 0 : _c.call(max)) != null ? _d : {};
|
|
597
|
+
const fromModule = Object.keys(c).filter((k) => /^ON_.*_AD_REVENUE_PAID$/.test(k)).map((k) => c[k]).filter((v) => typeof v === "string");
|
|
598
|
+
if (fromModule.length)
|
|
599
|
+
names = [.../* @__PURE__ */ new Set([...fromModule, ...names])];
|
|
600
|
+
} catch {
|
|
601
|
+
}
|
|
602
|
+
const emitter = new rn.NativeEventEmitter(max);
|
|
603
|
+
for (const name of names)
|
|
604
|
+
subs.push(emitter.addListener(name, guard(fromMaxAdInfo, sink.applovinMax)));
|
|
605
|
+
coverage.applovinMax = [...MAX_RN_FULLSCREEN_FORMATS];
|
|
606
|
+
} catch {
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
coverage,
|
|
612
|
+
stop: () => {
|
|
613
|
+
for (const s of subs.splice(0)) {
|
|
614
|
+
try {
|
|
615
|
+
s.remove();
|
|
616
|
+
} catch {
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
|
|
360
625
|
// ../sdk-core/build/index.js
|
|
361
626
|
var require_build = __commonJS({
|
|
362
627
|
"../sdk-core/build/index.js"(exports) {
|
|
363
628
|
"use strict";
|
|
364
629
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
365
|
-
exports.Traqio = exports.Client = 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;
|
|
366
631
|
exports.normalizeAdvertisingId = normalizeAdvertisingId;
|
|
367
632
|
exports.fromMaxAd = fromMaxAd;
|
|
368
633
|
exports.detectDebug = detectDebug;
|
|
@@ -370,7 +635,8 @@ var require_build = __commonJS({
|
|
|
370
635
|
var skan_1 = require_skan();
|
|
371
636
|
var adservices_1 = require_adservices();
|
|
372
637
|
var deeplink_1 = require_deeplink();
|
|
373
|
-
|
|
638
|
+
var adRevenue_1 = require_adRevenue();
|
|
639
|
+
exports.SDK_VERSION = "0.5.0";
|
|
374
640
|
var skan_2 = require_skan();
|
|
375
641
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
376
642
|
return skan_2.Skan;
|
|
@@ -386,6 +652,43 @@ var require_build = __commonJS({
|
|
|
386
652
|
Object.defineProperty(exports, "isTrackingUrl", { enumerable: true, get: function() {
|
|
387
653
|
return deeplink_2.isTrackingUrl;
|
|
388
654
|
} });
|
|
655
|
+
var adRevenue_2 = require_adRevenue();
|
|
656
|
+
Object.defineProperty(exports, "CAPACITOR_ADMOB_PAID_EVENTS", { enumerable: true, get: function() {
|
|
657
|
+
return adRevenue_2.CAPACITOR_ADMOB_PAID_EVENTS;
|
|
658
|
+
} });
|
|
659
|
+
Object.defineProperty(exports, "GMA_FULLSCREEN_CHANNELS", { enumerable: true, get: function() {
|
|
660
|
+
return adRevenue_2.GMA_FULLSCREEN_CHANNELS;
|
|
661
|
+
} });
|
|
662
|
+
Object.defineProperty(exports, "GMA_MIN_VERSION", { enumerable: true, get: function() {
|
|
663
|
+
return adRevenue_2.GMA_MIN_VERSION;
|
|
664
|
+
} });
|
|
665
|
+
Object.defineProperty(exports, "MAX_RN_MIN_VERSION", { enumerable: true, get: function() {
|
|
666
|
+
return adRevenue_2.MAX_RN_MIN_VERSION;
|
|
667
|
+
} });
|
|
668
|
+
Object.defineProperty(exports, "MAX_RN_REVENUE_EVENTS", { enumerable: true, get: function() {
|
|
669
|
+
return adRevenue_2.MAX_RN_REVENUE_EVENTS;
|
|
670
|
+
} });
|
|
671
|
+
Object.defineProperty(exports, "fromCapacitorAdMob", { enumerable: true, get: function() {
|
|
672
|
+
return adRevenue_2.fromCapacitorAdMob;
|
|
673
|
+
} });
|
|
674
|
+
Object.defineProperty(exports, "fromGoogleMobileAdsChannel", { enumerable: true, get: function() {
|
|
675
|
+
return adRevenue_2.fromGoogleMobileAdsChannel;
|
|
676
|
+
} });
|
|
677
|
+
Object.defineProperty(exports, "fromGoogleMobileAdsNativeAd", { enumerable: true, get: function() {
|
|
678
|
+
return adRevenue_2.fromGoogleMobileAdsNativeAd;
|
|
679
|
+
} });
|
|
680
|
+
Object.defineProperty(exports, "fromGoogleMobileAdsPaid", { enumerable: true, get: function() {
|
|
681
|
+
return adRevenue_2.fromGoogleMobileAdsPaid;
|
|
682
|
+
} });
|
|
683
|
+
Object.defineProperty(exports, "fromMaxAdInfo", { enumerable: true, get: function() {
|
|
684
|
+
return adRevenue_2.fromMaxAdInfo;
|
|
685
|
+
} });
|
|
686
|
+
Object.defineProperty(exports, "watchReactNativeAds", { enumerable: true, get: function() {
|
|
687
|
+
return adRevenue_2.watchReactNativeAds;
|
|
688
|
+
} });
|
|
689
|
+
Object.defineProperty(exports, "AdRevenueGate", { enumerable: true, get: function() {
|
|
690
|
+
return adRevenue_2.AdRevenueGate;
|
|
691
|
+
} });
|
|
389
692
|
var INSTALL_SENT_KEY = "traq_install_sent";
|
|
390
693
|
var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
|
|
391
694
|
var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
|
|
@@ -483,6 +786,7 @@ var require_build = __commonJS({
|
|
|
483
786
|
constructor() {
|
|
484
787
|
this.queue = [];
|
|
485
788
|
this.adQueue = [];
|
|
789
|
+
this.adGate = new adRevenue_1.AdRevenueGate();
|
|
486
790
|
this.adBatchId = null;
|
|
487
791
|
this.context = { sdkVersion: exports.SDK_VERSION };
|
|
488
792
|
this.referrer = null;
|
|
@@ -497,6 +801,15 @@ var require_build = __commonJS({
|
|
|
497
801
|
this.deferred = null;
|
|
498
802
|
this.consent = null;
|
|
499
803
|
this.debug = false;
|
|
804
|
+
this.maxRevenuePaid = (adInfo) => {
|
|
805
|
+
try {
|
|
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");
|
|
810
|
+
} catch {
|
|
811
|
+
}
|
|
812
|
+
};
|
|
500
813
|
}
|
|
501
814
|
/** Whether this run is in debug mode — see `InitOptions.debug`. Settled by `init()`. */
|
|
502
815
|
get isDebug() {
|
|
@@ -530,9 +843,33 @@ var require_build = __commonJS({
|
|
|
530
843
|
await this.initSkan();
|
|
531
844
|
await this.initAppleAds();
|
|
532
845
|
this.wireLifecycle();
|
|
846
|
+
this.wireAdRevenue();
|
|
533
847
|
if (this.queue.length || this.adQueue.length)
|
|
534
848
|
this.scheduleFlush(0);
|
|
535
849
|
}
|
|
850
|
+
// `InitOptions.adRevenue`: hand the ad SDKs' own paid events to the trackers.
|
|
851
|
+
wireAdRevenue() {
|
|
852
|
+
var _a, _b;
|
|
853
|
+
const want = this.opts.adRevenue;
|
|
854
|
+
if (!want || this.isWeb || !(want.admob || want.applovinMax))
|
|
855
|
+
return;
|
|
856
|
+
const sink = {
|
|
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
|
+
}
|
|
866
|
+
};
|
|
867
|
+
try {
|
|
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);
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
}
|
|
536
873
|
track(name, props) {
|
|
537
874
|
var _a, _b;
|
|
538
875
|
if (!this.started || this.erased)
|
|
@@ -564,9 +901,14 @@ var require_build = __commonJS({
|
|
|
564
901
|
*
|
|
565
902
|
* Impressions are batched and sent to /ingest/ad-revenue, where they are matched
|
|
566
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.
|
|
567
907
|
*/
|
|
568
908
|
trackAdRevenue(ad) {
|
|
569
|
-
this.
|
|
909
|
+
if (!this.adGate.manual("admob", "trackAdRevenue"))
|
|
910
|
+
return;
|
|
911
|
+
this.queueAdRevenue(ad, "admob", "manual");
|
|
570
912
|
}
|
|
571
913
|
/**
|
|
572
914
|
* Report one AppLovin MAX impression's revenue. Call it from MAX's callback:
|
|
@@ -578,20 +920,46 @@ var require_build = __commonJS({
|
|
|
578
920
|
* }); }
|
|
579
921
|
*
|
|
580
922
|
* Same batching, same endpoint and same ROAS numerator as AdMob, filed under
|
|
581
|
-
* the `applovin_max` source.
|
|
923
|
+
* the `applovin_max` source. Ignored (one warning) once
|
|
924
|
+
* `adRevenue: { applovinMax: true }` captures MAX.
|
|
582
925
|
*/
|
|
583
926
|
trackMaxAdRevenue(ad) {
|
|
927
|
+
if (!this.adGate.manual("applovinMax", "trackMaxAdRevenue"))
|
|
928
|
+
return;
|
|
584
929
|
const converted = fromMaxAd(ad);
|
|
585
930
|
if (converted)
|
|
586
|
-
this.queueAdRevenue(converted, "applovin_max");
|
|
931
|
+
this.queueAdRevenue(converted, "applovin_max", "manual");
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* The one line for an ad that reports through its own callback — a
|
|
935
|
+
* react-native-google-mobile-ads `<BannerAd>` (the full-screen formats are
|
|
936
|
+
* captured by `adRevenue: { admob: true }`):
|
|
937
|
+
*
|
|
938
|
+
* <BannerAd unitId={AD_UNIT_ID} size={…} onPaid={Traqio.admobPaid(AD_UNIT_ID)} />
|
|
939
|
+
* ad.addAdEventListener(AdEventType.PAID, Traqio.admobPaid(AD_UNIT_ID, "rewarded"))
|
|
940
|
+
*
|
|
941
|
+
* Reads the library's PAID payload (`value` in currency units, or v17's exact
|
|
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.
|
|
945
|
+
*/
|
|
946
|
+
admobPaid(adUnitId, adFormat = "banner") {
|
|
947
|
+
return (event) => {
|
|
948
|
+
try {
|
|
949
|
+
const ad = (0, adRevenue_1.fromGoogleMobileAdsPaid)(event, { adUnitId, adFormat });
|
|
950
|
+
if (ad && this.adGate.helper("admob", adFormat, event, "Traqio.admobPaid()"))
|
|
951
|
+
this.queueAdRevenue(ad, "admob", "auto");
|
|
952
|
+
} catch {
|
|
953
|
+
}
|
|
954
|
+
};
|
|
587
955
|
}
|
|
588
|
-
queueAdRevenue(ad, source) {
|
|
956
|
+
queueAdRevenue(ad, source, origin) {
|
|
589
957
|
var _a;
|
|
590
958
|
if (!this.started || this.erased)
|
|
591
959
|
return;
|
|
592
960
|
if (!(ad.valueMicros >= 0) || !ad.currency)
|
|
593
961
|
return;
|
|
594
|
-
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) });
|
|
595
963
|
this.skan.addRevenue(ad.valueMicros / 1e6);
|
|
596
964
|
if (this.adQueue.length > MAX_AD_QUEUE)
|
|
597
965
|
this.adQueue.splice(0, this.adQueue.length - MAX_AD_QUEUE);
|