mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 15:40:47 +00:00
feat: updated frontend use run time config inject value
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
/* eslint-disable no-undef */
|
||||
import { envConfig } from "@app/config/env";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
import { ENV, POSTHOG_API_KEY, POSTHOG_HOST } from "../utilities/config";
|
||||
|
||||
export const initPostHog = () => {
|
||||
// @ts-ignore
|
||||
console.log("Hi there 👋");
|
||||
try {
|
||||
if (typeof window !== "undefined") {
|
||||
// @ts-ignore
|
||||
if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED === true) {
|
||||
posthog.init(POSTHOG_API_KEY, {
|
||||
api_host: POSTHOG_HOST
|
||||
if (
|
||||
envConfig.ENV === "production" &&
|
||||
envConfig.TELEMETRY_CAPTURING_ENABLED === true &&
|
||||
envConfig.POSTHOG_API_KEY
|
||||
) {
|
||||
posthog.init(envConfig.POSTHOG_API_KEY, {
|
||||
api_host: envConfig.POSTHOG_HOST
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export const RegionSelect = () => {
|
||||
))}
|
||||
</Select>
|
||||
<Modal>
|
||||
<ModalTrigger>
|
||||
<ModalTrigger asChild>
|
||||
<button type="button" className="mt-1 text-right text-xs text-mineshaft-400 underline">
|
||||
Help me pick a data region
|
||||
</button>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
const ENV = process.env.NEXT_PUBLIC_ENV! || "development"; // investigate
|
||||
const POSTHOG_API_KEY = process.env.NEXT_PUBLIC_POSTHOG_API_KEY!;
|
||||
const POSTHOG_HOST = process.env.NEXT_PUBLIC_POSTHOG_HOST! || "https://app.posthog.com";
|
||||
const INTERCOMid = process.env.NEXT_PUBLIC_INTERCOMid!;
|
||||
const CAPTCHA_SITE_KEY = process.env.NEXT_PUBLIC_CAPTCHA_SITE_KEY!;
|
||||
|
||||
export { CAPTCHA_SITE_KEY, ENV, INTERCOMid, POSTHOG_API_KEY, POSTHOG_HOST };
|
||||
@@ -1,9 +1,7 @@
|
||||
/* eslint-disable */
|
||||
import { PostHog } from "posthog-js";
|
||||
import { initPostHog } from "@app/components/analytics/posthog";
|
||||
import { ENV } from "@app/components/utilities/config";
|
||||
|
||||
declare let TELEMETRY_CAPTURING_ENABLED: any;
|
||||
import { envConfig } from "@app/config/env";
|
||||
|
||||
class Capturer {
|
||||
api: PostHog;
|
||||
@@ -13,7 +11,7 @@ class Capturer {
|
||||
}
|
||||
|
||||
capture(item: string) {
|
||||
if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED === true) {
|
||||
if (envConfig.ENV === "production" && envConfig.TELEMETRY_CAPTURING_ENABLED === true) {
|
||||
try {
|
||||
this.api.capture(item);
|
||||
} catch (error) {
|
||||
@@ -23,7 +21,7 @@ class Capturer {
|
||||
}
|
||||
|
||||
identify(id: string, email?: string) {
|
||||
if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED === true) {
|
||||
if (envConfig.ENV === "production" && envConfig.TELEMETRY_CAPTURING_ENABLED === true) {
|
||||
try {
|
||||
this.api.identify(id, {
|
||||
email: email
|
||||
|
||||
Reference in New Issue
Block a user