Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
set telemetry post frontend build in standalone docker img
Maidul Islamfb7c7045e995
diff --git a/Dockerfile.standalone-infisical b/Dockerfile.standalone-infisicalindex 1ce05ccc17..34b7607b74 100644--- a/Dockerfile.standalone-infisical+++ b/Dockerfile.standalone-infisical@@ -74,6 +74,7 @@ COPY backend/package*.json ./RUN npm ci --only-productionCOPY /backend .+COPY standalone-entrypoint.sh standalone-entrypoint.shRUN npm run build# Production stage@@ -105,6 +106,9 @@ ENV NODE_ENV productionWORKDIR /backend-CMD ["node", "build/index.js"]+ENV TELEMETRY_ENABLED true++CMD ["./standalone-entrypoint.sh"]+diff --git a/backend/src/utils/setup/index.ts b/backend/src/utils/setup/index.tsindex d85d63aca0..6625bff7b4 100644--- a/backend/src/utils/setup/index.ts+++ b/backend/src/utils/setup/index.ts@@ -55,9 +55,6 @@ export const setup = async () => {// initializing global feature setawait EELicenseService.initGlobalFeatureSet();- // initializing the database connection- await DatabaseService.initDatabase(await getMongoURL());-await initializePassport();// re-encrypt any data previously encrypted under server hex 128-bit ENCRYPTION_KEYdiff --git a/frontend/scripts/initialize-standalone-build.sh b/frontend/scripts/initialize-standalone-build.shnew file mode 100755index 0000000000..d9138bb77e--- /dev/null+++ b/frontend/scripts/initialize-standalone-build.sh@@ -0,0 +1,13 @@+#!/bin/sh++scripts/replace-standalone-build-variable.sh "$BAKED_NEXT_PUBLIC_POSTHOG_API_KEY" "$NEXT_PUBLIC_POSTHOG_API_KEY"++scripts/replace-standalone-build-variable.sh "$BAKED_NEXT_PUBLIC_INTERCOM_ID" "$NEXT_PUBLIC_INTERCOM_ID"++if [ "$TELEMETRY_ENABLED" != "false" ]; then+ echo "Telemetry is enabled"+ scripts/set-standalone-build-telemetry.sh true+else+ echo "Client opted out of telemetry"+ scripts/set-standalone-build-telemetry.sh false+fidiff --git a/frontend/scripts/replace-standalone-build-variable.sh b/frontend/scripts/replace-standalone-build-variable.shnew file mode 100755index 0000000000..fde4ca282f--- /dev/null+++ b/frontend/scripts/replace-standalone-build-variable.sh@@ -0,0 +1,16 @@+#!/bin/sh++ORIGINAL=$1+REPLACEMENT=$2++if [ "${ORIGINAL}" = "${REPLACEMENT}" ]; then+ echo "Environment variable replacement is the same, skipping.."+ exit 0+fi++echo "Replacing pre-baked value.."++find public .next -type f -name "*.js" |+while read file; do+ sed -i "s|$ORIGINAL|$REPLACEMENT|g" "$file"+donediff --git a/frontend/scripts/replace-variable.sh b/frontend/scripts/replace-variable.shold mode 100644new mode 100755diff --git a/frontend/scripts/set-standalone-build-telemetry.sh b/frontend/scripts/set-standalone-build-telemetry.shnew file mode 100644index 0000000000..5e788b6b91--- /dev/null+++ b/frontend/scripts/set-standalone-build-telemetry.sh@@ -0,0 +1,8 @@+#!/bin/sh++VALUE=$1++find public .next -type f -name "*.js" |+while read file; do+ sed -i "s|TELEMETRY_CAPTURING_ENABLED|$VALUE|g" "$file"+donediff --git a/frontend/scripts/set-telemetry.sh b/frontend/scripts/set-telemetry.shold mode 100644new mode 100755diff --git a/frontend/src/components/analytics/posthog.ts b/frontend/src/components/analytics/posthog.tsindex 706f795151..246d5c9cc4 100644--- a/frontend/src/components/analytics/posthog.ts+++ b/frontend/src/components/analytics/posthog.ts@@ -10,7 +10,7 @@ export const initPostHog = () => {try {if (typeof window !== "undefined") {// @ts-ignore- if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED) {+ if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED === "true") {posthog.init(POSTHOG_API_KEY, {api_host: POSTHOG_HOST});diff --git a/frontend/src/components/utilities/telemetry/Telemetry.ts b/frontend/src/components/utilities/telemetry/Telemetry.tsindex 2676bed852..76e86fa379 100644--- a/frontend/src/components/utilities/telemetry/Telemetry.ts+++ b/frontend/src/components/utilities/telemetry/Telemetry.ts@@ -13,7 +13,7 @@ class Capturer {}capture(item: string) {- if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED) {+ if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED === "true") {try {this.api.capture(item);} catch (error) {@@ -23,7 +23,7 @@ class Capturer {}identify(id: string, email?: string) {- if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED) {+ if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED === "true") {try {this.api.identify(id, {email: emaildiff --git a/standalone-entrypoint.sh b/standalone-entrypoint.shnew file mode 100755index 0000000000..e15931dc41--- /dev/null+++ b/standalone-entrypoint.sh@@ -0,0 +1,8 @@+#!/bin/sh++cd frontend-build+scripts/initialize-standalone-build.sh++cd ../++exec node build/index.js