Skip to content

Commit

Permalink
add mixpanel event name to sentry report
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-byrne committed Feb 22, 2025
1 parent b7c844b commit d939eea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/services/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ const getLogTail = (numLines: number, logFilename: string): string => {
/**
* Capture a Sentry exception and return the Sentry URL for the captured event.
* @param error The error to capture
* @param eventName The name to tag the captured Sentry event with
* @returns The Sentry URL for the captured event
*/
export function captureSentryException(error: unknown) {
export function captureSentryException(error: unknown, eventName: string) {
const settings = useComfySettings();
const eventId = Sentry.captureException(error, {
tags: {
Expand All @@ -50,6 +51,7 @@ export function captureSentryException(error: unknown) {
pythonMirror: settings.get('Comfy-Desktop.UV.PythonInstallMirror'),
pypiMirror: settings.get('Comfy-Desktop.UV.PypiInstallMirror'),
torchMirror: settings.get('Comfy-Desktop.UV.TorchInstallMirror'),
eventName,
},
extra: {
logs: getLogTail(NUM_LOG_LINES_CAPTURED, MAIN_LOG_FILENAME),
Expand Down
5 changes: 3 additions & 2 deletions src/services/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ export function trackEvent<T extends HasTelemetry>(eventName: string) {
await originalMethod!.apply(this, args);
this.telemetry.track(`${eventName}_end`);
} catch (error) {
const sentryUrl = captureSentryException(error);
this.telemetry.track(`${eventName}_error`, {
const errorEventName = `${eventName}_error`;
const sentryUrl = captureSentryException(error, errorEventName);
this.telemetry.track(errorEventName, {
error_message: (error as Error)?.message,
error_name: (error as Error)?.name,
sentry_url: sentryUrl,
Expand Down
8 changes: 6 additions & 2 deletions src/virtualEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,12 @@ export class VirtualEnvironment implements HasTelemetry {
});
log.info('Successfully created virtual environment at', this.venvPath);
} catch (error) {
const sentryUrl = captureSentryException(error instanceof Error ? error : new Error(String(error)));
this.telemetry.track('install_flow:virtual_environment_create_error', {
const errorEventName = 'install_flow:virtual_environment_create_error';
const sentryUrl = captureSentryException(
error instanceof Error ? error : new Error(String(error)),
errorEventName
);
this.telemetry.track(errorEventName, {
error_name: error instanceof Error ? error.name : 'UnknownError',
error_type: error instanceof Error ? error.constructor.name : typeof error,
error_message: error instanceof Error ? error.message : 'Unknown error occurred',
Expand Down

0 comments on commit d939eea

Please sign in to comment.