feat: add basic analytics (#29)

This commit is contained in:
Connor Fogarty
2024-08-12 10:37:45 -05:00
committed by GitHub
parent 6e99e4c11e
commit 8fd9d4477e
9 changed files with 278 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import type { Message } from 'ai';
import { openDatabase, setMessages, getMessages, getNextId, getUrlId } from './db';
import { toast } from 'react-toastify';
import { workbenchStore } from '~/lib/stores/workbench';
import { sendAnalyticsEvent, AnalyticsAction } from '~/lib/analytics';
export interface ChatHistory {
id: string;
@@ -111,4 +112,14 @@ function navigateChat(nextId: string) {
url.pathname = `/chat/${nextId}`;
window.history.replaceState({}, '', url);
// since the `replaceState` call doesn't trigger a page reload, we need to manually log this event
sendAnalyticsEvent({
action: AnalyticsAction.Page,
payload: {
properties: {
url: url.href,
},
},
});
}