From 5f4fd108abb5446618a2bee3676ce457979a478b Mon Sep 17 00:00:00 2001 From: John Rosendahl Date: Wed, 11 Nov 2026 15:24:14 -0700 Subject: [PATCH] fix(targeting): make hids optional in TargetingRequest Co-Authored-By: Claude Opus 5.5 --- lib/edge/targeting.ts | 4 ++-- lib/sdk.test.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/edge/targeting.ts b/lib/edge/targeting.ts index a4cfdc47..91ebfcff 100644 --- a/lib/edge/targeting.ts +++ b/lib/edge/targeting.ts @@ -27,7 +27,7 @@ type UserIdentifiers = { type TargetingRequest = { ids: string[]; - hids: string[]; + hids?: string[]; }; type TargetingResponse = { @@ -49,7 +49,7 @@ const TARGETING_DONE_KEY = "OPTABLE_TARGETING_DONE"; async function Targeting(config: ResolvedConfig, req: TargetingRequest): Promise { const searchParams = new URLSearchParams(); req.ids.forEach((id) => searchParams.append("id", id)); - req.hids.forEach((id) => searchParams.append("hid", id)); + req.hids?.forEach((id) => searchParams.append("hid", id)); const abTest = determineABTest(config.abTests); if (abTest) { searchParams.append("ab_test_id", abTest.id); diff --git a/lib/sdk.test.ts b/lib/sdk.test.ts index 6e083595..acd977ea 100644 --- a/lib/sdk.test.ts +++ b/lib/sdk.test.ts @@ -903,6 +903,15 @@ describe("behavior testing of", () => { }) ); + await sdk.targeting({ ids: ["someId"], hids: ["someHint"] }); + + expect(fetchSpy).toHaveBeenLastCalledWith( + expect.objectContaining({ + method: "GET", + url: expect.stringContaining("v2/targeting?id=someId&hid=someHint"), + }) + ); + const latestResultFromCache = sdk.targetingFromCache(); expect(latestResultFromCache).toEqual({ ...targetingWithParam, refs: {} });