diff --git a/src/components/Generator.tsx b/src/components/Generator.tsx index 48f2151..d084445 100644 --- a/src/components/Generator.tsx +++ b/src/components/Generator.tsx @@ -43,6 +43,8 @@ export default () => { const moderationInterval = Number(import.meta.env.PUBLIC_MODERATION_INTERVAL ?? '2000') + createEffect(() => currentError() && trackEvent('error', { code: currentError()!.code })) + const isHigher = () => { const distanceToBottom = footer.offsetTop - window.innerHeight const currentScrollHeight = window.scrollY @@ -201,7 +203,7 @@ export default () => { } const handleSubmit = async() => { - trackEvent(inputValue() ? 'send' : `${recording() ? 'end' : 'start'}Record`, recording() ? undefined : { length: messageList().length }) + !inputValue() && trackEvent(`${recording() ? 'end' : 'start'}-record`, recording() ? undefined : { length: messageList().length }) if (recording()) { stopRecording() @@ -298,6 +300,13 @@ export default () => { setCurrentError({ code: `${res.status} ${res.statusText}`, message }) throw new Error('Request failed') } + + trackEvent('send', { + model: payload.model, + temperature: payload.temperature, + originalTokenCont: encoder() && countTokens(encoder()!, systemMsg ? [systemMsg, ...messageList()] : messageList())!.total, + tokenCount: encoder() && `<=${Math.ceil(countTokens(encoder()!, requestMessageList)!.total / 1000)}k`, + }) const data = res.body if (!data) throw new Error('No data')