@traqio/web 0.6.0 → 0.6.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 +140 -7
- package/build/index.cjs.map +2 -2
- package/build/index.js +140 -7
- 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
|
@@ -810,6 +810,7 @@ var require_build = __commonJS({
|
|
|
810
810
|
"use strict";
|
|
811
811
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
812
812
|
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.ANALYTICS_SESSION_IDLE_MS = exports.reportAdServicesToken = exports.Skan = exports.SDK_VERSION = void 0;
|
|
813
|
+
exports.normalizeMetaInstallReferrers = normalizeMetaInstallReferrers;
|
|
813
814
|
exports.normalizeAdvertisingId = normalizeAdvertisingId;
|
|
814
815
|
exports.fromMaxAd = fromMaxAd;
|
|
815
816
|
exports.detectDebug = detectDebug;
|
|
@@ -819,7 +820,7 @@ var require_build = __commonJS({
|
|
|
819
820
|
var adservices_1 = require_adservices();
|
|
820
821
|
var deeplink_1 = require_deeplink();
|
|
821
822
|
var adRevenue_1 = require_adRevenue();
|
|
822
|
-
exports.SDK_VERSION = "0.
|
|
823
|
+
exports.SDK_VERSION = "0.11.0";
|
|
823
824
|
var skan_2 = require_skan();
|
|
824
825
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
825
826
|
return skan_2.Skan;
|
|
@@ -882,6 +883,9 @@ var require_build = __commonJS({
|
|
|
882
883
|
var AD_ID_SENT_KEY = "traq_ad_id_sent";
|
|
883
884
|
var AD_ID_SENT_DEBUG_KEY = "traq_ad_id_sent_debug";
|
|
884
885
|
var AD_ID_PATH = "/ingest/advertising-id";
|
|
886
|
+
var AD_ID_CONSENT_KEY = "traq_ad_id_consent";
|
|
887
|
+
var AD_ID_ANSWER_SENT_KEY = "traq_ad_id_answer_sent";
|
|
888
|
+
var AD_ID_ANSWER_SENT_DEBUG_KEY = "traq_ad_id_answer_sent_debug";
|
|
885
889
|
var REFERRER_KEY = "traq_referrer";
|
|
886
890
|
var QUEUE_KEY = "traq_queue";
|
|
887
891
|
var AD_QUEUE_KEY = "traq_ad_queue";
|
|
@@ -910,6 +914,32 @@ var require_build = __commonJS({
|
|
|
910
914
|
var FLUSH_DELAY_MS = 3e3;
|
|
911
915
|
var MAX_INSTALL_ATTEMPTS = 3;
|
|
912
916
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
917
|
+
var META_PROVIDERS = ["facebook", "instagram", "facebook_lite"];
|
|
918
|
+
function normalizeMetaInstallReferrers(raw) {
|
|
919
|
+
if (!Array.isArray(raw))
|
|
920
|
+
return [];
|
|
921
|
+
const out = [];
|
|
922
|
+
for (const item of raw) {
|
|
923
|
+
if (!item || typeof item !== "object")
|
|
924
|
+
continue;
|
|
925
|
+
const r = item;
|
|
926
|
+
if (typeof r.provider !== "string" || !META_PROVIDERS.includes(r.provider))
|
|
927
|
+
continue;
|
|
928
|
+
if (typeof r.installReferrer !== "string" || !r.installReferrer.trim())
|
|
929
|
+
continue;
|
|
930
|
+
const isCt = r.isCt === 1 || r.isCt === true ? 1 : r.isCt === 0 || r.isCt === false ? 0 : null;
|
|
931
|
+
if (isCt === null)
|
|
932
|
+
continue;
|
|
933
|
+
const ts = typeof r.actualTimestamp === "number" && Number.isFinite(r.actualTimestamp) && r.actualTimestamp > 0 ? r.actualTimestamp : void 0;
|
|
934
|
+
out.push({
|
|
935
|
+
provider: r.provider,
|
|
936
|
+
installReferrer: r.installReferrer,
|
|
937
|
+
isCt,
|
|
938
|
+
...ts !== void 0 ? { actualTimestamp: ts } : {}
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
return out;
|
|
942
|
+
}
|
|
913
943
|
var TRACKING_AUTHORIZATIONS = ["not_determined", "restricted", "denied", "authorized"];
|
|
914
944
|
var MAX_PRECISION = {
|
|
915
945
|
exact: "precise",
|
|
@@ -1009,6 +1039,7 @@ var require_build = __commonJS({
|
|
|
1009
1039
|
this.deferred = null;
|
|
1010
1040
|
this.consent = null;
|
|
1011
1041
|
this.att = null;
|
|
1042
|
+
this.adIdConsent = null;
|
|
1012
1043
|
this.adIdSync = null;
|
|
1013
1044
|
this.debug = false;
|
|
1014
1045
|
this.analyticsQueue = [];
|
|
@@ -1043,6 +1074,7 @@ var require_build = __commonJS({
|
|
|
1043
1074
|
}
|
|
1044
1075
|
this.debug = await detectDebug(opts);
|
|
1045
1076
|
await this.restoreConsent(opts.consent);
|
|
1077
|
+
await this.restoreAdvertisingIdConsent();
|
|
1046
1078
|
await this.restoreQueue();
|
|
1047
1079
|
await this.restoreAdQueue();
|
|
1048
1080
|
await this.restoreAnalytics();
|
|
@@ -1584,6 +1616,37 @@ var require_build = __commonJS({
|
|
|
1584
1616
|
await this.deferred;
|
|
1585
1617
|
}
|
|
1586
1618
|
}
|
|
1619
|
+
/**
|
|
1620
|
+
* The user's answer to YOUR advertising-id consent (GDPR / ePrivacy CMP, ATT prompt)
|
|
1621
|
+
* — HQ todo cmx4z20d. Call it once the user has answered, at any launch; persisted.
|
|
1622
|
+
*
|
|
1623
|
+
* `true` turns IDFA / GAID collection on from now: the SDK reads the id (never
|
|
1624
|
+
* prompting) and sends it once. With `waitForAdvertisingIdConsent` at init, the
|
|
1625
|
+
* install's Meta / TikTok postback was held for it and now leaves with it. On iOS,
|
|
1626
|
+
* call it AFTER your ATT prompt: the IDFA exists only once ATT is authorized (a yes
|
|
1627
|
+
* before that releases the install without it; the IDFA follows at the next
|
|
1628
|
+
* foreground for later conversions).
|
|
1629
|
+
*
|
|
1630
|
+
* `false` stops collection, tells the server to forget an id it kept from an
|
|
1631
|
+
* earlier yes, and lets a held install leave without one. First-party measurement
|
|
1632
|
+
* is unchanged either way.
|
|
1633
|
+
*
|
|
1634
|
+
* Traqio.setAdvertisingIdConsent(cmp.hasConsentFor("ads"));
|
|
1635
|
+
*
|
|
1636
|
+
* Overrides `collectAdvertisingId` once called. Android still needs Google's
|
|
1637
|
+
* `play-services-ads-identifier` and the `AD_ID` permission in the app.
|
|
1638
|
+
*/
|
|
1639
|
+
async setAdvertisingIdConsent(granted) {
|
|
1640
|
+
var _a, _b;
|
|
1641
|
+
this.adIdConsent = granted ? "granted" : "denied";
|
|
1642
|
+
if (!this.started || !this.opts)
|
|
1643
|
+
return;
|
|
1644
|
+
await ((_a = this.opts.storage) == null ? void 0 : _a.setItem(AD_ID_CONSENT_KEY, this.adIdConsent).catch(() => void 0));
|
|
1645
|
+
if (this.isWeb || this.erased)
|
|
1646
|
+
return;
|
|
1647
|
+
await ((_b = this.adIdSync) == null ? void 0 : _b.catch(() => void 0));
|
|
1648
|
+
await this.syncAdvertisingId();
|
|
1649
|
+
}
|
|
1587
1650
|
/** True once `forgetMe()` has been honoured — this install sends nothing any more. */
|
|
1588
1651
|
get forgotten() {
|
|
1589
1652
|
return this.erased;
|
|
@@ -1782,6 +1845,31 @@ var require_build = __commonJS({
|
|
|
1782
1845
|
get adIdSentKey() {
|
|
1783
1846
|
return this.debug ? AD_ID_SENT_DEBUG_KEY : AD_ID_SENT_KEY;
|
|
1784
1847
|
}
|
|
1848
|
+
get adIdAnswerSentKey() {
|
|
1849
|
+
return this.debug ? AD_ID_ANSWER_SENT_DEBUG_KEY : AD_ID_ANSWER_SENT_KEY;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* May the advertising id be read right now? The user's stored answer first; then,
|
|
1853
|
+
* for an app that said it would ask, no until it has; then the init opt-in.
|
|
1854
|
+
*/
|
|
1855
|
+
get collectsAdvertisingId() {
|
|
1856
|
+
if (this.adIdConsent)
|
|
1857
|
+
return this.adIdConsent === "granted";
|
|
1858
|
+
if (this.opts.waitForAdvertisingIdConsent)
|
|
1859
|
+
return false;
|
|
1860
|
+
return this.opts.collectAdvertisingId === true;
|
|
1861
|
+
}
|
|
1862
|
+
/** A `setAdvertisingIdConsent()` made before `init()` wins over the stored answer. */
|
|
1863
|
+
async restoreAdvertisingIdConsent() {
|
|
1864
|
+
var _a, _b;
|
|
1865
|
+
if (this.adIdConsent) {
|
|
1866
|
+
await ((_a = this.opts.storage) == null ? void 0 : _a.setItem(AD_ID_CONSENT_KEY, this.adIdConsent).catch(() => void 0));
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
const stored = await ((_b = this.opts.storage) == null ? void 0 : _b.getItem(AD_ID_CONSENT_KEY).catch(() => null));
|
|
1870
|
+
if (stored === "granted" || stored === "denied")
|
|
1871
|
+
this.adIdConsent = stored;
|
|
1872
|
+
}
|
|
1785
1873
|
/** Spread into every body: present only in debug mode, so a release build's payload is unchanged. */
|
|
1786
1874
|
debugField() {
|
|
1787
1875
|
return this.debug ? { debug: true } : {};
|
|
@@ -2104,10 +2192,28 @@ var require_build = __commonJS({
|
|
|
2104
2192
|
}
|
|
2105
2193
|
return result;
|
|
2106
2194
|
}
|
|
2195
|
+
/**
|
|
2196
|
+
* Meta's Install Referrer answers, Android only, read just before the install
|
|
2197
|
+
* leaves. Never throws: an old native build, a bridge teardown or no Meta app
|
|
2198
|
+
* installed all mean « no field ».
|
|
2199
|
+
*/
|
|
2200
|
+
async readMetaInstallReferrers(platform) {
|
|
2201
|
+
var _a, _b;
|
|
2202
|
+
const read = (_a = this.opts.native) == null ? void 0 : _a.getMetaInstallReferrers;
|
|
2203
|
+
if (platform !== "android" || !read)
|
|
2204
|
+
return void 0;
|
|
2205
|
+
try {
|
|
2206
|
+
const appId = ((_b = this.opts.metaAppId) == null ? void 0 : _b.trim()) || void 0;
|
|
2207
|
+
const list = normalizeMetaInstallReferrers(await read.call(this.opts.native, appId));
|
|
2208
|
+
return list.length ? list : void 0;
|
|
2209
|
+
} catch {
|
|
2210
|
+
return void 0;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2107
2213
|
/** Only with the host's opt-in; a zeroed or malformed id is never sent. */
|
|
2108
2214
|
async readAdvertisingId() {
|
|
2109
2215
|
var _a;
|
|
2110
|
-
if (!this.
|
|
2216
|
+
if (!this.collectsAdvertisingId || !((_a = this.opts.native) == null ? void 0 : _a.getAdvertisingId))
|
|
2111
2217
|
return void 0;
|
|
2112
2218
|
try {
|
|
2113
2219
|
return normalizeAdvertisingId(await this.opts.native.getAdvertisingId());
|
|
@@ -2136,12 +2242,16 @@ var require_build = __commonJS({
|
|
|
2136
2242
|
}
|
|
2137
2243
|
}
|
|
2138
2244
|
const advertisingId = await this.readAdvertisingId();
|
|
2245
|
+
const metaInstallReferrers = await this.readMetaInstallReferrers(platform);
|
|
2139
2246
|
const ok = await this.post({
|
|
2140
2247
|
install: {
|
|
2141
2248
|
platform,
|
|
2142
2249
|
installReferrer: referrer.referrer,
|
|
2250
|
+
...metaInstallReferrers ? { metaInstallReferrers } : {},
|
|
2143
2251
|
appUserId: this.opts.userId,
|
|
2144
2252
|
advertisingId,
|
|
2253
|
+
// The app has not asked yet: the server holds the install postback for the id.
|
|
2254
|
+
...this.opts.waitForAdvertisingIdConsent && !this.adIdConsent ? { advertisingIdPending: true } : {},
|
|
2145
2255
|
context: this.context
|
|
2146
2256
|
}
|
|
2147
2257
|
});
|
|
@@ -2171,17 +2281,40 @@ var require_build = __commonJS({
|
|
|
2171
2281
|
async postAdvertisingIdIfChanged() {
|
|
2172
2282
|
var _a;
|
|
2173
2283
|
const store = this.opts.storage;
|
|
2174
|
-
if (this.isWeb || this.erased || !store
|
|
2284
|
+
if (this.isWeb || this.erased || !store)
|
|
2175
2285
|
return;
|
|
2176
2286
|
try {
|
|
2177
2287
|
if (!await store.getItem(this.installSentKey))
|
|
2178
2288
|
return;
|
|
2289
|
+
const answer = this.adIdConsent;
|
|
2290
|
+
const deviceId = (_a = this.context.deviceId) != null ? _a : await this.getOrCreateDeviceId();
|
|
2291
|
+
const who = { deviceId, appUserId: this.opts.userId };
|
|
2292
|
+
if (answer === "denied") {
|
|
2293
|
+
if (await store.getItem(this.adIdAnswerSentKey) === "denied")
|
|
2294
|
+
return;
|
|
2295
|
+
if (await this.post({ ...who, advertisingIdConsent: "denied" }, AD_ID_PATH)) {
|
|
2296
|
+
await store.setItem(this.adIdAnswerSentKey, "denied");
|
|
2297
|
+
await store.setItem(this.adIdSentKey, "");
|
|
2298
|
+
}
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
if (!this.collectsAdvertisingId)
|
|
2302
|
+
return;
|
|
2303
|
+
const consent = answer ? { advertisingIdConsent: answer } : {};
|
|
2179
2304
|
const advertisingId = await this.readAdvertisingId();
|
|
2180
|
-
if (
|
|
2305
|
+
if (advertisingId) {
|
|
2306
|
+
if (await store.getItem(this.adIdSentKey) === advertisingId)
|
|
2307
|
+
return;
|
|
2308
|
+
if (await this.post({ ...who, advertisingId, ...consent }, AD_ID_PATH)) {
|
|
2309
|
+
await store.setItem(this.adIdSentKey, advertisingId);
|
|
2310
|
+
if (answer)
|
|
2311
|
+
await store.setItem(this.adIdAnswerSentKey, answer);
|
|
2312
|
+
}
|
|
2181
2313
|
return;
|
|
2182
|
-
|
|
2183
|
-
if (await
|
|
2184
|
-
await
|
|
2314
|
+
}
|
|
2315
|
+
if (answer === "granted" && await store.getItem(this.adIdAnswerSentKey) !== "granted") {
|
|
2316
|
+
if (await this.post({ ...who, advertisingIdConsent: "granted" }, AD_ID_PATH))
|
|
2317
|
+
await store.setItem(this.adIdAnswerSentKey, "granted");
|
|
2185
2318
|
}
|
|
2186
2319
|
} catch {
|
|
2187
2320
|
}
|