Doceditor: add loggs for API timers

This commit is contained in:
Timofey Boyko 2024-05-08 17:04:38 +03:00
parent 05f4471567
commit 5d572b1236
5 changed files with 23 additions and 6 deletions

View File

@ -37,7 +37,9 @@ export default async function RootLayout({
}: {
children: React.ReactNode;
}) {
const startDate = new Date();
const [user, settings] = await Promise.all([getUser(), getSettings()]);
const timer = new Date().getTime() - startDate.getTime();
if (settings === "access-restricted") redirect(`${getBaseUrl()}/${settings}`);
@ -58,7 +60,11 @@ export default async function RootLayout({
</head>
<body>
<StyledComponentsRegistry>
<Providers contextData={{ user, settings }} api_host={api_host}>
<Providers
contextData={{ user, settings }}
api_host={api_host}
timer={timer}
>
{children}
</Providers>
</StyledComponentsRegistry>

View File

@ -57,6 +57,8 @@ async function Page({ searchParams }: RootPageProps) {
const { fileId, fileid, version, doc, action, share, editorType } =
searchParams ?? initialSearchParams;
const startDate = new Date();
const data = await getData(
fileId ?? fileid ?? "",
version,
@ -66,7 +68,9 @@ async function Page({ searchParams }: RootPageProps) {
editorType,
);
return <Root {...data} />;
const timer = new Date().getTime() - startDate.getTime();
return <Root {...data} timer={timer} />;
}
export default Page;

View File

@ -26,7 +26,7 @@
"use client";
import React from "react";
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
import ErrorContainer from "@docspace/shared/components/error-container/ErrorContainer";
@ -62,6 +62,7 @@ const Root = ({
doc,
fileId,
hash,
timer,
}: TResponse) => {
const documentserverUrl = config?.editorUrl ?? error?.editorUrl;
const fileInfo = config?.file;
@ -75,6 +76,10 @@ const Root = ({
const { t } = useTranslation(["Editor", "Common"]);
useEffect(() => {
console.log("editor timer: ", timer);
}, [timer]);
useRootInit({
documentType: config?.documentType,
});

View File

@ -45,12 +45,14 @@ const TranslationProvider = ({
settings,
user,
api_host,
timer,
}: TTranslationProvider) => {
const { i18n } = useI18N({ settings, user });
React.useEffect(() => {
console.log("API_HOST: ", api_host);
}, [api_host]);
console.log("LAYOUT API timer:", timer);
}, [api_host, timer]);
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
};

View File

@ -42,9 +42,9 @@ export type TProviders = {
contextData: TContextData;
};
const Providers = ({ children, contextData, api_host }: TProviders) => {
const Providers = ({ children, contextData, api_host, timer }: TProviders) => {
return (
<TranslationProvider {...contextData} api_host={api_host}>
<TranslationProvider {...contextData} api_host={api_host} timer={timer}>
<ThemeProvider {...contextData}>
<ErrorProvider {...contextData}>
{children}