mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-05 02:58:36 -06:00
* Add new env variable NEXT_PUBLIC_WEBAPP_URL that is used server-side for the current address * Move Next-Auth to App-Directory * Move Membership-API & User-API to App-Directory * Update env-examples with new structure
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/* We use this telemetry service to better understand how Formbricks 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 captureTelemetry = async (eventName: string, properties = {}) => {
|
|
if (
|
|
process.env.TELEMETRY_DISABLED !== "1" &&
|
|
process.env.NODE_ENV === "production" &&
|
|
process.env.INSTANCE_ID
|
|
) {
|
|
try {
|
|
await fetch("https://eu.posthog.com/capture/", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
api_key: "phc_6XBUthOJLVe0Ij9EYkwEKpV96fUbA1aXxnHDq5ryASk",
|
|
event: eventName,
|
|
properties: {
|
|
distinct_id: process.env.INSTANCE_ID,
|
|
...properties,
|
|
},
|
|
timestamp: new Date().toISOString(),
|
|
}),
|
|
});
|
|
} catch (error) {
|
|
console.log("error sending telemetry:", error);
|
|
}
|
|
}
|
|
};
|