@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.js
CHANGED
|
@@ -636,7 +636,7 @@ var require_build = __commonJS({
|
|
|
636
636
|
var adservices_1 = require_adservices();
|
|
637
637
|
var deeplink_1 = require_deeplink();
|
|
638
638
|
var adRevenue_1 = require_adRevenue();
|
|
639
|
-
exports.SDK_VERSION = "0.5.
|
|
639
|
+
exports.SDK_VERSION = "0.5.1";
|
|
640
640
|
var skan_2 = require_skan();
|
|
641
641
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
642
642
|
return skan_2.Skan;
|
|
@@ -712,6 +712,7 @@ var require_build = __commonJS({
|
|
|
712
712
|
var FLUSH_DELAY_MS = 3e3;
|
|
713
713
|
var MAX_INSTALL_ATTEMPTS = 3;
|
|
714
714
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
715
|
+
var TRACKING_AUTHORIZATIONS = ["not_determined", "restricted", "denied", "authorized"];
|
|
715
716
|
var MAX_PRECISION = {
|
|
716
717
|
exact: "precise",
|
|
717
718
|
publisher_defined: "publisher_provided",
|
|
@@ -782,6 +783,15 @@ var require_build = __commonJS({
|
|
|
782
783
|
}
|
|
783
784
|
return void 0;
|
|
784
785
|
}
|
|
786
|
+
function reactNativeOs() {
|
|
787
|
+
var _a, _b;
|
|
788
|
+
try {
|
|
789
|
+
const os = (_b = (_a = (init_empty(), __toCommonJS(empty_exports))) == null ? void 0 : _a.Platform) == null ? void 0 : _b.OS;
|
|
790
|
+
return os === "ios" || os === "android" ? os : void 0;
|
|
791
|
+
} catch {
|
|
792
|
+
return void 0;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
785
795
|
var Client2 = class {
|
|
786
796
|
constructor() {
|
|
787
797
|
this.queue = [];
|
|
@@ -800,6 +810,7 @@ var require_build = __commonJS({
|
|
|
800
810
|
this.undelivered = [];
|
|
801
811
|
this.deferred = null;
|
|
802
812
|
this.consent = null;
|
|
813
|
+
this.att = null;
|
|
803
814
|
this.debug = false;
|
|
804
815
|
this.maxRevenuePaid = (adInfo) => {
|
|
805
816
|
try {
|
|
@@ -886,9 +897,18 @@ var require_build = __commonJS({
|
|
|
886
897
|
if (props == null ? void 0 : props.value)
|
|
887
898
|
this.skan.addRevenue(props.value);
|
|
888
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* The store this app runs on: the native bridge's word, else React Native's
|
|
902
|
+
* `Platform.OS`, else UNKNOWN. Never a guess — until 2026-11 a missing bridge meant
|
|
903
|
+
* "android", and every bridgeless iPhone was filed as an Android install whose
|
|
904
|
+
* purchases then went to Meta with the Android package (todo cmwl6okn).
|
|
905
|
+
*/
|
|
906
|
+
get hostPlatform() {
|
|
907
|
+
var _a, _b;
|
|
908
|
+
return (_b = (_a = this.opts.native) == null ? void 0 : _a.platform) != null ? _b : reactNativeOs();
|
|
909
|
+
}
|
|
889
910
|
defaultStore() {
|
|
890
|
-
|
|
891
|
-
const platform = (_a = this.opts.native) == null ? void 0 : _a.platform;
|
|
911
|
+
const platform = this.hostPlatform;
|
|
892
912
|
return platform === "ios" ? "app_store" : platform === "android" ? "play_store" : void 0;
|
|
893
913
|
}
|
|
894
914
|
/**
|
|
@@ -1178,7 +1198,6 @@ var require_build = __commonJS({
|
|
|
1178
1198
|
* (still counted as fresh, since the flag is only written on an answer).
|
|
1179
1199
|
*/
|
|
1180
1200
|
async resolveDeferredOnce(freshInstall) {
|
|
1181
|
-
var _a, _b;
|
|
1182
1201
|
const store = this.opts.storage;
|
|
1183
1202
|
try {
|
|
1184
1203
|
const cached = await (store == null ? void 0 : store.getItem(DEFERRED_KEY));
|
|
@@ -1188,7 +1207,7 @@ var require_build = __commonJS({
|
|
|
1188
1207
|
}
|
|
1189
1208
|
if (!freshInstall && !await (store == null ? void 0 : store.getItem(`${DEFERRED_KEY}_pending`).catch(() => null)))
|
|
1190
1209
|
return null;
|
|
1191
|
-
const platform =
|
|
1210
|
+
const platform = this.hostPlatform;
|
|
1192
1211
|
const referrer = platform === "android" ? await this.readReferrer() : null;
|
|
1193
1212
|
await (store == null ? void 0 : store.setItem(`${DEFERRED_KEY}_pending`, "1").catch(() => void 0));
|
|
1194
1213
|
const answer = await this.askDeferred(platform, referrer == null ? void 0 : referrer.referrer);
|
|
@@ -1225,7 +1244,7 @@ var require_build = __commonJS({
|
|
|
1225
1244
|
* Never when a link is already known, never twice.
|
|
1226
1245
|
*/
|
|
1227
1246
|
async retryDeferredWithConsent() {
|
|
1228
|
-
var _a, _b
|
|
1247
|
+
var _a, _b;
|
|
1229
1248
|
const store = (_a = this.opts) == null ? void 0 : _a.storage;
|
|
1230
1249
|
if (!store || this.consent !== "granted" || this.opts.deepLinking === false || this.isWeb)
|
|
1231
1250
|
return null;
|
|
@@ -1238,10 +1257,10 @@ var require_build = __commonJS({
|
|
|
1238
1257
|
const known = await this.storedDeferred();
|
|
1239
1258
|
if (known)
|
|
1240
1259
|
return known;
|
|
1241
|
-
const link = (0, deeplink_1.toDeepLink)(await this.askDeferred(
|
|
1260
|
+
const link = (0, deeplink_1.toDeepLink)(await this.askDeferred(this.hostPlatform, void 0), true);
|
|
1242
1261
|
if (!link)
|
|
1243
1262
|
return null;
|
|
1244
|
-
await ((
|
|
1263
|
+
await ((_b = this.opts.storage) == null ? void 0 : _b.setItem(DEFERRED_KEY, JSON.stringify(link)).catch(() => void 0));
|
|
1245
1264
|
this.emitDeepLink(link);
|
|
1246
1265
|
return link;
|
|
1247
1266
|
}
|
|
@@ -1505,11 +1524,17 @@ var require_build = __commonJS({
|
|
|
1505
1524
|
}
|
|
1506
1525
|
}
|
|
1507
1526
|
async sendInstallOnce() {
|
|
1508
|
-
var _a, _b;
|
|
1509
1527
|
const store = this.opts.storage;
|
|
1510
1528
|
if (store && await store.getItem(this.installSentKey))
|
|
1511
1529
|
return;
|
|
1512
|
-
const platform =
|
|
1530
|
+
const platform = this.hostPlatform;
|
|
1531
|
+
if (!platform) {
|
|
1532
|
+
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().");
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
if (!this.opts.native) {
|
|
1536
|
+
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.`);
|
|
1537
|
+
}
|
|
1513
1538
|
const referrer = await this.readReferrer();
|
|
1514
1539
|
if (referrer.retryable && store) {
|
|
1515
1540
|
const attempts = Number(await store.getItem(INSTALL_ATTEMPTS_KEY)) || 0;
|
|
@@ -1633,6 +1658,21 @@ var require_build = __commonJS({
|
|
|
1633
1658
|
keepalive() {
|
|
1634
1659
|
return this.isWeb ? { keepalive: true } : {};
|
|
1635
1660
|
}
|
|
1661
|
+
get asksTrackingAuthorization() {
|
|
1662
|
+
var _a;
|
|
1663
|
+
return ((_a = this.opts.native) == null ? void 0 : _a.platform) === "ios" && typeof this.opts.native.getTrackingAuthorization === "function";
|
|
1664
|
+
}
|
|
1665
|
+
/** iOS only; the last good answer when the bridge cannot give one now. */
|
|
1666
|
+
async readTrackingAuthorization() {
|
|
1667
|
+
var _a, _b;
|
|
1668
|
+
try {
|
|
1669
|
+
const status = await ((_b = (_a = this.opts.native) == null ? void 0 : _a.getTrackingAuthorization) == null ? void 0 : _b.call(_a));
|
|
1670
|
+
if (TRACKING_AUTHORIZATIONS.includes(status))
|
|
1671
|
+
this.att = status != null ? status : null;
|
|
1672
|
+
} catch {
|
|
1673
|
+
}
|
|
1674
|
+
return this.att;
|
|
1675
|
+
}
|
|
1636
1676
|
async post(body, path = "/ingest") {
|
|
1637
1677
|
return await this.send(body, path) === "ok";
|
|
1638
1678
|
}
|
|
@@ -1644,11 +1684,18 @@ var require_build = __commonJS({
|
|
|
1644
1684
|
*/
|
|
1645
1685
|
async send(body, path = "/ingest") {
|
|
1646
1686
|
const consent = this.consent && (path === "/ingest" || path === "/ingest/session") ? { consent: this.consent } : {};
|
|
1687
|
+
const att = path === "/ingest" && this.asksTrackingAuthorization ? await this.readTrackingAuthorization() : null;
|
|
1647
1688
|
try {
|
|
1648
1689
|
const res = await fetch(`${this.opts.endpoint}${path}`, {
|
|
1649
1690
|
method: "POST",
|
|
1650
1691
|
headers: { "Content-Type": "application/json" },
|
|
1651
|
-
body: JSON.stringify({
|
|
1692
|
+
body: JSON.stringify({
|
|
1693
|
+
sdkKey: this.opts.sdkKey,
|
|
1694
|
+
...body,
|
|
1695
|
+
...consent,
|
|
1696
|
+
...att ? { att } : {},
|
|
1697
|
+
...this.debugField()
|
|
1698
|
+
}),
|
|
1652
1699
|
...this.keepalive()
|
|
1653
1700
|
});
|
|
1654
1701
|
if (res.ok)
|