Skip to content

Commit 4d993c2

Browse files
authored
chore: improve SOCIAL_LOGIN event flows (#5120)
1 parent b8bdea4 commit 4d993c2

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

packages/controllers/src/utils/SocialsUtil.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ export async function connectSocial(
9494
}
9595
} catch (error) {
9696
popupWindow?.close()
97-
SnackController.showError((error as Error)?.message)
97+
const errorMessage = CoreHelperUtil.parseError(error)
98+
SnackController.showError(errorMessage)
99+
100+
EventsController.sendEvent({
101+
type: 'track',
102+
event: 'SOCIAL_LOGIN_ERROR',
103+
properties: { provider: socialProvider, message: errorMessage }
104+
})
98105
}
99106
}
100107

packages/scaffold-ui/src/views/w3m-connecting-farcaster-view/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ export class W3mConnectingFarcasterView extends LitElement {
7272
super.disconnectedCallback()
7373
clearTimeout(this.timeout)
7474
window.removeEventListener('resize', this.forceUpdate)
75+
76+
// Track cancellation if user navigates away or closes modal without completing connection
77+
const isConnected = ChainController.state.activeCaipAddress
78+
if (!isConnected && this.socialProvider && (this.uri || this.loading)) {
79+
EventsController.sendEvent({
80+
type: 'track',
81+
event: 'SOCIAL_LOGIN_CANCELED',
82+
properties: { provider: this.socialProvider }
83+
})
84+
}
7585
}
7686

7787
// -- Render -------------------------------------------- //

packages/scaffold-ui/src/views/w3m-connecting-social-view/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ export class W3mConnectingSocialView extends LitElement {
104104
public override disconnectedCallback() {
105105
this.unsubscribe.forEach(unsubscribe => unsubscribe())
106106
window.removeEventListener('message', this.handleSocialConnection, false)
107+
108+
// Track cancellation if user navigates away or closes modal without completing connection
109+
const isConnected = ChainController.state.activeCaipAddress
110+
if (!isConnected && this.socialProvider && !this.connecting) {
111+
EventsController.sendEvent({
112+
type: 'track',
113+
event: 'SOCIAL_LOGIN_CANCELED',
114+
properties: { provider: this.socialProvider }
115+
})
116+
}
117+
107118
this.socialWindow?.close()
108119
ChainController.setAccountProp('socialWindow', undefined, ChainController.state.activeChain)
109120
}
@@ -223,13 +234,6 @@ export class W3mConnectingSocialView extends LitElement {
223234
const interval = setInterval(() => {
224235
if (this.socialWindow?.closed) {
225236
if (!this.connecting && RouterController.state.view === 'ConnectingSocial') {
226-
if (this.socialProvider) {
227-
EventsController.sendEvent({
228-
type: 'track',
229-
event: 'SOCIAL_LOGIN_CANCELED',
230-
properties: { provider: this.socialProvider }
231-
})
232-
}
233237
RouterController.goBack()
234238
}
235239
clearInterval(interval)

0 commit comments

Comments
 (0)