@action-x/ad-sdk 0.1.0 → 0.1.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/README.md +158 -586
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +30 -13
- package/dist/index.js +163 -149
- package/dist/index.umd.js +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class P {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.events = {};
|
|
4
4
|
}
|
|
@@ -42,7 +42,7 @@ class I {
|
|
|
42
42
|
return ((t = this.events[e]) == null ? void 0 : t.length) || 0;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
class
|
|
45
|
+
class y {
|
|
46
46
|
/**
|
|
47
47
|
* Render Action Card ad as HTML string
|
|
48
48
|
*
|
|
@@ -51,15 +51,15 @@ class f {
|
|
|
51
51
|
* @returns HTML string
|
|
52
52
|
*/
|
|
53
53
|
static renderActionCard(e, t = {}) {
|
|
54
|
-
var
|
|
55
|
-
const { variant: i = "horizontal", includeWrapper: n = !0 } = t, s = e.adapted, r = e.tracking, a = n ? `<div class="ax-ad-card ax-ad-card-${i}" data-ad-id="${e.original.id}">` : "", c = (
|
|
54
|
+
var h;
|
|
55
|
+
const { variant: i = "horizontal", includeWrapper: n = !0 } = t, s = e.adapted, r = e.tracking, a = n ? `<div class="ax-ad-card ax-ad-card-${i}" data-ad-id="${e.original.id}">` : "", c = (h = s.image) != null && h.url ? `<img
|
|
56
56
|
src="${s.image.url}"
|
|
57
57
|
alt="${s.title}"
|
|
58
58
|
class="ax-ad-image"
|
|
59
59
|
loading="lazy"
|
|
60
60
|
/>` : "", l = s.price ? `<span class="ax-ad-price">${s.price.display || s.price.value}</span>` : "", d = s.rating ? `<div class="ax-ad-rating" aria-label="Rating: ${s.rating}">
|
|
61
61
|
${"★".repeat(Math.floor(s.rating))}${"☆".repeat(5 - Math.floor(s.rating))}
|
|
62
|
-
</div>` : "", u = s.brand ? `<span class="ax-ad-brand">${s.brand}</span>` : "",
|
|
62
|
+
</div>` : "", u = s.brand ? `<span class="ax-ad-brand">${s.brand}</span>` : "", p = `
|
|
63
63
|
${c}
|
|
64
64
|
<div class="ax-ad-content">
|
|
65
65
|
${u}
|
|
@@ -80,8 +80,8 @@ class f {
|
|
|
80
80
|
</a>
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
83
|
-
`,
|
|
84
|
-
return a +
|
|
83
|
+
`, m = n ? "</div>" : "";
|
|
84
|
+
return a + p + m;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* Render Suffix ad as HTML string
|
|
@@ -173,22 +173,22 @@ class f {
|
|
|
173
173
|
* @param renderFn - Render function to use
|
|
174
174
|
* @returns HTML string with all ads
|
|
175
175
|
*/
|
|
176
|
-
static renderAds(e, t =
|
|
176
|
+
static renderAds(e, t = y.renderActionCard.bind(y)) {
|
|
177
177
|
return e.map(t).join(`
|
|
178
178
|
`);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
const
|
|
182
|
-
function
|
|
181
|
+
const U = "/api/v1/ads", O = "ad_session_id";
|
|
182
|
+
function L() {
|
|
183
183
|
if (typeof window < "u") {
|
|
184
184
|
const o = window.__AD_CONFIG__;
|
|
185
185
|
if (o != null && o.apiKey)
|
|
186
186
|
return o.apiKey;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
class
|
|
189
|
+
class C {
|
|
190
190
|
constructor(e = {}) {
|
|
191
|
-
this.memoryCache = /* @__PURE__ */ new Map(), this.sessionKey = e.sessionKey ||
|
|
191
|
+
this.memoryCache = /* @__PURE__ */ new Map(), this.sessionKey = e.sessionKey || O, this.storage = e.storage || "sessionStorage", (typeof window > "u" || typeof window.sessionStorage > "u") && (this.storage = "memory");
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
194
|
* 获取 Session ID
|
|
@@ -222,10 +222,10 @@ class A {
|
|
|
222
222
|
this.storage === "sessionStorage" ? sessionStorage.removeItem(this.sessionKey) : this.memoryCache.delete(this.sessionKey);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
class
|
|
225
|
+
const B = new C(), f = () => B.getSessionId();
|
|
226
|
+
class V {
|
|
227
227
|
constructor(e = {}) {
|
|
228
|
-
this.baseUrl = e.baseUrl ||
|
|
228
|
+
this.baseUrl = e.baseUrl || U, this.timeout = e.timeout || 1e4, this.retryAttempts = e.retryAttempts ?? 2, this.retryDelay = e.retryDelay || 1e3, this.debug = e.debug || !1;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* 发送广告展示事件
|
|
@@ -258,7 +258,7 @@ class S {
|
|
|
258
258
|
this.debug && console.log(`[Analytics] Sending ${i} event (attempt ${s + 1}):`, t);
|
|
259
259
|
const r = new AbortController(), a = setTimeout(() => r.abort(), this.timeout), c = {
|
|
260
260
|
"Content-Type": "application/json"
|
|
261
|
-
}, l =
|
|
261
|
+
}, l = L();
|
|
262
262
|
l && (c["X-API-Key"] = l, this.debug && console.log(`[Analytics] Adding X-API-Key header for ${i} event`));
|
|
263
263
|
const d = await fetch(e, {
|
|
264
264
|
method: "POST",
|
|
@@ -283,37 +283,37 @@ class S {
|
|
|
283
283
|
return new Promise((t) => setTimeout(t, e));
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
const
|
|
287
|
-
function
|
|
286
|
+
const E = new V(), x = (o) => E.trackImpression(o), A = (o) => E.trackClick(o);
|
|
287
|
+
function H(o, e) {
|
|
288
288
|
return `vt_${o}_${e}`;
|
|
289
289
|
}
|
|
290
|
-
async function
|
|
291
|
-
return Promise.all(o.map((e) =>
|
|
290
|
+
async function D(o) {
|
|
291
|
+
return Promise.all(o.map((e) => x(e)));
|
|
292
292
|
}
|
|
293
|
-
async function
|
|
294
|
-
return Promise.all(o.map((e) =>
|
|
293
|
+
async function G(o) {
|
|
294
|
+
return Promise.all(o.map((e) => A(e)));
|
|
295
295
|
}
|
|
296
|
-
function
|
|
297
|
-
const e = new
|
|
296
|
+
function F(o) {
|
|
297
|
+
const e = new V(o);
|
|
298
298
|
return {
|
|
299
299
|
trackImpression: (t) => e.trackImpression(t),
|
|
300
300
|
trackClick: (t) => e.trackClick(t)
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
const e = new
|
|
303
|
+
function j(o = {}) {
|
|
304
|
+
const e = new C(o);
|
|
305
305
|
return {
|
|
306
306
|
getSessionId: () => e.getSessionId(),
|
|
307
307
|
regenerateSessionId: () => e.regenerateSessionId(),
|
|
308
308
|
clearSessionId: () => e.clearSessionId()
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
class
|
|
311
|
+
class v {
|
|
312
312
|
/**
|
|
313
313
|
* Render Action Card ad into container
|
|
314
314
|
*/
|
|
315
315
|
static renderActionCard(e, t, i = {}) {
|
|
316
|
-
t.innerHTML =
|
|
316
|
+
t.innerHTML = y.renderActionCard(e, i);
|
|
317
317
|
const n = t.querySelector(".ax-ad-cta");
|
|
318
318
|
return n && n.addEventListener("click", (s) => {
|
|
319
319
|
s.preventDefault(), this.handleClick(e, i);
|
|
@@ -345,7 +345,7 @@ class g {
|
|
|
345
345
|
* Render Lead Gen ad into container
|
|
346
346
|
*/
|
|
347
347
|
static renderLeadGenAd(e, t, i = {}) {
|
|
348
|
-
t.innerHTML =
|
|
348
|
+
t.innerHTML = y.renderLeadGenAd(e);
|
|
349
349
|
const n = t.querySelector(".ax-ad-leadgen-cta");
|
|
350
350
|
return n && n.addEventListener("click", (s) => {
|
|
351
351
|
s.preventDefault(), this.handleClick(e, i);
|
|
@@ -368,12 +368,12 @@ class g {
|
|
|
368
368
|
*/
|
|
369
369
|
static handleClick(e, t) {
|
|
370
370
|
const { analytics: i, onClick: n } = t;
|
|
371
|
-
n && n(e), i &&
|
|
371
|
+
n && n(e), i && A({
|
|
372
372
|
requestId: i.requestId,
|
|
373
373
|
adId: e.original.id,
|
|
374
374
|
destinationUrl: e.tracking.clickUrl,
|
|
375
375
|
slotId: i.slotId,
|
|
376
|
-
sessionId:
|
|
376
|
+
sessionId: f(),
|
|
377
377
|
adTitle: e.adapted.title,
|
|
378
378
|
format: e.original.type
|
|
379
379
|
}).catch((s) => {
|
|
@@ -386,13 +386,13 @@ class g {
|
|
|
386
386
|
*/
|
|
387
387
|
static trackImpression(e, t, i) {
|
|
388
388
|
const { analytics: n, onImpression: s } = i, r = () => {
|
|
389
|
-
n ?
|
|
389
|
+
n ? x({
|
|
390
390
|
requestId: n.requestId,
|
|
391
391
|
adId: e.original.id,
|
|
392
392
|
slotId: n.slotId,
|
|
393
393
|
position: n.position,
|
|
394
394
|
totalAds: n.totalAds,
|
|
395
|
-
sessionId:
|
|
395
|
+
sessionId: f(),
|
|
396
396
|
adTitle: e.adapted.title,
|
|
397
397
|
format: e.original.type,
|
|
398
398
|
source: "internal",
|
|
@@ -491,7 +491,7 @@ class g {
|
|
|
491
491
|
`;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
class
|
|
494
|
+
class S {
|
|
495
495
|
constructor() {
|
|
496
496
|
this.cachedStaticInfo = null, this.cacheTimestamp = 0, this.CACHE_TTL = 36e5;
|
|
497
497
|
}
|
|
@@ -578,7 +578,7 @@ class v {
|
|
|
578
578
|
* Get singleton instance
|
|
579
579
|
*/
|
|
580
580
|
static getInstance() {
|
|
581
|
-
return this.instance || (this.instance = new
|
|
581
|
+
return this.instance || (this.instance = new S()), this.instance;
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
584
584
|
* Collect all available client information
|
|
@@ -881,35 +881,35 @@ class v {
|
|
|
881
881
|
this.cachedStaticInfo = null, this.cacheTimestamp = 0;
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
|
-
const
|
|
885
|
-
function
|
|
886
|
-
return
|
|
884
|
+
const T = () => S.getInstance();
|
|
885
|
+
function g(o) {
|
|
886
|
+
return T().collect(o);
|
|
887
887
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
888
|
+
function z() {
|
|
889
|
+
return g().device;
|
|
890
890
|
}
|
|
891
|
-
function
|
|
892
|
-
return
|
|
891
|
+
function q() {
|
|
892
|
+
return g().user;
|
|
893
893
|
}
|
|
894
|
-
function
|
|
895
|
-
return
|
|
894
|
+
function W() {
|
|
895
|
+
return g().app;
|
|
896
896
|
}
|
|
897
|
-
function
|
|
898
|
-
return
|
|
897
|
+
function Q() {
|
|
898
|
+
return g().geo;
|
|
899
899
|
}
|
|
900
|
-
function
|
|
901
|
-
return
|
|
900
|
+
function J() {
|
|
901
|
+
return q().id;
|
|
902
902
|
}
|
|
903
|
-
function
|
|
904
|
-
|
|
903
|
+
function X() {
|
|
904
|
+
T().clearCache();
|
|
905
905
|
}
|
|
906
|
-
function
|
|
907
|
-
const e =
|
|
906
|
+
function Z(o) {
|
|
907
|
+
const e = g(o);
|
|
908
908
|
return JSON.stringify(e, null, 2);
|
|
909
909
|
}
|
|
910
|
-
function
|
|
910
|
+
function Y() {
|
|
911
911
|
var t;
|
|
912
|
-
const o =
|
|
912
|
+
const o = g();
|
|
913
913
|
return [
|
|
914
914
|
o.device.os,
|
|
915
915
|
o.device.osv,
|
|
@@ -918,7 +918,7 @@ function Q() {
|
|
|
918
918
|
((t = o.geo) == null ? void 0 : t.country) || "Unknown"
|
|
919
919
|
].join(" / ");
|
|
920
920
|
}
|
|
921
|
-
function
|
|
921
|
+
function ee(o) {
|
|
922
922
|
var e, t;
|
|
923
923
|
return {
|
|
924
924
|
id: o.original.id,
|
|
@@ -945,8 +945,8 @@ function z(o) {
|
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
947
|
}
|
|
948
|
-
async function
|
|
949
|
-
const t = e.apiBaseUrl || "/api/v1", n =
|
|
948
|
+
async function K(o, e = {}) {
|
|
949
|
+
const t = e.apiBaseUrl || "/api/v1", n = T().collect(), s = {
|
|
950
950
|
...o,
|
|
951
951
|
clientInfo: n
|
|
952
952
|
// Auto-injected
|
|
@@ -966,93 +966,105 @@ async function _(o, e = {}) {
|
|
|
966
966
|
throw new Error(c.error || "Ad request failed");
|
|
967
967
|
return c.data;
|
|
968
968
|
}
|
|
969
|
-
|
|
969
|
+
const R = { width: 400, height: 200 }, k = {
|
|
970
|
+
variant: "horizontal",
|
|
971
|
+
count: 1,
|
|
972
|
+
preferences: {}
|
|
973
|
+
};
|
|
974
|
+
function $(o = {}) {
|
|
975
|
+
const e = {
|
|
976
|
+
variant: o.variant ?? k.variant,
|
|
977
|
+
count: o.count ?? k.count,
|
|
978
|
+
preferences: { ...k.preferences, ...o.preferences }
|
|
979
|
+
};
|
|
980
|
+
return [
|
|
981
|
+
{
|
|
982
|
+
slotId: "action_card",
|
|
983
|
+
slotName: "Action Card",
|
|
984
|
+
format: "action_card",
|
|
985
|
+
variant: e.variant,
|
|
986
|
+
size: R,
|
|
987
|
+
count: e.count,
|
|
988
|
+
preferences: e.preferences,
|
|
989
|
+
placement: { position: "below_fold", context: "post_response" }
|
|
990
|
+
}
|
|
991
|
+
];
|
|
992
|
+
}
|
|
993
|
+
const w = class w {
|
|
970
994
|
constructor(e) {
|
|
971
|
-
this.slots = {}, this.isLoading = !1, this.currentRequestId = null, this.adsAnalyticsMap = /* @__PURE__ */ new Map(), this.config = e, this.enabled = e.enabled !== !1, this.eventBus = new
|
|
995
|
+
this.slots = {}, this.isLoading = !1, this.currentRequestId = null, this.adsAnalyticsMap = /* @__PURE__ */ new Map(), this.config = e, this.enabled = e.enabled !== !1, this.eventBus = new P(), this.slots_config = $(e.cardOption), typeof window < "u" && (window.__AD_CONFIG__ = {
|
|
972
996
|
...window.__AD_CONFIG__ || {},
|
|
973
997
|
apiKey: e.apiKey,
|
|
974
998
|
apiBaseUrl: e.apiBaseUrl
|
|
975
999
|
}), this.config.debug && console.log("[AdManager] Initialized with config:", {
|
|
976
1000
|
apiBaseUrl: e.apiBaseUrl,
|
|
977
1001
|
hasApiKey: !!e.apiKey,
|
|
978
|
-
slotCount: e.slots.length,
|
|
979
1002
|
enabled: this.enabled
|
|
980
1003
|
});
|
|
981
1004
|
}
|
|
982
|
-
/**
|
|
983
|
-
* Request ads for all configured slots
|
|
984
|
-
* ClientInfo is automatically collected and injected
|
|
985
|
-
*
|
|
986
|
-
* @param context - Conversation and user context
|
|
987
|
-
* @returns Promise resolving to ad response batch
|
|
988
|
-
*/
|
|
989
1005
|
async requestAds(e) {
|
|
990
1006
|
if (!this.enabled)
|
|
991
1007
|
throw this.config.debug && console.warn("[AdManager] Ads are disabled, skipping request"), new Error("Ads are disabled");
|
|
992
1008
|
if (this.isLoading)
|
|
993
1009
|
throw this.config.debug && console.warn("[AdManager] Request already in progress"), new Error("Request already in progress");
|
|
994
1010
|
this.isLoading = !0, this.eventBus.emit("adsLoading"), this.config.debug && console.log("[AdManager] Starting ad request...");
|
|
1011
|
+
const t = "conversationContext" in e ? e : { conversationContext: e };
|
|
995
1012
|
try {
|
|
996
|
-
const
|
|
1013
|
+
const i = await K(
|
|
997
1014
|
{
|
|
998
|
-
conversationContext:
|
|
999
|
-
userContext:
|
|
1000
|
-
slots: this.
|
|
1015
|
+
conversationContext: t.conversationContext,
|
|
1016
|
+
userContext: t.userContext ? { ...t.userContext, sessionId: t.userContext.sessionId ?? f() } : { sessionId: f() },
|
|
1017
|
+
slots: this.slots_config
|
|
1001
1018
|
},
|
|
1002
1019
|
{
|
|
1003
1020
|
apiBaseUrl: this.config.apiBaseUrl,
|
|
1004
1021
|
apiKey: this.config.apiKey
|
|
1005
1022
|
}
|
|
1006
1023
|
);
|
|
1007
|
-
this.currentRequestId =
|
|
1008
|
-
|
|
1009
|
-
const
|
|
1010
|
-
this.adsAnalyticsMap.set(
|
|
1011
|
-
requestId:
|
|
1012
|
-
slotId:
|
|
1013
|
-
position:
|
|
1014
|
-
totalAds:
|
|
1024
|
+
this.currentRequestId = i.requestId, this.adsAnalyticsMap.clear(), i.slots.forEach((s) => {
|
|
1025
|
+
s.ads.forEach((r, a) => {
|
|
1026
|
+
const c = r.original.id;
|
|
1027
|
+
this.adsAnalyticsMap.set(c, {
|
|
1028
|
+
requestId: i.requestId,
|
|
1029
|
+
slotId: s.slotId,
|
|
1030
|
+
position: a,
|
|
1031
|
+
totalAds: s.ads.length
|
|
1015
1032
|
});
|
|
1016
1033
|
});
|
|
1017
1034
|
});
|
|
1018
|
-
const
|
|
1019
|
-
return
|
|
1020
|
-
|
|
1021
|
-
}), this.slots =
|
|
1035
|
+
const n = {};
|
|
1036
|
+
return i.slots.forEach((s) => {
|
|
1037
|
+
n[s.slotId] = s;
|
|
1038
|
+
}), this.slots = n, this.eventBus.emit("adsUpdated", this.slots), this.config.debug && console.log("[AdManager] Ads received:", {
|
|
1022
1039
|
slotCount: Object.keys(this.slots).length,
|
|
1023
1040
|
slots: Object.keys(this.slots)
|
|
1024
|
-
}),
|
|
1025
|
-
} catch (
|
|
1026
|
-
const
|
|
1027
|
-
throw this.eventBus.emit("adsError",
|
|
1041
|
+
}), i;
|
|
1042
|
+
} catch (i) {
|
|
1043
|
+
const n = i;
|
|
1044
|
+
throw this.eventBus.emit("adsError", n), n;
|
|
1028
1045
|
} finally {
|
|
1029
1046
|
this.isLoading = !1;
|
|
1030
1047
|
}
|
|
1031
1048
|
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Render a single ad from a slot into a container element
|
|
1034
|
-
*
|
|
1035
|
-
* @param slotId - Slot ID to render
|
|
1036
|
-
* @param container - DOM element to render into
|
|
1037
|
-
* @param options - Rendering options
|
|
1038
|
-
* @returns Rendered HTMLElement or null if slot/ad not found
|
|
1039
|
-
*/
|
|
1040
1049
|
render(e, t, i = {}) {
|
|
1041
|
-
const n =
|
|
1042
|
-
if (!n || !n.ads || n.ads.length === 0)
|
|
1043
|
-
return this.config.debug && console.warn("[AdManager] No ads in slot:", e), null;
|
|
1044
|
-
const s = i.adIndex ?? 0, r = n.ads[s];
|
|
1050
|
+
const n = typeof e != "string", s = n ? w.DEFAULT_SLOT_ID : e, r = n ? e : t, a = (n ? t : i) || {};
|
|
1045
1051
|
if (!r)
|
|
1046
|
-
return this.config.debug && console.warn(
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1052
|
+
return this.config.debug && console.warn("[AdManager] Render container is required"), null;
|
|
1053
|
+
const c = this.slots[s];
|
|
1054
|
+
if (!c || !c.ads || c.ads.length === 0)
|
|
1055
|
+
return this.config.debug && console.warn("[AdManager] No ads in slot:", s), null;
|
|
1056
|
+
const l = a.adIndex ?? 0, d = c.ads[l];
|
|
1057
|
+
if (!d)
|
|
1058
|
+
return this.config.debug && console.warn(`[AdManager] Ad at index ${l} not found in slot:`, s), null;
|
|
1059
|
+
const u = this.adsAnalyticsMap.get(d.original.id), p = this.slots_config.find((_) => _.slotId === s), m = (p == null ? void 0 : p.format) || "action_card";
|
|
1060
|
+
r.innerHTML = "";
|
|
1061
|
+
const h = {
|
|
1062
|
+
analytics: u,
|
|
1063
|
+
variant: a.variant,
|
|
1064
|
+
onClick: a.onClick,
|
|
1065
|
+
onImpression: a.onImpression
|
|
1054
1066
|
};
|
|
1055
|
-
return
|
|
1067
|
+
return m === "suffix" ? v.renderSuffixAd(d, r, h) : m === "source" ? v.renderSponsoredSource(d, r, h) : m === "lead_gen" ? v.renderLeadGenAd(d, r, h) : v.renderActionCard(d, r, h);
|
|
1056
1068
|
}
|
|
1057
1069
|
/**
|
|
1058
1070
|
* Get ad slots data
|
|
@@ -1091,7 +1103,7 @@ class F {
|
|
|
1091
1103
|
* Update configuration
|
|
1092
1104
|
*/
|
|
1093
1105
|
updateConfig(e) {
|
|
1094
|
-
this.config = { ...this.config, ...e }, this.config.debug && console.log("[AdManager] Config updated:", e);
|
|
1106
|
+
this.config = { ...this.config, ...e }, e.cardOption !== void 0 && (this.slots_config = $(this.config.cardOption)), this.config.debug && console.log("[AdManager] Config updated:", e);
|
|
1095
1107
|
}
|
|
1096
1108
|
/**
|
|
1097
1109
|
* Clear all slot data
|
|
@@ -1146,7 +1158,7 @@ class F {
|
|
|
1146
1158
|
const n = this.adsAnalyticsMap.get(e);
|
|
1147
1159
|
if (!n || !this.currentRequestId)
|
|
1148
1160
|
return this.config.debug && console.warn("[AdManager] No analytics info for ad:", e), null;
|
|
1149
|
-
const s =
|
|
1161
|
+
const s = f(), r = await A({
|
|
1150
1162
|
requestId: this.currentRequestId,
|
|
1151
1163
|
adId: e,
|
|
1152
1164
|
destinationUrl: t,
|
|
@@ -1165,7 +1177,7 @@ class F {
|
|
|
1165
1177
|
const i = this.adsAnalyticsMap.get(e);
|
|
1166
1178
|
if (!i || !this.currentRequestId)
|
|
1167
1179
|
return this.config.debug && console.warn("[AdManager] No analytics info for ad:", e), null;
|
|
1168
|
-
const n =
|
|
1180
|
+
const n = f(), s = await x({
|
|
1169
1181
|
requestId: this.currentRequestId,
|
|
1170
1182
|
adId: e,
|
|
1171
1183
|
slotId: i.slotId,
|
|
@@ -1185,15 +1197,17 @@ class F {
|
|
|
1185
1197
|
destroy() {
|
|
1186
1198
|
this.removeAllListeners(), this.clearSlots(), this.config.debug && console.log("[AdManager] Destroyed");
|
|
1187
1199
|
}
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1200
|
+
};
|
|
1201
|
+
w.DEFAULT_SLOT_ID = "action_card";
|
|
1202
|
+
let I = w;
|
|
1203
|
+
function M() {
|
|
1190
1204
|
if (typeof window < "u") {
|
|
1191
1205
|
const o = window.__AD_CONFIG__;
|
|
1192
1206
|
if (o != null && o.apiKey)
|
|
1193
1207
|
return o.apiKey;
|
|
1194
1208
|
}
|
|
1195
1209
|
}
|
|
1196
|
-
class
|
|
1210
|
+
class N {
|
|
1197
1211
|
constructor(e = {}, t = "/api/v1") {
|
|
1198
1212
|
var i, n;
|
|
1199
1213
|
this.observers = /* @__PURE__ */ new Map(), this.metrics = /* @__PURE__ */ new Map(), this.timers = /* @__PURE__ */ new Map(), this.batchTimers = /* @__PURE__ */ new Map(), this.eventQueue = /* @__PURE__ */ new Map(), this.isTracking = /* @__PURE__ */ new Map(), this.config = {
|
|
@@ -1354,7 +1368,7 @@ class O {
|
|
|
1354
1368
|
try {
|
|
1355
1369
|
const n = {
|
|
1356
1370
|
"Content-Type": "application/json"
|
|
1357
|
-
}, s =
|
|
1371
|
+
}, s = M();
|
|
1358
1372
|
s && (n["x-api-key"] = s), await fetch(`${this.baseUrl}/ads/viewability/batch`, {
|
|
1359
1373
|
method: "POST",
|
|
1360
1374
|
headers: n,
|
|
@@ -1428,7 +1442,7 @@ class O {
|
|
|
1428
1442
|
if (t && t.length > 0) {
|
|
1429
1443
|
const i = {
|
|
1430
1444
|
"Content-Type": "application/json"
|
|
1431
|
-
}, n =
|
|
1445
|
+
}, n = M();
|
|
1432
1446
|
n && (i["x-api-key"] = n), fetch(`${this.baseUrl}/ads/viewability/batch`, {
|
|
1433
1447
|
method: "POST",
|
|
1434
1448
|
headers: i,
|
|
@@ -1440,39 +1454,39 @@ class O {
|
|
|
1440
1454
|
});
|
|
1441
1455
|
}
|
|
1442
1456
|
}
|
|
1443
|
-
let
|
|
1444
|
-
function
|
|
1445
|
-
return
|
|
1457
|
+
let b = null;
|
|
1458
|
+
function te(o, e) {
|
|
1459
|
+
return b || (b = new N(o, e), b.setupBeforeUnload()), b;
|
|
1446
1460
|
}
|
|
1447
|
-
const
|
|
1461
|
+
const ie = "0.1.0";
|
|
1448
1462
|
export {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1463
|
+
I as AdManager,
|
|
1464
|
+
V as AnalyticsSender,
|
|
1465
|
+
S as ClientInfoCollector,
|
|
1466
|
+
v as DOMRenderer,
|
|
1467
|
+
y as HTMLRenderer,
|
|
1468
|
+
ie as SDK_VERSION,
|
|
1469
|
+
C as SessionManager,
|
|
1470
|
+
N as ViewabilityTracker,
|
|
1471
|
+
ee as adaptAdToKoahAd,
|
|
1472
|
+
X as clearClientInfoCache,
|
|
1473
|
+
F as createAnalytics,
|
|
1474
|
+
j as createSession,
|
|
1475
|
+
K as fetchAds,
|
|
1476
|
+
H as generateViewToken,
|
|
1477
|
+
W as getAppInfo,
|
|
1478
|
+
g as getClientInfo,
|
|
1479
|
+
T as getClientInfoCollector,
|
|
1480
|
+
Z as getClientInfoJSON,
|
|
1481
|
+
Y as getClientInfoSummary,
|
|
1482
|
+
z as getDeviceInfo,
|
|
1483
|
+
Q as getGeoInfo,
|
|
1484
|
+
f as getSessionId,
|
|
1485
|
+
J as getUserId,
|
|
1486
|
+
q as getUserInfo,
|
|
1487
|
+
te as getViewabilityTracker,
|
|
1488
|
+
A as trackAdClick,
|
|
1489
|
+
x as trackAdImpression,
|
|
1490
|
+
G as trackClicksBatch,
|
|
1491
|
+
D as trackImpressionsBatch
|
|
1478
1492
|
};
|