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
6 changes: 5 additions & 1 deletion app/components/LLMChatInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useCustomization } from "./CustomizationContext";
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { callLLM, callLLMStream, getLLMDescription, MessageContentPart } from "@/lib/llm-client";
import { trackLLMQuestionAsked } from "@/lib/analytics";
import { trackLLMQuestionAsked, trackAIConsentGiven, trackAIConsentDeclined, trackAIConsentModalShown, trackExampleQuestionClicked } from "@/lib/analytics";

type AttachmentType = 'text' | 'pdf' | 'csv' | 'tsv' | 'image';

Expand Down Expand Up @@ -105,18 +105,21 @@ export default function AIChatInline() {
localStorage.setItem(CONSENT_STORAGE_KEY, "true");
setHasConsent(true);
setShowConsentModal(false);
trackAIConsentGiven();
void handleSendMessage(true);
}
};

const handleConsentDecline = () => {
setShowConsentModal(false);
trackAIConsentDeclined();
};


const handleExampleClick = (question: string) => {
setInputValue(question);
inputRef.current?.focus();
trackExampleQuestionClicked();
};

const handleCopyMessage = async (content: string) => {
Expand Down Expand Up @@ -304,6 +307,7 @@ export default function AIChatInline() {
// Check consent before sending first message
if (!skipConsentCheck && !hasConsent) {
setShowConsentModal(true);
trackAIConsentModalShown();
return;
}

Expand Down
4 changes: 3 additions & 1 deletion app/dna-chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import GuidedTour from "../components/GuidedTour";
import { dnaChatTour } from "../components/tours/tourContent";
import { useResults } from "../components/ResultsContext";
import { ResultsManager } from "@/lib/results-manager";
import { trackDNAChatViewed } from "@/lib/analytics";
import { trackDNAChatViewed, trackDNAChatSampleDataLoaded, trackDNAChatSampleDataFailed } from "@/lib/analytics";

const SAMPLE_RESULTS_FILE_NAME = "monadic_dna_explorer_results_2026-05-19.tsv";

Expand Down Expand Up @@ -123,6 +123,7 @@ export default function DNAChatPage() {
await clearResults();
await addResultsBatch(session.results);
localStorage.setItem("dna_chat_sample_results_loaded", "true");
trackDNAChatSampleDataLoaded(session.results.length);

setSampleLoad({
status: "loaded",
Expand All @@ -133,6 +134,7 @@ export default function DNAChatPage() {
});
} catch (error) {
console.error("[DNA Chat] Sample results load failed:", error);
trackDNAChatSampleDataFailed(error instanceof Error ? error.message : undefined);
setSampleLoad({
status: "error",
downloadedBytes: 0,
Expand Down
16 changes: 16 additions & 0 deletions lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,22 @@ export function trackDNAChatViewed() {
trackEvent('dna_chat_viewed');
}

export function trackDNAChatSampleDataLoaded(resultCount: number) {
trackEvent('dna_chat_sample_data_loaded', { result_count: resultCount });
}

export function trackDNAChatSampleDataFailed(reason?: string) {
trackEvent('dna_chat_sample_data_failed', { reason: sanitizeErrorReason(reason) });
}

export function trackExampleQuestionClicked() {
trackEvent('example_question_clicked');
}

export function trackAIConsentModalShown() {
trackEvent('ai_consent_modal_shown');
}

export function trackOverviewReportViewed() {
trackEvent('overview_report_viewed');
}
Expand Down
Loading