fix(3932): Fix User traits changed during onboarding are never sent to Segment #29865
+280
−34
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.
Description
User traits are not logged during onboarding (including the initial values, and any changes made during onboarding).
After following the steps https://github.com/MetaMask/MetaMask-planning/issues/3932#issuecomment-2604742483, The data changes are as follows:
{participateInMetaMetrics : null, dataCollectionForMarketing: null}
participateInMetaMetrics
to false by clicking "No thanks", and state is{participateInMetaMetrics : false, dataCollectionForMarketing: null}
{participateInMetaMetrics : true, dataCollectionForMarketing: null}
=> the state of
dataCollectionForMarketing
is not changed from this action, hence the batch request will not include unchanged valuedataCollectionForMarketing
, which meanshas_marketing_consent
is not going to be included in first identify call to segment.Hence the solution is to modify the value of
dataCollectionForMarketing
to false in the state and the difference of state will be picked up and included intraits
sent to segment in identify call.You can find some e2e tests covering the situation in
test/e2e/tests/metrics/segment-user-traits.spec.ts
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3932
Manual testing steps
type: "identify"
to Segment, it comes with traits of{has_marketing_consent : true, is_metrics_opted_in: false}
Screenshots/Recordings
Before
After
https://www.loom.com/share/9375153003c44231a65a685305ec1828?sid=c58f98f0-6fba-400f-8f96-8e53c316879f
Pre-merge author checklist
Pre-merge reviewer checklist