chore: remove Baselime monitoring integration and dependencies (#348)
- Deleted `@kit/baselime` package and its related files. - Removed Baselime service registration from monitoring in API services. - Cleared `registerInstrumentation`, hooks, provider components, and server utilities associated with Baselime. - Updated package dependencies to exclude `@kit/baselime`.
This commit is contained in:
committed by
GitHub
parent
caf86ce09b
commit
b3acbbe801
@@ -17,7 +17,6 @@
|
||||
"./components": "./src/components/index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/baselime": "workspace:*",
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
"@kit/monitoring-core": "workspace:*",
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
|
||||
@@ -26,19 +26,6 @@ const monitoringProviderRegistry = createRegistry<
|
||||
NonNullable<MonitoringProviderType>
|
||||
>();
|
||||
|
||||
// Register the Baselime provider
|
||||
monitoringProviderRegistry.register('baselime', async () => {
|
||||
const { BaselimeProvider } = await import('@kit/baselime/provider');
|
||||
|
||||
return {
|
||||
default: function BaselimeProviderWrapper({
|
||||
children,
|
||||
}: React.PropsWithChildren) {
|
||||
return <BaselimeProvider enableWebVitals>{children}</BaselimeProvider>;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// Register the Sentry provider
|
||||
monitoringProviderRegistry.register('sentry', async () => {
|
||||
const { SentryProvider } = await import('@kit/sentry/provider');
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const MONITORING_PROVIDERS = [
|
||||
'sentry',
|
||||
'',
|
||||
// Add more providers here
|
||||
] as const;
|
||||
|
||||
export const MONITORING_PROVIDER = z
|
||||
.enum(['baselime', 'sentry', ''])
|
||||
.enum(MONITORING_PROVIDERS)
|
||||
.optional()
|
||||
.transform((value) => value || undefined);
|
||||
|
||||
|
||||
@@ -16,15 +16,6 @@ const instrumentationRegistry = createRegistry<
|
||||
NonNullable<MonitoringProvider>
|
||||
>();
|
||||
|
||||
// Register the 'baselime' instrumentation provider
|
||||
instrumentationRegistry.register('baselime', async () => {
|
||||
const { registerInstrumentation } = await import(
|
||||
'@kit/baselime/instrumentation'
|
||||
);
|
||||
|
||||
return { register: registerInstrumentation };
|
||||
});
|
||||
|
||||
// Register the 'sentry' instrumentation provider with a no-op registration, since Sentry v8 sets up automatically
|
||||
instrumentationRegistry.register('sentry', () => {
|
||||
return {
|
||||
|
||||
@@ -15,15 +15,6 @@ const serverMonitoringRegistry = createRegistry<
|
||||
NonNullable<MonitoringProvider>
|
||||
>();
|
||||
|
||||
// Register the 'baselime' monitoring service
|
||||
serverMonitoringRegistry.register('baselime', async () => {
|
||||
const { BaselimeServerMonitoringService } = await import(
|
||||
'@kit/baselime/server'
|
||||
);
|
||||
|
||||
return new BaselimeServerMonitoringService();
|
||||
});
|
||||
|
||||
// Register the 'sentry' monitoring service
|
||||
serverMonitoringRegistry.register('sentry', async () => {
|
||||
const { SentryMonitoringService } = await import('@kit/sentry');
|
||||
@@ -45,6 +36,7 @@ export async function getServerMonitoringService() {
|
||||
console.info(
|
||||
`No instrumentation provider specified. Returning console service...`,
|
||||
);
|
||||
|
||||
return new ConsoleMonitoringService();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# Baselime Monitoring / @kit/baselime
|
||||
|
||||
Please refer to the [documentation](https://makerkit.dev/docs/next-supabase-turbo/baselime).
|
||||
@@ -1,3 +0,0 @@
|
||||
import eslintConfigBase from '@kit/eslint-config/base.js';
|
||||
|
||||
export default eslintConfigBase;
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"name": "@kit/baselime",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .turbo node_modules",
|
||||
"format": "prettier --check \"**/*.{ts,tsx}\"",
|
||||
"lint": "eslint .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"exports": {
|
||||
"./server": "./src/server.ts",
|
||||
"./client": "./src/client.ts",
|
||||
"./instrumentation": "./src/instrumentation.ts",
|
||||
"./provider": "./src/components/provider.tsx"
|
||||
},
|
||||
"dependencies": {
|
||||
"@baselime/node-opentelemetry": "^0.5.8",
|
||||
"@baselime/react-rum": "^0.3.1",
|
||||
"@kit/monitoring-core": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
"@kit/prettier-config": "workspace:*",
|
||||
"@kit/tsconfig": "workspace:*",
|
||||
"@types/react": "19.1.12",
|
||||
"react": "19.1.1",
|
||||
"zod": "^3.25.74"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './hooks/use-baselime';
|
||||
@@ -1,44 +0,0 @@
|
||||
import { useRef } from 'react';
|
||||
|
||||
import { BaselimeRum } from '@baselime/react-rum';
|
||||
|
||||
import { MonitoringContext } from '@kit/monitoring-core';
|
||||
|
||||
import { useBaselime } from '../hooks/use-baselime';
|
||||
|
||||
export function BaselimeProvider({
|
||||
children,
|
||||
apiKey,
|
||||
enableWebVitals,
|
||||
}: React.PropsWithChildren<{
|
||||
apiKey?: string;
|
||||
enableWebVitals?: boolean;
|
||||
}>) {
|
||||
const key = apiKey ?? process.env.NEXT_PUBLIC_BASELIME_KEY ?? '';
|
||||
|
||||
if (!key) {
|
||||
console.warn(
|
||||
'You configured Baselime as monitoring provider but did not provide a key. ' +
|
||||
'Please provide a key to enable monitoring with Baselime using the variable NEXT_PUBLIC_BASELIME_KEY.',
|
||||
);
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
return (
|
||||
<BaselimeRum apiKey={key} enableWebVitals={enableWebVitals}>
|
||||
<MonitoringProvider>{children}</MonitoringProvider>
|
||||
</BaselimeRum>
|
||||
);
|
||||
}
|
||||
|
||||
function MonitoringProvider(props: React.PropsWithChildren) {
|
||||
const service = useBaselime();
|
||||
const provider = useRef(service);
|
||||
|
||||
return (
|
||||
<MonitoringContext.Provider value={provider.current}>
|
||||
{props.children}
|
||||
</MonitoringContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { useBaselimeRum } from '@baselime/react-rum';
|
||||
|
||||
import { MonitoringService } from '@kit/monitoring-core';
|
||||
|
||||
/**
|
||||
* @name useBaselime
|
||||
* @description Get the Baselime monitoring service for the browser.
|
||||
*/
|
||||
export function useBaselime(): MonitoringService {
|
||||
const { captureException, setUser, sendEvent } = useBaselimeRum();
|
||||
|
||||
return useMemo(() => {
|
||||
return {
|
||||
captureException(error: Error, extra?: React.ErrorInfo) {
|
||||
void captureException(error, extra);
|
||||
},
|
||||
identifyUser(params) {
|
||||
setUser(params.id);
|
||||
},
|
||||
captureEvent<Extra extends object>(event: string, extra?: Extra) {
|
||||
return sendEvent(event, extra);
|
||||
},
|
||||
ready() {
|
||||
return Promise.resolve();
|
||||
},
|
||||
} satisfies MonitoringService;
|
||||
}, [captureException, sendEvent, setUser]);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* @name registerInstrumentation
|
||||
* @description This file is used to register Baselime instrumentation for your Next.js application.
|
||||
*
|
||||
* Please set the MONITORING_PROVIDER environment variable to 'baselime' to register Baselime instrumentation.
|
||||
*/
|
||||
export async function registerInstrumentation() {
|
||||
if (process.env.ENABLE_MONITORING_INSTRUMENTATION !== 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
const serviceName = process.env.INSTRUMENTATION_SERVICE_NAME;
|
||||
|
||||
if (!serviceName) {
|
||||
throw new Error(`
|
||||
You have set the Baselime instrumentation provider, but have not set the INSTRUMENTATION_SERVICE_NAME environment variable.
|
||||
Please set the INSTRUMENTATION_SERVICE_NAME environment variable.
|
||||
`);
|
||||
}
|
||||
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
const { BaselimeSDK, BetterHttpInstrumentation, VercelPlugin } =
|
||||
await import('@baselime/node-opentelemetry');
|
||||
|
||||
const sdk = new BaselimeSDK({
|
||||
serverless: true,
|
||||
service: serviceName,
|
||||
baselimeKey: process.env.NEXT_PUBLIC_BASELIME_KEY,
|
||||
instrumentations: [
|
||||
new BetterHttpInstrumentation({
|
||||
plugins: [new VercelPlugin()],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
sdk.start();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './services/baselime-server-monitoring.service';
|
||||
@@ -1,115 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { MonitoringService } from '@kit/monitoring-core';
|
||||
|
||||
const apiKey = z
|
||||
.string({
|
||||
required_error: 'NEXT_PUBLIC_BASELIME_KEY is required',
|
||||
description: 'The Baseline API key',
|
||||
})
|
||||
.parse(process.env.NEXT_PUBLIC_BASELIME_KEY);
|
||||
|
||||
export class BaselimeServerMonitoringService implements MonitoringService {
|
||||
userId: string | null = null;
|
||||
|
||||
async captureException(
|
||||
error: Error | null,
|
||||
extra?: {
|
||||
requestId?: string;
|
||||
sessionId?: string;
|
||||
namespace?: string;
|
||||
service?: string;
|
||||
},
|
||||
) {
|
||||
const formattedError = error ? getFormattedError(error) : {};
|
||||
|
||||
const event = {
|
||||
level: 'error',
|
||||
data: { error },
|
||||
error: {
|
||||
...formattedError,
|
||||
},
|
||||
message: error ? `${error.name}: ${error.message}` : `Unknown error`,
|
||||
};
|
||||
|
||||
const response = await fetch(`https://events.baselime.io/v1/logs`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
contentType: 'application/json',
|
||||
'x-api-key': apiKey,
|
||||
'x-service': extra?.service ?? '',
|
||||
'x-namespace': extra?.namespace ?? '',
|
||||
},
|
||||
body: JSON.stringify([
|
||||
{
|
||||
userId: this.userId,
|
||||
sessionId: extra?.sessionId,
|
||||
namespace: extra?.namespace,
|
||||
...event,
|
||||
},
|
||||
]),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(
|
||||
{
|
||||
response,
|
||||
event,
|
||||
},
|
||||
'Failed to send event to Baselime',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async captureEvent<
|
||||
Extra extends {
|
||||
sessionId?: string;
|
||||
namespace?: string;
|
||||
service?: string;
|
||||
},
|
||||
>(event: string, extra?: Extra) {
|
||||
const response = await fetch(`https://events.baselime.io/v1/logs`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
contentType: 'application/json',
|
||||
'x-api-key': apiKey,
|
||||
'x-service': extra?.service ?? '',
|
||||
'x-namespace': extra?.namespace ?? '',
|
||||
},
|
||||
body: JSON.stringify([
|
||||
{
|
||||
userId: this.userId,
|
||||
sessionId: extra?.sessionId,
|
||||
namespace: extra?.namespace,
|
||||
message: event,
|
||||
},
|
||||
]),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(
|
||||
{
|
||||
response,
|
||||
event,
|
||||
},
|
||||
'Failed to send event to Baselime',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
identifyUser<Info extends { id: string }>(info: Info) {
|
||||
this.userId = info.id;
|
||||
}
|
||||
|
||||
ready() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
function getFormattedError(error: Error) {
|
||||
return {
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "@kit/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["*.ts", "src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
769
pnpm-lock.yaml
generated
769
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user