Repository navigation
fix: Drop context attributes that are not JSON types from analytics events - #311
Merged
Merged
Conversation
…vents A context attribute value that is, or contains, an object other than stdClass can not be redacted reliably. The event serializer now leaves the attribute out of analytics events and logs a warning.
There was a problem hiding this comment.
Risk: medium. Not approved: SDK rules 1–3 would allow this (not a release PR, allowed author, no workflow-file changes), but the configured approval threshold is low only and this changes analytics-event privacy redaction. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver
kinyoklion
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


The event serializer can only redact private attributes inside JSON values: null, bool, int, float, string, array, and
stdClass. A context attribute whose value is, or contains, any other object (aJsonSerializable, a class with public properties,DateTime,ArrayObject, and so on) was sent tojson_encodeas is, so private attribute references inside it were not applied.The serializer now checks each custom attribute. If the value is or contains a type other than a JSON type, the attribute is left out of the event and a warning is logged through the configured logger. Attributes that are private as a whole are still redacted as before and do not log a warning.
Behavior change: contexts that use objects other than
stdClassas attribute values, includingDateTime, no longer send those attributes in analytics events. Flag evaluation is unchanged. TheLDContextBuilder::set()docs now say to use only JSON types.This matches the approach agreed with the JS SDK maintainer. Follows #306 and #309.
Ticket: SDK-3784
Note
Overview
Analytics events now validate context custom attributes with a new
isJsonValuecheck before serialization. Values that are not JSON types (null, scalars, arrays,stdClass) or that nest disallowed objects (DateTime,JsonSerializable, arbitrary classes, etc.) are omitted from the event payload, and the SDK emits a warning via the configured PSR-3 logger (defaults to silentNullLogger).Nested invalid types cause the whole attribute to be dropped; valid siblings and purely JSON structures are unchanged. Attributes marked fully private still redact without a warning, so private paths inside non-JSON values are no longer a redaction gap. Flag evaluation is unaffected—only event export behavior changes.
LDContextBuilder::set()documentation now states that only JSON types should be used in attribute values if they are to appear in analytics.Reviewed by Cursor Bugbot for commit 7538d66. Bugbot is set up for automated code reviews on this repo. Configure here.