@traqio/web 0.2.0 → 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.cjs +276 -2
- package/build/index.cjs.map +3 -3
- package/build/index.js +276 -2
- package/build/index.js.map +3 -3
- 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,203 @@ 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 = 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
|
+
|
|
360
551
|
// ../sdk-core/build/index.js
|
|
361
552
|
var require_build = __commonJS({
|
|
362
553
|
"../sdk-core/build/index.js"(exports) {
|
|
363
554
|
"use strict";
|
|
364
555
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
365
|
-
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;
|
|
366
557
|
exports.normalizeAdvertisingId = normalizeAdvertisingId;
|
|
367
558
|
exports.fromMaxAd = fromMaxAd;
|
|
368
559
|
exports.detectDebug = detectDebug;
|
|
@@ -370,7 +561,8 @@ var require_build = __commonJS({
|
|
|
370
561
|
var skan_1 = require_skan();
|
|
371
562
|
var adservices_1 = require_adservices();
|
|
372
563
|
var deeplink_1 = require_deeplink();
|
|
373
|
-
|
|
564
|
+
var adRevenue_1 = require_adRevenue();
|
|
565
|
+
exports.SDK_VERSION = "0.4.0";
|
|
374
566
|
var skan_2 = require_skan();
|
|
375
567
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
376
568
|
return skan_2.Skan;
|
|
@@ -386,6 +578,40 @@ var require_build = __commonJS({
|
|
|
386
578
|
Object.defineProperty(exports, "isTrackingUrl", { enumerable: true, get: function() {
|
|
387
579
|
return deeplink_2.isTrackingUrl;
|
|
388
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
|
+
} });
|
|
389
615
|
var INSTALL_SENT_KEY = "traq_install_sent";
|
|
390
616
|
var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
|
|
391
617
|
var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
|
|
@@ -497,6 +723,14 @@ var require_build = __commonJS({
|
|
|
497
723
|
this.deferred = null;
|
|
498
724
|
this.consent = null;
|
|
499
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
|
+
};
|
|
500
734
|
}
|
|
501
735
|
/** Whether this run is in debug mode — see `InitOptions.debug`. Settled by `init()`. */
|
|
502
736
|
get isDebug() {
|
|
@@ -530,9 +764,28 @@ var require_build = __commonJS({
|
|
|
530
764
|
await this.initSkan();
|
|
531
765
|
await this.initAppleAds();
|
|
532
766
|
this.wireLifecycle();
|
|
767
|
+
this.wireAdRevenue();
|
|
533
768
|
if (this.queue.length || this.adQueue.length)
|
|
534
769
|
this.scheduleFlush(0);
|
|
535
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
|
+
}
|
|
536
789
|
track(name, props) {
|
|
537
790
|
var _a, _b;
|
|
538
791
|
if (!this.started || this.erased)
|
|
@@ -585,6 +838,27 @@ var require_build = __commonJS({
|
|
|
585
838
|
if (converted)
|
|
586
839
|
this.queueAdRevenue(converted, "applovin_max");
|
|
587
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
|
+
}
|
|
588
862
|
queueAdRevenue(ad, source) {
|
|
589
863
|
var _a;
|
|
590
864
|
if (!this.started || this.erased)
|