Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 21 additions & 5 deletions src/features/profile/TraditionsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { TraditionApi, type TraditionSetting } from '../../api/rest';
import { trackUi, UiElement } from '../../lib/analytics/analytics';
import { trackProps, trackUi, UiElement } from '../../lib/analytics/analytics';

const NEEDS: Record<string, string> = {
DATE: 'Uses your date of birth',
Expand All @@ -17,11 +17,14 @@ export function TraditionsSection() {
const [saving, setSaving] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
const [loadFailed, setLoadFailed] = useState(false);
const load = () => {
setLoadFailed(false);
TraditionApi.get()
.then((r) => setItems(r.traditions))
.catch(() => setError('Could not load traditions.'));
}, []);
.catch(() => setLoadFailed(true));
};
useEffect(load, []);

const toggle = async (t: TraditionSetting) => {
if (!items) return;
Expand Down Expand Up @@ -52,7 +55,20 @@ export function TraditionsSection() {
</p>
</div>
{error && <p className="text-xs text-red-600">{error}</p>}
{!items && !error && <p className="text-xs opacity-60">Loading…</p>}
{loadFailed && (
<div className="flex items-center gap-3" data-testid="traditions-load-error">
<p className="text-xs text-red-600">Couldn't load traditional matching.</p>
<button
type="button"
onClick={load}
{...trackProps(UiElement.PREFERENCES_TRADITIONS_RETRY)}
className="px-3 py-1 rounded-lg border border-border text-xs font-semibold cursor-pointer"
>
Retry
</button>
</div>
)}
{!items && !error && !loadFailed && <p className="text-xs opacity-60">Loading…</p>}
<ul className="divide-y divide-border border border-border">
{items?.map((t) => (
<li key={t.id} className="flex items-start justify-between gap-3 p-3">
Expand Down
10 changes: 6 additions & 4 deletions src/lib/analytics/generated/telemetryCatalog.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// GENERATED FILE - DO NOT EDIT.
// telemetry-integrity: sha256 892250b64cde2852dba08e06d6e5df25d28155d202de62331ee0ce12d53e6d88
// telemetry-integrity: sha256 eb26b79e95efdcecec8c38d7f7f4e6f5a507d7abc2ec14ba82092910fd6a3341
// Source of truth: OneHookBackend/packages/telemetry/src/catalog.ts
// Regenerate: (OneHookBackend) npm run telemetry:generate && npm run telemetry:sync
// Catalog version 1.13.0, hash 67439546f8614319.
// Catalog version 1.14.0, hash 93ffca84480c903b.
//
// HARD RULE: every user interaction MUST emit ui_interaction with an id from THIS file, and
// ids are controlled by the backend. Read TELEMETRY_CONTRACT.txt (printed by every build).
/* eslint-disable */

export const TELEMETRY_CATALOG_VERSION = "1.13.0";
export const TELEMETRY_CATALOG_HASH = "67439546f8614319";
export const TELEMETRY_CATALOG_VERSION = "1.14.0";
export const TELEMETRY_CATALOG_HASH = "93ffca84480c903b";

/** Every signal type the ingest accepts. */
export const SignalType = {
Expand Down Expand Up @@ -461,6 +461,7 @@ export const UiElement = {
PREFERENCES_SUGGESTION_REMOVE: "preferences.suggestion_remove",
PREFERENCES_OWN_SUGGESTION_SAVE: "preferences.own_suggestion_save",
PREFERENCES_TRADITION_TOGGLE: "preferences.tradition_toggle",
PREFERENCES_TRADITIONS_RETRY: "preferences.traditions_retry",
PREFERENCES_OWN_SUGGESTION_REMOVE: "preferences.own_suggestion_remove",
SETTINGS_EMAIL_MANAGE: "settings.email_manage",
SETTINGS_PHONE_UPDATE: "settings.phone_update",
Expand Down Expand Up @@ -728,6 +729,7 @@ export const UI_ELEMENTS: { readonly [K in UiElementId]: UiElementSpec } = {
"preferences.suggestion_remove": { screen: "PREFERENCES", kind: "button", actions: ["tap"], values: null, platforms: ["web", "ios", "android"] },
"preferences.own_suggestion_save": { screen: "PREFERENCES", kind: "button", actions: ["submit"], values: null, platforms: ["web", "ios", "android"] },
"preferences.tradition_toggle": { screen: "PREFERENCES", kind: "toggle", actions: ["toggle"], values: ["kundali", "western", "bazi", "zi_wei_dou_shu", "tzolkin", "tibetan", "hebrew", "arabic_parts", "buddhist", "celtic", "egyptian", "hellenistic", "babylonian"], platforms: ["web", "ios", "android"] },
"preferences.traditions_retry": { screen: "PREFERENCES", kind: "button", actions: ["tap"], values: null, platforms: ["web", "ios", "android"] },
"preferences.own_suggestion_remove": { screen: "PREFERENCES", kind: "button", actions: ["tap"], values: null, platforms: ["web", "ios", "android"] },
"settings.email_manage": { screen: "SETTINGS", kind: "button", actions: ["tap", "dismiss"], values: null, platforms: ["web", "ios", "android"] },
"settings.phone_update": { screen: "SETTINGS", kind: "button", actions: ["tap", "dismiss"], values: null, platforms: ["ios", "android"] },
Expand Down
Loading