Conversation
added 2 commits
April 2, 2025 11:00
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Funnel class to support passing properties for analytics events, allowing events to include additional context data such as the userId and source.
- Modified the Funnel class to accept and forward optional properties in the init and trigger methods, and to include these properties in the close event.
- Updated the Funnel tests to verify that events are correctly sent with or without properties, and that property merging works as expected.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/frontend/src/utils/analytics/Funnel.ts | Enhanced the Funnel class to support optional properties with analytics events by adding parameters and merging properties where appropriate. |
| src/frontend/src/utils/analytics/Funnel.test.ts | Extended tests to cover the new behavior of passing and merging properties in init, trigger, and close methods. |
Comments suppressed due to low confidence (1)
src/frontend/src/utils/analytics/Funnel.ts:55
- [nitpick] Consider resetting the stored properties (this.#properties) to undefined at the end of the close() method after triggering the final analytics event to ensure the funnel state is fully reset and to avoid potential unintended reuse of stale properties.
this.#startTimestamp = undefined;
Merged
sea-snake
approved these changes
Apr 2, 2025
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.
Motivation
Properties need to be set in all the events in order to be able filter Funnels by them.
For example, to check the Funnel of NNS Dapp logins, we need to always set the origin of NNS Dapp in all the events triggered in that Funnel.
Changes
This pull request includes enhancements to the
Funnelclass and its associated tests to support the inclusion of properties in analytics events. The changes ensure that properties can be passed during initialization and triggering of events, and that these properties are correctly merged and tracked.Enhancements to
Funnelclass:src/frontend/src/utils/analytics/Funnel.ts: Added support for properties in theinitandtriggermethods, and modified theclosemethod to include these properties when tracking the duration.Enhancements to
Funneltests:src/frontend/src/utils/analytics/Funnel.test.ts: Added new test cases to verify that properties are correctly passed and merged in theinitandtriggermethods, and that theclosemethod tracks the duration with these properties.🟡 Some screens were changed