mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 06:19:41 +02:00
Add basic analytics
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Environment, Workspace } from '../lib/models';
|
||||
import { useConfirm } from './useConfirm';
|
||||
import { environmentsQueryKey } from './useEnvironments';
|
||||
@@ -23,13 +24,13 @@ export function useDeleteEnvironment(environment: Environment | null) {
|
||||
if (!confirmed) return null;
|
||||
return invoke('delete_environment', { environmentId: environment?.id });
|
||||
},
|
||||
onSettled: () => trackEvent('environment', 'delete'),
|
||||
onSuccess: async (environment) => {
|
||||
if (environment === null) return;
|
||||
|
||||
const { id: environmentId, workspaceId } = environment;
|
||||
queryClient.setQueryData<Workspace[]>(
|
||||
environmentsQueryKey({ workspaceId }),
|
||||
(environments) => environments?.filter((e) => e.id !== environmentId),
|
||||
queryClient.setQueryData<Workspace[]>(environmentsQueryKey({ workspaceId }), (environments) =>
|
||||
environments?.filter((e) => e.id !== environmentId),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user