-
Notifications
You must be signed in to change notification settings - Fork 59
feat: add beforeSend hook #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
17bd991
feat: add beforeSend hook
ioannisj 656b3ac
fix: changelog
ioannisj 402cfd4
fix: accept list of beforeSend callbacks
ioannisj a965746
fix: avoid null assertion
ioannisj 4b133ef
Merge branch 'main' into feat/before_send
ioannisj 570927b
feat: add userProperties and userPropertiesSetOnce to beforeSend event
ioannisj 6713329
feat: add unit tests
ioannisj 8e657cf
feat: support async beforeSend callbacks with FutureOr
ioannisj df71fcd
fix: use non-nullable values
ioannisj 9e08334
fix: add constants
ioannisj 707a295
Merge branch 'main' into feat/before_send
ioannisj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /// Event names used throughout the PostHog Flutter SDK | ||
| class PostHogEventName { | ||
| PostHogEventName._(); | ||
|
|
||
| static const screen = '\$screen'; | ||
| static const exception = '\$exception'; | ||
| } | ||
|
|
||
| /// Property keys used throughout the PostHog Flutter SDK | ||
| class PostHogPropertyName { | ||
| PostHogPropertyName._(); | ||
|
|
||
| static const screenName = '\$screen_name'; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /// Represents an event that can be modified or dropped by the [BeforeSendCallback]. | ||
| /// | ||
| /// This class is used in the beforeSend callback to allow modification of events before they are sent to PostHog. | ||
| class PostHogEvent { | ||
ioannisj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// The name of the event (e.g., 'button_clicked', '$screen', '$exception') | ||
| String event; | ||
|
|
||
| /// User-provided properties for this event. | ||
| /// | ||
| /// Note: System properties (like $device_type, $session_id, etc.) are added | ||
| /// by the native SDK at a later stage and are not available in this map. | ||
| Map<String, Object>? properties; | ||
|
|
||
| /// User properties to set on the user profile ($set). | ||
| /// | ||
| /// These properties will be merged with any existing user properties. | ||
| Map<String, Object>? userProperties; | ||
|
|
||
| /// User properties to set only once on the user profile ($set_once). | ||
| /// | ||
| /// These properties will only be set if they don't already exist on the user profile. | ||
| Map<String, Object>? userPropertiesSetOnce; | ||
|
|
||
| PostHogEvent({ | ||
| required this.event, | ||
| this.properties, | ||
| this.userProperties, | ||
| this.userPropertiesSetOnce, | ||
| }); | ||
|
|
||
| @override | ||
| String toString() { | ||
| return 'PostHogEvent(event: $event, properties: $properties, userProperties: $userProperties, userPropertiesSetOnce: $userPropertiesSetOnce)'; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.