mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
set telemetry post frontend build in standalone docker img
This commit is contained in:
@@ -74,6 +74,7 @@ COPY backend/package*.json ./
|
|||||||
RUN npm ci --only-production
|
RUN npm ci --only-production
|
||||||
|
|
||||||
COPY /backend .
|
COPY /backend .
|
||||||
|
COPY standalone-entrypoint.sh standalone-entrypoint.sh
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
@@ -105,6 +106,9 @@ ENV NODE_ENV production
|
|||||||
|
|
||||||
WORKDIR /backend
|
WORKDIR /backend
|
||||||
|
|
||||||
CMD ["node", "build/index.js"]
|
ENV TELEMETRY_ENABLED true
|
||||||
|
|
||||||
|
CMD ["./standalone-entrypoint.sh"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ export const setup = async () => {
|
|||||||
// initializing global feature set
|
// initializing global feature set
|
||||||
await EELicenseService.initGlobalFeatureSet();
|
await EELicenseService.initGlobalFeatureSet();
|
||||||
|
|
||||||
// initializing the database connection
|
|
||||||
await DatabaseService.initDatabase(await getMongoURL());
|
|
||||||
|
|
||||||
await initializePassport();
|
await initializePassport();
|
||||||
|
|
||||||
// re-encrypt any data previously encrypted under server hex 128-bit ENCRYPTION_KEY
|
// re-encrypt any data previously encrypted under server hex 128-bit ENCRYPTION_KEY
|
||||||
|
|||||||
13
frontend/scripts/initialize-standalone-build.sh
Executable file
13
frontend/scripts/initialize-standalone-build.sh
Executable file
@@ -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
|
||||||
|
fi
|
||||||
16
frontend/scripts/replace-standalone-build-variable.sh
Executable file
16
frontend/scripts/replace-standalone-build-variable.sh
Executable file
@@ -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"
|
||||||
|
done
|
||||||
0
frontend/scripts/replace-variable.sh
Normal file → Executable file
0
frontend/scripts/replace-variable.sh
Normal file → Executable file
8
frontend/scripts/set-standalone-build-telemetry.sh
Normal file
8
frontend/scripts/set-standalone-build-telemetry.sh
Normal file
@@ -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"
|
||||||
|
done
|
||||||
0
frontend/scripts/set-telemetry.sh
Normal file → Executable file
0
frontend/scripts/set-telemetry.sh
Normal file → Executable file
@@ -10,7 +10,7 @@ export const initPostHog = () => {
|
|||||||
try {
|
try {
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED) {
|
if (ENV === "production" && TELEMETRY_CAPTURING_ENABLED === "true") {
|
||||||
posthog.init(POSTHOG_API_KEY, {
|
posthog.init(POSTHOG_API_KEY, {
|
||||||
api_host: POSTHOG_HOST
|
api_host: POSTHOG_HOST
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Capturer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
capture(item: string) {
|
capture(item: string) {
|
||||||
if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED) {
|
if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED === "true") {
|
||||||
try {
|
try {
|
||||||
this.api.capture(item);
|
this.api.capture(item);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -23,7 +23,7 @@ class Capturer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
identify(id: string, email?: string) {
|
identify(id: string, email?: string) {
|
||||||
if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED) {
|
if (ENV === 'production' && TELEMETRY_CAPTURING_ENABLED === "true") {
|
||||||
try {
|
try {
|
||||||
this.api.identify(id, {
|
this.api.identify(id, {
|
||||||
email: email
|
email: email
|
||||||
|
|||||||
8
standalone-entrypoint.sh
Executable file
8
standalone-entrypoint.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd frontend-build
|
||||||
|
scripts/initialize-standalone-build.sh
|
||||||
|
|
||||||
|
cd ../
|
||||||
|
|
||||||
|
exec node build/index.js
|
||||||
Reference in New Issue
Block a user