Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): add posthog key as environment variable #3185

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions web/public/index.html
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const emptyValues: IEnv = {
serverPathPrefix: '/',
segmentLoaded: false,
isTracetestDev: false,
posthogKey: '',
};

const Env = {
Expand Down