@@ -7,7 +7,7 @@ import { ENV, MODE, VARS, isCloud } from '$lib/system';
77import { AppwriteException } from '@appwrite.io/console' ;
88import { browser } from '$app/environment' ;
99import { getReferrerAndUtmSource , getTrackedQueryParams } from '$lib/helpers/utm' ;
10- import { ProfileMode } from '$lib/profiles/index.svelte' ;
10+ import { resolvedProfile } from '$lib/profiles/index.svelte' ;
1111
1212function plausible ( domain : string ) : AnalyticsPlugin {
1313 if ( ! browser ) return { name : 'analytics-plugin-plausible' } ;
@@ -41,24 +41,17 @@ function plausible(domain: string): AnalyticsPlugin {
4141 } ;
4242}
4343
44- const PLAUSIBLE_DOMAINS = {
45- CLOUD : 'cloud.appwrite.io' ,
46- STUDIO : 'studio.imagine.dev' ,
47- SELF_HOSTED : 'self-hosted.appwrite'
48- /*GLOBAL: 'console.appwrite',*/
49- } ;
44+ function getPlausibleDomain ( ) : string | null {
45+ const plausibleConfig = resolvedProfile . analytics . plausible ;
46+ if ( ! plausibleConfig ) return null ;
5047
51- function getPlausibleDomain ( ) : string {
52- if ( VARS . CONSOLE_PROFILE === ProfileMode . STUDIO ) {
53- return PLAUSIBLE_DOMAINS . STUDIO ;
54- } else {
55- return isCloud ? PLAUSIBLE_DOMAINS . CLOUD : PLAUSIBLE_DOMAINS . SELF_HOSTED ;
56- }
48+ return isCloud ? plausibleConfig . cloud : ( plausibleConfig . selfHosted ?? null ) ;
5749}
5850
51+ const plausibleDomain = getPlausibleDomain ( ) ;
5952const analytics = Analytics ( {
6053 app : 'appwrite' ,
61- plugins : [ plausible ( getPlausibleDomain ( ) ) ]
54+ plugins : plausibleDomain ? [ plausible ( plausibleDomain ) ] : [ ]
6255} ) ;
6356
6457export function trackEvent ( name : string , data : object = null ) : void {
0 commit comments