diff --git a/lib/edge/targeting.ts b/lib/edge/targeting.ts index 487c19c..6c1505f 100644 --- a/lib/edge/targeting.ts +++ b/lib/edge/targeting.ts @@ -27,8 +27,8 @@ type TargetingResponse = { ortb2: { user: ortb2.User }; }; -async function Targeting(config: ResolvedConfig, id: string): Promise { - const searchParams = new URLSearchParams({ id }); +async function Targeting(config: ResolvedConfig, ...ids: readonly string[]): Promise { + const searchParams = new URLSearchParams(ids.map((id) => ["id", id])); const path = "/v2/targeting?" + searchParams.toString(); const response: TargetingResponse = await fetch(path, config, { diff --git a/lib/sdk.test.ts b/lib/sdk.test.ts index 4a6d638..cc75e82 100644 --- a/lib/sdk.test.ts +++ b/lib/sdk.test.ts @@ -395,13 +395,13 @@ describe("behavior testing of", () => { }) ); - const targetingWithParam = await sdk.targeting("someId"); + const targetingWithParam = await sdk.targeting("someId", "someOtherId"); expect(targetingWithParam).toBeDefined(); expect(fetchSpy).toHaveBeenLastCalledWith( expect.objectContaining({ method: "GET", - url: expect.stringContaining("v2/targeting?id=someId"), + url: expect.stringContaining("v2/targeting?id=someId&id=someOtherId"), }) ); diff --git a/lib/sdk.ts b/lib/sdk.ts index 78755ea..eb080b9 100644 --- a/lib/sdk.ts +++ b/lib/sdk.ts @@ -54,9 +54,13 @@ class OptableSDK { return Uid2Token(this.dcn, id); } - async targeting(id: string = "__passport__"): Promise { + async targeting(...ids: string[]): Promise { + if (!ids.length) { + ids = ["__passport__"]; + } + await this.init; - return Targeting(this.dcn, id); + return Targeting(this.dcn, ...ids); } targetingFromCache(): TargetingResponse | null {