Skip to content

Commit

Permalink
fix: Force posthog recording to be disabled outside cloud
Browse files Browse the repository at this point in the history
The recordings are not enabled by default, but env variable enabled opt-in. This
changes the logic that opt-in requires specific domain.
  • Loading branch information
tomi committed Jan 18, 2024
1 parent 9945701 commit 5bb0acd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
6 changes: 0 additions & 6 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,12 +1143,6 @@ export const schema = {
default: 'https://ph.n8n.io',
env: 'N8N_DIAGNOSTICS_POSTHOG_API_HOST',
},
disableSessionRecording: {
doc: 'Disable posthog session recording',
format: Boolean,
default: true,
env: 'N8N_DIAGNOSTICS_POSTHOG_DISABLE_RECORDING',
},
},
sentry: {
dsn: {
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/src/services/frontend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ export class FrontendService {
apiHost: config.getEnv('diagnostics.config.posthog.apiHost'),
apiKey: config.getEnv('diagnostics.config.posthog.apiKey'),
autocapture: false,
disableSessionRecording: config.getEnv(
'diagnostics.config.posthog.disableSessionRecording',
),
debug: config.getEnv('logs.level') === 'debug',
},
personalizationSurveyEnabled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const defaultSettings: IN8nUISettings = {
apiKey: '',
autocapture: false,
debug: false,
disableSessionRecording: false,
enabled: false,
},
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
Expand Down
1 change: 0 additions & 1 deletion packages/editor-ui/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const SETTINGS_STORE_DEFAULT_STATE: ISettingsState = {
apiKey: '',
autocapture: false,
debug: false,
disableSessionRecording: false,
enabled: false,
},
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
Expand Down
1 change: 0 additions & 1 deletion packages/editor-ui/src/stores/__tests__/posthog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const DEFAULT_POSTHOG_SETTINGS: IN8nUISettings['posthog'] = {
apiHost: 'host',
apiKey: 'key',
autocapture: false,
disableSessionRecording: true,
debug: false,
};
const CURRENT_USER_ID = '1';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/stores/posthog.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const usePostHog = defineStore('posthog', () => {
return;
}

const config = settingsStore.settings.posthog;
const config = settingsStore.posthogSettings;
if (!config.enabled) {
return;
}
Expand Down
12 changes: 12 additions & 0 deletions packages/editor-ui/src/stores/settings.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import { useTitleChange } from '@/composables/useTitleChange';
import { useToast } from '@/composables/useToast';
import { i18n } from '@/plugins/i18n';

export type PosthogSettings = IN8nUISettings['posthog'] & {
disableSessionRecording: boolean;
};

export const useSettingsStore = defineStore(STORES.SETTINGS, {
state: (): ISettingsState => ({
initialized: false,
Expand Down Expand Up @@ -193,6 +197,14 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
isDevRelease(): boolean {
return this.settings.releaseChannel === 'dev';
},
posthogSettings(): PosthogSettings {
const disableSessionRecording = !window.location.hostname.endsWith('n8n.cloud');

return {
...this.settings.posthog,
disableSessionRecording,
};
},
},
actions: {
async initialize() {
Expand Down
1 change: 0 additions & 1 deletion packages/workflow/src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,6 @@ export interface IN8nUISettings {
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
personalizationSurveyEnabled: boolean;
Expand Down

0 comments on commit 5bb0acd

Please sign in to comment.