Instalación
Creando una Subasta
Reportando Eventos
Errores Reintentables
La funciónreportEvent devuelve retry: true para errores 429 o 5xx:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Descripción general del JavaScript SDK de Topsort para subastas y seguimiento de eventos
<script
async
type="module"
src="https://unpkg.com/@topsort/sdk@latest/dist/index.mjs"
></script>
<script>
window.TS = {
token: "TSE_XXXXXXXXXXXX", // Replace with your Topsort API key
};
</script>
import { TopsortClient } from "https://unpkg.com/@topsort/sdk@latest/dist/index.mjs";
const topsortClient = new TopsortClient({ apiKey: window.TS.token });
const auctionDetails = {
auctions: [
{
type: "listings",
slots: 3,
searchQuery: "winter",
},
{
type: "banners",
slots: 1,
device: "desktop",
slotId: "slot123",
},
],
};
topsortClient
.createAuction(auctionDetails)
.then((result) => console.log("Auction Result", result))
.catch((error) => console.error("Auction Error", error));
const winners = auctionResult.results.flatMap((result) => result.winners || []);
if (winners.length > 0) {
const impressions = winners.map((winner) => ({
resolvedBidId: winner.resolvedBidId,
id: crypto.randomUUID(),
occurredAt: new Date().toISOString(),
opaqueUserId: crypto.randomUUID(),
placement: { path: "/search/winter" },
}));
topsortClient
.reportEvent({ impressions })
.then((result) => console.log("Event Result", result))
.catch((error) => console.error("Event Error", error));
}
reportEvent devuelve retry: true para errores 429 o 5xx:
topsortClient.reportEvent(eventPayload).then((result) => {
if (result.retry) {
console.warn("Transient error. Retry the call.");
}
});
¿Esta página le ayudó?