posthog added
This commit is contained in:
@@ -16,6 +16,7 @@ import { AuthInterceptor } from './interceptors/auth.interceptor';
|
||||
import { LoadingInterceptor } from './interceptors/loading.interceptor';
|
||||
import { TimeoutInterceptor } from './interceptors/timeout.interceptor';
|
||||
import { GlobalErrorHandler } from './services/globalErrorHandler';
|
||||
import { POSTHOG_INIT_PROVIDER } from './services/posthog.factory';
|
||||
import { SelectOptionsService } from './services/select-options.service';
|
||||
import { createLogger } from './utils/utils';
|
||||
// provideClientHydration()
|
||||
@@ -67,6 +68,7 @@ export const appConfig: ApplicationConfig = {
|
||||
anchorScrolling: 'enabled',
|
||||
}),
|
||||
),
|
||||
...(environment.production ? [POSTHOG_INIT_PROVIDER] : []),
|
||||
provideAnimations(),
|
||||
provideNgxStripe('pk_test_IlpbVQhxAXZypLgnCHOCqlj8'),
|
||||
provideQuillConfig({
|
||||
|
||||
26
bizmatch/src/app/services/posthog.factory.ts
Normal file
26
bizmatch/src/app/services/posthog.factory.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// posthog.factory.ts
|
||||
import { isPlatformBrowser } from '@angular/common';
|
||||
import { APP_INITIALIZER, FactoryProvider, PLATFORM_ID, inject } from '@angular/core';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
export function initPosthog() {
|
||||
const platformId = inject(PLATFORM_ID);
|
||||
|
||||
// Nur Browser + nur Production
|
||||
if (!isPlatformBrowser(platformId) || !environment.production) return () => {};
|
||||
|
||||
return async () => {
|
||||
// Dynamisch laden -> eigener Chunk, wird in Dev nie gezogen
|
||||
const { default: posthog } = await import('posthog-js');
|
||||
posthog.init(environment.POSTHOG_KEY, {
|
||||
api_host: environment.POSTHOG_HOST,
|
||||
capture_pageview: 'history_change',
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const POSTHOG_INIT_PROVIDER: FactoryProvider = {
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: initPosthog,
|
||||
multi: true,
|
||||
};
|
||||
Reference in New Issue
Block a user