Instrument extra files warning (#345)
https://github.com/dyad-sh/dyad/issues/244
This commit is contained in:
@@ -188,6 +188,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
|
|||||||
showExtraFilesToast({
|
showExtraFilesToast({
|
||||||
files: result.extraFiles,
|
files: result.extraFiles,
|
||||||
error: result.extraFilesError,
|
error: result.extraFilesError,
|
||||||
|
posthog,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { useSearch } from "@tanstack/react-router";
|
|||||||
import { useRunApp } from "./useRunApp";
|
import { useRunApp } from "./useRunApp";
|
||||||
import { useCountTokens } from "./useCountTokens";
|
import { useCountTokens } from "./useCountTokens";
|
||||||
import { useUserBudgetInfo } from "./useUserBudgetInfo";
|
import { useUserBudgetInfo } from "./useUserBudgetInfo";
|
||||||
|
import { usePostHog } from "posthog-js/react";
|
||||||
|
|
||||||
export function getRandomNumberId() {
|
export function getRandomNumberId() {
|
||||||
return Math.floor(Math.random() * 1_000_000_000_000_000);
|
return Math.floor(Math.random() * 1_000_000_000_000_000);
|
||||||
@@ -40,7 +41,7 @@ export function useStreamChat({
|
|||||||
const { refreshAppIframe } = useRunApp();
|
const { refreshAppIframe } = useRunApp();
|
||||||
const { countTokens } = useCountTokens();
|
const { countTokens } = useCountTokens();
|
||||||
const { refetchUserBudget } = useUserBudgetInfo();
|
const { refetchUserBudget } = useUserBudgetInfo();
|
||||||
|
const posthog = usePostHog();
|
||||||
let chatId: number | undefined;
|
let chatId: number | undefined;
|
||||||
|
|
||||||
if (hasChatId) {
|
if (hasChatId) {
|
||||||
@@ -93,6 +94,7 @@ export function useStreamChat({
|
|||||||
showExtraFilesToast({
|
showExtraFilesToast({
|
||||||
files: response.extraFiles,
|
files: response.extraFiles,
|
||||||
error: response.extraFilesError,
|
error: response.extraFilesError,
|
||||||
|
posthog,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
refreshProposal(chatId);
|
refreshProposal(chatId);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { PostHog } from "posthog-js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toast utility functions for consistent notifications across the app
|
* Toast utility functions for consistent notifications across the app
|
||||||
@@ -61,19 +62,28 @@ export const showLoading = <T>(
|
|||||||
export const showExtraFilesToast = ({
|
export const showExtraFilesToast = ({
|
||||||
files,
|
files,
|
||||||
error,
|
error,
|
||||||
|
posthog,
|
||||||
}: {
|
}: {
|
||||||
files: string[];
|
files: string[];
|
||||||
error?: string;
|
error?: string;
|
||||||
|
posthog: PostHog;
|
||||||
}) => {
|
}) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
showError(
|
showError(
|
||||||
`Error committing files ${files.join(", ")} changed outside of Dyad: ${error}`,
|
`Error committing files ${files.join(", ")} changed outside of Dyad: ${error}`,
|
||||||
);
|
);
|
||||||
|
posthog.capture("extra-files:error", {
|
||||||
|
files: files,
|
||||||
|
error,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
showWarning(
|
showWarning(
|
||||||
`Files changed outside of Dyad have automatically been committed:
|
`Files changed outside of Dyad have automatically been committed:
|
||||||
\n\n${files.join("\n")}`,
|
\n\n${files.join("\n")}`,
|
||||||
);
|
);
|
||||||
|
posthog.capture("extra-files:warning", {
|
||||||
|
files: files,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user