mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
* make all env variables required at build time * update env files * add .env.docker file with basic docker configuration * update Readme with new instructions
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { hashString } from "./utils";
|
|
|
|
/* We use this telemetry service to better understand how snoopForms is being used
|
|
and how we can improve it. All data including the IP address is collected anonymously
|
|
and we cannot trace anything back to you or your customers. If you still want to
|
|
disable telemetry, set the environment variable TELEMETRY_DISABLED=1 */
|
|
|
|
export const sendTelemetry = async (eventName: string) => {
|
|
if (
|
|
process.env.TELEMETRY_DISABLED !== "1" &&
|
|
process.env.NODE_ENV === "production" &&
|
|
process.env.NEXTAUTH_URL !== "http://localhost:3000"
|
|
) {
|
|
try {
|
|
await fetch("https://posthog.snoopforms.com/capture/", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
api_key: "phc_BTq4eagaCzPyUSURXVYwlScTQRvcmBDXjYh7OG6kiqw",
|
|
event: eventName,
|
|
properties: {
|
|
distinct_id: hashString(process.env.NEXTAUTH_URL),
|
|
},
|
|
timestamp: new Date().toISOString(),
|
|
}),
|
|
});
|
|
} catch (error) {
|
|
console.log("error sending telemetry:", error);
|
|
}
|
|
}
|
|
};
|