Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Plausible from 'plausible-tracker';
import { get } from 'svelte/store';
import { page } from '$app/state';
import { user } from '$lib/stores/user';
import { ENV, MODE, VARS, isCloud } from '$lib/system';
import { ENV, MODE, VARS } from '$lib/system';
import { AppwriteException } from '@appwrite.io/console';
import { browser } from '$app/environment';
import { getReferrerAndUtmSource, getTrackedQueryParams } from '$lib/helpers/utm';
Expand Down Expand Up @@ -41,17 +41,9 @@ function plausible(domain: string): AnalyticsPlugin {
};
}

function getPlausibleDomain(): string | null {
const plausibleConfig = resolvedProfile.analytics.plausible;
if (!plausibleConfig) return null;

return isCloud ? plausibleConfig.cloud : (plausibleConfig.selfHosted ?? null);
}

const plausibleDomain = getPlausibleDomain();
const analytics = Analytics({
app: 'appwrite',
plugins: plausibleDomain ? [plausible(plausibleDomain)] : []
plugins: [plausible(resolvedProfile.analytics.plausible)]
});

export function trackEvent(name: string, data: object = null): void {
Expand Down
14 changes: 3 additions & 11 deletions src/lib/profiles/index.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ export type Profile = {
technical: string[];
};
analytics: {
plausible?: {
cloud: string;
selfHosted?: string;
};
plausible?: string;
};
};

Expand Down Expand Up @@ -169,10 +166,7 @@ export const base: Profile = {
]
},
analytics: {
plausible: {
cloud: 'cloud.appwrite.io',
selfHosted: 'self-hosted.appwrite'
}
plausible: isCloud ? 'cloud.appwrite.io' : 'self-hosted.appwrite'
}
};

Expand Down Expand Up @@ -257,9 +251,7 @@ export const studio: Profile = {
]
},
analytics: {
plausible: {
cloud: 'studio.imagine.dev'
}
plausible: 'studio.imagine.dev'
}
};

Expand Down
Loading