fix: config ID precision loss in telemetry reporting #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Ported from prefab-cloud/prefab-cloud-node#108
Fixes a JavaScript precision issue where large config IDs lose accuracy during telemetry reporting. Config ID 17537369033474523 was being reported as 17537369033474524 due to JavaScript's number precision limits.
Root Cause:
The telemetry system serializes evaluation data to JSON for aggregation, then deserializes it before sending to the API. During JSON.parse(), numeric strings in arrays are automatically converted to JavaScript numbers. For integers larger than Number.MAX_SAFE_INTEGER (2^53 - 1), this causes precision loss.
The Fix:
Changed Long.fromNumber(configId) to Long.fromString(configId) in the telemetry counter deserialization logic. This preserves the exact string representation throughout the JSON round-trip, avoiding JavaScript number precision issues.
Testing
The fix is minimal and targeted, only affecting the specific conversion point where precision was being lost.