From 8a54136b3a99bbc9414ff5dda90339ae4621887a Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Wed, 17 Apr 2024 21:38:30 +0800 Subject: [PATCH] refactor(console): remove AppInsights --- packages/console/jest.config.ts | 1 - packages/console/package.json | 1 - packages/console/src/App.tsx | 42 ++++++++----------- .../console/src/components/PageMeta/index.tsx | 17 +------- .../src/containers/ConsoleRoutes/index.tsx | 3 -- .../console/src/hooks/use-track-user-id.ts | 42 ------------------- packages/console/src/onboarding/index.tsx | 21 ++++------ .../pages/SignInExperience/index.tsx | 3 +- .../src/onboarding/pages/Welcome/index.tsx | 3 +- .../src/pages/ApiResourceDetails/index.tsx | 3 +- .../console/src/pages/ApiResources/index.tsx | 3 +- .../src/pages/ApplicationDetails/index.tsx | 3 +- .../console/src/pages/Applications/index.tsx | 3 +- .../src/pages/AuditLogDetails/index.tsx | 3 +- .../console/src/pages/AuditLogs/index.tsx | 4 +- .../src/pages/ConnectorDetails/index.tsx | 3 +- .../console/src/pages/Connectors/index.tsx | 3 +- .../console/src/pages/CustomizeJwt/index.tsx | 3 +- .../src/pages/CustomizeJwtDetails/index.tsx | 9 ++-- .../console/src/pages/Dashboard/index.tsx | 3 +- .../console/src/pages/EnterpriseSso/index.tsx | 5 +-- .../src/pages/EnterpriseSsoDetails/index.tsx | 5 +-- .../console/src/pages/GetStarted/index.tsx | 3 +- packages/console/src/pages/Mfa/index.tsx | 3 +- packages/console/src/pages/NotFound/index.tsx | 4 +- .../pages/OrganizationRoleDetails/index.tsx | 3 +- .../src/pages/OrganizationTemplate/index.tsx | 3 +- packages/console/src/pages/Profile/index.tsx | 3 +- .../console/src/pages/RoleDetails/index.tsx | 3 +- packages/console/src/pages/Roles/index.tsx | 3 +- .../src/pages/SignInExperience/index.tsx | 3 +- .../console/src/pages/SigningKeys/index.tsx | 3 +- .../TenantSettings/BillingHistory/index.tsx | 3 +- .../TenantSettings/Subscription/index.tsx | 3 +- .../TenantDomainSettings/index.tsx | 3 +- .../console/src/pages/UserDetails/index.tsx | 3 +- packages/console/src/pages/Users/index.tsx | 3 +- .../src/pages/WebhookDetails/index.tsx | 3 +- packages/console/src/pages/Webhooks/index.tsx | 3 +- pnpm-lock.yaml | 5 +-- 40 files changed, 65 insertions(+), 175 deletions(-) delete mode 100644 packages/console/src/hooks/use-track-user-id.ts diff --git a/packages/console/jest.config.ts b/packages/console/jest.config.ts index 2b732771d..f1895b939 100644 --- a/packages/console/jest.config.ts +++ b/packages/console/jest.config.ts @@ -23,7 +23,6 @@ const config: Config.InitialOptions = { }, moduleNameMapper: { '^@/(.*)$': '/src/$1', - '^@logto/app-insights/(.*)$': '/../app-insights/lib/$1', '^@logto/shared/(.*)$': '/../shared/lib/$1', '\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', }, diff --git a/packages/console/package.json b/packages/console/package.json index 54b901769..117561402 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -27,7 +27,6 @@ "devDependencies": { "@fontsource/roboto-mono": "^5.0.0", "@jest/types": "^29.5.0", - "@logto/app-insights": "workspace:^1.4.0", "@logto/cloud": "0.2.5-821690c", "@logto/connector-kit": "workspace:^3.0.0", "@logto/core-kit": "workspace:^2.4.0", diff --git a/packages/console/src/App.tsx b/packages/console/src/App.tsx index 451560e44..e211dd52a 100644 --- a/packages/console/src/App.tsx +++ b/packages/console/src/App.tsx @@ -1,4 +1,3 @@ -import { AppInsightsBoundary } from '@logto/app-insights/react'; import { UserScope } from '@logto/core-kit'; import { LogtoProvider, Prompt, useLogto } from '@logto/react'; import { @@ -23,7 +22,6 @@ import AppLoading from '@/components/AppLoading'; import { isCloud } from '@/consts/env'; import { cloudApi, getManagementApi, meApi } from '@/consts/resources'; import { ConsoleRoutes } from '@/containers/ConsoleRoutes'; -import useTrackUserId from '@/hooks/use-track-user-id'; import { OnboardingRoutes } from '@/onboarding'; import useUserOnboardingData from '@/onboarding/hooks/use-user-onboarding-data'; @@ -114,26 +112,24 @@ function Providers() { }} > - - - - - {/** - * If it's not Cloud (OSS), render the tenant app container directly since only default tenant is available; - * if it's Cloud, render the tenant app container only when a tenant ID is available (in a tenant context). - */} - {!isCloud || currentTenantId ? ( - - - - - - ) : ( - - )} - - - + + + + {/** + * If it's not Cloud (OSS), render the tenant app container directly since only default tenant is available; + * if it's Cloud, render the tenant app container only when a tenant ID is available (in a tenant context). + */} + {!isCloud || currentTenantId ? ( + + + + + + ) : ( + + )} + + ); @@ -146,8 +142,6 @@ function AppRoutes() { const { isOnboarding } = useUserOnboardingData(); const { isAuthenticated } = useLogto(); - useTrackUserId(); - // Authenticated user should load onboarding data before rendering the app. // This looks weird and it will be refactored soon by merging the onboarding // routes with the console routes. diff --git a/packages/console/src/components/PageMeta/index.tsx b/packages/console/src/components/PageMeta/index.tsx index 3818d74d1..f7d6ebe65 100644 --- a/packages/console/src/components/PageMeta/index.tsx +++ b/packages/console/src/components/PageMeta/index.tsx @@ -1,31 +1,16 @@ -import { AppInsightsContext } from '@logto/app-insights/react'; import type { AdminConsoleKey } from '@logto/phrases'; -import { useContext, useEffect, useState } from 'react'; import { Helmet } from 'react-helmet'; import { useTranslation } from 'react-i18next'; export type Props = { titleKey: AdminConsoleKey | AdminConsoleKey[]; - // eslint-disable-next-line react/boolean-prop-naming - trackPageView?: boolean; }; -function PageMeta({ titleKey, trackPageView = true }: Props) { +function PageMeta({ titleKey }: Props) { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); - const { isSetupFinished, appInsights } = useContext(AppInsightsContext); - const [pageViewTracked, setPageViewTracked] = useState(false); const keys = typeof titleKey === 'string' ? [titleKey] : titleKey; - const rawTitle = keys.map((key) => t(key, { lng: 'en' })).join(' - '); const title = keys.map((key) => t(key)).join(' - '); - useEffect(() => { - // Only track once for the same page - if (isSetupFinished && trackPageView && !pageViewTracked) { - appInsights.trackPageView?.({ name: `Console: ${rawTitle}` }); - setPageViewTracked(true); - } - }, [appInsights, isSetupFinished, pageViewTracked, rawTitle, trackPageView]); - return ; } diff --git a/packages/console/src/containers/ConsoleRoutes/index.tsx b/packages/console/src/containers/ConsoleRoutes/index.tsx index ec49548bc..9dbb4d7df 100644 --- a/packages/console/src/containers/ConsoleRoutes/index.tsx +++ b/packages/console/src/containers/ConsoleRoutes/index.tsx @@ -1,5 +1,3 @@ -import { Component, GeneralEvent } from '@logto/app-insights/custom-event'; -import { TrackOnce } from '@logto/app-insights/react'; import { ossConsolePath } from '@logto/schemas'; import { Navigate, Outlet, Route, Routes } from 'react-router-dom'; import { SWRConfig } from 'swr'; @@ -25,7 +23,6 @@ function Layout() { return ( - diff --git a/packages/console/src/hooks/use-track-user-id.ts b/packages/console/src/hooks/use-track-user-id.ts deleted file mode 100644 index 35f4eca84..000000000 --- a/packages/console/src/hooks/use-track-user-id.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { AppInsightsContext } from '@logto/app-insights/react'; -import { useLogto } from '@logto/react'; -import { trySafe } from '@silverhand/essentials'; -import { useContext, useEffect } from 'react'; - -class NoIdTokenClaimsError extends Error { - name = 'NoIdTokenClaimsError'; - message = 'Cloud not fetch ID Token claims where user is authenticated.'; -} - -const useTrackUserId = () => { - const { isAuthenticated, getIdTokenClaims } = useLogto(); - const { isSetupFinished, appInsights } = useContext(AppInsightsContext); - - useEffect(() => { - const setUserId = async () => { - if (!appInsights.instance) { - return; - } - - if (!isAuthenticated) { - appInsights.instance.clearAuthenticatedUserContext(); - - return; - } - - const claims = await trySafe(getIdTokenClaims()); - - if (claims) { - appInsights.instance.setAuthenticatedUserContext(claims.sub, claims.sub, true); - } else { - appInsights.instance.trackException({ exception: new NoIdTokenClaimsError() }); - } - }; - - if (isSetupFinished) { - void setUserId(); - } - }, [getIdTokenClaims, isSetupFinished, isAuthenticated, appInsights.instance]); -}; - -export default useTrackUserId; diff --git a/packages/console/src/onboarding/index.tsx b/packages/console/src/onboarding/index.tsx index 4f3bf45c9..a5f5833d1 100644 --- a/packages/console/src/onboarding/index.tsx +++ b/packages/console/src/onboarding/index.tsx @@ -1,5 +1,3 @@ -import { Component, ConsoleEvent } from '@logto/app-insights/custom-event'; -import { TrackOnce } from '@logto/app-insights/react'; import { Theme } from '@logto/schemas'; import { useContext, useEffect } from 'react'; import { Route, Navigate, Outlet, Routes } from 'react-router-dom'; @@ -64,17 +62,14 @@ function Layout() { } return ( - <> - -
- - - - - - -
- +
+ + + + + + +
); } diff --git a/packages/console/src/onboarding/pages/SignInExperience/index.tsx b/packages/console/src/onboarding/pages/SignInExperience/index.tsx index 7e6e14b11..04539f8a0 100644 --- a/packages/console/src/onboarding/pages/SignInExperience/index.tsx +++ b/packages/console/src/onboarding/pages/SignInExperience/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { ConnectorType, ServiceConnector } from '@logto/connector-kit'; import { SignInIdentifier } from '@logto/schemas'; import type { SignInExperience as SignInExperienceType, ConnectorResponse } from '@logto/schemas'; @@ -250,4 +249,4 @@ function SignInExperience() { ); } -export default withAppInsights(SignInExperience); +export default SignInExperience; diff --git a/packages/console/src/onboarding/pages/Welcome/index.tsx b/packages/console/src/onboarding/pages/Welcome/index.tsx index 205f743e5..6c1ab69ac 100644 --- a/packages/console/src/onboarding/pages/Welcome/index.tsx +++ b/packages/console/src/onboarding/pages/Welcome/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type Questionnaire, Project } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import { useEffect } from 'react'; @@ -130,4 +129,4 @@ function Welcome() { ); } -export default withAppInsights(Welcome); +export default Welcome; diff --git a/packages/console/src/pages/ApiResourceDetails/index.tsx b/packages/console/src/pages/ApiResourceDetails/index.tsx index 7635a3fa1..5e6972171 100644 --- a/packages/console/src/pages/ApiResourceDetails/index.tsx +++ b/packages/console/src/pages/ApiResourceDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { Resource } from '@logto/schemas'; import { isManagementApi, Theme } from '@logto/schemas'; import { conditionalArray } from '@silverhand/essentials'; @@ -193,4 +192,4 @@ function ApiResourceDetails() { ); } -export default withAppInsights(ApiResourceDetails); +export default ApiResourceDetails; diff --git a/packages/console/src/pages/ApiResources/index.tsx b/packages/console/src/pages/ApiResources/index.tsx index 86b65966e..ec680119c 100644 --- a/packages/console/src/pages/ApiResources/index.tsx +++ b/packages/console/src/pages/ApiResources/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { Resource } from '@logto/schemas'; import { Theme, isManagementApi } from '@logto/schemas'; import { useTranslation } from 'react-i18next'; @@ -146,4 +145,4 @@ function ApiResources() { ); } -export default withAppInsights(ApiResources); +export default ApiResources; diff --git a/packages/console/src/pages/ApplicationDetails/index.tsx b/packages/console/src/pages/ApplicationDetails/index.tsx index 8d8974bba..14f6a1e53 100644 --- a/packages/console/src/pages/ApplicationDetails/index.tsx +++ b/packages/console/src/pages/ApplicationDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type ApplicationResponse, type SnakeCaseOidcConfig } from '@logto/schemas'; import { useParams } from 'react-router-dom'; import useSWR from 'swr'; @@ -65,4 +64,4 @@ function ApplicationDetails() { ); } -export default withAppInsights(ApplicationDetails); +export default ApplicationDetails; diff --git a/packages/console/src/pages/Applications/index.tsx b/packages/console/src/pages/Applications/index.tsx index 720c1cb66..64e8a5ee1 100644 --- a/packages/console/src/pages/Applications/index.tsx +++ b/packages/console/src/pages/Applications/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { joinPath } from '@silverhand/essentials'; import { useTranslation } from 'react-i18next'; import { useLocation } from 'react-router-dom'; @@ -185,4 +184,4 @@ function Applications({ tab }: Props) { ); } -export default withAppInsights(Applications); +export default Applications; diff --git a/packages/console/src/pages/AuditLogDetails/index.tsx b/packages/console/src/pages/AuditLogDetails/index.tsx index b14406e33..8789187b6 100644 --- a/packages/console/src/pages/AuditLogDetails/index.tsx +++ b/packages/console/src/pages/AuditLogDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { Application, User, Log, Hook } from '@logto/schemas'; import { demoAppApplicationId } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; @@ -161,4 +160,4 @@ function AuditLogDetails() { ); } -export default withAppInsights(AuditLogDetails); +export default AuditLogDetails; diff --git a/packages/console/src/pages/AuditLogs/index.tsx b/packages/console/src/pages/AuditLogs/index.tsx index 20268c90a..f56857c64 100644 --- a/packages/console/src/pages/AuditLogs/index.tsx +++ b/packages/console/src/pages/AuditLogs/index.tsx @@ -1,5 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; - import AuditLogTable from '@/components/AuditLogTable'; import PageMeta from '@/components/PageMeta'; import CardTitle from '@/ds-components/CardTitle'; @@ -17,4 +15,4 @@ function AuditLogs() { ); } -export default withAppInsights(AuditLogs); +export default AuditLogs; diff --git a/packages/console/src/pages/ConnectorDetails/index.tsx b/packages/console/src/pages/ConnectorDetails/index.tsx index d7aae4de6..63647d569 100644 --- a/packages/console/src/pages/ConnectorDetails/index.tsx +++ b/packages/console/src/pages/ConnectorDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { ServiceConnector } from '@logto/connector-kit'; import { ConnectorType } from '@logto/schemas'; import type { ConnectorFactoryResponse, ConnectorResponse } from '@logto/schemas'; @@ -232,4 +231,4 @@ function ConnectorDetails() { ); } -export default withAppInsights(ConnectorDetails); +export default ConnectorDetails; diff --git a/packages/console/src/pages/Connectors/index.tsx b/packages/console/src/pages/Connectors/index.tsx index 8d9fa9903..fab02b798 100644 --- a/packages/console/src/pages/Connectors/index.tsx +++ b/packages/console/src/pages/Connectors/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { ServiceConnector } from '@logto/connector-kit'; import { ConnectorType } from '@logto/schemas'; import type { ConnectorFactoryResponse } from '@logto/schemas'; @@ -243,4 +242,4 @@ function Connectors() { ); } -export default withAppInsights(Connectors); +export default Connectors; diff --git a/packages/console/src/pages/CustomizeJwt/index.tsx b/packages/console/src/pages/CustomizeJwt/index.tsx index e088c23ca..3377fc842 100644 --- a/packages/console/src/pages/CustomizeJwt/index.tsx +++ b/packages/console/src/pages/CustomizeJwt/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { LogtoJwtTokenKeyType } from '@logto/schemas'; import { useTranslation } from 'react-i18next'; @@ -64,4 +63,4 @@ function CustomizeJwt() { ); } -export default withAppInsights(CustomizeJwt); +export default CustomizeJwt; diff --git a/packages/console/src/pages/CustomizeJwtDetails/index.tsx b/packages/console/src/pages/CustomizeJwtDetails/index.tsx index 09421f3ea..850f427b7 100644 --- a/packages/console/src/pages/CustomizeJwtDetails/index.tsx +++ b/packages/console/src/pages/CustomizeJwtDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { type LogtoJwtTokenKeyType } from '@logto/schemas'; import { useMemo, useState } from 'react'; import { useParams } from 'react-router-dom'; @@ -18,7 +17,7 @@ type Props = { action: Action; }; -function CustomizeJwtDetails({ tokenType, action }: Props) { +function Content({ tokenType, action }: Props) { const { isLoading, error, ...rest } = useDataFetch(tokenType, action); const [isMonacoLoaded, setIsMonacoLoaded] = useState(false); @@ -51,7 +50,7 @@ function CustomizeJwtDetails({ tokenType, action }: Props) { } // Guard the parameters to ensure they are valid -function CustomizeJwtDetailsWrapper() { +function CustomizeJwtDetails() { const { tokenType, action } = useParams(); const params = pageParamsGuard.safeParse({ tokenType, action }); @@ -60,7 +59,7 @@ function CustomizeJwtDetailsWrapper() { return ; } - return ; + return ; } -export default withAppInsights(CustomizeJwtDetailsWrapper); +export default CustomizeJwtDetails; diff --git a/packages/console/src/pages/Dashboard/index.tsx b/packages/console/src/pages/Dashboard/index.tsx index e36c8765c..a0a1a30d9 100644 --- a/packages/console/src/pages/Dashboard/index.tsx +++ b/packages/console/src/pages/Dashboard/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { format } from 'date-fns'; import type { ChangeEventHandler } from 'react'; import { useState } from 'react'; @@ -153,4 +152,4 @@ function Dashboard() { ); } -export default withAppInsights(Dashboard); +export default Dashboard; diff --git a/packages/console/src/pages/EnterpriseSso/index.tsx b/packages/console/src/pages/EnterpriseSso/index.tsx index 9dbcff09c..74d78056a 100644 --- a/packages/console/src/pages/EnterpriseSso/index.tsx +++ b/packages/console/src/pages/EnterpriseSso/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type SsoConnectorWithProviderConfig, ReservedPlanId } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import { useContext } from 'react'; @@ -32,7 +31,7 @@ const enterpriseSsoPathname = '/enterprise-sso'; const createEnterpriseSsoPathname = `${enterpriseSsoPathname}/create`; const buildDetailsPathname = (id: string) => `${enterpriseSsoPathname}/${id}`; -function EnterpriseSsoConnectors() { +function EnterpriseSso() { const { pathname } = useLocation(); const { navigate } = useTenantPathname(); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); @@ -176,4 +175,4 @@ function EnterpriseSsoConnectors() { ); } -export default withAppInsights(EnterpriseSsoConnectors); +export default EnterpriseSso; diff --git a/packages/console/src/pages/EnterpriseSsoDetails/index.tsx b/packages/console/src/pages/EnterpriseSsoDetails/index.tsx index 9351609be..9f69ecf66 100644 --- a/packages/console/src/pages/EnterpriseSsoDetails/index.tsx +++ b/packages/console/src/pages/EnterpriseSsoDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type SignInExperience, type SsoConnectorWithProviderConfig } from '@logto/schemas'; import { pick } from '@silverhand/essentials'; import { useEffect, useState } from 'react'; @@ -31,7 +30,7 @@ import useDeleteConnector from './use-delete-connector'; const getSsoConnectorDetailsPathname = (ssoConnectorId: string, tab: EnterpriseSsoDetailsTabs) => `${enterpriseSsoPathname}/${ssoConnectorId}/${tab}`; -function EnterpriseSsoConnectorDetails() { +function EnterpriseSsoDetails() { const { pathname } = useLocation(); const { ssoConnectorId, tab } = useParams(); @@ -175,4 +174,4 @@ function EnterpriseSsoConnectorDetails() { ); } -export default withAppInsights(EnterpriseSsoConnectorDetails); +export default EnterpriseSsoDetails; diff --git a/packages/console/src/pages/GetStarted/index.tsx b/packages/console/src/pages/GetStarted/index.tsx index 7f6c083ad..50bccdb42 100644 --- a/packages/console/src/pages/GetStarted/index.tsx +++ b/packages/console/src/pages/GetStarted/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { Theme, type Application, type Resource } from '@logto/schemas'; import classNames from 'classnames'; import { useCallback, useContext, useMemo, useRef, useState } from 'react'; @@ -208,4 +207,4 @@ function GetStarted() { ); } -export default withAppInsights(GetStarted); +export default GetStarted; diff --git a/packages/console/src/pages/Mfa/index.tsx b/packages/console/src/pages/Mfa/index.tsx index 45cc18c4c..457631a5e 100644 --- a/packages/console/src/pages/Mfa/index.tsx +++ b/packages/console/src/pages/Mfa/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { type SignInExperience } from '@logto/schemas'; import useSWR from 'swr'; @@ -44,4 +43,4 @@ function Mfa() { ); } -export default withAppInsights(Mfa); +export default Mfa; diff --git a/packages/console/src/pages/NotFound/index.tsx b/packages/console/src/pages/NotFound/index.tsx index c574e6201..2d102d21a 100644 --- a/packages/console/src/pages/NotFound/index.tsx +++ b/packages/console/src/pages/NotFound/index.tsx @@ -1,7 +1,6 @@ import { Theme } from '@logto/schemas'; import classNames from 'classnames'; import { useTranslation } from 'react-i18next'; -import { useLocation } from 'react-router-dom'; import NotFoundDarkImage from '@/assets/images/not-found-dark.svg'; import NotFoundImage from '@/assets/images/not-found.svg'; @@ -18,12 +17,11 @@ type Props = { function NotFound({ className }: Props) { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const theme = useTheme(); - const location = useLocation(); return (
{/* Don't track "not found" for the root path as it will be redirected. */} - + {theme === Theme.Light ? : }
{t('errors.page_not_found')}
diff --git a/packages/console/src/pages/OrganizationRoleDetails/index.tsx b/packages/console/src/pages/OrganizationRoleDetails/index.tsx index e4f9f2e76..835119814 100644 --- a/packages/console/src/pages/OrganizationRoleDetails/index.tsx +++ b/packages/console/src/pages/OrganizationRoleDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { type OrganizationRole } from '@logto/schemas'; import classNames from 'classnames'; import { useEffect, useState } from 'react'; @@ -133,4 +132,4 @@ function OrganizationRoleDetails() { ); } -export default withAppInsights(OrganizationRoleDetails); +export default OrganizationRoleDetails; diff --git a/packages/console/src/pages/OrganizationTemplate/index.tsx b/packages/console/src/pages/OrganizationTemplate/index.tsx index 01c840844..8ff02d032 100644 --- a/packages/console/src/pages/OrganizationTemplate/index.tsx +++ b/packages/console/src/pages/OrganizationTemplate/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { ReservedPlanId } from '@logto/schemas'; import { cond } from '@silverhand/essentials'; import classNames from 'classnames'; @@ -111,4 +110,4 @@ function OrganizationTemplate() { ); } -export default withAppInsights(OrganizationTemplate); +export default OrganizationTemplate; diff --git a/packages/console/src/pages/Profile/index.tsx b/packages/console/src/pages/Profile/index.tsx index ad84e5980..afc6d451d 100644 --- a/packages/console/src/pages/Profile/index.tsx +++ b/packages/console/src/pages/Profile/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { ConnectorResponse } from '@logto/schemas'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -99,4 +98,4 @@ function Profile() { ); } -export default withAppInsights(Profile); +export default Profile; diff --git a/packages/console/src/pages/RoleDetails/index.tsx b/packages/console/src/pages/RoleDetails/index.tsx index 9ec727495..4cba0d186 100644 --- a/packages/console/src/pages/RoleDetails/index.tsx +++ b/packages/console/src/pages/RoleDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { Role } from '@logto/schemas'; import { Theme, RoleType } from '@logto/schemas'; import classNames from 'classnames'; @@ -151,4 +150,4 @@ function RoleDetails() { ); } -export default withAppInsights(RoleDetails); +export default RoleDetails; diff --git a/packages/console/src/pages/Roles/index.tsx b/packages/console/src/pages/Roles/index.tsx index 2a3072ee7..172f8d52e 100644 --- a/packages/console/src/pages/Roles/index.tsx +++ b/packages/console/src/pages/Roles/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { RoleType, type RoleResponse } from '@logto/schemas'; import { Theme } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; @@ -211,4 +210,4 @@ function Roles() { ); } -export default withAppInsights(Roles); +export default Roles; diff --git a/packages/console/src/pages/SignInExperience/index.tsx b/packages/console/src/pages/SignInExperience/index.tsx index 589f97e10..213313f18 100644 --- a/packages/console/src/pages/SignInExperience/index.tsx +++ b/packages/console/src/pages/SignInExperience/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { SignInExperience as SignInExperienceType } from '@logto/schemas'; import type { ReactNode } from 'react'; import useSWR from 'swr'; @@ -101,4 +100,4 @@ function SignInExperience() { ); } -export default withAppInsights(SignInExperience); +export default SignInExperience; diff --git a/packages/console/src/pages/SigningKeys/index.tsx b/packages/console/src/pages/SigningKeys/index.tsx index f2f3aaba3..f90263134 100644 --- a/packages/console/src/pages/SigningKeys/index.tsx +++ b/packages/console/src/pages/SigningKeys/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact'; import { LogtoOidcConfigKeyType } from '@logto/schemas'; import PageMeta from '@/components/PageMeta'; @@ -27,4 +26,4 @@ function SigningKeys() { ); } -export default withAppInsights(SigningKeys); +export default SigningKeys; diff --git a/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx b/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx index 16c8dfea6..4ed312ae3 100644 --- a/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx +++ b/packages/console/src/pages/TenantSettings/BillingHistory/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { conditional } from '@silverhand/essentials'; import dayjs from 'dayjs'; import { useCallback, useContext, useMemo } from 'react'; @@ -92,4 +91,4 @@ function BillingHistory() { ); } -export default withAppInsights(BillingHistory); +export default BillingHistory; diff --git a/packages/console/src/pages/TenantSettings/Subscription/index.tsx b/packages/console/src/pages/TenantSettings/Subscription/index.tsx index 578eb6449..69bb11865 100644 --- a/packages/console/src/pages/TenantSettings/Subscription/index.tsx +++ b/packages/console/src/pages/TenantSettings/Subscription/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { useContext } from 'react'; import PageMeta from '@/components/PageMeta'; @@ -61,4 +60,4 @@ function Subscription() { ); } -export default withAppInsights(Subscription); +export default Subscription; diff --git a/packages/console/src/pages/TenantSettings/TenantDomainSettings/index.tsx b/packages/console/src/pages/TenantSettings/TenantDomainSettings/index.tsx index b573021ac..d234ed13f 100644 --- a/packages/console/src/pages/TenantSettings/TenantDomainSettings/index.tsx +++ b/packages/console/src/pages/TenantSettings/TenantDomainSettings/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type Domain, DomainStatus } from '@logto/schemas'; import { Trans, useTranslation } from 'react-i18next'; @@ -92,4 +91,4 @@ function TenantDomainSettings() { ); } -export default withAppInsights(TenantDomainSettings); +export default TenantDomainSettings; diff --git a/packages/console/src/pages/UserDetails/index.tsx b/packages/console/src/pages/UserDetails/index.tsx index 22383a8b6..8a7bc0d59 100644 --- a/packages/console/src/pages/UserDetails/index.tsx +++ b/packages/console/src/pages/UserDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { UserProfileResponse, User } from '@logto/schemas'; import classNames from 'classnames'; import { useEffect, useState } from 'react'; @@ -235,4 +234,4 @@ function UserDetails() { ); } -export default withAppInsights(UserDetails); +export default UserDetails; diff --git a/packages/console/src/pages/Users/index.tsx b/packages/console/src/pages/Users/index.tsx index d35ffef16..5d7803ac1 100644 --- a/packages/console/src/pages/Users/index.tsx +++ b/packages/console/src/pages/Users/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import type { User } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import { useTranslation } from 'react-i18next'; @@ -177,4 +176,4 @@ function Users() { ); } -export default withAppInsights(Users); +export default Users; diff --git a/packages/console/src/pages/WebhookDetails/index.tsx b/packages/console/src/pages/WebhookDetails/index.tsx index bab502a8b..52771e37f 100644 --- a/packages/console/src/pages/WebhookDetails/index.tsx +++ b/packages/console/src/pages/WebhookDetails/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type HookResponse, type Hook } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import classNames from 'classnames'; @@ -176,4 +175,4 @@ function WebhookDetails() { ); } -export default withAppInsights(WebhookDetails); +export default WebhookDetails; diff --git a/packages/console/src/pages/Webhooks/index.tsx b/packages/console/src/pages/Webhooks/index.tsx index 8be1c1877..e7e881c9c 100644 --- a/packages/console/src/pages/Webhooks/index.tsx +++ b/packages/console/src/pages/Webhooks/index.tsx @@ -1,4 +1,3 @@ -import { withAppInsights } from '@logto/app-insights/react'; import { type HookEvent, type Hook, Theme, type HookResponse } from '@logto/schemas'; import { conditional } from '@silverhand/essentials'; import { toast } from 'react-hot-toast'; @@ -181,4 +180,4 @@ function Webhooks() { ); } -export default withAppInsights(Webhooks); +export default Webhooks; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9796db70c..ecb2191c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2711,9 +2711,6 @@ importers: '@jest/types': specifier: ^29.5.0 version: 29.5.0 - '@logto/app-insights': - specifier: workspace:^1.4.0 - version: link:../app-insights '@logto/cloud': specifier: 0.2.5-821690c version: 0.2.5-821690c(zod@3.22.4) @@ -10589,7 +10586,7 @@ packages: strip-literal: 2.0.0 test-exclude: 6.0.0 v8-to-istanbul: 9.2.0 - vitest: 1.4.0(@types/node@20.11.20) + vitest: 1.4.0(@types/node@20.10.4) transitivePeerDependencies: - supports-color dev: true