@traqio/web 0.3.0 → 0.3.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 +58 -11
- package/build/index.cjs.map +2 -2
- package/build/index.js +58 -11
- 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.5.
|
|
644
|
+
exports.SDK_VERSION = "0.5.1";
|
|
645
645
|
var skan_2 = require_skan();
|
|
646
646
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
647
647
|
return skan_2.Skan;
|
|
@@ -717,6 +717,7 @@ var require_build = __commonJS({
|
|
|
717
717
|
var FLUSH_DELAY_MS = 3e3;
|
|
718
718
|
var MAX_INSTALL_ATTEMPTS = 3;
|
|
719
719
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
720
|
+
var TRACKING_AUTHORIZATIONS = ["not_determined", "restricted", "denied", "authorized"];
|
|
720
721
|
var MAX_PRECISION = {
|
|
721
722
|
exact: "precise",
|
|
722
723
|
publisher_defined: "publisher_provided",
|
|
@@ -787,6 +788,15 @@ var require_build = __commonJS({
|
|
|
787
788
|
}
|
|
788
789
|
return void 0;
|
|
789
790
|
}
|
|
791
|
+
function reactNativeOs() {
|
|
792
|
+
var _a, _b;
|
|
793
|
+
try {
|
|
794
|
+
const os = (_b = (_a = (init_empty(), __toCommonJS(empty_exports))) == null ? void 0 : _a.Platform) == null ? void 0 : _b.OS;
|
|
795
|
+
return os === "ios" || os === "android" ? os : void 0;
|
|
796
|
+
} catch {
|
|
797
|
+
return void 0;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
790
800
|
var Client2 = class {
|
|
791
801
|
constructor() {
|
|
792
802
|
this.queue = [];
|
|
@@ -805,6 +815,7 @@ var require_build = __commonJS({
|
|
|
805
815
|
this.undelivered = [];
|
|
806
816
|
this.deferred = null;
|
|
807
817
|
this.consent = null;
|
|
818
|
+
this.att = null;
|
|
808
819
|
this.debug = false;
|
|
809
820
|
this.maxRevenuePaid = (adInfo) => {
|
|
810
821
|
try {
|
|
@@ -891,9 +902,18 @@ var require_build = __commonJS({
|
|
|
891
902
|
if (props == null ? void 0 : props.value)
|
|
892
903
|
this.skan.addRevenue(props.value);
|
|
893
904
|
}
|
|
905
|
+
/**
|
|
906
|
+
* The store this app runs on: the native bridge's word, else React Native's
|
|
907
|
+
* `Platform.OS`, else UNKNOWN. Never a guess — until 2026-11 a missing bridge meant
|
|
908
|
+
* "android", and every bridgeless iPhone was filed as an Android install whose
|
|
909
|
+
* purchases then went to Meta with the Android package (todo cmwl6okn).
|
|
910
|
+
*/
|
|
911
|
+
get hostPlatform() {
|
|
912
|
+
var _a, _b;
|
|
913
|
+
return (_b = (_a = this.opts.native) == null ? void 0 : _a.platform) != null ? _b : reactNativeOs();
|
|
914
|
+
}
|
|
894
915
|
defaultStore() {
|
|
895
|
-
|
|
896
|
-
const platform = (_a = this.opts.native) == null ? void 0 : _a.platform;
|
|
916
|
+
const platform = this.hostPlatform;
|
|
897
917
|
return platform === "ios" ? "app_store" : platform === "android" ? "play_store" : void 0;
|
|
898
918
|
}
|
|
899
919
|
/**
|
|
@@ -1183,7 +1203,6 @@ var require_build = __commonJS({
|
|
|
1183
1203
|
* (still counted as fresh, since the flag is only written on an answer).
|
|
1184
1204
|
*/
|
|
1185
1205
|
async resolveDeferredOnce(freshInstall) {
|
|
1186
|
-
var _a, _b;
|
|
1187
1206
|
const store = this.opts.storage;
|
|
1188
1207
|
try {
|
|
1189
1208
|
const cached = await (store == null ? void 0 : store.getItem(DEFERRED_KEY));
|
|
@@ -1193,7 +1212,7 @@ var require_build = __commonJS({
|
|
|
1193
1212
|
}
|
|
1194
1213
|
if (!freshInstall && !await (store == null ? void 0 : store.getItem(`${DEFERRED_KEY}_pending`).catch(() => null)))
|
|
1195
1214
|
return null;
|
|
1196
|
-
const platform =
|
|
1215
|
+
const platform = this.hostPlatform;
|
|
1197
1216
|
const referrer = platform === "android" ? await this.readReferrer() : null;
|
|
1198
1217
|
await (store == null ? void 0 : store.setItem(`${DEFERRED_KEY}_pending`, "1").catch(() => void 0));
|
|
1199
1218
|
const answer = await this.askDeferred(platform, referrer == null ? void 0 : referrer.referrer);
|
|
@@ -1230,7 +1249,7 @@ var require_build = __commonJS({
|
|
|
1230
1249
|
* Never when a link is already known, never twice.
|
|
1231
1250
|
*/
|
|
1232
1251
|
async retryDeferredWithConsent() {
|
|
1233
|
-
var _a, _b
|
|
1252
|
+
var _a, _b;
|
|
1234
1253
|
const store = (_a = this.opts) == null ? void 0 : _a.storage;
|
|
1235
1254
|
if (!store || this.consent !== "granted" || this.opts.deepLinking === false || this.isWeb)
|
|
1236
1255
|
return null;
|
|
@@ -1243,10 +1262,10 @@ var require_build = __commonJS({
|
|
|
1243
1262
|
const known = await this.storedDeferred();
|
|
1244
1263
|
if (known)
|
|
1245
1264
|
return known;
|
|
1246
|
-
const link = (0, deeplink_1.toDeepLink)(await this.askDeferred(
|
|
1265
|
+
const link = (0, deeplink_1.toDeepLink)(await this.askDeferred(this.hostPlatform, void 0), true);
|
|
1247
1266
|
if (!link)
|
|
1248
1267
|
return null;
|
|
1249
|
-
await ((
|
|
1268
|
+
await ((_b = this.opts.storage) == null ? void 0 : _b.setItem(DEFERRED_KEY, JSON.stringify(link)).catch(() => void 0));
|
|
1250
1269
|
this.emitDeepLink(link);
|
|
1251
1270
|
return link;
|
|
1252
1271
|
}
|
|
@@ -1510,11 +1529,17 @@ var require_build = __commonJS({
|
|
|
1510
1529
|
}
|
|
1511
1530
|
}
|
|
1512
1531
|
async sendInstallOnce() {
|
|
1513
|
-
var _a, _b;
|
|
1514
1532
|
const store = this.opts.storage;
|
|
1515
1533
|
if (store && await store.getItem(this.installSentKey))
|
|
1516
1534
|
return;
|
|
1517
|
-
const platform =
|
|
1535
|
+
const platform = this.hostPlatform;
|
|
1536
|
+
if (!platform) {
|
|
1537
|
+
console.warn("[traqio] unknown platform \u2014 no native bridge and not React Native: the install is not reported. Pass `native: getNativeBridge()` (React Native / Expo) or your SDK's bridge to init().");
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
if (!this.opts.native) {
|
|
1541
|
+
console.warn(`[traqio] the Traqio native module is missing on ${platform} (Expo Go, or not linked in this build): install reported without its attribution signals. Use a development / EAS build.`);
|
|
1542
|
+
}
|
|
1518
1543
|
const referrer = await this.readReferrer();
|
|
1519
1544
|
if (referrer.retryable && store) {
|
|
1520
1545
|
const attempts = Number(await store.getItem(INSTALL_ATTEMPTS_KEY)) || 0;
|
|
@@ -1638,6 +1663,21 @@ var require_build = __commonJS({
|
|
|
1638
1663
|
keepalive() {
|
|
1639
1664
|
return this.isWeb ? { keepalive: true } : {};
|
|
1640
1665
|
}
|
|
1666
|
+
get asksTrackingAuthorization() {
|
|
1667
|
+
var _a;
|
|
1668
|
+
return ((_a = this.opts.native) == null ? void 0 : _a.platform) === "ios" && typeof this.opts.native.getTrackingAuthorization === "function";
|
|
1669
|
+
}
|
|
1670
|
+
/** iOS only; the last good answer when the bridge cannot give one now. */
|
|
1671
|
+
async readTrackingAuthorization() {
|
|
1672
|
+
var _a, _b;
|
|
1673
|
+
try {
|
|
1674
|
+
const status = await ((_b = (_a = this.opts.native) == null ? void 0 : _a.getTrackingAuthorization) == null ? void 0 : _b.call(_a));
|
|
1675
|
+
if (TRACKING_AUTHORIZATIONS.includes(status))
|
|
1676
|
+
this.att = status != null ? status : null;
|
|
1677
|
+
} catch {
|
|
1678
|
+
}
|
|
1679
|
+
return this.att;
|
|
1680
|
+
}
|
|
1641
1681
|
async post(body, path = "/ingest") {
|
|
1642
1682
|
return await this.send(body, path) === "ok";
|
|
1643
1683
|
}
|
|
@@ -1649,11 +1689,18 @@ var require_build = __commonJS({
|
|
|
1649
1689
|
*/
|
|
1650
1690
|
async send(body, path = "/ingest") {
|
|
1651
1691
|
const consent = this.consent && (path === "/ingest" || path === "/ingest/session") ? { consent: this.consent } : {};
|
|
1692
|
+
const att = path === "/ingest" && this.asksTrackingAuthorization ? await this.readTrackingAuthorization() : null;
|
|
1652
1693
|
try {
|
|
1653
1694
|
const res = await fetch(`${this.opts.endpoint}${path}`, {
|
|
1654
1695
|
method: "POST",
|
|
1655
1696
|
headers: { "Content-Type": "application/json" },
|
|
1656
|
-
body: JSON.stringify({
|
|
1697
|
+
body: JSON.stringify({
|
|
1698
|
+
sdkKey: this.opts.sdkKey,
|
|
1699
|
+
...body,
|
|
1700
|
+
...consent,
|
|
1701
|
+
...att ? { att } : {},
|
|
1702
|
+
...this.debugField()
|
|
1703
|
+
}),
|
|
1657
1704
|
...this.keepalive()
|
|
1658
1705
|
});
|
|
1659
1706
|
if (res.ok)
|