mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 10:29:17 +00:00
43 lines
825 B
JavaScript
43 lines
825 B
JavaScript
/* eslint-disable */
|
|
import { initPostHog } from "~/components/analytics/posthog";
|
|
import { ENV } from "~/components/utilities/config";
|
|
|
|
class Capturer {
|
|
constructor() {
|
|
this.api = initPostHog();
|
|
}
|
|
|
|
capture(item) {
|
|
if (ENV == "production" && TELEMETRY_CAPTURING_ENABLED) {
|
|
try {
|
|
this.api.capture(item);
|
|
} catch (error) {
|
|
console.error("PostHog", error);
|
|
}
|
|
}
|
|
}
|
|
|
|
identify(id) {
|
|
if (ENV == "production" && TELEMETRY_CAPTURING_ENABLED) {
|
|
try {
|
|
this.api.identify(id);
|
|
} catch (error) {
|
|
console.error("PostHog", error);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default class Telemetry {
|
|
constructor() {
|
|
if (!Telemetry.instance) {
|
|
Telemetry.instance = new Capturer();
|
|
}
|
|
}
|
|
|
|
getInstance() {
|
|
return Telemetry.instance;
|
|
}
|
|
}
|