Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix analytic events #1730

Merged
merged 36 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
86be226
Fix login event
ernstmul Mar 5, 2025
d6a82ea
Add mfa tracking
ernstmul Mar 5, 2025
36dfc62
Add mfa tracking
ernstmul Mar 5, 2025
b048381
Add mfa tracking
ernstmul Mar 5, 2025
b34067f
Add mfa tracking
ernstmul Mar 5, 2025
0b550f0
Only fire once on account create
ernstmul Mar 5, 2025
66cc2df
Fix billing address event
ernstmul Mar 5, 2025
63ea62f
Track clear search
ernstmul Mar 5, 2025
834a34a
Track create org in breadcrumbs
ernstmul Mar 5, 2025
fee2baf
Add platfrom create click
ernstmul Mar 5, 2025
610ebfa
Add platfrom create click
ernstmul Mar 5, 2025
7d616c8
Fix onboarding events
ernstmul Mar 5, 2025
6203e86
Introduce click enum
ernstmul Mar 5, 2025
017b1b9
Update exiting clicks to enum
ernstmul Mar 5, 2025
fb1a223
Auth events
ernstmul Mar 5, 2025
e02fe18
Filter events
ernstmul Mar 5, 2025
a4a212a
Database events
ernstmul Mar 5, 2025
c7793e1
Functions WIP
ernstmul Mar 5, 2025
97c8c42
Functions WIP
ernstmul Mar 5, 2025
1db51a9
Variable update
ernstmul Mar 6, 2025
64d0e1a
Variable import
ernstmul Mar 6, 2025
4687ff3
Add domains
ernstmul Mar 6, 2025
ce92639
Delete domain, and typo for collections
ernstmul Mar 6, 2025
ff6eddc
Finish up functions
ernstmul Mar 6, 2025
23e9f1a
WIP messaging
ernstmul Mar 6, 2025
cacb67e
WIP messaging
ernstmul Mar 6, 2025
34b5be4
WIP messaging
ernstmul Mar 6, 2025
514e16e
Merge branch 'feat-pink-v2' into fix-analytic-events
ernstmul Mar 6, 2025
330327a
Storage events
ernstmul Mar 6, 2025
ab377e7
WIP settings
ernstmul Mar 6, 2025
ca85fcc
feedback
ernstmul Mar 6, 2025
9c36abe
support
ernstmul Mar 6, 2025
438009d
Legacy clicks replace
ernstmul Mar 6, 2025
5f390e0
Legacy clicks replace
ernstmul Mar 6, 2025
c276f66
Legacy clicks replace
ernstmul Mar 6, 2025
334eb29
Merge branch 'feat-pink-v2' into fix-analytic-events
ernstmul Mar 6, 2025
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
66 changes: 65 additions & 1 deletion src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,59 @@ export function isTrackingAllowed() {
}
}

export enum Click {
BackupRestoreClick = 'click_backup_restore',
BreadcrumbClick = 'click_breadcrumb',
ConnectRepositoryClick = 'click_connect_repository',
CreditsRedeemClick = 'click_credits_redeem',
CloudSignupClick = 'click_cloud_signup',
DatabaseAttributeDelete = 'click_attribute_delete',
DatabaseIndexDelete = 'click_index_delete',
DatabaseCollectionDelete = 'click_collection_delete',
DatabaseDatabaseDelete = 'click_database_delete',
DomainCreateClick = 'click_domain_create',
DomainDeleteClick = 'click_domain_delete',
DomainRetryDomainVerificationClick = 'click_domain_retry_domain_verification',
FeedbackSubmitClick = 'click_leave_feedback',
FilterApplyClick = 'click_apply_filter',
FunctionsRedeployClick = 'click_function_redeploy',
FunctionsDeploymentDeleteClick = 'click_deployment_delete',
KeyCreateClick = 'click_key_create',
MenuDropDownClick = 'click_menu_dropdown',
MenuOverviewClick = 'click_menu_overview',
ModalCloseClick = 'click_close_modal',
MessagingScheduleClick = 'click_messaging_schedule',
MessagingTopicCreateClick = 'click_messaging_topic_create',
MessagingTargetCreateClick = 'click_messaging_target_create',
MembershipDeleteClick = 'click_delete_membership',
PlatformCreateClick = 'click_platform_create',
OrganizationClickCreate = 'click_create_organization',
OrganizationClickUpgrade = 'click_organization_upgrade',
OnboardingSetupDatabaseClick = 'click_onboarding_setup_database',
OnboardingApiReferencesClick = 'click_onboarding_api_references',
OnboardingTutorialsClick = 'click_onboarding_tutorials',
OnboardingStorageQuickstartClick = 'click_onboarding_storage_quickstart',
OnboardingFunctionsQuickstartClick = 'click_onboarding_functions_quickstart',
OnboardingAuthEmailPasswordClick = 'click_onboarding_auth_email_password',
OnboardingAuthOauth2Click = 'click_onboarding_auth_oauth2',
OnboardingAuthAllMethodsClick = 'click_onboarding_auth_all_methods',
OnboardingDiscordClick = 'click_onboarding_discord',
StorageBucketDeleteClick = 'click_bucket_delete',
SettingsWebhookUpdateSignatureClick = 'click_webhook_update_signature',
SettingsWebhookDeleteClick = 'click_webhook_delete',
SettingsInstallProviderClick = 'click_install_provider',
SettingsStartMigrationClick = 'click_start_migration',
SubmitFormClick = 'click_submit_form',
ShowCustomIdClick = 'click_show_custom_id',
SupportOpenClick = 'click_open_support_menu',
PromoClick = 'click_promo',
PolicyDeleteClick = 'click_policy_delete',
VariablesCreateClick = 'click_variable_create',
VariablesUpdateClick = 'click_variable_update',
VariablesImportClick = 'click_variable_import',
WebsiteOpenClick = 'click_open_website'
}

export enum Submit {
DownloadDPA = 'submit_download_dpa',
Error = 'submit_error',
Expand All @@ -158,13 +211,17 @@ export enum Submit {
AccountRecoveryCodesCreate = 'submit_account_recovery_codes_create',
AccountRecoveryCodesUpdate = 'submit_account_recovery_codes_update',
AccountDeleteIdentity = 'submit_account_delete_identity',
FeedbackSubmit = 'submit_leave_feedback',
FilterClear = 'submit_clear_filter',
FilterApply = 'submit_filter_apply',
UserCreate = 'submit_user_create',
UserDelete = 'submit_user_delete',
UserUpdateEmail = 'submit_user_update_email',
UserUpdateLabels = 'submit_user_update_labels',
UserUpdateName = 'submit_user_update_name',
UserUpdatePassword = 'submit_user_update_password',
UserUpdatePhone = 'submit_user_update_phone',
UserUpdateMfa = 'submit_user_update_mfa',
UserUpdatePreferences = 'submit_user_update_preferences',
UserUpdateStatus = 'submit_user_update_status',
UserUpdateVerificationEmail = 'submit_user_update_verification_email',
Expand All @@ -186,9 +243,12 @@ export enum Submit {
MemberDelete = 'submit_member_delete',
MembershipUpdate = 'submit_membership_update',
MembershipUpdateStatus = 'submit_membership_update_status',
MessagingTargetUpdate = 'submit_messaging_target_update',
MessagingUpdateHtmlMode = 'submit_update_html_mode',
ProviderUpdate = 'submit_provider_update',
TeamCreate = 'submit_team_create',
TeamDelete = 'submit_team_delete',
TeamUpdatePreferences = 'submit_team_update_preferences',
TeamUpdateName = 'submit_team_update_name',
AuthLimitUpdate = 'submit_auth_limit_update',
AuthStatusUpdate = 'submit_auth_status_update',
Expand Down Expand Up @@ -231,6 +291,7 @@ export enum Submit {
FunctionUpdateTimeout = 'submit_function_update_timeout',
FunctionUpdateEvents = 'submit_function_update_events',
FunctionUpdateScopes = 'submit_function_key_update_scopes',
FunctionUpdateRuntime = 'submit_function_update_runtime',
FunctionConnectRepo = 'submit_function_connect_repo',
FunctionDisconnectRepo = 'submit_function_disconnect_repo',
FunctionRedeploy = 'submit_function_redeploy',
Expand All @@ -249,9 +310,11 @@ export enum Submit {
KeyUpdateName = 'submit_key_update_name',
KeyUpdateScopes = 'submit_key_update_scopes',
KeyUpdateExpire = 'submit_key_update_expire',

PlatformCreate = 'submit_platform_create',
PlatformDelete = 'submit_platform_delete',
PlatformUpdate = 'submit_platform_update',

DomainCreate = 'submit_domain_create',
DomainDelete = 'submit_domain_delete',
DomainUpdateVerification = 'submit_domain_update_verification',
Expand Down Expand Up @@ -344,5 +407,6 @@ export enum Submit {
SiteActivateDeployment = 'submit_site_activate_deployment',
RecordCreate = 'submit_dns_record_create',
RecordUpdate = 'submit_dns_record_update',
RecordDelete = 'submit_dns_record_delete'
RecordDelete = 'submit_dns_record_delete',
SearchClear = 'submit_clear_search'
}
10 changes: 10 additions & 0 deletions src/lib/commandCenter/panels/template.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { clearSubPanels, popSubPanel, subPanels } from '../subPanels';
import { IconArrowSmRight } from '@appwrite.io/pink-icons-svelte';
import { Icon, Keyboard, Layout } from '@appwrite.io/pink-svelte';
import { Submit, trackEvent } from '$lib/actions/analytics';

/* eslint no-undef: "off" */
type Option = $$Generic<Omit<Command, 'group'> & { group?: string }>;
Expand All @@ -22,6 +23,7 @@
let selected = 0;
let usingKeyboard = false;
let contentEl: HTMLElement;
let didSearch = false;

async function triggerOption(option: Option) {
const prevPanels = $subPanels.length;
Expand All @@ -43,6 +45,14 @@
if (!open) return;
usingKeyboard = true;

if (search.length > 0) {
didSearch = true;
}

if (search === '' && didSearch) {
trackEvent(Submit.SearchClear);
}

let canceled = false;
dispatch('keydown', {
originalEvent: event,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/billing/alerts/limitReached.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
import { BillingPlan } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { HeaderAlert } from '$lib/layout';
Expand All @@ -26,7 +26,7 @@
<Button
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
trackEvent(Click.OrganizationClickUpgrade, {
from: 'button',
source: 'limit_reached_banner'
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/billing/alerts/newDevUpgradePro.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
import { BillingPlan } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { organization } from '$lib/stores/organization';
Expand Down Expand Up @@ -31,7 +31,7 @@
class="u-line-height-1"
href={`${base}/apply-credit?code=appw50&org=${$organization.$id}`}
on:click={() => {
trackEvent('click_credits_redeem', {
trackEvent(Click.CreditsRedeemClick, {
from: 'button',
source: 'cloud_credits_banner',
campaign: 'WelcomeManual'
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/billing/emptyCardCloud.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
import { BillingPlan } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { tierToPlan, upgradeURL } from '$lib/stores/billing';
Expand All @@ -23,7 +23,7 @@
fullWidthMobile
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
trackEvent(Click.OrganizationClickUpgrade, {
from: 'button',
source: eventSource
});
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/bottomModalAlert.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { addBottomModalAlerts } from '$routes/(console)/bottomAlerts';
import { project } from '$routes/(console)/project-[project]/store';
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
let currentIndex = 0;
let openModalOnMobile = false;
Expand Down Expand Up @@ -170,7 +170,7 @@
external={!!currentModalAlert.cta.external}
fullWidthMobile
on:click={() => {
trackEvent('click_promo', {
trackEvent(Click.PromoClick, {
promo: currentModalAlert.id,
type: shouldShowUpgrade ? 'upgrade' : 'try_now'
});
Expand Down Expand Up @@ -282,7 +282,7 @@
fullWidthMobile
on:click={() => {
openModalOnMobile = false;
trackEvent('click_promo', {
trackEvent(Click.PromoClick, {
promo: currentModalAlert.id,
type: shouldShowUpgrade ? 'upgrade' : 'try_now'
});
Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/breadcrumbs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { newOrgModal } from '$lib/stores/organization';
import { Click, trackEvent } from '$lib/actions/analytics';

type Project = {
name: string;
Expand Down Expand Up @@ -68,6 +69,7 @@
let projectsBottomSheetOpen = false;

function createOrg() {
trackEvent(Click.OrganizationClickCreate, { source: 'breadcrumbs' });
if (isCloud) {
goto(`${base}/create-organization`);
} else newOrgModal.set(true);
Expand Down
8 changes: 7 additions & 1 deletion src/lib/components/cardPlanLimit.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { upgradeURL } from '$lib/stores/billing';
import { Click, trackEvent } from '$lib/actions/analytics';

export let service: string;
</script>

<article class="card u-grid u-cross-center u-width-full-line">
<div class="u-flex u-flex-vertical u-gap-24 u-main-center u-cross-center">
<p class="text u-text-center">Upgrade your plan to add more {service}</p>
<Button secondary href={$upgradeURL}>Change plan</Button>
<Button
secondary
href={$upgradeURL}
on:click={() => {
trackEvent(Click.OrganizationClickUpgrade, { source: 'card_plan_limit' });
}}>Change plan</Button>
</div>
</article>
4 changes: 2 additions & 2 deletions src/lib/components/customId.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
import { InputId } from '$lib/elements/forms';
import { InputProjectId } from '$lib/elements/forms';
import Button from '$lib/elements/forms/button.svelte';
Expand All @@ -20,7 +20,7 @@
}

$: if (show) {
trackEvent('click_show_custom_id');
trackEvent(Click.ShowCustomIdClick);
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/fakeModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Alert } from '$lib/components';
import { onMount } from 'svelte';
import Form from '$lib/elements/forms/form.svelte';
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';
import { clickOnEnter } from '$lib/helpers/a11y';

export let show = false;
Expand All @@ -23,7 +23,7 @@

function handleBLur(event: MouseEvent) {
if (event.target === backdrop) {
trackEvent('click_close_modal', {
trackEvent(Click.ModalCloseClick, {
from: 'backdrop'
});
closeModal();
Expand All @@ -38,7 +38,7 @@
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') {
event.preventDefault();
trackEvent('click_close_modal', {
trackEvent(Click.ModalCloseClick, {
from: 'escape'
});
closeModal();
Expand Down Expand Up @@ -100,7 +100,7 @@
aria-label="Close Modal"
title="Close Modal"
on:click={() =>
trackEvent('click_close_modal', {
trackEvent(Click.ModalCloseClick, {
from: 'button'
})}
on:click={closeModal}>
Expand Down
12 changes: 11 additions & 1 deletion src/lib/components/filters/filters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { createEventDispatcher } from 'svelte';
import { Icon, Layout, Popover } from '@appwrite.io/pink-svelte';
import { IconFilter, IconFilterLine } from '@appwrite.io/pink-icons-svelte';
import { Click, Submit, trackEvent } from '$lib/actions/analytics';

export let query = '[]';
export let columns: Writable<Column[]>;
Expand All @@ -25,6 +26,7 @@
export let clearOnClick = false; // When enabled the user doesn't have to click apply to clear the filters
export let enableApply = false;
export let quickFilters = false;
export let analyticsSource = '';
let displayQuickFilters = quickFilters;

const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -53,12 +55,14 @@
selectedColumn = null;
queries.clearAll();
if (clearOnClick) {
trackEvent(Submit.FilterClear, { source: analyticsSource });
queries.apply();
}
}

function apply() {
if (quickFilters && displayQuickFilters) {
trackEvent(Submit.FilterApply, { source: analyticsSource });
dispatch('apply');
} else if (
selectedColumn &&
Expand Down Expand Up @@ -118,7 +122,13 @@

<div class="is-not-mobile">
<Popover let:toggle placement="bottom-start">
<Button secondary on:click={toggle} {disabled}>
<Button
secondary
on:click={(event) => {
toggle(event);
trackEvent(Click.FilterApplyClick, { source: analyticsSource });
}}
{disabled}>
<Icon icon={IconFilterLine} slot="start" size="s" />
Filters
{#if applied > 0}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/mfaChallengeFormList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
}
await sdk.forConsole.account.updateMfaChallenge(challenge.$id, code);
await invalidate(Dependencies.ACCOUNT);
trackEvent(Submit.AccountCreate);
trackEvent(Submit.AccountLogin, { mfa_used: true });
} catch (error) {
inputDigitFields?.clearInputsAndRefocus();
trackError(error, Submit.AccountCreate);
trackError(error, Submit.AccountLogin);
throw error;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { disableCommands } from '$lib/commandCenter';
import { beforeNavigate } from '$app/navigation';
import { Layout, Modal } from '@appwrite.io/pink-svelte';
import { trackEvent } from '$lib/actions/analytics';
import { Click, trackEvent } from '$lib/actions/analytics';

export let show = false;
export let error: string = null;
Expand All @@ -28,7 +28,7 @@
event.preventDefault();
if (show) {
formComponent.triggerSubmit();
trackEvent('click_submit_form', { from: 'enter' });
trackEvent(Click.SubmitFormClick, { from: 'enter' });
}
}
}
Expand Down
Loading
Loading