diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 5ba64ae04..fae540aa4 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -2,7 +2,7 @@ import type { Action } from 'svelte/action'; export type AnalyticsActionParam = { name: string; - action: string; + action?: string; category?: string; label?: string; parameters?: Record; @@ -22,6 +22,16 @@ export const event: Action> = (node, }); }; +export function sendEvent(event: { + action: string; + label?: string; + category?: string; + data?: object; +}): void { + console.log(`send event ${event.action}`) + //TODO: implement analytics +} + const isTrackingAllowed = () => { if (!('gtag' in window)) { return false; diff --git a/src/lib/components/empty.svelte b/src/lib/components/empty.svelte index 37bf41dce..05c27ac35 100644 --- a/src/lib/components/empty.svelte +++ b/src/lib/components/empty.svelte @@ -37,6 +37,7 @@ {:else} {/if} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 790b7efa1..edd671772 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -11,6 +11,7 @@ import { Progress, Notifications } from '$lib/layout'; import { loading } from './store'; import Loading from './loading.svelte'; + import { sendEvent } from '$lib/actions/analytics'; if (browser) { window.VERCEL_ANALYTICS_ID = import.meta.env.VERCEL_ANALYTICS_ID?.toString() ?? false; @@ -52,6 +53,21 @@ } }); + function track(event: MouseEvent) { + const target = event.target as HTMLElement; + + if (target.hasAttribute('data-event')) { + const value = target.getAttribute('data-event'); + if (!value) { + return; + } + + sendEvent({ + action: `click_${value}` + }); + } + } + $: { if (browser) { if ($app.theme === 'auto') { @@ -86,6 +102,7 @@ {/if} + diff --git a/src/routes/console/account/delete.svelte b/src/routes/console/account/delete.svelte index 0e6a1e46e..9fde708a2 100644 --- a/src/routes/console/account/delete.svelte +++ b/src/routes/console/account/delete.svelte @@ -1,4 +1,5 @@ - + + sendEvent({ + action: 'submit_account_delete' + })} + warning> Delete Account

Are you sure you want to delete your account?

diff --git a/src/routes/console/createOrganization.svelte b/src/routes/console/createOrganization.svelte index f1f632ffa..9763f0337 100644 --- a/src/routes/console/createOrganization.svelte +++ b/src/routes/console/createOrganization.svelte @@ -7,6 +7,7 @@ import { createEventDispatcher } from 'svelte'; import { goto, invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let show = false; @@ -36,7 +37,15 @@ }; - + + sendEvent({ + action: 'submit_organization_create' + })} + size="big" + bind:show> Create New Organization - + + sendEvent({ + action: 'submit_organization_member_invite' + })}> Invite Member import { goto } from '$app/navigation'; + import { sendEvent } from '$lib/actions/analytics'; import { Modal, CustomId } from '$lib/components'; import { Pill } from '$lib/elements'; import { InputText, Button, FormList } from '$lib/elements/forms'; @@ -41,7 +42,15 @@ }; - + + sendEvent({ + action: 'submit_project_create' + })} + size="big" + bind:show> Create Project - + + sendEvent({ + action: 'submit_organization_member_delete' + })} + warning> {isUser ? 'Leave Organization' : 'Delete Member'} diff --git a/src/routes/console/organization-[organization]/deleteOrganization.svelte b/src/routes/console/organization-[organization]/deleteOrganization.svelte index 37a5adda4..5c706ed32 100644 --- a/src/routes/console/organization-[organization]/deleteOrganization.svelte +++ b/src/routes/console/organization-[organization]/deleteOrganization.svelte @@ -7,6 +7,7 @@ import { goto, invalidate } from '$app/navigation'; import { base } from '$app/paths'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let showDelete = false; @@ -34,7 +35,14 @@ }; - + + sendEvent({ + action: 'submit_organization_delete' + })} + bind:show={showDelete} + warning> Delete Organization

Are you sure you want to delete {$organization.name}? All projects ({$organization.total}) diff --git a/src/routes/console/project-[project]/auth/_appleOAuth.svelte b/src/routes/console/project-[project]/auth/_appleOAuth.svelte index aa176bfd8..4c5de8079 100644 --- a/src/routes/console/project-[project]/auth/_appleOAuth.svelte +++ b/src/routes/console/project-[project]/auth/_appleOAuth.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let provider: Provider; @@ -51,7 +52,19 @@ $: secret = keyID && teamID && p8 ? JSON.stringify({ keyID, teamID, p8 }) : provider.secret; - + + sendEvent({ + action: 'submit_auth_provider_update', + data: { + provider + } + })} + size="big" + show + on:close> {provider.name} OAuth2 Settings

diff --git a/src/routes/console/project-[project]/auth/_auth0OAuth.svelte b/src/routes/console/project-[project]/auth/_auth0OAuth.svelte index 129bf4903..fa737772a 100644 --- a/src/routes/console/project-[project]/auth/_auth0OAuth.svelte +++ b/src/routes/console/project-[project]/auth/_auth0OAuth.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let provider: Provider; @@ -52,7 +53,19 @@ : provider.secret; - + + sendEvent({ + action: 'submit_auth_provider_update', + data: { + provider + } + })} + on:close> {provider.name} OAuth2 Settings

diff --git a/src/routes/console/project-[project]/auth/_createTeam.svelte b/src/routes/console/project-[project]/auth/_createTeam.svelte index d91118fe5..f807a1e3c 100644 --- a/src/routes/console/project-[project]/auth/_createTeam.svelte +++ b/src/routes/console/project-[project]/auth/_createTeam.svelte @@ -1,4 +1,5 @@ - + + sendEvent({ + action: 'submit_auth_team_create' + })}> Create Team + import { sendEvent } from '$lib/actions/analytics'; import { Modal, CustomId } from '$lib/components'; import { Pill } from '$lib/elements/'; import { @@ -52,7 +53,15 @@ } - + + sendEvent({ + action: 'submit_auth_user_create' + })}> Create User - + + sendEvent({ + action: 'submit_auth_provider_update', + data: { + provider + } + })} + on:close> {provider.name} OAuth2 Settings

diff --git a/src/routes/console/project-[project]/auth/_microsoftOAuth.svelte b/src/routes/console/project-[project]/auth/_microsoftOAuth.svelte index 4466ae493..df6168d7d 100644 --- a/src/routes/console/project-[project]/auth/_microsoftOAuth.svelte +++ b/src/routes/console/project-[project]/auth/_microsoftOAuth.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let provider: Provider; @@ -51,7 +52,19 @@ clientSecret && tenantID ? JSON.stringify({ clientSecret, tenantID }) : provider.secret; - + + sendEvent({ + action: 'submit_auth_provider_update', + data: { + provider + } + })} + size="big" + show + on:close> {provider.name} OAuth2 Settings

diff --git a/src/routes/console/project-[project]/auth/_oktaOAuth.svelte b/src/routes/console/project-[project]/auth/_oktaOAuth.svelte index bb4ff54c0..c6d7a9e65 100644 --- a/src/routes/console/project-[project]/auth/_oktaOAuth.svelte +++ b/src/routes/console/project-[project]/auth/_oktaOAuth.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import { invalidate } from '$app/navigation'; import { Dependencies } from '$lib/constants'; + import { sendEvent } from '$lib/actions/analytics'; export let provider: Provider; @@ -55,7 +56,19 @@ : provider.secret; - + + sendEvent({ + action: 'submit_auth_provider_update', + data: { + provider + } + })} + size="big" + show + on:close> {provider.name} OAuth2 Settings

diff --git a/src/routes/console/project-[project]/auth/teams/[[page]]/+page.svelte b/src/routes/console/project-[project]/auth/teams/[[page]]/+page.svelte index fec59dafb..07985ea47 100644 --- a/src/routes/console/project-[project]/auth/teams/[[page]]/+page.svelte +++ b/src/routes/console/project-[project]/auth/teams/[[page]]/+page.svelte @@ -41,7 +41,7 @@ type: 'team' } }}> - diff --git a/src/routes/console/project-[project]/auth/teams/team-[team]/+page.svelte b/src/routes/console/project-[project]/auth/teams/team-[team]/+page.svelte index 1b411daea..251f92ba7 100644 --- a/src/routes/console/project-[project]/auth/teams/team-[team]/+page.svelte +++ b/src/routes/console/project-[project]/auth/teams/team-[team]/+page.svelte @@ -11,6 +11,7 @@ import { Dependencies } from '$lib/constants'; import { invalidate } from '$app/navigation'; import DeleteTeam from './deleteTeam.svelte'; + import { sendEvent } from '$lib/actions/analytics'; let showDelete = false; let teamName: string = null; @@ -52,7 +53,12 @@ -

+ + sendEvent({ + action: 'submit_auth_team_update_name' + })}> Update Name @@ -68,11 +74,7 @@ - +
@@ -99,7 +101,8 @@
- + diff --git a/src/routes/console/project-[project]/auth/teams/team-[team]/createMembership.svelte b/src/routes/console/project-[project]/auth/teams/team-[team]/createMembership.svelte index ef46c7d5f..4d36501f7 100644 --- a/src/routes/console/project-[project]/auth/teams/team-[team]/createMembership.svelte +++ b/src/routes/console/project-[project]/auth/teams/team-[team]/createMembership.svelte @@ -1,5 +1,6 @@ - + + sendEvent({ + action: 'submit_auth_member_create' + })} + size="big" + bind:show={showCreate}> Create Membership - + + sendEvent({ + action: 'submit_auth_member_delete' + })} + warning> Delete Member

Are you sure you want to delete {selectedMembership.userName} from '{selectedMembership.teamName}'? diff --git a/src/routes/console/project-[project]/auth/teams/team-[team]/deleteTeam.svelte b/src/routes/console/project-[project]/auth/teams/team-[team]/deleteTeam.svelte index 2a79abc62..60eeceb3a 100644 --- a/src/routes/console/project-[project]/auth/teams/team-[team]/deleteTeam.svelte +++ b/src/routes/console/project-[project]/auth/teams/team-[team]/deleteTeam.svelte @@ -2,6 +2,7 @@ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; + import { sendEvent } from '$lib/actions/analytics'; import { Modal } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { addNotification } from '$lib/stores/notifications'; @@ -25,7 +26,14 @@ }; - + + sendEvent({ + action: 'submit_auth_team_delete' + })} + warning> Delete Team

diff --git a/src/routes/console/project-[project]/auth/teams/team-[team]/members/[[page]]/+page.svelte b/src/routes/console/project-[project]/auth/teams/team-[team]/members/[[page]]/+page.svelte index 90c9d0a6a..66e576b42 100644 --- a/src/routes/console/project-[project]/auth/teams/team-[team]/members/[[page]]/+page.svelte +++ b/src/routes/console/project-[project]/auth/teams/team-[team]/members/[[page]]/+page.svelte @@ -12,7 +12,7 @@ import { Button } from '$lib/elements/forms'; import { Container } from '$lib/layout'; import type { Models } from '@aw-labs/appwrite-console'; - import { goto, invalidate } from '$app/navigation'; + import { invalidate } from '$app/navigation'; import { base } from '$app/paths'; import { toLocaleDateTime } from '$lib/helpers/date'; import type { PageData } from './$types'; @@ -28,14 +28,14 @@ const project = $page.params.project; - async function memberCreated(event: CustomEvent) { - await goto(`${base}/console/project-${project}/auth/teams-${event.detail.teamId}/members`); + async function memberCreated() { + invalidate(Dependencies.MEMBERSHIPS); } - @@ -70,7 +70,10 @@ selectedMembership = membership; showDelete = true; }}> -

+ + sendEvent({ + action: 'submit_auth_user_update_name' + })}> Update Name @@ -301,7 +318,12 @@
-
+ + sendEvent({ + action: 'submit_auth_user_update_email' + })}> Update Email @@ -321,7 +343,12 @@
-
+ + sendEvent({ + action: 'submit_auth_user_update_phone' + })}> Update Phone @@ -341,7 +368,12 @@
-
+ + sendEvent({ + action: 'submit_auth_user_update_password' + })}>
Update Password @@ -369,7 +401,12 @@ -
+ + sendEvent({ + action: 'submit_auth_user_update_preferences' + })}> User Preferences

@@ -483,7 +520,7 @@ - + diff --git a/src/routes/console/project-[project]/auth/user-[user]/deleteAllSessions.svelte b/src/routes/console/project-[project]/auth/user-[user]/deleteAllSessions.svelte index f80d82f50..99a1bcf0a 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/deleteAllSessions.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/deleteAllSessions.svelte @@ -1,6 +1,7 @@ - + + sendEvent({ + action: 'submit_auth_session_delete_all' + })} + warning> Delete All Sessions

Are you sure you want to delete all of {$user.name}'s sessions? diff --git a/src/routes/console/project-[project]/auth/user-[user]/deleteMembership.svelte b/src/routes/console/project-[project]/auth/user-[user]/deleteMembership.svelte index eec7bd042..b1c30ec8c 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/deleteMembership.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/deleteMembership.svelte @@ -2,6 +2,7 @@ import { goto, invalidate } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; + import { sendEvent } from '$lib/actions/analytics'; import { Modal } from '$lib/components'; import { Dependencies } from '$lib/constants'; import { Button } from '$lib/elements/forms'; @@ -37,7 +38,14 @@ }; - + + sendEvent({ + action: 'submit_auth_member_delete' + })} + warning> Delete Member {#if selectedMembership}

diff --git a/src/routes/console/project-[project]/auth/user-[user]/deleteSession.svelte b/src/routes/console/project-[project]/auth/user-[user]/deleteSession.svelte index 8091070ce..0736c418c 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/deleteSession.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/deleteSession.svelte @@ -1,6 +1,7 @@ - + + sendEvent({ + action: 'submit_auth_session_delete' + })} + warning> Delete Sessions

Are you sure you want to delete this session?

diff --git a/src/routes/console/project-[project]/auth/user-[user]/deleteUser.svelte b/src/routes/console/project-[project]/auth/user-[user]/deleteUser.svelte index bfec8cbed..fd2a5f43e 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/deleteUser.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/deleteUser.svelte @@ -8,6 +8,7 @@ import { sdkForProject } from '$lib/stores/sdk'; import { user } from './store'; import { project } from '../../store'; + import { sendEvent } from '$lib/actions/analytics'; export let showDelete = false; @@ -29,7 +30,14 @@ }; - + + sendEvent({ + action: 'submit_auth_user_delete' + })} + warning> Delete User

Are you sure you want to delete {$user.name} from '{$project.name}'?

diff --git a/src/routes/console/project-[project]/auth/user-[user]/memberships/[[page]]/+page.svelte b/src/routes/console/project-[project]/auth/user-[user]/memberships/[[page]]/+page.svelte index 81abfff91..7a8e3a81e 100644 --- a/src/routes/console/project-[project]/auth/user-[user]/memberships/[[page]]/+page.svelte +++ b/src/routes/console/project-[project]/auth/user-[user]/memberships/[[page]]/+page.svelte @@ -59,7 +59,7 @@ selectedMembership = membership; showDelete = true; }}> -