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

@@ -11,6 +11,7 @@ import { fileModificationsToHTML } from '~/utils/diff';
import { cubicEasingFn } from '~/utils/easings';
import { createScopedLogger, renderLogger } from '~/utils/logger';
import { BaseChat } from './BaseChat';
import { sendAnalyticsEvent, AnalyticsTrackEvent, AnalyticsAction } from '~/lib/analytics';
const toastAnimation = cssTransition({
enter: 'animated fadeInRight',
@@ -191,6 +192,18 @@ export const ChatImpl = memo(({ initialMessages, storeMessageHistory }: ChatProp
resetEnhancer();
textareaRef.current?.blur();
const event = messages.length === 0 ? AnalyticsTrackEvent.ChatCreated : AnalyticsTrackEvent.MessageSent;
sendAnalyticsEvent({
action: AnalyticsAction.Track,
payload: {
event,
properties: {
message: _input,
},
},
});
};
const [messageRef, scrollRef] = useSnapScroll();