Skip to content

Commit

Permalink
fix(frontend): add posthog key as environment variable (#3185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Sep 26, 2023
1 parent 3dbaff5 commit 235d073
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions web/public/index.html
Expand Up @@ -68,6 +68,7 @@
env: getTemplateValue('{{ .Env }}', '', parser.toString),
experimentalFeatures: getTemplateValue('{{ .ExperimentalFeatures }}', '[]', parser.toArray),
isTracetestDev: getTemplateValue('{{ .IsTracetestDev }}', 'false', parser.toBoolean),
posthogKey: 'phc_Rg59ClPckoqa5p4onheukqHKJFPbTJkiNzECjIG4lMj',
};

var base = document.createElement('base');
Expand Down
3 changes: 2 additions & 1 deletion web/src/services/Analytics/Analytics.service.ts
Expand Up @@ -8,6 +8,7 @@ const appVersion = Env.get('appVersion');
const env = Env.get('env');
const serverID = Env.get('serverID');
const measurementId = Env.get('measurementId');
const posthogKey = Env.get('posthogKey');

export const analytics = new AnalyticsBrowser();

Expand Down Expand Up @@ -47,7 +48,7 @@ const AnalyticsService = (): TAnalyticsService => ({
env,
});

posthog.init('phc_Rg59ClPckoqa5p4onheukqHKJFPbTJkiNzECjIG4lMj', {
posthog.init(posthogKey, {
api_host: 'https://app.posthog.com',
loaded: ph => {
ph.identify(serverID, {appVersion, env});
Expand Down
1 change: 1 addition & 0 deletions web/src/types/Common.types.ts
Expand Up @@ -11,6 +11,7 @@ export interface IEnv {
serverPathPrefix: string;
segmentLoaded: boolean;
isTracetestDev: boolean;
posthogKey: string;
}

export interface IMockFactory<T, R> {
Expand Down
1 change: 1 addition & 0 deletions web/src/utils/Env.ts
Expand Up @@ -13,6 +13,7 @@ const emptyValues: IEnv = {
serverPathPrefix: '/',
segmentLoaded: false,
isTracetestDev: false,
posthogKey: '',
};

const Env = {
Expand Down

0 comments on commit 235d073

Please sign in to comment.