diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 825790a7..5fcdd9f4 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -8000,6 +8000,7 @@ dependencies = [ "tauri-plugin-yaak-license", "tokio", "tokio-stream", + "ts-rs", "urlencoding", "uuid", "yaak_grpc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index eedeb2a8..9a2b6b15 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -63,6 +63,7 @@ tauri-plugin-updater = "2.0.2" tauri-plugin-window-state = "2.0.1" tokio = { version = "1.36.0", features = ["sync"] } tokio-stream = "0.1.15" +ts-rs = { workspace = true } uuid = "1.7.0" mime_guess = "2.0.5" urlencoding = "2.1.3" diff --git a/src-tauri/bindings/analytics.ts b/src-tauri/bindings/analytics.ts new file mode 100644 index 00000000..23e21581 --- /dev/null +++ b/src-tauri/bindings/analytics.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AnalyticsAction = "cancel" | "click" | "commit" | "create" | "delete" | "delete_many" | "duplicate" | "export" | "hide" | "import" | "launch" | "launch_first" | "launch_update" | "send" | "show" | "toggle" | "update" | "upsert"; + +export type AnalyticsResource = "app" | "appearance" | "button" | "checkbox" | "cookie_jar" | "dialog" | "environment" | "folder" | "grpc_connection" | "grpc_event" | "grpc_request" | "http_request" | "http_response" | "link" | "key_value" | "plugin" | "select" | "setting" | "sidebar" | "tab" | "theme" | "workspace"; diff --git a/src-tauri/src/analytics.rs b/src-tauri/src/analytics.rs index dda9a053..284f64b8 100644 --- a/src-tauri/src/analytics.rs +++ b/src-tauri/src/analytics.rs @@ -4,7 +4,7 @@ use log::{debug, info}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use tauri::{Manager, Runtime, WebviewWindow}; - +use ts_rs::TS; use yaak_models::queries::{generate_id, get_key_value_int, get_key_value_string, get_or_create_settings, set_key_value_int, set_key_value_string}; use crate::is_dev; @@ -13,11 +13,14 @@ const NAMESPACE: &str = "analytics"; const NUM_LAUNCHES_KEY: &str = "num_launches"; // serializable -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, TS)] #[serde(rename_all = "snake_case")] +#[ts(export, export_to = "analytics.ts")] pub enum AnalyticsResource { App, Appearance, + Button, + Checkbox, CookieJar, Dialog, Environment, @@ -27,10 +30,13 @@ pub enum AnalyticsResource { GrpcRequest, HttpRequest, HttpResponse, + Link, KeyValue, Plugin, + Select, Setting, Sidebar, + Tab, Theme, Workspace, } @@ -51,10 +57,12 @@ impl Display for AnalyticsResource { } } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, TS)] #[serde(rename_all = "snake_case")] +#[ts(export, export_to = "analytics.ts")] pub enum AnalyticsAction { Cancel, + Click, Commit, Create, Delete, @@ -156,7 +164,7 @@ pub async fn track_event( action: AnalyticsAction, attributes: Option, ) { - + let id = get_id(w).await; let event = format!("{}.{}", resource, action); let attributes_json = attributes.unwrap_or("{}".to_string().into()).to_string(); diff --git a/src-tauri/yaak_license/bindings/license.ts b/src-tauri/yaak_license/bindings/license.ts index 6f847f63..0232d424 100644 --- a/src-tauri/yaak_license/bindings/license.ts +++ b/src-tauri/yaak_license/bindings/license.ts @@ -8,4 +8,4 @@ export type ActivateLicenseResponsePayload = { activationId: string, }; export type CheckActivationResponsePayload = { active: boolean, }; -export type LicenseCheckStatus = { "type": "personal_use" } | { "type": "commercial_use" } | { "type": "trialing", end: string, } | { "type": "trial_ended", end: string, }; +export type LicenseCheckStatus = { "type": "personal_use", trial_ended: string, } | { "type": "commercial_use" } | { "type": "invalid_license" } | { "type": "trialing", end: string, }; diff --git a/src-web/components/LicenseBadge.tsx b/src-web/components/LicenseBadge.tsx index 3850e561..7712eaa7 100644 --- a/src-web/components/LicenseBadge.tsx +++ b/src-web/components/LicenseBadge.tsx @@ -10,9 +10,9 @@ const details: Record< { label: string; color: ButtonProps['color'] } | null > = { commercial_use: null, - invalid_license: { label: 'Invalid License', color: 'danger' }, - personal_use: { label: 'Personal Use', color: 'success' }, - trialing: { label: 'Personal Use', color: 'success' }, + invalid_license: { label: 'License Error', color: 'danger' }, + personal_use: { label: 'Personal Use', color: 'primary' }, + trialing: { label: 'Personal Use', color: 'primary' }, }; export function LicenseBadge() { @@ -35,6 +35,7 @@ export function LicenseBadge() { className="!rounded-full mx-1" onClick={() => openSettings.mutate()} color={detail.color} + event={{ id: 'license-badge', status: check.data.type }} > {detail.label} diff --git a/src-web/components/Settings/SettingsAppearance.tsx b/src-web/components/Settings/SettingsAppearance.tsx index 443fe6c6..097edd0c 100644 --- a/src-web/components/Settings/SettingsAppearance.tsx +++ b/src-web/components/Settings/SettingsAppearance.tsx @@ -4,7 +4,6 @@ import { useResolvedAppearance } from '../../hooks/useResolvedAppearance'; import { useResolvedTheme } from '../../hooks/useResolvedTheme'; import { useSettings } from '../../hooks/useSettings'; import { useUpdateSettings } from '../../hooks/useUpdateSettings'; -import { trackEvent } from '../../lib/analytics'; import { clamp } from '../../lib/clamp'; import { getThemes } from '../../lib/theme/themes'; import { isThemeDark } from '../../lib/theme/window'; @@ -89,6 +88,7 @@ export function SettingsAppearance() { value={`${settings.interfaceFontSize}`} options={fontSizes} onChange={(v) => updateSettings.mutate({ interfaceFontSize: parseInt(v) })} + event="font-size.interface" /> onChange(e.target.value as T)} + onChange={(e) => handleChange(e.target.value as T)} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)} className={classNames('pr-7 w-full outline-none bg-transparent')} @@ -98,7 +108,7 @@ export function Select({ ) : ( // Use custom "select" component until Tauri can be configured to have select menus not always appear in // light mode - +