Instrument signup (#8037)
This commit is contained in:
+25
-10
@@ -1,7 +1,6 @@
|
||||
import React from 'react'
|
||||
import {AtpSessionEvent, BskyAgent} from '@atproto/api'
|
||||
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
|
||||
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {isWeb} from '#/platform/detection'
|
||||
import * as persisted from '#/state/persisted'
|
||||
import {useCloseAllActiveElements} from '#/state/util'
|
||||
@@ -9,7 +8,7 @@ import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
||||
import {emitSessionDropped} from '../events'
|
||||
import {
|
||||
agentToSessionAccount,
|
||||
BskyAppAgent,
|
||||
type BskyAppAgent,
|
||||
createAgentAndCreateAccount,
|
||||
createAgentAndLogin,
|
||||
createAgentAndResume,
|
||||
@@ -20,7 +19,11 @@ import {getInitialState, reducer} from './reducer'
|
||||
export {isSignupQueued} from './util'
|
||||
import {addSessionDebugLog} from './logging'
|
||||
export type {SessionAccount} from '#/state/session/types'
|
||||
import {SessionApiContext, SessionStateContext} from '#/state/session/types'
|
||||
import {logger} from '#/logger'
|
||||
import {
|
||||
type SessionApiContext,
|
||||
type SessionStateContext,
|
||||
} from '#/state/session/types'
|
||||
|
||||
const StateContext = React.createContext<SessionStateContext>({
|
||||
accounts: [],
|
||||
@@ -65,10 +68,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
)
|
||||
|
||||
const createAccount = React.useCallback<SessionApiContext['createAccount']>(
|
||||
async params => {
|
||||
async (params, metrics) => {
|
||||
addSessionDebugLog({type: 'method:start', method: 'createAccount'})
|
||||
const signal = cancelPendingTask()
|
||||
logEvent('account:create:begin', {})
|
||||
logger.metric('account:create:begin', {}, {statsig: true})
|
||||
const {agent, account} = await createAgentAndCreateAccount(
|
||||
params,
|
||||
onAgentSessionChange,
|
||||
@@ -82,7 +85,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
newAgent: agent,
|
||||
newAccount: account,
|
||||
})
|
||||
logEvent('account:create:success', {})
|
||||
logger.metric('account:create:success', metrics, {statsig: true})
|
||||
addSessionDebugLog({type: 'method:end', method: 'createAccount', account})
|
||||
},
|
||||
[onAgentSessionChange, cancelPendingTask],
|
||||
@@ -105,7 +108,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
newAgent: agent,
|
||||
newAccount: account,
|
||||
})
|
||||
logEvent('account:loggedIn', {logContext, withPassword: true})
|
||||
logger.metric(
|
||||
'account:loggedIn',
|
||||
{logContext, withPassword: true},
|
||||
{statsig: true},
|
||||
)
|
||||
addSessionDebugLog({type: 'method:end', method: 'login', account})
|
||||
},
|
||||
[onAgentSessionChange, cancelPendingTask],
|
||||
@@ -120,7 +127,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
dispatch({
|
||||
type: 'logged-out-current-account',
|
||||
})
|
||||
logEvent('account:loggedOut', {logContext, scope: 'current'})
|
||||
logger.metric(
|
||||
'account:loggedOut',
|
||||
{logContext, scope: 'current'},
|
||||
{statsig: true},
|
||||
)
|
||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||
},
|
||||
[cancelPendingTask],
|
||||
@@ -135,7 +146,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
dispatch({
|
||||
type: 'logged-out-every-account',
|
||||
})
|
||||
logEvent('account:loggedOut', {logContext, scope: 'every'})
|
||||
logger.metric(
|
||||
'account:loggedOut',
|
||||
{logContext, scope: 'every'},
|
||||
{statsig: true},
|
||||
)
|
||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||
},
|
||||
[cancelPendingTask],
|
||||
|
||||
+13
-10
@@ -10,16 +10,19 @@ export type SessionStateContext = {
|
||||
}
|
||||
|
||||
export type SessionApiContext = {
|
||||
createAccount: (props: {
|
||||
service: string
|
||||
email: string
|
||||
password: string
|
||||
handle: string
|
||||
birthDate: Date
|
||||
inviteCode?: string
|
||||
verificationPhone?: string
|
||||
verificationCode?: string
|
||||
}) => Promise<void>
|
||||
createAccount: (
|
||||
props: {
|
||||
service: string
|
||||
email: string
|
||||
password: string
|
||||
handle: string
|
||||
birthDate: Date
|
||||
inviteCode?: string
|
||||
verificationPhone?: string
|
||||
verificationCode?: string
|
||||
},
|
||||
metrics: LogEvents['account:create:success'],
|
||||
) => Promise<void>
|
||||
login: (
|
||||
props: {
|
||||
service: string
|
||||
|
||||
Reference in New Issue
Block a user