Skip to content

Commit 6f0da1b

Browse files
committed
add: plausible.
1 parent 3d96a06 commit 6f0da1b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/lib/actions/analytics.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ENV, MODE, VARS, isCloud } from '$lib/system';
77
import { AppwriteException } from '@appwrite.io/console';
88
import { browser } from '$app/environment';
99
import { getReferrerAndUtmSource, getTrackedQueryParams } from '$lib/helpers/utm';
10+
import { ProfileMode } from '$lib/profiles/index.svelte';
1011

1112
function plausible(domain: string): AnalyticsPlugin {
1213
if (!browser) return { name: 'analytics-plugin-plausible' };
@@ -42,13 +43,24 @@ function plausible(domain: string): AnalyticsPlugin {
4243

4344
const PLAUSIBLE_DOMAINS = {
4445
CLOUD: 'cloud.appwrite.io',
45-
GLOBAL: 'console.appwrite',
46+
STUDIO: 'studio.imagine.dev',
4647
SELF_HOSTED: 'self-hosted.appwrite'
48+
/*GLOBAL: 'console.appwrite',*/
4749
};
4850

51+
function getPlausibleDomain(): string {
52+
if (VARS.CONSOLE_PROFILE === ProfileMode.STUDIO) {
53+
return PLAUSIBLE_DOMAINS.STUDIO;
54+
} else {
55+
return isCloud
56+
? PLAUSIBLE_DOMAINS.CLOUD
57+
: PLAUSIBLE_DOMAINS.SELF_HOSTED;
58+
}
59+
}
60+
4961
const analytics = Analytics({
5062
app: 'appwrite',
51-
plugins: [plausible(isCloud ? PLAUSIBLE_DOMAINS.CLOUD : PLAUSIBLE_DOMAINS.SELF_HOSTED)]
63+
plugins: [plausible(getPlausibleDomain())]
5264
});
5365

5466
export function trackEvent(name: string, data: object = null): void {

0 commit comments

Comments
 (0)