mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
chore: collect data for self hosted instances
This commit is contained in:
@ -116,3 +116,6 @@ E2E_TEST_AUTHENTICATE_USER_PASSWORD="test_Password123"
|
||||
# [[REDIS]]
|
||||
NEXT_PRIVATE_REDIS_URL=
|
||||
NEXT_PRIVATE_REDIS_TOKEN=
|
||||
|
||||
# [[Telemetry]]
|
||||
DISABLE_TELEMETRY=true
|
||||
|
||||
@ -4,12 +4,14 @@ import { Caveat, Inter } from 'next/font/google';
|
||||
|
||||
import { AxiomWebVitals } from 'next-axiom';
|
||||
import { PublicEnvScript } from 'next-runtime-env';
|
||||
import { version } from 'package.json';
|
||||
|
||||
import { FeatureFlagProvider } from '@documenso/lib/client-only/providers/feature-flag';
|
||||
import { LocaleProvider } from '@documenso/lib/client-only/providers/locale';
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app';
|
||||
import { getServerComponentAllFlags } from '@documenso/lib/server-only/feature-flags/get-server-component-feature-flag';
|
||||
import { getLocale } from '@documenso/lib/server-only/headers/get-locale';
|
||||
import { sendInstanceInfo } from '@documenso/lib/server-only/telemetry/send-instance-info';
|
||||
import { TrpcProvider } from '@documenso/trpc/react';
|
||||
import { cn } from '@documenso/ui/lib/utils';
|
||||
import { Toaster } from '@documenso/ui/primitives/toaster';
|
||||
@ -58,6 +60,13 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
|
||||
const locale = getLocale();
|
||||
|
||||
void sendInstanceInfo({
|
||||
// TODO: Get actual uniqueId for each user
|
||||
uniqueId: 1,
|
||||
timestamp: new Date(),
|
||||
version,
|
||||
});
|
||||
|
||||
return (
|
||||
<html
|
||||
lang="en"
|
||||
|
||||
42
packages/lib/server-only/telemetry/send-instance-info.ts
Normal file
42
packages/lib/server-only/telemetry/send-instance-info.ts
Normal file
@ -0,0 +1,42 @@
|
||||
export type SendInstanceInfo = {
|
||||
uniqueId: number;
|
||||
timestamp: Date;
|
||||
version: string;
|
||||
};
|
||||
|
||||
export const sendInstanceInfo = async ({
|
||||
uniqueId,
|
||||
timestamp,
|
||||
version,
|
||||
}: SendInstanceInfo): Promise<void> => {
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const isTelemetryDisabled = process.env.DISABLE_TELEMETRY === 'true';
|
||||
|
||||
if (!isProduction || isTelemetryDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = 'https://documenso-instances.fly.dev/ping';
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
uniqueId,
|
||||
timestamp,
|
||||
version,
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to record instance, failed with status code ${response.status}`);
|
||||
}
|
||||
|
||||
await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error posting instance information:', error);
|
||||
}
|
||||
};
|
||||
2
packages/tsconfig/process-env.d.ts
vendored
2
packages/tsconfig/process-env.d.ts
vendored
@ -79,5 +79,7 @@ declare namespace NodeJS {
|
||||
DATABASE_URL?: string;
|
||||
POSTGRES_PRISMA_URL?: string;
|
||||
POSTGRES_URL_NON_POOLING?: string;
|
||||
|
||||
DISABLE_TELEMETRY?: string;
|
||||
}
|
||||
}
|
||||
|
||||
26
turbo.json
26
turbo.json
@ -2,13 +2,8 @@
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"outputs": [
|
||||
".next/**",
|
||||
"!.next/cache/**"
|
||||
]
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": [".next/**", "!.next/cache/**"]
|
||||
},
|
||||
"lint": {
|
||||
"cache": false
|
||||
@ -24,9 +19,7 @@
|
||||
"persistent": true
|
||||
},
|
||||
"start": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"dependsOn": ["^build"],
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
},
|
||||
@ -34,15 +27,11 @@
|
||||
"cache": false
|
||||
},
|
||||
"test:e2e": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"dependsOn": ["^build"],
|
||||
"cache": false
|
||||
}
|
||||
},
|
||||
"globalDependencies": [
|
||||
"**/.env.*local"
|
||||
],
|
||||
"globalDependencies": ["**/.env.*local"],
|
||||
"globalEnv": [
|
||||
"APP_VERSION",
|
||||
"NEXT_PRIVATE_ENCRYPTION_KEY",
|
||||
@ -121,6 +110,7 @@
|
||||
"GOOGLE_APPLICATION_CREDENTIALS",
|
||||
"E2E_TEST_AUTHENTICATE_USERNAME",
|
||||
"E2E_TEST_AUTHENTICATE_USER_EMAIL",
|
||||
"E2E_TEST_AUTHENTICATE_USER_PASSWORD"
|
||||
"E2E_TEST_AUTHENTICATE_USER_PASSWORD",
|
||||
"DISABLE_TELEMETRY"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user