Skip to content

feat: forward allowlisted Segment events to Braze [GE-165] [GE-190]#28805

Merged
Montoya merged 17 commits into
mainfrom
feat/enable-braze-plugin-from-segment
Apr 16, 2026
Merged

feat: forward allowlisted Segment events to Braze [GE-165] [GE-190]#28805
Montoya merged 17 commits into
mainfrom
feat/enable-braze-plugin-from-segment

Conversation

@baptiste-marchand
Copy link
Copy Markdown
Contributor

@baptiste-marchand baptiste-marchand commented Apr 14, 2026

Description

Enables Braze events tracking via Segment’s device-mode pipeline by adding a custom BrazePlugin that identifies users via MetaMask profileId, forwards only allowlisted track events and identify traits via the Braze SDK.

Allowlisted events are managed on LaunchDarkly with a feature flag, so that we can update them without having to do a new release

A custom BrazePlugin was used instead of Segment's one for 2 reasons:

  • to use a different ID in Segment and Braze events. Segment identify calls use the Metametrics ID, while we needed to use the profile ID in Braze. The base plugin was instead copying Segment's ID for Braze
  • to fix an issue with Segment's destinations that their support team wasn't able to help with considering our constraints.

Changelog

CHANGELOG entry:

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/GE-165

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Changes the analytics pipeline and remote-config-driven allowlisting, which can affect what data is sent to Braze and when. Incorrect flag values or identity syncing issues could lead to dropped/extra analytics events or misattribution.

Overview
Routes Braze tracking through Segment device-mode by introducing a custom BrazePlugin destination plugin that gates track events and identify traits behind configurable allowlists and a profileId guard, and adds support for forwarding language/flush calls to the native Braze SDK.

Updates the public Braze API (app/core/Braze/index.ts) to manage a singleton plugin, set/clear Braze identity on sign-in/sign-out, keep Braze language in sync with locale changes, and validate/apply allowlists from a new remote feature flag.

Wires the plugin into analytics initialization by extending createPlatformAdapter to accept optional Segment plugins, subscribing analytics-controller-init.ts to remote feature flag updates (and an initial fetch), and adds a new init messenger plus Jest/test/mocks and feature-flag registry entries to support this behavior.

Reviewed by Cursor Bugbot for commit e248adf. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added size-L risk-low Low testing needed · Low bug introduction risk labels Apr 14, 2026
Comment thread app/util/identity/hooks/useBrazeIdentity/useBrazeIdentity.ts
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 14, 2026
Comment thread app/core/Braze/index.test.ts Outdated
Comment thread app/core/Braze/index.ts
@baptiste-marchand baptiste-marchand force-pushed the feat/enable-braze-plugin-from-segment branch from 7e9bc1d to af5300b Compare April 15, 2026 09:37
@baptiste-marchand baptiste-marchand requested review from a team as code owners April 15, 2026 09:37
@github-actions github-actions Bot added size-XL risk-medium Moderate testing recommended · Possible bug introduction risk and removed size-L risk-low Low testing needed · Low bug introduction risk labels Apr 15, 2026
@baptiste-marchand baptiste-marchand changed the title Feat/enable braze plugin from segment feat: forward some Segment events to Braze Apr 15, 2026
@baptiste-marchand baptiste-marchand added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Apr 15, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
Comment thread app/util/identity/hooks/useBrazeIdentity/useBrazeIdentity.test.ts Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.24%. Comparing base (15470f4) to head (0e43f0b).
⚠️ Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
...ne/controllers/analytics-controller/BrazePlugin.ts 74.46% 10 Missing and 2 partials ⚠️
app/core/Braze/index.ts 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28805      +/-   ##
==========================================
+ Coverage   82.20%   82.24%   +0.03%     
==========================================
  Files        5017     5030      +13     
  Lines      131659   132129     +470     
  Branches    29381    29496     +115     
==========================================
+ Hits       108228   108663     +435     
- Misses      16083    16099      +16     
- Partials     7348     7367      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 15, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3a2e67f. Configure here.

Comment thread app/core/Braze/index.ts
Comment thread app/core/Braze/index.test.ts
@baptiste-marchand baptiste-marchand changed the title feat: forward some Segment events to Braze feat: forward some Segment events to Braze [GE-165] [GE-190] Apr 15, 2026
@baptiste-marchand baptiste-marchand changed the title feat: forward some Segment events to Braze [GE-165] [GE-190] feat: forward allowlisted Segment events to Braze [GE-165] [GE-190] Apr 15, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
samir-acle
samir-acle previously approved these changes Apr 15, 2026
Copy link
Copy Markdown
Contributor

@samir-acle samir-acle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work.

Comment thread app/core/Engine/controllers/analytics-controller/BrazePlugin.ts Outdated
Comment thread app/core/Engine/controllers/analytics-controller/BrazePlugin.ts
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 15, 2026
jbblanc
jbblanc previously approved these changes Apr 16, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeIdentity, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR refactors the Braze analytics integration by introducing a new BrazePlugin Segment destination, moving useBrazeIdentity hook, and wiring up the AnalyticsController init messenger. Key impacts:

  1. Identity/sign-in flow: useBrazeIdentity now also calls clearBrazeUser() on sign-out (new behavior). This hook is used in useIdentityEffects which is called in Nav/Main/index.js — the main navigation component. This affects every user session's sign-in/sign-out lifecycle.

  2. Engine initialization: AnalyticsController init now uses a real getAnalyticsControllerInitMessenger (replacing noop) and subscribes to RemoteFeatureFlagController:stateChange. This is a change to Engine startup behavior.

  3. E2E guards in place: Both setBrazeUser() and clearBrazeUser() have isE2E guards that return early, so Braze SDK calls won't execute during E2E tests. The testSetup.js adds proper mocks for the new Braze SDK methods.

  4. No UI changes: No visual components were modified, so most feature-specific tests are not impacted.

SmokeIdentity is selected because the changes directly touch the identity sign-in/sign-out flow (useBrazeIdentity, useIdentityEffects), account syncing infrastructure, and the profile ID management that underpins identity features.

SmokeWalletPlatform is selected because it covers wallet lifecycle analytics tracking (new wallet creation, SRP import events) and the analytics controller initialization changes could affect how analytics events are tracked during wallet lifecycle events. It also covers multi-SRP architecture which intersects with the identity changes.

Other tags (SmokeConfirmations, SmokeTrade, etc.) are not selected because the changes are analytics infrastructure with proper E2E guards, and don't touch transaction flows, network management, or other feature-specific code paths.

Performance Test Selection:
The changes are analytics infrastructure (Braze plugin, identity hooks, Engine messenger wiring). They don't affect UI rendering, list components, data loading performance, or critical user flow timing. The BrazePlugin is a Segment destination plugin that runs asynchronously and is no-op in E2E. No performance-sensitive code paths are modified.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@ccharly ccharly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for accounts (not tested)

@Montoya Montoya enabled auto-merge April 16, 2026 16:49
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platform files lgtm!

@Montoya Montoya added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit 9faf0fb Apr 16, 2026
286 of 297 checks passed
@Montoya Montoya deleted the feat/enable-braze-plugin-from-segment branch April 16, 2026 18:16
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-XL team-engagement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants