Add support for custom events - log_event #107
Merged
madhuchavva merged 4 commits intomainfrom Mar 23, 2026
Merged
Conversation
…Client Adds a public log_event(event_name, properties) method to the sync GrowthBook class and an async equivalent to GrowthBookClient. Both expose set_event_logger() so plugins (or callers directly) can register the callable that handles dispatch. Without a registered logger the call is a no-op with a WARNING. Options.event_logger field is added to common_types to carry the logger on the async client's options object. Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
set_attributes() replaces self._attributes with a new dict but does not write back to _user_ctx.attributes — that sync only happened lazily inside _get_eval_context() (called by eval_feature). If log_event was called after set_attributes() without an intervening eval_feature call, it would pass stale attribute values (from initialization time) to the ingestor. Fix mirrors the same two-line sync that _get_eval_context already performs. Adds a regression test that fails without the fix. Made-with: Cursor
bryce-fitzsimons
approved these changes
Mar 23, 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.
This PR adds the ability to log custom events using
log_eventsupported by the existingGrowthBookTrackingPlugin.Usage
Sync client (GrowthBook)
Async client (GrowthBookClient)
How it works:
log_eventlogs a WARNING (no-op for the user's app)set_event_loggeris a public API, just like thesetEventLoggerin JS SDK.