track email conversion rates with plausible

This commit is contained in:
Abi Raja 2023-12-05 11:42:59 -05:00
parent 0f7425eb3b
commit afb1b3b036
3 changed files with 11 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import html2canvas from "html2canvas";
import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants"; import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants";
import CodeTab from "./components/CodeTab"; import CodeTab from "./components/CodeTab";
import OutputSettingsSection from "./components/OutputSettingsSection"; import OutputSettingsSection from "./components/OutputSettingsSection";
import { addEvent } from "./lib/analytics";
function App() { function App() {
const [appState, setAppState] = useState<AppState>(AppState.INITIAL); const [appState, setAppState] = useState<AppState>(AppState.INITIAL);
@ -83,11 +84,7 @@ function App() {
}; };
const downloadCode = () => { const downloadCode = () => {
try { addEvent("Download");
window.plausible("Download");
} catch {
// Ignore
}
// Create a blob from the generated code // Create a blob from the generated code
const blob = new Blob([generatedCode], { type: "text/html" }); const blob = new Blob([generatedCode], { type: "text/html" });

View File

@ -10,6 +10,7 @@ import {
import { Input } from "./ui/input"; import { Input } from "./ui/input";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { PICO_BACKEND_FORM_SECRET } from "../config"; import { PICO_BACKEND_FORM_SECRET } from "../config";
import { addEvent } from "../lib/analytics";
const LOGOS = ["microsoft", "amazon", "mit", "stanford", "bytedance", "baidu"]; const LOGOS = ["microsoft", "amazon", "mit", "stanford", "bytedance", "baidu"];
@ -81,6 +82,7 @@ const TermsOfServiceDialog: React.FC<{
e.preventDefault(); e.preventDefault();
toast.error("Please enter your email"); toast.error("Please enter your email");
} else { } else {
addEvent("EmailSubmit");
onSubscribe(); onSubscribe();
} }
}} }}

View File

@ -0,0 +1,7 @@
export function addEvent(eventName: string) {
try {
window.plausible(eventName);
} catch (e) {
// silently fail in non-production environments
}
}