Skip to content

Commit 5c16271

Browse files
committed
AXON-130: refactor login action message flow to include better error handling and analytic posting
1 parent 9fe90a5 commit 5c16271

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib/webview/controller/onboarding/onboardingWebviewController.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,23 @@ export class OnboardingWebviewController implements WebviewController<SectionCha
9595
}
9696
case OnboardingActionType.Login: {
9797
let isCloud = true;
98-
if (isBasicAuthInfo(msg.authInfo)) {
99-
isCloud = false;
100-
try {
98+
this._analytics.fireAuthenticateButtonEvent(id, msg.siteInfo, isCloud);
99+
try {
100+
if (isBasicAuthInfo(msg.authInfo)) {
101+
isCloud = false;
101102
await this._api.authenticateServer(msg.siteInfo, msg.authInfo);
102-
} catch (e) {
103-
const err = new Error(`Authentication error: ${e}`);
104-
this._logger.error(err);
105-
this.postMessage({
106-
type: CommonMessageType.Error,
107-
reason: formatError(e, 'Authentication error'),
108-
});
103+
} else {
104+
await this._api.authenticateCloud(msg.siteInfo, this._onboardingUrl);
109105
}
110-
} else {
111-
await this._api.authenticateCloud(msg.siteInfo, this._onboardingUrl);
106+
this.postMessage({ type: OnboardingMessageType.LoginResponse });
107+
} catch (e) {
108+
const env = isCloud ? 'cloud' : 'server';
109+
this._logger.error(new Error(`${env} onboarding authentication error: ${e}`));
110+
this.postMessage({
111+
type: CommonMessageType.Error,
112+
reason: formatError(e, `${env} onboarding authentication error`),
113+
});
112114
}
113-
this.postMessage({ type: OnboardingMessageType.LoginResponse });
114-
this._analytics.fireAuthenticateButtonEvent(id, msg.siteInfo, isCloud);
115115
break;
116116
}
117117
case OnboardingActionType.SaveSettings: {

0 commit comments

Comments
 (0)