mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: track custom id usage
This commit is contained in:
1 parent
99772f4301
commit
91352f9a30
13 files changed
+64
-23
No files matched your search
@@ -22,7 +22,15 @@ export function trackEvent(name: string, data: object = null): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const path = get(page).route.id;
|
||||
const currentPage = get(page);
|
||||
const path = currentPage.route.id;
|
||||
|
||||
if (currentPage.params?.project) {
|
||||
data = {
|
||||
...data,
|
||||
project: currentPage.params.project
|
||||
};
|
||||
}
|
||||
|
||||
if (isDevelopment) {
|
||||
console.debug(`[Analytics] Event ${name} ${path}`, data);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
export let show = false;
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const org = await sdkForConsole.teams.create(id ?? 'unique()', name);
|
||||
const org = await sdkForConsole.teams.create(id ?? ID.unique(), name);
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
dispatch('created');
|
||||
await goto(`/console/organization-${org.$id}`);
|
||||
@@ -28,7 +29,9 @@
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
trackEvent(Submit.OrganizationCreate);
|
||||
trackEvent(Submit.OrganizationCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
name = null;
|
||||
id = null;
|
||||
show = false;
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
);
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
goto(`/console/project-${project.$id}`);
|
||||
trackEvent(Submit.ProjectCreate);
|
||||
trackEvent(Submit.ProjectCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
} catch (error) {
|
||||
loading = false;
|
||||
addNotification({
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let show = false;
|
||||
@@ -23,13 +24,15 @@
|
||||
try {
|
||||
isCreating = true;
|
||||
const project = await sdkForConsole.projects.create(
|
||||
id ?? 'unique()',
|
||||
id ?? ID.unique(),
|
||||
name,
|
||||
teamId,
|
||||
'default'
|
||||
);
|
||||
dispatch('created', project);
|
||||
trackEvent(Submit.ProjectCreate);
|
||||
trackEvent(Submit.ProjectCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const team = await sdkForProject.teams.create(id ?? 'unique()', name);
|
||||
const team = await sdkForProject.teams.create(id ?? ID.unique(), name);
|
||||
name = '';
|
||||
showCreate = false;
|
||||
showCustomId = false;
|
||||
@@ -24,7 +25,9 @@
|
||||
type: 'success',
|
||||
message: `${team.name} has been created`
|
||||
});
|
||||
trackEvent(Submit.TeamCreate);
|
||||
trackEvent(Submit.TeamCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
dispatch('created', team);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
} from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
@@ -25,7 +26,7 @@
|
||||
const create = async () => {
|
||||
try {
|
||||
const user = await sdkForProject.users.create(
|
||||
id ?? 'unique()',
|
||||
id ?? ID.unique(),
|
||||
mail,
|
||||
phone,
|
||||
pass,
|
||||
@@ -38,7 +39,9 @@
|
||||
type: 'success',
|
||||
message: `${user.name ? user.name : 'User'} has been created`
|
||||
});
|
||||
trackEvent(Submit.UserCreate);
|
||||
trackEvent(Submit.UserCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
dispatch('created', user);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { Button, InputText, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
@@ -17,14 +18,16 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const database = await sdkForProject.databases.create(id ? id : 'unique()', name);
|
||||
const database = await sdkForProject.databases.create(id ? id : ID.unique(), name);
|
||||
showCreate = false;
|
||||
dispatch('created', database);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
trackEvent(Submit.DatabaseCreate);
|
||||
trackEvent(Submit.DatabaseCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
name = id = null;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
+5
-2
@@ -13,6 +13,7 @@
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
@@ -35,7 +36,7 @@
|
||||
await sdkForProject.databases.createDocument(
|
||||
databaseId,
|
||||
collectionId,
|
||||
$createDocument.id ?? 'unique()',
|
||||
$createDocument.id ?? ID.unique(),
|
||||
$createDocument.document,
|
||||
$createDocument.permissions
|
||||
);
|
||||
@@ -44,7 +45,9 @@
|
||||
message: 'Document has been created',
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.DocumentCreate);
|
||||
trackEvent(Submit.DocumentCreate, {
|
||||
customId: !!$createDocument.id
|
||||
});
|
||||
invalidate(Dependencies.DOCUMENTS);
|
||||
|
||||
createDocument.reset();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { Button, InputText, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
@@ -22,7 +23,7 @@
|
||||
try {
|
||||
const collection = await sdkForProject.databases.createCollection(
|
||||
databaseId,
|
||||
id ? id : 'unique()',
|
||||
id ? id : ID.unique(),
|
||||
name
|
||||
);
|
||||
showCreate = false;
|
||||
@@ -32,7 +33,9 @@
|
||||
message: `${name} has been created`
|
||||
});
|
||||
name = id = null;
|
||||
trackEvent(Submit.CollectionCreate);
|
||||
trackEvent(Submit.CollectionCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
|
||||
@@ -25,7 +26,7 @@
|
||||
async function create() {
|
||||
try {
|
||||
const response = await sdkForProject.functions.create(
|
||||
$createFunction.id ?? 'unique()',
|
||||
$createFunction.id ?? ID.unique(),
|
||||
$createFunction.name,
|
||||
$createFunction.execute,
|
||||
$createFunction.runtime,
|
||||
@@ -43,7 +44,9 @@
|
||||
message: `${$createFunction.name} has been created`,
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.FunctionCreate);
|
||||
trackEvent(Submit.FunctionCreate, {
|
||||
customId: !!$createFunction.id
|
||||
});
|
||||
wizard.hide();
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { Permissions } from '$lib/components/permissions';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
export let showCreate = false;
|
||||
|
||||
@@ -24,7 +25,7 @@
|
||||
async function create() {
|
||||
try {
|
||||
showCreate = false;
|
||||
await uploader.uploadFile(bucketId, id, files[0], permissions);
|
||||
await uploader.uploadFile(bucketId, id ?? ID.unique(), files[0], permissions);
|
||||
files = null;
|
||||
showCustomId = false;
|
||||
dispatch('created');
|
||||
@@ -32,7 +33,9 @@
|
||||
type: 'success',
|
||||
message: `File has been uploaded`
|
||||
});
|
||||
trackEvent(Submit.FileCreate);
|
||||
trackEvent(Submit.FileCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.FileCreate);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { Button, InputText, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const bucket = await sdkForProject.storage.createBucket(id ? id : 'unique()', name);
|
||||
const bucket = await sdkForProject.storage.createBucket(id ? id : ID.unique(), name);
|
||||
showCreate = false;
|
||||
dispatch('created', bucket);
|
||||
addNotification({
|
||||
@@ -26,7 +27,9 @@
|
||||
message: `${name} has been created`
|
||||
});
|
||||
name = null;
|
||||
trackEvent(Submit.BucketCreate);
|
||||
trackEvent(Submit.BucketCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.BucketCreate);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import FormList from '$lib/elements/forms/formList.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { ID } from '@aw-labs/appwrite-console';
|
||||
|
||||
let name: string, mail: string, pass: string, disabled: boolean;
|
||||
let terms = false;
|
||||
@@ -23,7 +24,7 @@
|
||||
async function register() {
|
||||
try {
|
||||
disabled = true;
|
||||
await sdkForConsole.account.create('unique()', mail, pass, name ?? '');
|
||||
await sdkForConsole.account.create(ID.unique(), mail, pass, name ?? '');
|
||||
await sdkForConsole.account.createEmailSession(mail, pass);
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
await goto(`${base}/console`);
|
||||
|
||||
Reference in new issue
Block a user