fix(core): auth events are not continuous (#8874)
This commit is contained in:
@@ -2,6 +2,7 @@ import { Skeleton } from '@affine/component';
|
|||||||
import { Button } from '@affine/component/ui/button';
|
import { Button } from '@affine/component/ui/button';
|
||||||
import { UrlService } from '@affine/core/modules/url';
|
import { UrlService } from '@affine/core/modules/url';
|
||||||
import { OAuthProviderType } from '@affine/graphql';
|
import { OAuthProviderType } from '@affine/graphql';
|
||||||
|
import track from '@affine/track';
|
||||||
import { GithubIcon, GoogleDuotoneIcon } from '@blocksuite/icons/rc';
|
import { GithubIcon, GoogleDuotoneIcon } from '@blocksuite/icons/rc';
|
||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
import { type ReactElement, useCallback } from 'react';
|
import { type ReactElement, useCallback } from 'react';
|
||||||
@@ -86,6 +87,8 @@ function OAuthProvider({
|
|||||||
const oauthUrl =
|
const oauthUrl =
|
||||||
BUILD_CONFIG.serverUrlPrefix + `/oauth/login?${params.toString()}`;
|
BUILD_CONFIG.serverUrlPrefix + `/oauth/login?${params.toString()}`;
|
||||||
|
|
||||||
|
track.$.$.auth.signIn({ method: 'oauth', provider });
|
||||||
|
|
||||||
popupWindow(oauthUrl);
|
popupWindow(oauthUrl);
|
||||||
}, [popupWindow, provider, redirectUrl, scheme]);
|
}, [popupWindow, provider, redirectUrl, scheme]);
|
||||||
|
|
||||||
|
|||||||
@@ -255,9 +255,7 @@ export function setupTracker() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
AIProvider.slots.requestLogin.on(() => {
|
AIProvider.slots.requestLogin.on(() => {
|
||||||
track.$.$.auth.signIn({
|
track.doc.editor.aiActions.requestSignIn();
|
||||||
control: 'aiAction',
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AIProvider.slots.actions.on(event => {
|
AIProvider.slots.actions.on(event => {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const SignInItem = () => {
|
|||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
|
|
||||||
const onClickSignIn = useCallback(() => {
|
const onClickSignIn = useCallback(() => {
|
||||||
track.$.navigationPanel.workspaceList.signIn();
|
track.$.navigationPanel.workspaceList.requestSignIn();
|
||||||
setOpen(state => ({
|
setOpen(state => ({
|
||||||
...state,
|
...state,
|
||||||
openModal: true,
|
openModal: true,
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ export class AuthService extends Service {
|
|||||||
client: string,
|
client: string,
|
||||||
/** @deprecated*/ redirectUrl?: string
|
/** @deprecated*/ redirectUrl?: string
|
||||||
) {
|
) {
|
||||||
track.$.$.auth.signIn({ method: 'oauth', provider });
|
|
||||||
try {
|
try {
|
||||||
const res = await this.fetchService.fetch('/api/oauth/preflight', {
|
const res = await this.fetchService.fetch('/api/oauth/preflight', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -94,7 +94,12 @@ type ShareEvents =
|
|||||||
| 'copyShareLink'
|
| 'copyShareLink'
|
||||||
| 'openShareMenu'
|
| 'openShareMenu'
|
||||||
| 'share';
|
| 'share';
|
||||||
type AuthEvents = 'signIn' | 'signInFail' | 'signedIn' | 'signOut';
|
type AuthEvents =
|
||||||
|
| 'requestSignIn'
|
||||||
|
| 'signIn'
|
||||||
|
| 'signInFail'
|
||||||
|
| 'signedIn'
|
||||||
|
| 'signOut';
|
||||||
type AccountEvents = 'uploadAvatar' | 'removeAvatar' | 'updateUserName';
|
type AccountEvents = 'uploadAvatar' | 'removeAvatar' | 'updateUserName';
|
||||||
type PaymentEvents =
|
type PaymentEvents =
|
||||||
| 'viewPlans'
|
| 'viewPlans'
|
||||||
@@ -143,7 +148,7 @@ const PageEvents = {
|
|||||||
$: {
|
$: {
|
||||||
$: {
|
$: {
|
||||||
$: ['createWorkspace', 'checkout'],
|
$: ['createWorkspace', 'checkout'],
|
||||||
auth: ['signIn', 'signedIn', 'signInFail', 'signOut'],
|
auth: ['requestSignIn', 'signIn', 'signedIn', 'signInFail', 'signOut'],
|
||||||
},
|
},
|
||||||
sharePanel: {
|
sharePanel: {
|
||||||
$: ['createShareLink', 'copyShareLink', 'export', 'open'],
|
$: ['createShareLink', 'copyShareLink', 'export', 'open'],
|
||||||
@@ -220,8 +225,8 @@ const PageEvents = {
|
|||||||
others: ['navigate'],
|
others: ['navigate'],
|
||||||
importModal: ['open'],
|
importModal: ['open'],
|
||||||
workspaceList: [
|
workspaceList: [
|
||||||
|
'requestSignIn',
|
||||||
'open',
|
'open',
|
||||||
'signIn',
|
|
||||||
'createWorkspace',
|
'createWorkspace',
|
||||||
'createDoc',
|
'createDoc',
|
||||||
'openSettings',
|
'openSettings',
|
||||||
@@ -278,6 +283,7 @@ const PageEvents = {
|
|||||||
formatToolbar: ['bold'],
|
formatToolbar: ['bold'],
|
||||||
pageRef: ['navigate'],
|
pageRef: ['navigate'],
|
||||||
toolbar: ['copyBlockToLink'],
|
toolbar: ['copyBlockToLink'],
|
||||||
|
aiActions: ['requestSignIn'],
|
||||||
},
|
},
|
||||||
inlineDocInfo: {
|
inlineDocInfo: {
|
||||||
$: ['toggle'],
|
$: ['toggle'],
|
||||||
|
|||||||
Reference in New Issue
Block a user