Commit 5783dd3
authored
feat: add analytics tracking for social login failures (#22182)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
This PR adds analytics tracking for social login failures to help
identify where and why failures occur during the OAuth login flow.
The implementation tracks failures at three stages:
1. **Provider login failures** - When users cancel or encounter errors
during the OAuth provider authentication step
2. **Token exchange failures** - When errors occur during the
authorization code to JWT token exchange
3. **Seedless authentication failures** - When errors occur during the
seedless authentication step
Each failure event includes contextual metadata:
- `account_type` - The type of account being created (e.g.,
`default_google`, `default_apple`)
- `is_rehydration` - Whether this is a rehydration flow (existing user
returning)
- `failure_type` - Whether the failure was due to user cancellation or
an error
- `error_category` - The specific stage where the failure occurred
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/SL-257
## **Manual testing steps**
1. Start a social login flow (Google or Apple)
2. Cancel the OAuth provider authentication dialog
3. Verify that a `SocialLoginFailed` event is tracked with
`failure_type: 'user_cancelled'` and `error_category: 'provider_login'`
4. Attempt a social login and simulate a network error during token
exchange
5. Verify that a `SocialLoginFailed` event is tracked with
`failure_type: 'error'` and `error_category: 'get_auth_tokens'`
6. Attempt a social login and simulate an error during seedless
authentication
7. Verify that a `SocialLoginFailed` event is tracked with
`failure_type: 'error'` and `error_category: 'seedless_auth'`
## **Screenshots/Recordings**
<!-- Not applicable - this is an analytics-only change with no UI
changes -->
### **Before**
<!-- N/A -->
### **After**
<!-- N/A -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds SOCIAL_LOGIN_FAILED tracking with rehydration context across
provider login, token exchange, and seedless auth; updates OAuth login
API and tests accordingly.
>
> - **Analytics**:
> - Add `SOCIAL_LOGIN_FAILED` event in
`core/Analytics/MetaMetrics.events.ts` and export mapping.
> - **OAuth** (`core/OAuthService/OAuthService.ts`):
> - Add `userClickedRehydration` to local state and
`#trackSocialLoginFailure` to emit `SOCIAL_LOGIN_FAILED` with
`account_type`, `is_rehydration`, `failure_type`, and `error_category`.
> - Invoke tracking on failures in `provider_login`, `get_auth_tokens`,
and `seedless_auth` stages; validate `id_token` earlier.
> - Change `handleOAuthLogin(loginHandler, userClickedRehydration)`
signature and wire usage.
> - **Onboarding** (`components/Views/Onboarding/index.js`):
> - Pass rehydration flag to `handleOAuthLogin` (`!createWallet`).
> - **Tests**:
> - Update unit tests in `OAuthService.test.ts` and
`Onboarding/index.test.tsx` to reflect new `handleOAuthLogin` param and
event behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
37e8b08. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent af57390 commit 5783dd3
File tree
5 files changed
+81
-10
lines changed- app
- components/Views/Onboarding
- core
- Analytics
- OAuthService
5 files changed
+81
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
628 | 629 | | |
629 | 630 | | |
630 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
744 | 744 | | |
745 | 745 | | |
746 | 746 | | |
| 747 | + | |
747 | 748 | | |
748 | 749 | | |
749 | 750 | | |
| |||
794 | 795 | | |
795 | 796 | | |
796 | 797 | | |
| 798 | + | |
797 | 799 | | |
798 | 800 | | |
799 | 801 | | |
| |||
847 | 849 | | |
848 | 850 | | |
849 | 851 | | |
| 852 | + | |
850 | 853 | | |
851 | 854 | | |
852 | 855 | | |
| |||
897 | 900 | | |
898 | 901 | | |
899 | 902 | | |
| 903 | + | |
900 | 904 | | |
901 | 905 | | |
902 | 906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
756 | 757 | | |
757 | 758 | | |
758 | 759 | | |
| 760 | + | |
759 | 761 | | |
760 | 762 | | |
761 | 763 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
| |||
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
175 | | - | |
| 181 | + | |
176 | 182 | | |
177 | 183 | | |
178 | 184 | | |
| |||
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
191 | | - | |
| 197 | + | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| |||
209 | 215 | | |
210 | 216 | | |
211 | 217 | | |
212 | | - | |
| 218 | + | |
213 | 219 | | |
214 | 220 | | |
215 | 221 | | |
| |||
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
228 | | - | |
| 234 | + | |
229 | 235 | | |
230 | 236 | | |
231 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
143 | 182 | | |
144 | 183 | | |
| 184 | + | |
145 | 185 | | |
146 | 186 | | |
147 | 187 | | |
| |||
151 | 191 | | |
152 | 192 | | |
153 | 193 | | |
| 194 | + | |
154 | 195 | | |
155 | 196 | | |
156 | 197 | | |
| |||
174 | 215 | | |
175 | 216 | | |
176 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
177 | 224 | | |
178 | 225 | | |
179 | 226 | | |
| |||
196 | 243 | | |
197 | 244 | | |
198 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
199 | 249 | | |
200 | 250 | | |
201 | 251 | | |
| |||
210 | 260 | | |
211 | 261 | | |
212 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
213 | 269 | | |
214 | 270 | | |
215 | 271 | | |
| |||
218 | 274 | | |
219 | 275 | | |
220 | 276 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 277 | | |
226 | 278 | | |
227 | 279 | | |
| |||
257 | 309 | | |
258 | 310 | | |
259 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
260 | 318 | | |
261 | 319 | | |
262 | 320 | | |
| |||
0 commit comments