track email conversion rates with plausible
This commit is contained in:
parent
0f7425eb3b
commit
afb1b3b036
@ -29,6 +29,7 @@ import html2canvas from "html2canvas";
|
||||
import { USER_CLOSE_WEB_SOCKET_CODE } from "./constants";
|
||||
import CodeTab from "./components/CodeTab";
|
||||
import OutputSettingsSection from "./components/OutputSettingsSection";
|
||||
import { addEvent } from "./lib/analytics";
|
||||
|
||||
function App() {
|
||||
const [appState, setAppState] = useState<AppState>(AppState.INITIAL);
|
||||
@ -83,11 +84,7 @@ function App() {
|
||||
};
|
||||
|
||||
const downloadCode = () => {
|
||||
try {
|
||||
window.plausible("Download");
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
addEvent("Download");
|
||||
|
||||
// Create a blob from the generated code
|
||||
const blob = new Blob([generatedCode], { type: "text/html" });
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
import { Input } from "./ui/input";
|
||||
import toast from "react-hot-toast";
|
||||
import { PICO_BACKEND_FORM_SECRET } from "../config";
|
||||
import { addEvent } from "../lib/analytics";
|
||||
|
||||
const LOGOS = ["microsoft", "amazon", "mit", "stanford", "bytedance", "baidu"];
|
||||
|
||||
@ -81,6 +82,7 @@ const TermsOfServiceDialog: React.FC<{
|
||||
e.preventDefault();
|
||||
toast.error("Please enter your email");
|
||||
} else {
|
||||
addEvent("EmailSubmit");
|
||||
onSubscribe();
|
||||
}
|
||||
}}
|
||||
|
||||
7
frontend/src/lib/analytics.ts
Normal file
7
frontend/src/lib/analytics.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export function addEvent(eventName: string) {
|
||||
try {
|
||||
window.plausible(eventName);
|
||||
} catch (e) {
|
||||
// silently fail in non-production environments
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user