* feat: add sentry to core * feat: implement comprehensive Sentry error tracking with privacy-first anonymization - Add Sentry ErrorBoundary components following React best practices - Implement shared anonymization logic between core and GUI environments - Create organized sentry directory structure with clean exports - Add Continue team member access control (@continue.dev email check) - Preserve node_modules package names for debugging while anonymizing user paths - Include comprehensive test coverage for all anonymization scenarios - Set up source maps for readable production error stack traces - Add browser-compatible hashing without crypto module dependency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: complete Sentry integration with GUI components and tests - Add GUI TelemetryProviders with Sentry ErrorBoundary - Create shared isContinueTeamMember utilities for both core and GUI - Update all imports and dependencies for new sentry structure - Add comprehensive test coverage and fix all TypeScript issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * prettier * fix: resolve GUI build errors by removing sentry index.ts and using specific imports - Remove problematic index.ts that was pulling Node.js-specific Sentry code into browser bundle - Update GUI to import specifically from anonymization.ts and constants.ts files - Update core imports to use specific SentryLogger.ts import path - GUI build now succeeds with proper source map upload to Sentry 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: move TelemetryProviders inside AuthProvider to fix test failures - Move TelemetryProviders from main.tsx to Layout.tsx inside AuthProvider - Fixes "useAuth must be used within an AuthProvider" error in tests - TelemetryProviders now has access to auth context for Continue team member check - GUI build and functionality remain working correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * prettier * merge main * Update package.json * fix tests * fix errors * Update extension.ts * disable sentry in tests/local dev * add additional error handling * Update SentryLogger.ts * remove global try/catch * remove test code * linting * Update SentryLogger.ts * more logs * Update core.ts * lower sampling rate * fix tests * feat: use `Logger` * Update logger.ts * Update logger.ts Co-Authored-By: Claude <noreply@anthropic.com> * lint fixes Co-Authored-By: Claude <noreply@anthropic.com> * fix: rename logger.ts to Logger.ts for case sensitivity This fixes TypeScript compilation errors in CI where the file was tracked as lowercase logger.ts but referenced as Logger.ts in imports. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * address ting-wai's feedback * Update core.ts --------- Co-authored-by: Claude <noreply@anthropic.com>
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import winston from "winston";
|
|
import { captureException } from "./sentry/SentryLogger";
|
|
|
|
class LoggerClass {
|
|
private static instance: LoggerClass;
|
|
private winston: winston.Logger;
|
|
|
|
private constructor() {
|
|
this.winston = winston.createLogger({
|
|
level: "info",
|
|
format: winston.format.combine(
|
|
winston.format.colorize(),
|
|
winston.format.timestamp(),
|
|
winston.format.printf(({ level, message, timestamp, ...meta }) => {
|
|
const metaStr = Object.keys(meta).length
|
|
? ` ${JSON.stringify(meta)}`
|
|
: "";
|
|
return `[@continuedev] ${level}: ${message}${metaStr}`;
|
|
}),
|
|
),
|
|
transports: [
|
|
// Write all logs with importance level of `info` or higher to `info.log`
|
|
...(process.env.NODE_ENV === "test"
|
|
? [
|
|
new winston.transports.File({
|
|
filename: "e2e.log",
|
|
level: "info",
|
|
}),
|
|
]
|
|
: []),
|
|
// Normal console.log behavior
|
|
new winston.transports.Console(),
|
|
],
|
|
});
|
|
}
|
|
|
|
public static getInstance(): LoggerClass {
|
|
if (!LoggerClass.instance) {
|
|
LoggerClass.instance = new LoggerClass();
|
|
}
|
|
return LoggerClass.instance;
|
|
}
|
|
|
|
private shouldSendToSentry(): boolean {
|
|
return process.env.NODE_ENV !== "test" && process.env.NODE_ENV !== "e2e";
|
|
}
|
|
|
|
public log(message: string, meta?: any): void {
|
|
this.winston.info(message, meta);
|
|
}
|
|
|
|
public debug(message: string, meta?: any): void {
|
|
this.winston.debug(message, meta);
|
|
}
|
|
|
|
public info(message: string, meta?: any): void {
|
|
this.winston.info(message, meta);
|
|
}
|
|
|
|
public warn(message: string, meta?: any): void {
|
|
this.winston.warn(message, meta);
|
|
}
|
|
|
|
public error(
|
|
error: Error | string | unknown,
|
|
context?: Record<string, any>,
|
|
): void {
|
|
let errorMessage: string;
|
|
|
|
if (error instanceof Error) {
|
|
errorMessage = error.message;
|
|
} else if (typeof error === "string") {
|
|
errorMessage = error;
|
|
} else {
|
|
errorMessage = "An unknown error occurred";
|
|
}
|
|
|
|
this.winston.error(errorMessage, context);
|
|
|
|
if (this.shouldSendToSentry() && error instanceof Error) {
|
|
captureException(error, context);
|
|
}
|
|
}
|
|
}
|
|
|
|
export const Logger = LoggerClass.getInstance();
|