Skip to content

fix: restore missing Segment analytics events in Authn MFE - #12

Merged
ssurendrannair merged 10 commits into
release-ulmofrom
AUT-209-authn-mfe-is-not-triggering-client-side-events-consistently
Jul 9, 2026
Merged

fix: restore missing Segment analytics events in Authn MFE#12
ssurendrannair merged 10 commits into
release-ulmofrom
AUT-209-authn-mfe-is-not-triggering-client-side-events-consistently

Conversation

@ssurendrannair

Copy link
Copy Markdown

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

  1. src/data/constants.js — Reverted APP_NAME from 'authn' back to 'authn_mfe' to fix downstream Segment dashboard filters
  2. src/login/LoginPage.jsx
  • Replaced bare sendPageEvent / sendTrackEvent calls with tracker wrappers that include app_name
  • Wired up trackLoginSuccess() to fire edx.bi.user.account.authenticated.client on login success
  • Restored cohesion tracking dispatch on sign-in submit handler
  • Re-added currectProvider prop to to correctly gate cohesion tracking for SSO logins
  • Restored ssoPipelineRedirectionDone cookie cleanup on successful login
  1. src/logistration/Logistration.jsx
  • Added app_name: APP_NAME to sendTrackEvent calls in handleInstitutionLogin and handleOnSelect
  • Fixed CSRF token useEffect missing dependency array (was firing on every render)

Events Restored

  • edx.bi.password_reset_form.viewed
  • edx.bi.user.account.authenticated.client
  • edx.bi.login_form.toggled
  • edx.bi.password-reset_form.toggled
  • edx.bi.register_form.toggled
  • edx.bi.institution_login_form.toggled

Notes

  • No changes to enterprise theming, routing, or logistration rendering logic
  • Existing SSO / TPA flows are unaffected

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_NAME to authn_mfe to restore downstream analytics filtering.
  • Replaces direct analytics calls in LoginPage with tracker wrappers (adds app_name) and restores login-success + cohesion tracking behaviors.
  • Adds app_name to 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

  • sendPageEvent calls here still omit { app_name: APP_NAME }, while the surrounding changes aim to restore Segment events with app_name for downstream filtering. As-is, the login_and_registration page events emitted from institution login toggles will remain missing app_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.

Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx
Copilot AI review requested due to automatic review settings June 24, 2026 11:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx
Comment on lines +153 to +158
useEffect(() => {
if (loginResult.success) {
trackLoginSuccess();
removeCookie('ssoPipelineRedirectionDone');
}
}, [loginResult]);
Comment thread src/login/LoginPage.jsx
Comment on lines 266 to 271
<RedirectLogistration
success={loginResult.success}
redirectUrl={loginResult.redirectUrl}
finishAuthUrl={finishAuthUrl}
currectProvider={currentProvider}
/>
Copilot AI review requested due to automatic review settings June 24, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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);

Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 in handleInstitutionLogin are missing the { app_name: APP_NAME } context that other page events get via createPageEventTracker. This means these page events won’t be attributed to authn_mfe and 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);
    }

Comment thread src/login/LoginPage.jsx

@nakhan-sonata-afk nakhan-sonata-afk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

authn_mfe has been configured. Approved

Comment thread src/logistration/Logistration.jsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread src/logistration/Logistration.jsx
Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx
Comment thread src/login/tests/LoginPage.test.jsx
Copilot AI review requested due to automatic review settings July 2, 2026 07:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comment thread src/logistration/Logistration.jsx
Comment thread src/login/LoginPage.jsx
Comment thread src/login/LoginPage.jsx
Comment thread src/login/tests/LoginPage.test.jsx

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread src/login/LoginPage.jsx
Comment on lines 266 to +270
<RedirectLogistration
success={loginResult.success}
redirectUrl={loginResult.redirectUrl}
finishAuthUrl={finishAuthUrl}
currectProvider={currentProvider}
Comment on lines 763 to +769
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' },
);
Comment thread src/login/LoginPage.jsx
Comment on lines +153 to +158
useEffect(() => {
if (loginResult.success) {
trackLoginSuccess();
removeCookie('ssoPipelineRedirectionDone');
}
}, [loginResult]);

@subhashree-sahu31 subhashree-sahu31 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good

@ssurendrannair
ssurendrannair merged commit 417c7dd into release-ulmo Jul 9, 2026
5 checks passed
@ssurendrannair
ssurendrannair deleted the AUT-209-authn-mfe-is-not-triggering-client-side-events-consistently branch July 9, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants