Skip to content

Commit

Permalink
Allow custom targeting id (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
zapo authored Jul 15, 2024
1 parent d05e136 commit 4a8e756
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/edge/targeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ type TargetingResponse = {

const lmpidProvider = "loblawmedia.ca";

async function Targeting(config: Required<OptableConfig>): Promise<TargetingResponse> {
const response: TargetingResponse = await fetch("/v2/targeting", config, {
async function Targeting(config: Required<OptableConfig>, id: string): Promise<TargetingResponse> {
const searchParams = new URLSearchParams({ id });
const path = "/v2/targeting?" + searchParams.toString();

const response: TargetingResponse = await fetch(path, config, {
method: "GET",
headers: { Accept: "application/json" },
});
Expand Down
4 changes: 2 additions & 2 deletions lib/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class OptableSDK {
return Uid2Token(this.dcn, id);
}

async targeting(): Promise<TargetingResponse> {
async targeting(id: string = "__passport__"): Promise<TargetingResponse> {
await this.init;
return Targeting(this.dcn);
return Targeting(this.dcn, id);
}

targetingFromCache(): TargetingResponse | null {
Expand Down

0 comments on commit 4a8e756

Please sign in to comment.