Summary
We suggest improving how the library returns data intended for insertion into extension fields. Currently, the library returns a JSON blob as a string, which introduces unnecessary overhead for consumers.
Problem
At the moment, extension data is returned as a JSON string. To access specific fields (e.g., treatment group for Amazon reporting), consumers must:
- Unmarshal the JSON string into a struct/map
- Extract the required fields
This adds extra CPU overhead and allocations, especially in high-throughput systems where this operation happens frequently.
Impact
- Increased marshaling/unmarshaling overhead
- latency in hot paths
- Higher CPU and memory usage under load
Expected behavior
The library should return structured data directly, allowing consumers to access fields without additional decoding.
Suggestion
Instead of returning a JSON string, consider returning:
- a
map[string]interface{}
or
- a well-defined struct representing the extension schema
Summary
We suggest improving how the library returns data intended for insertion into extension fields. Currently, the library returns a JSON blob as a string, which introduces unnecessary overhead for consumers.
Problem
At the moment, extension data is returned as a JSON string. To access specific fields (e.g., treatment group for Amazon reporting), consumers must:
This adds extra CPU overhead and allocations, especially in high-throughput systems where this operation happens frequently.
Impact
Expected behavior
The library should return structured data directly, allowing consumers to access fields without additional decoding.
Suggestion
Instead of returning a JSON string, consider returning:
map[string]interface{}or