fix: restore missing Segment analytics events in Authn MFE - #12
Conversation
There was a problem hiding this comment.
Pull request overview
Restores missing client-side Segment analytics events in the Authn micro-frontend by reintroducing dropped tracking calls and ensuring events include the expected app_name value used by downstream Segment dashboards.
Changes:
- Reverts
APP_NAMEtoauthn_mfeto restore downstream analytics filtering. - Replaces direct analytics calls in
LoginPagewith tracker wrappers (addsapp_name) and restores login-success + cohesion tracking behaviors. - Adds
app_nameto Logistration toggle tracking events and fixes the CSRF token effect to run once.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/data/constants.js | Restores APP_NAME value used by Segment event properties/filters. |
| src/login/LoginPage.jsx | Restores login page + success analytics via tracker wrappers, re-adds cohesion dispatch, and cookie cleanup on success. |
| src/logistration/Logistration.jsx | Adds app_name to toggle track events and fixes CSRF token effect execution frequency. |
Comments suppressed due to low confidence (1)
src/logistration/Logistration.jsx:79
sendPageEventcalls here still omit{ app_name: APP_NAME }, while the surrounding changes aim to restore Segment events withapp_namefor downstream filtering. As-is, thelogin_and_registrationpage events emitted from institution login toggles will remain missingapp_name.
sendTrackEvent('edx.bi.institution_login_form.toggled', { category: 'user-engagement', app_name: APP_NAME });
if (typeof e === 'string') {
sendPageEvent('login_and_registration', e === '/login' ? 'login' : 'register');
} else {
sendPageEvent('login_and_registration', e.target.dataset.eventName);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| if (loginResult.success) { | ||
| trackLoginSuccess(); | ||
| removeCookie('ssoPipelineRedirectionDone'); | ||
| } | ||
| }, [loginResult]); |
| <RedirectLogistration | ||
| success={loginResult.success} | ||
| redirectUrl={loginResult.redirectUrl} | ||
| finishAuthUrl={finishAuthUrl} | ||
| currectProvider={currentProvider} | ||
| /> |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/logistration/Logistration.jsx:79
- These sendPageEvent calls still omit the app_name options object, so the corresponding page events won’t be filterable by app_name (which this PR is restoring for other Segment events). Pass { app_name: APP_NAME } as the 3rd argument (or use createPageEventTracker) for consistency.
sendPageEvent('login_and_registration', e === '/login' ? 'login' : 'register');
} else {
sendPageEvent('login_and_registration', e.target.dataset.eventName);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/logistration/Logistration.jsx:80
- The
sendPageEvent('login_and_registration', ...)calls inhandleInstitutionLoginare missing the{ app_name: APP_NAME }context that other page events get viacreatePageEventTracker. This means these page events won’t be attributed toauthn_mfeand can still be filtered out downstream.
if (typeof e === 'string') {
sendPageEvent('login_and_registration', e === '/login' ? 'login' : 'register');
} else {
sendPageEvent('login_and_registration', e.target.dataset.eventName);
}
nakhan-sonata-afk
left a comment
There was a problem hiding this comment.
authn_mfe has been configured. Approved
| <RedirectLogistration | ||
| success={loginResult.success} | ||
| redirectUrl={loginResult.redirectUrl} | ||
| finishAuthUrl={finishAuthUrl} | ||
| currectProvider={currentProvider} |
| it('should send page event when login page is rendered', () => { | ||
| render(reduxWrapper(<LoginPage {...props} />)); | ||
| expect(sendPageEvent).toHaveBeenCalledWith('login_and_registration', 'login'); | ||
| expect(sendPageEvent).toHaveBeenCalledWith( | ||
| 'login_and_registration', | ||
| 'login', | ||
| { app_name: 'authn_mfe' }, | ||
| ); |
| useEffect(() => { | ||
| if (loginResult.success) { | ||
| trackLoginSuccess(); | ||
| removeCookie('ssoPipelineRedirectionDone'); | ||
| } | ||
| }, [loginResult]); |
Summary
The Authn MFE stopped consistently triggering client-side Segment events since Feb 20, 2026. This was traced back to the enterprise theming PR (#6) where several analytics tracking calls were inadvertently dropped during the LoginPage.jsx refactor from Redux connect to React hooks.
This PR restores all affected events.
Changes
Events Restored
Notes