Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/edge/targeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type TargetingResponse = {
ortb2: { user: ortb2.User };
};

async function Targeting(config: ResolvedConfig, id: string): Promise<TargetingResponse> {
const searchParams = new URLSearchParams({ id });
async function Targeting(config: ResolvedConfig, ...ids: readonly string[]): Promise<TargetingResponse> {
const searchParams = new URLSearchParams(ids.map((id) => ["id", id]));
const path = "/v2/targeting?" + searchParams.toString();

const response: TargetingResponse = await fetch(path, config, {
Expand Down
4 changes: 2 additions & 2 deletions lib/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
);

Expand Down
8 changes: 6 additions & 2 deletions lib/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ class OptableSDK {
return Uid2Token(this.dcn, id);
}

async targeting(id: string = "__passport__"): Promise<TargetingResponse> {
async targeting(...ids: string[]): Promise<TargetingResponse> {
if (!ids.length) {
ids = ["__passport__"];
}

await this.init;
return Targeting(this.dcn, id);
return Targeting(this.dcn, ...ids);
}

targetingFromCache(): TargetingResponse | null {
Expand Down