From 0094c832160f571837a5d7c41cfc87ae7d43333c Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 6 Jun 2022 15:27:29 +0100 Subject: [PATCH] Environment config --- .github/workflows/deploy-preprod.yml | 2 -- .github/workflows/release-develop.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- charts/budibase/values.yaml | 2 +- packages/builder/src/analytics/PosthogClient.js | 7 ++----- packages/builder/src/analytics/index.js | 5 +---- packages/builder/vite.config.js | 1 - packages/server/Dockerfile | 1 + packages/worker/Dockerfile | 1 + 9 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy-preprod.yml b/.github/workflows/deploy-preprod.yml index ac76e9bed8..ab941100a0 100644 --- a/.github/workflows/deploy-preprod.yml +++ b/.github/workflows/deploy-preprod.yml @@ -4,9 +4,7 @@ on: workflow_dispatch: env: - POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }} INTERCOM_TOKEN: ${{ secrets.INTERCOM_TOKEN }} - POSTHOG_URL: ${{ secrets.POSTHOG_URL }} SENTRY_DSN: ${{ secrets.SENTRY_DSN }} jobs: diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index aebc865002..18dfbc4cca 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -18,9 +18,9 @@ on: workflow_dispatch: env: - POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }} + # Posthog token used by ui at build time + POSTHOG_TOKEN: phc_mA8rLA1Flfs1MLgkDQnhYYGhD2s3VBupMvhHyED19bh INTERCOM_TOKEN: ${{ secrets.INTERCOM_TOKEN }} - POSTHOG_URL: ${{ secrets.POSTHOG_URL }} PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa3aaf28e9..f33dcc6d53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,9 @@ on: workflow_dispatch: env: - POSTHOG_TOKEN: ${{ secrets.POSTHOG_TOKEN }} + # Posthog token used by ui at build time + POSTHOG_TOKEN: phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS INTERCOM_TOKEN: ${{ secrets.INTERCOM_TOKEN }} - POSTHOG_URL: ${{ secrets.POSTHOG_URL }} SENTRY_DSN: ${{ secrets.SENTRY_DSN }} PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/charts/budibase/values.yaml b/charts/budibase/values.yaml index 52ead6d076..b04a8f242f 100644 --- a/charts/budibase/values.yaml +++ b/charts/budibase/values.yaml @@ -91,7 +91,7 @@ globals: budibaseEnv: PRODUCTION enableAnalytics: true sentryDSN: "" - posthogToken: "" + posthogToken: "phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS" logLevel: info selfHosted: "1" # set to 0 for budibase cloud environment, set to 1 for self-hosted setup multiTenancy: "0" # set to 0 to disable multiple orgs, set to 1 to enable multiple orgs diff --git a/packages/builder/src/analytics/PosthogClient.js b/packages/builder/src/analytics/PosthogClient.js index 8252737325..0b9f052906 100644 --- a/packages/builder/src/analytics/PosthogClient.js +++ b/packages/builder/src/analytics/PosthogClient.js @@ -1,20 +1,17 @@ import posthog from "posthog-js" import { Events } from "./constants" -// export default class PosthogClient { - constructor(token, url) { + constructor(token) { this.token = token - this.url = url } init() { - if (!this.token || !this.url) return + if (!this.token) return posthog.init(this.token, { autocapture: false, capture_pageview: true, - api_host: this.url, }) posthog.set_config({ persistence: "cookie" }) diff --git a/packages/builder/src/analytics/index.js b/packages/builder/src/analytics/index.js index 24d3da43c1..e49ec6d197 100644 --- a/packages/builder/src/analytics/index.js +++ b/packages/builder/src/analytics/index.js @@ -4,10 +4,7 @@ import IntercomClient from "./IntercomClient" import SentryClient from "./SentryClient" import { Events, EventSource } from "./constants" -const posthog = new PosthogClient( - process.env.POSTHOG_TOKEN, - process.env.POSTHOG_URL -) +const posthog = new PosthogClient(process.env.POSTHOG_TOKEN) const sentry = new SentryClient(process.env.SENTRY_DSN) const intercom = new IntercomClient(process.env.INTERCOM_TOKEN) diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 47fed87e1e..56ffbf20f5 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -31,7 +31,6 @@ export default ({ mode }) => { "process.env.INTERCOM_TOKEN": JSON.stringify( process.env.INTERCOM_TOKEN ), - "process.env.POSTHOG_URL": JSON.stringify(process.env.POSTHOG_URL), "process.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN), }), ], diff --git a/packages/server/Dockerfile b/packages/server/Dockerfile index 54468abdee..1d15dd501f 100644 --- a/packages/server/Dockerfile +++ b/packages/server/Dockerfile @@ -11,6 +11,7 @@ ENV PORT=4001 ENV COUCH_DB_URL=https://couchdb.budi.live:5984 ENV BUDIBASE_ENVIRONMENT=PRODUCTION ENV SERVICE=app-service +ENV POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS # copy files and install dependencies COPY . ./ diff --git a/packages/worker/Dockerfile b/packages/worker/Dockerfile index 086c69fddc..607352ad92 100644 --- a/packages/worker/Dockerfile +++ b/packages/worker/Dockerfile @@ -22,5 +22,6 @@ EXPOSE 4001 ENV NODE_ENV=production ENV CLUSTER_MODE=${CLUSTER_MODE} ENV SERVICE=worker-service +ENV POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS CMD ["./docker_run.sh"]