Skip to content

Commit

Permalink
chore(core): track otp usage (#10248)
Browse files Browse the repository at this point in the history
close AF-2235
  • Loading branch information
forehalo committed Feb 18, 2025
1 parent cb15d48 commit cd00f06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const SignInWithEmailStep = ({
setIsVerifying(true);

try {
await authService.signInMagicLink(email, otp);
await authService.signInMagicLink(email, otp, false);
} catch (e) {
if (e instanceof BackendError) {
notify.error({
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/core/src/modules/cloud/services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export class AuthService extends Service {
}
}

async signInMagicLink(email: string, token: string) {
async signInMagicLink(email: string, token: string, byLink = true) {
const method = byLink ? 'magic-link' : 'otp';
try {
await this.fetchService.fetch('/api/auth/magic-link', {
method: 'POST',
Expand All @@ -120,10 +121,10 @@ export class AuthService extends Service {
});

this.session.revalidate();
track.$.$.auth.signedIn({ method: 'magic-link' });
track.$.$.auth.signedIn({ method });
} catch (e) {
track.$.$.auth.signInFail({
method: 'magic-link',
method,
reason: e instanceof BackendError ? e.originError.name : 'unknown',
});
throw e;
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/track/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ type SplitViewActionControlType = 'menu' | 'indicator';
type SplitViewActionType = 'open' | 'close' | 'move' | 'closeOthers';

type AuthArgs = {
method: 'password' | 'magic-link' | 'oauth';
method: 'password' | 'magic-link' | 'oauth' | 'otp';
provider?: string;
};

Expand Down

0 comments on commit cd00f06

Please sign in to comment.