@traqio/web 0.6.1 → 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 +93 -7
- package/build/index.cjs.map +2 -2
- package/build/index.js +93 -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.cjs
CHANGED
|
@@ -825,7 +825,7 @@ var require_build = __commonJS({
|
|
|
825
825
|
var adservices_1 = require_adservices();
|
|
826
826
|
var deeplink_1 = require_deeplink();
|
|
827
827
|
var adRevenue_1 = require_adRevenue();
|
|
828
|
-
exports.SDK_VERSION = "0.
|
|
828
|
+
exports.SDK_VERSION = "0.11.0";
|
|
829
829
|
var skan_2 = require_skan();
|
|
830
830
|
Object.defineProperty(exports, "Skan", { enumerable: true, get: function() {
|
|
831
831
|
return skan_2.Skan;
|
|
@@ -888,6 +888,9 @@ var require_build = __commonJS({
|
|
|
888
888
|
var AD_ID_SENT_KEY = "traq_ad_id_sent";
|
|
889
889
|
var AD_ID_SENT_DEBUG_KEY = "traq_ad_id_sent_debug";
|
|
890
890
|
var AD_ID_PATH = "/ingest/advertising-id";
|
|
891
|
+
var AD_ID_CONSENT_KEY = "traq_ad_id_consent";
|
|
892
|
+
var AD_ID_ANSWER_SENT_KEY = "traq_ad_id_answer_sent";
|
|
893
|
+
var AD_ID_ANSWER_SENT_DEBUG_KEY = "traq_ad_id_answer_sent_debug";
|
|
891
894
|
var REFERRER_KEY = "traq_referrer";
|
|
892
895
|
var QUEUE_KEY = "traq_queue";
|
|
893
896
|
var AD_QUEUE_KEY = "traq_ad_queue";
|
|
@@ -1041,6 +1044,7 @@ var require_build = __commonJS({
|
|
|
1041
1044
|
this.deferred = null;
|
|
1042
1045
|
this.consent = null;
|
|
1043
1046
|
this.att = null;
|
|
1047
|
+
this.adIdConsent = null;
|
|
1044
1048
|
this.adIdSync = null;
|
|
1045
1049
|
this.debug = false;
|
|
1046
1050
|
this.analyticsQueue = [];
|
|
@@ -1075,6 +1079,7 @@ var require_build = __commonJS({
|
|
|
1075
1079
|
}
|
|
1076
1080
|
this.debug = await detectDebug(opts);
|
|
1077
1081
|
await this.restoreConsent(opts.consent);
|
|
1082
|
+
await this.restoreAdvertisingIdConsent();
|
|
1078
1083
|
await this.restoreQueue();
|
|
1079
1084
|
await this.restoreAdQueue();
|
|
1080
1085
|
await this.restoreAnalytics();
|
|
@@ -1616,6 +1621,37 @@ var require_build = __commonJS({
|
|
|
1616
1621
|
await this.deferred;
|
|
1617
1622
|
}
|
|
1618
1623
|
}
|
|
1624
|
+
/**
|
|
1625
|
+
* The user's answer to YOUR advertising-id consent (GDPR / ePrivacy CMP, ATT prompt)
|
|
1626
|
+
* — HQ todo cmx4z20d. Call it once the user has answered, at any launch; persisted.
|
|
1627
|
+
*
|
|
1628
|
+
* `true` turns IDFA / GAID collection on from now: the SDK reads the id (never
|
|
1629
|
+
* prompting) and sends it once. With `waitForAdvertisingIdConsent` at init, the
|
|
1630
|
+
* install's Meta / TikTok postback was held for it and now leaves with it. On iOS,
|
|
1631
|
+
* call it AFTER your ATT prompt: the IDFA exists only once ATT is authorized (a yes
|
|
1632
|
+
* before that releases the install without it; the IDFA follows at the next
|
|
1633
|
+
* foreground for later conversions).
|
|
1634
|
+
*
|
|
1635
|
+
* `false` stops collection, tells the server to forget an id it kept from an
|
|
1636
|
+
* earlier yes, and lets a held install leave without one. First-party measurement
|
|
1637
|
+
* is unchanged either way.
|
|
1638
|
+
*
|
|
1639
|
+
* Traqio.setAdvertisingIdConsent(cmp.hasConsentFor("ads"));
|
|
1640
|
+
*
|
|
1641
|
+
* Overrides `collectAdvertisingId` once called. Android still needs Google's
|
|
1642
|
+
* `play-services-ads-identifier` and the `AD_ID` permission in the app.
|
|
1643
|
+
*/
|
|
1644
|
+
async setAdvertisingIdConsent(granted) {
|
|
1645
|
+
var _a, _b;
|
|
1646
|
+
this.adIdConsent = granted ? "granted" : "denied";
|
|
1647
|
+
if (!this.started || !this.opts)
|
|
1648
|
+
return;
|
|
1649
|
+
await ((_a = this.opts.storage) == null ? void 0 : _a.setItem(AD_ID_CONSENT_KEY, this.adIdConsent).catch(() => void 0));
|
|
1650
|
+
if (this.isWeb || this.erased)
|
|
1651
|
+
return;
|
|
1652
|
+
await ((_b = this.adIdSync) == null ? void 0 : _b.catch(() => void 0));
|
|
1653
|
+
await this.syncAdvertisingId();
|
|
1654
|
+
}
|
|
1619
1655
|
/** True once `forgetMe()` has been honoured — this install sends nothing any more. */
|
|
1620
1656
|
get forgotten() {
|
|
1621
1657
|
return this.erased;
|
|
@@ -1814,6 +1850,31 @@ var require_build = __commonJS({
|
|
|
1814
1850
|
get adIdSentKey() {
|
|
1815
1851
|
return this.debug ? AD_ID_SENT_DEBUG_KEY : AD_ID_SENT_KEY;
|
|
1816
1852
|
}
|
|
1853
|
+
get adIdAnswerSentKey() {
|
|
1854
|
+
return this.debug ? AD_ID_ANSWER_SENT_DEBUG_KEY : AD_ID_ANSWER_SENT_KEY;
|
|
1855
|
+
}
|
|
1856
|
+
/**
|
|
1857
|
+
* May the advertising id be read right now? The user's stored answer first; then,
|
|
1858
|
+
* for an app that said it would ask, no until it has; then the init opt-in.
|
|
1859
|
+
*/
|
|
1860
|
+
get collectsAdvertisingId() {
|
|
1861
|
+
if (this.adIdConsent)
|
|
1862
|
+
return this.adIdConsent === "granted";
|
|
1863
|
+
if (this.opts.waitForAdvertisingIdConsent)
|
|
1864
|
+
return false;
|
|
1865
|
+
return this.opts.collectAdvertisingId === true;
|
|
1866
|
+
}
|
|
1867
|
+
/** A `setAdvertisingIdConsent()` made before `init()` wins over the stored answer. */
|
|
1868
|
+
async restoreAdvertisingIdConsent() {
|
|
1869
|
+
var _a, _b;
|
|
1870
|
+
if (this.adIdConsent) {
|
|
1871
|
+
await ((_a = this.opts.storage) == null ? void 0 : _a.setItem(AD_ID_CONSENT_KEY, this.adIdConsent).catch(() => void 0));
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
const stored = await ((_b = this.opts.storage) == null ? void 0 : _b.getItem(AD_ID_CONSENT_KEY).catch(() => null));
|
|
1875
|
+
if (stored === "granted" || stored === "denied")
|
|
1876
|
+
this.adIdConsent = stored;
|
|
1877
|
+
}
|
|
1817
1878
|
/** Spread into every body: present only in debug mode, so a release build's payload is unchanged. */
|
|
1818
1879
|
debugField() {
|
|
1819
1880
|
return this.debug ? { debug: true } : {};
|
|
@@ -2157,7 +2218,7 @@ var require_build = __commonJS({
|
|
|
2157
2218
|
/** Only with the host's opt-in; a zeroed or malformed id is never sent. */
|
|
2158
2219
|
async readAdvertisingId() {
|
|
2159
2220
|
var _a;
|
|
2160
|
-
if (!this.
|
|
2221
|
+
if (!this.collectsAdvertisingId || !((_a = this.opts.native) == null ? void 0 : _a.getAdvertisingId))
|
|
2161
2222
|
return void 0;
|
|
2162
2223
|
try {
|
|
2163
2224
|
return normalizeAdvertisingId(await this.opts.native.getAdvertisingId());
|
|
@@ -2194,6 +2255,8 @@ var require_build = __commonJS({
|
|
|
2194
2255
|
...metaInstallReferrers ? { metaInstallReferrers } : {},
|
|
2195
2256
|
appUserId: this.opts.userId,
|
|
2196
2257
|
advertisingId,
|
|
2258
|
+
// The app has not asked yet: the server holds the install postback for the id.
|
|
2259
|
+
...this.opts.waitForAdvertisingIdConsent && !this.adIdConsent ? { advertisingIdPending: true } : {},
|
|
2197
2260
|
context: this.context
|
|
2198
2261
|
}
|
|
2199
2262
|
});
|
|
@@ -2223,17 +2286,40 @@ var require_build = __commonJS({
|
|
|
2223
2286
|
async postAdvertisingIdIfChanged() {
|
|
2224
2287
|
var _a;
|
|
2225
2288
|
const store = this.opts.storage;
|
|
2226
|
-
if (this.isWeb || this.erased || !store
|
|
2289
|
+
if (this.isWeb || this.erased || !store)
|
|
2227
2290
|
return;
|
|
2228
2291
|
try {
|
|
2229
2292
|
if (!await store.getItem(this.installSentKey))
|
|
2230
2293
|
return;
|
|
2294
|
+
const answer = this.adIdConsent;
|
|
2295
|
+
const deviceId = (_a = this.context.deviceId) != null ? _a : await this.getOrCreateDeviceId();
|
|
2296
|
+
const who = { deviceId, appUserId: this.opts.userId };
|
|
2297
|
+
if (answer === "denied") {
|
|
2298
|
+
if (await store.getItem(this.adIdAnswerSentKey) === "denied")
|
|
2299
|
+
return;
|
|
2300
|
+
if (await this.post({ ...who, advertisingIdConsent: "denied" }, AD_ID_PATH)) {
|
|
2301
|
+
await store.setItem(this.adIdAnswerSentKey, "denied");
|
|
2302
|
+
await store.setItem(this.adIdSentKey, "");
|
|
2303
|
+
}
|
|
2304
|
+
return;
|
|
2305
|
+
}
|
|
2306
|
+
if (!this.collectsAdvertisingId)
|
|
2307
|
+
return;
|
|
2308
|
+
const consent = answer ? { advertisingIdConsent: answer } : {};
|
|
2231
2309
|
const advertisingId = await this.readAdvertisingId();
|
|
2232
|
-
if (
|
|
2310
|
+
if (advertisingId) {
|
|
2311
|
+
if (await store.getItem(this.adIdSentKey) === advertisingId)
|
|
2312
|
+
return;
|
|
2313
|
+
if (await this.post({ ...who, advertisingId, ...consent }, AD_ID_PATH)) {
|
|
2314
|
+
await store.setItem(this.adIdSentKey, advertisingId);
|
|
2315
|
+
if (answer)
|
|
2316
|
+
await store.setItem(this.adIdAnswerSentKey, answer);
|
|
2317
|
+
}
|
|
2233
2318
|
return;
|
|
2234
|
-
|
|
2235
|
-
if (await
|
|
2236
|
-
await
|
|
2319
|
+
}
|
|
2320
|
+
if (answer === "granted" && await store.getItem(this.adIdAnswerSentKey) !== "granted") {
|
|
2321
|
+
if (await this.post({ ...who, advertisingIdConsent: "granted" }, AD_ID_PATH))
|
|
2322
|
+
await store.setItem(this.adIdAnswerSentKey, "granted");
|
|
2237
2323
|
}
|
|
2238
2324
|
} catch {
|
|
2239
2325
|
}
|