@traqio/web 0.3.1 → 0.3.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 +54 -5
- package/build/index.cjs.map +2 -2
- package/build/index.js +54 -5
- package/build/index.js.map +2 -2
- 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
|
@@ -641,7 +641,7 @@ var require_build = __commonJS({
|
|
|
641
641
|
var adservices_1 = require_adservices();
|
|
642
642
|
var deeplink_1 = require_deeplink();
|
|
643
643
|
var adRevenue_1 = require_adRevenue();
|
|
644
|
-
exports.SDK_VERSION = "0.
|
|
644
|
+
exports.SDK_VERSION = "0.6.0";
|
|
645
645
|
var skan_2 = require_skan();
|
|
646
646
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
647
647
|
return skan_2.Skan;
|
|
@@ -697,6 +697,9 @@ var require_build = __commonJS({
|
|
|
697
697
|
var INSTALL_SENT_KEY = "traq_install_sent";
|
|
698
698
|
var INSTALL_SENT_DEBUG_KEY = "traq_install_sent_debug";
|
|
699
699
|
var INSTALL_ATTEMPTS_KEY = "traq_install_attempts";
|
|
700
|
+
var AD_ID_SENT_KEY = "traq_ad_id_sent";
|
|
701
|
+
var AD_ID_SENT_DEBUG_KEY = "traq_ad_id_sent_debug";
|
|
702
|
+
var AD_ID_PATH = "/ingest/advertising-id";
|
|
700
703
|
var REFERRER_KEY = "traq_referrer";
|
|
701
704
|
var QUEUE_KEY = "traq_queue";
|
|
702
705
|
var AD_QUEUE_KEY = "traq_ad_queue";
|
|
@@ -816,6 +819,7 @@ var require_build = __commonJS({
|
|
|
816
819
|
this.deferred = null;
|
|
817
820
|
this.consent = null;
|
|
818
821
|
this.att = null;
|
|
822
|
+
this.adIdSync = null;
|
|
819
823
|
this.debug = false;
|
|
820
824
|
this.maxRevenuePaid = (adInfo) => {
|
|
821
825
|
try {
|
|
@@ -850,6 +854,7 @@ var require_build = __commonJS({
|
|
|
850
854
|
if (!this.isWeb) {
|
|
851
855
|
const freshInstall = Boolean(this.opts.storage) && !await this.opts.storage.getItem(this.installSentKey).catch(() => "1");
|
|
852
856
|
await this.sendInstallOnce();
|
|
857
|
+
void this.syncAdvertisingId();
|
|
853
858
|
if (this.opts.deepLinking !== false) {
|
|
854
859
|
this.deferred = this.resolveDeferredOnce(freshInstall).then((link) => link != null ? link : this.retryDeferredWithConsent());
|
|
855
860
|
this.wireDeepLinks();
|
|
@@ -1152,6 +1157,7 @@ var require_build = __commonJS({
|
|
|
1152
1157
|
if (!this.started || this.erased)
|
|
1153
1158
|
return;
|
|
1154
1159
|
void this.maybeStartSession();
|
|
1160
|
+
void this.syncAdvertisingId();
|
|
1155
1161
|
}
|
|
1156
1162
|
/** The conversion-value mapping in force on this device, once fetched. */
|
|
1157
1163
|
get skanMapping() {
|
|
@@ -1316,6 +1322,9 @@ var require_build = __commonJS({
|
|
|
1316
1322
|
get installSentKey() {
|
|
1317
1323
|
return this.debug ? INSTALL_SENT_DEBUG_KEY : INSTALL_SENT_KEY;
|
|
1318
1324
|
}
|
|
1325
|
+
get adIdSentKey() {
|
|
1326
|
+
return this.debug ? AD_ID_SENT_DEBUG_KEY : AD_ID_SENT_KEY;
|
|
1327
|
+
}
|
|
1319
1328
|
/** Spread into every body: present only in debug mode, so a release build's payload is unchanged. */
|
|
1320
1329
|
debugField() {
|
|
1321
1330
|
return this.debug ? { debug: true } : {};
|
|
@@ -1339,6 +1348,7 @@ var require_build = __commonJS({
|
|
|
1339
1348
|
return;
|
|
1340
1349
|
}
|
|
1341
1350
|
void this.maybeStartSession();
|
|
1351
|
+
void this.syncAdvertisingId();
|
|
1342
1352
|
});
|
|
1343
1353
|
} catch {
|
|
1344
1354
|
}
|
|
@@ -1548,17 +1558,56 @@ var require_build = __commonJS({
|
|
|
1548
1558
|
return;
|
|
1549
1559
|
}
|
|
1550
1560
|
}
|
|
1561
|
+
const advertisingId = await this.readAdvertisingId();
|
|
1551
1562
|
const ok = await this.post({
|
|
1552
1563
|
install: {
|
|
1553
1564
|
platform,
|
|
1554
1565
|
installReferrer: referrer.referrer,
|
|
1555
1566
|
appUserId: this.opts.userId,
|
|
1556
|
-
advertisingId
|
|
1567
|
+
advertisingId,
|
|
1557
1568
|
context: this.context
|
|
1558
1569
|
}
|
|
1559
1570
|
});
|
|
1560
|
-
if (ok)
|
|
1571
|
+
if (ok) {
|
|
1561
1572
|
await (store == null ? void 0 : store.setItem(this.installSentKey, "1"));
|
|
1573
|
+
if (advertisingId)
|
|
1574
|
+
await (store == null ? void 0 : store.setItem(this.adIdSentKey, advertisingId).catch(() => void 0));
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* The opted-in advertising id the install could not carry (todo cmwlauev). The
|
|
1579
|
+
* install leaves at first launch, before an app shows its own ATT prompt, so on iOS
|
|
1580
|
+
* it almost never has the IDFA. Re-read at every start and foreground — reading
|
|
1581
|
+
* never prompts (decision cmvjohk6) — and posted ONCE when it differs from the one
|
|
1582
|
+
* the server last acknowledged; a failure is retried at the next foreground.
|
|
1583
|
+
*
|
|
1584
|
+
* Only after the install is reported: the install itself carries an id it can read.
|
|
1585
|
+
*/
|
|
1586
|
+
syncAdvertisingId() {
|
|
1587
|
+
if (this.adIdSync)
|
|
1588
|
+
return this.adIdSync;
|
|
1589
|
+
this.adIdSync = this.postAdvertisingIdIfChanged().finally(() => {
|
|
1590
|
+
this.adIdSync = null;
|
|
1591
|
+
});
|
|
1592
|
+
return this.adIdSync;
|
|
1593
|
+
}
|
|
1594
|
+
async postAdvertisingIdIfChanged() {
|
|
1595
|
+
var _a;
|
|
1596
|
+
const store = this.opts.storage;
|
|
1597
|
+
if (this.isWeb || this.erased || !store || !this.opts.collectAdvertisingId)
|
|
1598
|
+
return;
|
|
1599
|
+
try {
|
|
1600
|
+
if (!await store.getItem(this.installSentKey))
|
|
1601
|
+
return;
|
|
1602
|
+
const advertisingId = await this.readAdvertisingId();
|
|
1603
|
+
if (!advertisingId || await store.getItem(this.adIdSentKey) === advertisingId)
|
|
1604
|
+
return;
|
|
1605
|
+
const deviceId = (_a = this.context.deviceId) != null ? _a : await this.getOrCreateDeviceId();
|
|
1606
|
+
if (await this.post({ deviceId, appUserId: this.opts.userId, advertisingId }, AD_ID_PATH)) {
|
|
1607
|
+
await store.setItem(this.adIdSentKey, advertisingId);
|
|
1608
|
+
}
|
|
1609
|
+
} catch {
|
|
1610
|
+
}
|
|
1562
1611
|
}
|
|
1563
1612
|
scheduleFlush(delay = FLUSH_DELAY_MS) {
|
|
1564
1613
|
if (this.flushTimer)
|
|
@@ -1688,8 +1737,8 @@ var require_build = __commonJS({
|
|
|
1688
1737
|
* key fixed in the console makes the same queued batch succeed.
|
|
1689
1738
|
*/
|
|
1690
1739
|
async send(body, path = "/ingest") {
|
|
1691
|
-
const consent = this.consent && (path === "/ingest" || path === "/ingest/session") ? { consent: this.consent } : {};
|
|
1692
|
-
const att = path === "/ingest" && this.asksTrackingAuthorization ? await this.readTrackingAuthorization() : null;
|
|
1740
|
+
const consent = this.consent && (path === "/ingest" || path === "/ingest/session" || path === AD_ID_PATH) ? { consent: this.consent } : {};
|
|
1741
|
+
const att = (path === "/ingest" || path === AD_ID_PATH) && this.asksTrackingAuthorization ? await this.readTrackingAuthorization() : null;
|
|
1693
1742
|
try {
|
|
1694
1743
|
const res = await fetch(`${this.opts.endpoint}${path}`, {
|
|
1695
1744
|
method: "POST",
|