mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-06-12 17:34:27 +02:00
Track GRPC
This commit is contained in:
@@ -48,6 +48,7 @@ impl Display for AnalyticsResource {
|
|||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum AnalyticsAction {
|
pub enum AnalyticsAction {
|
||||||
Cancel,
|
Cancel,
|
||||||
|
Commit,
|
||||||
Create,
|
Create,
|
||||||
Delete,
|
Delete,
|
||||||
DeleteMany,
|
DeleteMany,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import { emit } from '@tauri-apps/api/event';
|
import { emit } from '@tauri-apps/api/event';
|
||||||
|
import { trackEvent } from '../lib/analytics';
|
||||||
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
||||||
import type { GrpcConnection, GrpcRequest } from '../lib/models';
|
import type { GrpcConnection, GrpcRequest } from '../lib/models';
|
||||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||||
@@ -21,21 +22,25 @@ export function useGrpc(
|
|||||||
|
|
||||||
const go = useMutation<void, string>({
|
const go = useMutation<void, string>({
|
||||||
mutationFn: async () => await invoke('cmd_grpc_go', { requestId, environmentId, protoFiles }),
|
mutationFn: async () => await invoke('cmd_grpc_go', { requestId, environmentId, protoFiles }),
|
||||||
|
onSettled: () => trackEvent('grpc_request', 'send'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const send = useMutation({
|
const send = useMutation({
|
||||||
mutationFn: async ({ message }: { message: string }) =>
|
mutationFn: async ({ message }: { message: string }) =>
|
||||||
await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, { Message: message }),
|
await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, { Message: message }),
|
||||||
|
onSettled: () => trackEvent('grpc_connection', 'send'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const cancel = useMutation({
|
const cancel = useMutation({
|
||||||
mutationKey: ['grpc_cancel', conn?.id ?? 'n/a'],
|
mutationKey: ['grpc_cancel', conn?.id ?? 'n/a'],
|
||||||
mutationFn: async () => await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, 'Cancel'),
|
mutationFn: async () => await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, 'Cancel'),
|
||||||
|
onSettled: () => trackEvent('grpc_connection', 'cancel'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const commit = useMutation({
|
const commit = useMutation({
|
||||||
mutationKey: ['grpc_commit', conn?.id ?? 'n/a'],
|
mutationKey: ['grpc_commit', conn?.id ?? 'n/a'],
|
||||||
mutationFn: async () => await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, 'Commit'),
|
mutationFn: async () => await emit(`grpc_client_msg_${conn?.id ?? 'none'}`, 'Commit'),
|
||||||
|
onSettled: () => trackEvent('grpc_connection', 'commit'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const debouncedUrl = useDebouncedValue<string>(req?.url ?? 'n/a', 500);
|
const debouncedUrl = useDebouncedValue<string>(req?.url ?? 'n/a', 500);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export function trackEvent(
|
|||||||
| 'workspace',
|
| 'workspace',
|
||||||
action:
|
action:
|
||||||
| 'cancel'
|
| 'cancel'
|
||||||
|
| 'commit'
|
||||||
| 'create'
|
| 'create'
|
||||||
| 'delete'
|
| 'delete'
|
||||||
| 'delete_many'
|
| 'delete_many'
|
||||||
|
|||||||
Reference in New Issue
Block a user