From 7c66d51d05ef8d2d7861ccab04ec5e700d46c48d Mon Sep 17 00:00:00 2001 From: Nicole White Date: Mon, 26 Feb 2024 11:20:55 -0500 Subject: [PATCH] Use new constructor (#112) --- JavaScript/chatbot-nextjs/src/pages/api/chat.ts | 3 ++- JavaScript/chatbot-nextjs/src/pages/index.tsx | 3 ++- JavaScript/openai-tracing/src/index.js | 2 +- JavaScript/spans/src/index.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/JavaScript/chatbot-nextjs/src/pages/api/chat.ts b/JavaScript/chatbot-nextjs/src/pages/api/chat.ts index 8413698f..905c28fa 100644 --- a/JavaScript/chatbot-nextjs/src/pages/api/chat.ts +++ b/JavaScript/chatbot-nextjs/src/pages/api/chat.ts @@ -35,7 +35,8 @@ export default async function handler( // Substitute this for process.env.AUTOBLOCKS_INGESTION_KEY in a production environment // You can also initialize this outside of the handler in that case - const tracer = new AutoblocksTracer(autoblocksIngestionKey, { + const tracer = new AutoblocksTracer({ + ingestionKey: autoblocksIngestionKey, traceId, properties: { provider: 'openai', diff --git a/JavaScript/chatbot-nextjs/src/pages/index.tsx b/JavaScript/chatbot-nextjs/src/pages/index.tsx index 813acb74..6d1b527d 100644 --- a/JavaScript/chatbot-nextjs/src/pages/index.tsx +++ b/JavaScript/chatbot-nextjs/src/pages/index.tsx @@ -93,7 +93,8 @@ export default function Chat() { }; const onFeedback = async (feedback: 'positive' | 'negative') => { - const tracer = new AutoblocksTracer(autoblocksIngestionKey, { + const tracer = new AutoblocksTracer({ + ingestionKey: autoblocksIngestionKey, traceId, }); await tracer.sendEvent('user.feedback', { diff --git a/JavaScript/openai-tracing/src/index.js b/JavaScript/openai-tracing/src/index.js index f19a0858..1c046bc4 100644 --- a/JavaScript/openai-tracing/src/index.js +++ b/JavaScript/openai-tracing/src/index.js @@ -6,7 +6,7 @@ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); -const tracer = new AutoblocksTracer(process.env.AUTOBLOCKS_INGESTION_KEY, { +const tracer = new AutoblocksTracer({ // These apply to every call of tracer.sendEvent() so we don't have to repeat them traceId: crypto.randomUUID(), properties: { diff --git a/JavaScript/spans/src/index.js b/JavaScript/spans/src/index.js index be8b2bb8..5138429c 100644 --- a/JavaScript/spans/src/index.js +++ b/JavaScript/spans/src/index.js @@ -1,7 +1,7 @@ import crypto from 'crypto'; import { AutoblocksTracer } from '@autoblocks/client'; -const tracer = new AutoblocksTracer(process.env.AUTOBLOCKS_INGESTION_KEY, { +const tracer = new AutoblocksTracer({ traceId: crypto.randomUUID(), properties: { provider: 'openai',