Instrument extra files warning (#345)

https://github.com/dyad-sh/dyad/issues/244
This commit is contained in:
Will Chen
2025-06-05 15:24:31 -07:00
committed by GitHub
parent 16bf0828f5
commit 0123e68dda
3 changed files with 14 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import { toast } from "sonner";
import { PostHog } from "posthog-js";
/**
* Toast utility functions for consistent notifications across the app
@@ -61,19 +62,28 @@ export const showLoading = <T>(
export const showExtraFilesToast = ({
files,
error,
posthog,
}: {
files: string[];
error?: string;
posthog: PostHog;
}) => {
if (error) {
showError(
`Error committing files ${files.join(", ")} changed outside of Dyad: ${error}`,
);
posthog.capture("extra-files:error", {
files: files,
error,
});
} else {
showWarning(
`Files changed outside of Dyad have automatically been committed:
\n\n${files.join("\n")}`,
);
posthog.capture("extra-files:warning", {
files: files,
});
}
};