@the_ro_show/agent-ads-sdk 0.14.0 → 0.14.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 +91 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -548,17 +548,22 @@ var AttentionMarketClient = class {
|
|
|
548
548
|
...params.optimizeFor && { optimizeFor: params.optimizeFor }
|
|
549
549
|
};
|
|
550
550
|
const response = await this.decideRaw(request, options);
|
|
551
|
-
if (response.creative) {
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
551
|
+
if (response && response.creative) {
|
|
552
|
+
if (response["_meta"]) {
|
|
553
|
+
try {
|
|
554
|
+
await this.track({
|
|
555
|
+
event_id: `evt_${generateUUID()}`,
|
|
556
|
+
event_type: "impression",
|
|
557
|
+
occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
558
|
+
agent_id: this.agentId,
|
|
559
|
+
request_id: response["_meta"]["request_id"],
|
|
560
|
+
decision_id: response["_meta"]["decision_id"],
|
|
561
|
+
unit_id: response["_meta"]["unit_id"],
|
|
562
|
+
tracking_token: response.tracking_token
|
|
563
|
+
});
|
|
564
|
+
} catch (error) {
|
|
565
|
+
console.warn("[AttentionMarket] Failed to auto-track impression:", error);
|
|
566
|
+
}
|
|
562
567
|
}
|
|
563
568
|
const adResponse2 = {
|
|
564
569
|
request_id: request.request_id,
|
|
@@ -571,6 +576,7 @@ var AttentionMarketClient = class {
|
|
|
571
576
|
tracking_url: response.click_url || "",
|
|
572
577
|
// Same as click_url
|
|
573
578
|
tracking_token: response.tracking_token || "",
|
|
579
|
+
...response.relevance_score !== void 0 && { relevance_score: response.relevance_score },
|
|
574
580
|
disclosure: response.disclosure || {
|
|
575
581
|
label: "Sponsored",
|
|
576
582
|
explanation: "This is a paid advertisement",
|
|
@@ -584,7 +590,7 @@ var AttentionMarketClient = class {
|
|
|
584
590
|
};
|
|
585
591
|
return adResponse2;
|
|
586
592
|
}
|
|
587
|
-
if (response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
593
|
+
if (!response || response.status === "no_fill" || !response.units || response.units.length === 0) {
|
|
588
594
|
return null;
|
|
589
595
|
}
|
|
590
596
|
const adUnit = response.units[0];
|