Skip to content

Commit cec8568

Browse files
jkebingerclaude
andauthored
Fix large config ID precision loss in telemetry reporting (#108)
🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent ae83f81 commit cec8568

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/__tests__/telemetry/evaluationSummaries.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,31 @@ describe("evaluationSummaries", () => {
356356
);
357357
});
358358
});
359+
360+
it("preserves large config IDs without precision loss", async () => {
361+
const largeConfigId = Long.fromString("17537369033474523");
362+
const largeConfig: Config = {
363+
...basicConfig,
364+
id: largeConfigId,
365+
};
366+
367+
const aggregator = evaluationSummaries(
368+
mockApiClient,
369+
telemetrySource,
370+
instanceHash,
371+
true
372+
);
373+
374+
aggregator.push(evaluationFor(largeConfig, usContexts));
375+
376+
const syncResult = await aggregator.sync();
377+
378+
if (syncResult === undefined) {
379+
throw new Error("syncResult is undefined");
380+
}
381+
382+
const counter = syncResult.dataSent.events[0].summaries?.summaries[0].counters[0];
383+
expect(counter?.configId?.toString()).toBe("17537369033474523");
384+
expect(counter?.configId?.equals(largeConfigId)).toBe(true);
385+
});
359386
});

src/telemetry/evaluationSummaries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const evaluationSummaries = (
144144
}
145145

146146
const counter: ConfigEvaluationCounter = {
147-
configId: Long.fromNumber(configId),
147+
configId: Long.fromString(configId),
148148
conditionalValueIndex,
149149
configRowIndex,
150150
selectedValue,

0 commit comments

Comments
 (0)