Skip to content

Commit 5cefc39

Browse files
authored
Merge pull request #18973 from mozilla/fxa-11697
fix(metrics): Set flowId when user verifies totp session
2 parents f65041b + b9eb37f commit 5cefc39

6 files changed

Lines changed: 20 additions & 3 deletions

File tree

packages/fxa-auth-client/lib/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,7 @@ export default class AuthClient {
17661766
code: string,
17671767
options: {
17681768
service?: string;
1769+
metricsContext?: MetricsContext;
17691770
} = {},
17701771
headers?: Headers
17711772
) {

packages/fxa-auth-server/lib/routes/totp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ module.exports = (
491491
.required()
492492
.description(DESCRIPTION.codeTotp),
493493
service: validators.service,
494+
metricsContext: METRICS_CONTEXT_SCHEMA
494495
}),
495496
},
496497
response: {

packages/fxa-graphql-api/src/gql/account.resolver.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ export class AccountResolver {
199199
@Args('input', { type: () => VerifyTotpInput })
200200
input: VerifyTotpInput
201201
): Promise<VerifyTotpPayload> {
202+
const options = {
203+
service: input.service,
204+
metricsContext: input.metricsContext,
205+
};
202206
const result = await this.authAPI.verifyTotpCode(
203207
token,
204208
input.code,
205-
input.service ? { service: input.service } : undefined,
209+
options,
206210
headers
207211
);
208212
return {

packages/fxa-graphql-api/src/gql/dto/input/verify-totp.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
import { Field, InputType } from '@nestjs/graphql';
5+
import { MetricsContext } from './metrics-context';
56

67
@InputType()
78
export class VerifyTotpInput {
@@ -16,4 +17,7 @@ export class VerifyTotpInput {
1617

1718
@Field({ nullable: true })
1819
public service?: string;
20+
21+
@Field(() => MetricsContext, { nullable: true })
22+
public metricsContext?: MetricsContext;
1923
}

packages/fxa-settings/src/components/App/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ const AuthAndAccountSetupRoutes = ({
522522
/>
523523
<SigninTotpCodeContainer
524524
path="/signin_totp_code/*"
525-
{...{ integration, serviceName }}
525+
{...{ integration, serviceName, flowQueryParams }}
526526
/>
527527
<SigninPushCodeContainer
528528
path="/signin_push_code/*"

packages/fxa-settings/src/pages/Signin/SigninTotpCode/container.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ import {
4343
import { tryFinalizeUpgrade } from '../../../lib/gql-key-stretch-upgrade';
4444
import { AuthUiErrors } from '../../../lib/auth-errors/auth-errors';
4545
import { useNavigateWithQuery } from '../../../lib/hooks/useNavigateWithQuery';
46+
import { queryParamsToMetricsContext } from '../../../lib/metrics';
47+
import { searchParams } from '../../../lib/utilities';
48+
import { QueryParams } from '../../../index';
4649

4750
export type SigninTotpCodeContainerProps = {
4851
integration: Integration;
4952
serviceName: MozServices;
53+
flowQueryParams?: QueryParams;
5054
};
5155

5256
export const SigninTotpCodeContainer = ({
5357
integration,
54-
serviceName,
58+
serviceName, flowQueryParams
5559
}: SigninTotpCodeContainerProps & RouteComponentProps) => {
5660
const authClient = useAuthClient();
5761
const { finishOAuthFlowHandler, oAuthDataError } = useFinishOAuthFlowHandler(
@@ -105,6 +109,9 @@ export const SigninTotpCodeContainer = ({
105109
input: {
106110
code,
107111
service,
112+
metricsContext: queryParamsToMetricsContext(
113+
flowQueryParams as ReturnType<typeof searchParams>
114+
)
108115
},
109116
},
110117
update: (cache, { data }) => {

0 commit comments

Comments
 (0)