Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

Observations: add level and statusMessage (#29)

Marc Klingen9256c498e3ac
diff --git a/fern/server/definition/event.yml b/fern/server/definition/event.yml
index 9c430e0a7f..3d82335ff6 100644
--- a/fern/server/definition/event.yml
+++ b/fern/server/definition/event.yml
@@ -14,21 +14,31 @@ service:
types:
CreateEventRequest:
properties:
- traceId: string
- name: string
- startTime: datetime
- metadata: unknown
- input: unknown
- output: unknown
+ traceId: optional<string>
+ name: optional<string>
+ startTime: optional<datetime>
+ metadata: optional<unknown>
+ input: optional<unknown>
+ output: optional<unknown>
+ level: optional<ObservationLevelEvent>
+ statusMessage: optional<string>
parentObservationId: optional<string>
Event:
properties:
id: string
traceId: string
type: string
- name: string
+ name: optional<string>
startTime: datetime
- metadata: unknown
- input: unknown
- output: unknown
+ metadata: optional<unknown>
+ input: optional<unknown>
+ output: optional<unknown>
+ level: ObservationLevelEvent
+ statusMessage: optional<string>
parentObservationId: optional<string>
+ ObservationLevelEvent:
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
diff --git a/fern/server/definition/generations.yml b/fern/server/definition/generations.yml
index 4a9449854f..b8e6306514 100644
--- a/fern/server/definition/generations.yml
+++ b/fern/server/definition/generations.yml
@@ -14,15 +14,17 @@ types:
CreateLog:
properties:
traceId: optional<string>
+ name: optional<string>
startTime: optional<datetime>
endTime: optional<datetime>
- name: optional<string>
model: optional<string>
modelParameters: optional<map<string, MapValue>>
prompt: optional<unknown>
metadata: optional<unknown>
completion: optional<string>
usage: optional<LLMUsage>
+ level: optional<ObservationLevelGeneration>
+ statusMessage: optional<string>
parentObservationId: optional<string>
Log:
@@ -31,9 +33,16 @@ types:
traceId: string
type: string
name: optional<string>
- startTime: optional<datetime>
+ startTime: datetime
endTime: optional<datetime>
- attributes: unknown
+ model: optional<string>
+ modelParameters: optional<map<string, MapValue>>
+ prompt: optional<unknown>
+ metadata: optional<unknown>
+ completion: optional<string>
+ usage: optional<LLMUsage>
+ level: ObservationLevelGeneration
+ statusMessage: optional<string>
parentObservationId: optional<string>
LLMUsage:
@@ -47,3 +56,9 @@ types:
- optional<string>
- optional<integer>
- optional<boolean>
+ ObservationLevelGeneration:
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
diff --git a/fern/server/definition/span.yml b/fern/server/definition/span.yml
index b6eca98503..13d40527db 100644
--- a/fern/server/definition/span.yml
+++ b/fern/server/definition/span.yml
@@ -21,12 +21,14 @@ types:
CreateSpanRequest:
properties:
traceId: optional<string>
- name: string
- startTime: datetime
+ name: optional<string>
+ startTime: optional<datetime>
endTime: optional<datetime>
- metadata: unknown
- input: unknown
- output: unknown
+ metadata: optional<unknown>
+ input: optional<unknown>
+ output: optional<unknown>
+ level: optional<ObservationLevelSpan>
+ statusMessage: optional<string>
parentObservationId: optional<string>
UpdateSpanRequest:
@@ -39,10 +41,18 @@ types:
id: string
traceId: string
type: string
- name: string
+ name: optional<string>
startTime: datetime
endTime: optional<datetime>
- metadata: unknown
- input: unknown
- output: unknown
+ metadata: optional<unknown>
+ input: optional<unknown>
+ output: optional<unknown>
+ level: ObservationLevelSpan
+ statusMessage: optional<string>
parentObservationId: optional<string>
+ ObservationLevelSpan:
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
diff --git a/fern/server/definition/trace.yml b/fern/server/definition/trace.yml
index c863cc0501..2f4214e166 100644
--- a/fern/server/definition/trace.yml
+++ b/fern/server/definition/trace.yml
@@ -14,11 +14,11 @@ service:
types:
CreateTraceRequest:
properties:
- name: string
- metadata: unknown
+ name: optional<string>
+ metadata: optional<unknown>
Trace:
properties:
id: string
timestamp: datetime
- name: string
- metadata: unknown
+ name: optional<string>
+ metadata: optional<unknown>
diff --git a/generated/openapi-server/openapi.yml b/generated/openapi-server/openapi.yml
index a79edc7d45..48996a33b3 100644
--- a/generated/openapi-server/openapi.yml
+++ b/generated/openapi-server/openapi.yml
@@ -136,24 +136,29 @@ components:
properties:
traceId:
type: string
+ nullable: true
name:
type: string
+ nullable: true
startTime:
type: string
format: date-time
- metadata: {}
- input: {}
- output: {}
+ nullable: true
+ metadata:
+ nullable: true
+ input:
+ nullable: true
+ output:
+ nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelEvent'
+ nullable: true
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
- required:
- - traceId
- - name
- - startTime
- - metadata
- - input
- - output
Event:
title: Event
type: object
@@ -166,12 +171,21 @@ components:
type: string
name:
type: string
+ nullable: true
startTime:
type: string
format: date-time
- metadata: {}
- input: {}
- output: {}
+ metadata:
+ nullable: true
+ input:
+ nullable: true
+ output:
+ nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelEvent'
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
@@ -179,11 +193,16 @@ components:
- id
- traceId
- type
- - name
- startTime
- - metadata
- - input
- - output
+ - level
+ ObservationLevelEvent:
+ title: ObservationLevelEvent
+ type: string
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
CreateLog:
title: CreateLog
type: object
@@ -191,6 +210,9 @@ components:
traceId:
type: string
nullable: true
+ name:
+ type: string
+ nullable: true
startTime:
type: string
format: date-time
@@ -199,9 +221,6 @@ components:
type: string
format: date-time
nullable: true
- name:
- type: string
- nullable: true
model:
type: string
nullable: true
@@ -220,6 +239,12 @@ components:
usage:
$ref: '#/components/schemas/LLMUsage'
nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelGeneration'
+ nullable: true
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
@@ -239,12 +264,33 @@ components:
startTime:
type: string
format: date-time
- nullable: true
endTime:
type: string
format: date-time
nullable: true
- attributes: {}
+ model:
+ type: string
+ nullable: true
+ modelParameters:
+ type: object
+ additionalProperties:
+ $ref: '#/components/schemas/MapValue'
+ nullable: true
+ prompt:
+ nullable: true
+ metadata:
+ nullable: true
+ completion:
+ type: string
+ nullable: true
+ usage:
+ $ref: '#/components/schemas/LLMUsage'
+ nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelGeneration'
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
@@ -252,7 +298,8 @@ components:
- id
- traceId
- type
- - attributes
+ - startTime
+ - level
LLMUsage:
title: LLMUsage
type: object
@@ -272,6 +319,14 @@ components:
nullable: true
- type: boolean
nullable: true
+ ObservationLevelGeneration:
+ title: ObservationLevelGeneration
+ type: string
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
CreateScoreRequest:
title: CreateScoreRequest
type: object
@@ -319,25 +374,30 @@ components:
nullable: true
name:
type: string
+ nullable: true
startTime:
type: string
format: date-time
+ nullable: true
endTime:
type: string
format: date-time
nullable: true
- metadata: {}
- input: {}
- output: {}
+ metadata:
+ nullable: true
+ input:
+ nullable: true
+ output:
+ nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelSpan'
+ nullable: true
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
- required:
- - name
- - startTime
- - metadata
- - input
- - output
UpdateSpanRequest:
title: UpdateSpanRequest
type: object
@@ -362,6 +422,7 @@ components:
type: string
name:
type: string
+ nullable: true
startTime:
type: string
format: date-time
@@ -369,9 +430,17 @@ components:
type: string
format: date-time
nullable: true
- metadata: {}
- input: {}
- output: {}
+ metadata:
+ nullable: true
+ input:
+ nullable: true
+ output:
+ nullable: true
+ level:
+ $ref: '#/components/schemas/ObservationLevelSpan'
+ statusMessage:
+ type: string
+ nullable: true
parentObservationId:
type: string
nullable: true
@@ -379,21 +448,25 @@ components:
- id
- traceId
- type
- - name
- startTime
- - metadata
- - input
- - output
+ - level
+ ObservationLevelSpan:
+ title: ObservationLevelSpan
+ type: string
+ enum:
+ - DEBUG
+ - DEFAULT
+ - WARNING
+ - ERROR
CreateTraceRequest:
title: CreateTraceRequest
type: object
properties:
name:
type: string
- metadata: {}
- required:
- - name
- - metadata
+ nullable: true
+ metadata:
+ nullable: true
Trace:
title: Trace
type: object
@@ -405,12 +478,12 @@ components:
format: date-time
name:
type: string
- metadata: {}
+ nullable: true
+ metadata:
+ nullable: true
required:
- id
- timestamp
- - name
- - metadata
securitySchemes:
BasicAuth:
type: http
diff --git a/package-lock.json b/package-lock.json
index 68ab3fb07a..53f687a0a2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -74,6 +74,7 @@
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"autoprefixer": "^10.4.14",
+ "dotenv-cli": "^7.2.1",
"eslint": "^8.43.0",
"eslint-config-next": "^13.4.6",
"postcss": "^8.4.24",
@@ -4211,6 +4212,42 @@
"csstype": "^3.0.2"
}
},
+ "node_modules/dotenv": {
+ "version": "16.3.1",
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
+ "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/motdotla/dotenv?sponsor=1"
+ }
+ },
+ "node_modules/dotenv-cli": {
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-7.2.1.tgz",
+ "integrity": "sha512-ODHbGTskqRtXAzZapDPvgNuDVQApu4oKX8lZW7Y0+9hKA6le1ZJlyRS687oU9FXjOVEDU/VFV6zI125HzhM1UQ==",
+ "dev": true,
+ "dependencies": {
+ "cross-spawn": "^7.0.3",
+ "dotenv": "^16.0.0",
+ "dotenv-expand": "^10.0.0",
+ "minimist": "^1.2.6"
+ },
+ "bin": {
+ "dotenv": "cli.js"
+ }
+ },
+ "node_modules/dotenv-expand": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz",
+ "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==",
+ "dev": true,
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
diff --git a/package.json b/package.json
index a5c9c52284..27740474a5 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,8 @@
"postinstall": "prisma generate",
"lint": "next lint",
"clean": "rm -rf node_modules",
- "start": "next start"
+ "start": "next start",
+ "migrate:prod": "dotenv -e .env.local -- npx prisma migrate deploy"
},
"prisma": {
"seed": "ts-node -r tsconfig-paths/register --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
@@ -79,6 +80,7 @@
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"autoprefixer": "^10.4.14",
+ "dotenv-cli": "^7.2.1",
"eslint": "^8.43.0",
"eslint-config-next": "^13.4.6",
"postcss": "^8.4.24",
diff --git a/prisma/migrations/20230623172401_observation_add_level_and_status_message/migration.sql b/prisma/migrations/20230623172401_observation_add_level_and_status_message/migration.sql
new file mode 100644
index 0000000000..a033cd3048
--- /dev/null
+++ b/prisma/migrations/20230623172401_observation_add_level_and_status_message/migration.sql
@@ -0,0 +1,6 @@
+-- CreateEnum
+CREATE TYPE "ObservationLevel" AS ENUM ('DEBUG', 'DEFAULT', 'WARNING', 'ERROR');
+
+-- AlterTable
+ALTER TABLE "observations" ADD COLUMN "level" "ObservationLevel" NOT NULL DEFAULT 'DEFAULT',
+ADD COLUMN "status_message" TEXT;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 93abeb6a07..52c8d95e80 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -126,15 +126,17 @@ model Trace {
}
model Observation {
- id String @id @default(cuid())
- traceId String @map("trace_id")
- trace Trace @relation(fields: [traceId], references: [id], onDelete: Cascade)
+ id String @id @default(cuid())
+ traceId String @map("trace_id")
+ trace Trace @relation(fields: [traceId], references: [id], onDelete: Cascade)
type ObservationType
- startTime DateTime @default(now()) @map("start_time")
- endTime DateTime? @map("end_time")
+ startTime DateTime @default(now()) @map("start_time")
+ endTime DateTime? @map("end_time")
name String?
metadata Json?
- parentObservationId String? @map("parent_observation_id")
+ parentObservationId String? @map("parent_observation_id")
+ level ObservationLevel @default(DEFAULT)
+ statusMessage String? @map("status_message")
// GENERATION ONLY
model String?
@@ -156,6 +158,13 @@ enum ObservationType {
GENERATION
}
+enum ObservationLevel {
+ DEBUG
+ DEFAULT
+ WARNING
+ ERROR
+}
+
model Score {
id String @id @default(cuid())
timestamp DateTime @default(now())
diff --git a/src/features/feedback/lib/corsMiddleware.ts b/src/features/feedback/server/corsMiddleware.ts
similarity index 100%
rename from src/features/feedback/lib/corsMiddleware.ts
rename to src/features/feedback/server/corsMiddleware.ts
diff --git a/src/features/feedback/server/feedbackHandler.ts b/src/features/feedback/server/feedbackHandler.ts
index a9e9a1b538..1992024ddd 100644
--- a/src/features/feedback/server/feedbackHandler.ts
+++ b/src/features/feedback/server/feedbackHandler.ts
@@ -1,5 +1,5 @@
+import { runFeedbackCorsMiddleware } from "@/src/features/feedback/server/corsMiddleware";
import { type NextApiRequest, type NextApiResponse } from "next";
-import { runFeedbackCorsMiddleware } from "../lib/corsMiddleware";
// Collects feedack from users that do not use the cloud version of the app
export default async function feedbackApiHandler(
diff --git a/src/pages/api/public/events.ts b/src/pages/api/public/events.ts
index 26333b505d..c9020134a5 100644
--- a/src/pages/api/public/events.ts
+++ b/src/pages/api/public/events.ts
@@ -1,5 +1,5 @@
import { prisma } from "@/src/server/db";
-import { ObservationType } from "@prisma/client";
+import { ObservationLevel, ObservationType } from "@prisma/client";
import { type NextApiRequest, type NextApiResponse } from "next";
import { z } from "zod";
import { cors, runMiddleware } from "./cors";
@@ -7,13 +7,15 @@ import { verifyAuthHeaderAndReturnScope } from "@/src/features/publicApi/server/
import { checkApiAccessScope } from "@/src/features/publicApi/server/apiScope";
const ObservationSchema = z.object({
- traceId: z.string(),
- name: z.string(),
- startTime: z.string().datetime(),
- metadata: z.record(z.string(), z.any()),
- input: z.record(z.string(), z.any()).nullish(),
- output: z.record(z.string(), z.any()).nullish(),
- parentObservationId: z.string().optional(),
+ traceId: z.string().nullish(),
+ name: z.string().nullish(),
+ startTime: z.string().datetime().nullish(),
+ metadata: z.unknown().nullish(),
+ input: z.unknown().nullish(),
+ output: z.unknown().nullish(),
+ level: z.nativeEnum(ObservationLevel).nullish(),
+ statusMessage: z.string().nullish(),
+ parentObservationId: z.string().nullish(),
});
export default async function handler(
@@ -46,11 +48,13 @@ export default async function handler(
input,
output,
parentObservationId,
+ level,
+ statusMessage,
} = ObservationSchema.parse(req.body);
// CHECK ACCESS SCOPE
const accessCheck = await checkApiAccessScope(authCheck.scope, [
- { type: "trace", id: traceId },
+ ...(traceId ? [{ type: "trace" as const, id: traceId }] : []),
...(parentObservationId
? [{ type: "observation" as const, id: parentObservationId }]
: []),
@@ -64,13 +68,24 @@ export default async function handler(
const newObservation = await prisma.observation.create({
data: {
- trace: { connect: { id: traceId } },
+ ...(traceId
+ ? { trace: { connect: { id: traceId } } }
+ : {
+ trace: {
+ create: {
+ name: name,
+ project: { connect: { id: authCheck.scope.projectId } },
+ },
+ },
+ }),
type: ObservationType.EVENT,
name,
- startTime: new Date(startTime),
- metadata,
+ startTime: startTime ? new Date(startTime) : undefined,
+ metadata: metadata ?? undefined,
input: input ?? undefined,
output: output ?? undefined,
+ level: level ?? undefined,
+ statusMessage: statusMessage ?? undefined,
parent: parentObservationId
? { connect: { id: parentObservationId } }
: undefined,
diff --git a/src/pages/api/public/generations.ts b/src/pages/api/public/generations.ts
index 59a47fcca6..cd2eac49f7 100644
--- a/src/pages/api/public/generations.ts
+++ b/src/pages/api/public/generations.ts
@@ -1,5 +1,5 @@
import { prisma } from "@/src/server/db";
-import { ObservationType, Prisma } from "@prisma/client";
+import { ObservationLevel, ObservationType } from "@prisma/client";
import { type NextApiRequest, type NextApiResponse } from "next";
import { z } from "zod";
import { cors, runMiddleware } from "./cors";
@@ -26,6 +26,8 @@ const GenerationsCreateSchema = z.object({
}),
metadata: z.unknown().nullish(),
parentObservationId: z.string().nullish(),
+ level: z.nativeEnum(ObservationLevel).nullish(),
+ statusMessage: z.string().nullish(),
});
export default async function handler(
@@ -63,6 +65,8 @@ export default async function handler(
usage,
metadata,
parentObservationId,
+ level,
+ statusMessage,
} = GenerationsCreateSchema.parse(req.body);
// CHECK ACCESS SCOPE
@@ -87,7 +91,6 @@ export default async function handler(
trace: {
create: {
name: name,
- metadata: Prisma.JsonNull,
project: { connect: { id: authCheck.scope.projectId } },
},
},
@@ -96,12 +99,14 @@ export default async function handler(
name,
startTime: startTime ? new Date(startTime) : undefined,
endTime: endTime ? new Date(endTime) : undefined,
- metadata: metadata ? metadata : undefined,
- model: model ? model : undefined,
- modelParameters: modelParameters ? modelParameters : undefined,
- input: prompt ? prompt : undefined,
+ metadata: metadata ?? undefined,
+ model: model ?? undefined,
+ modelParameters: modelParameters ?? undefined,
+ input: prompt ?? undefined,
output: completion ? { completion: completion } : undefined,
- usage: usage ? usage : undefined,
+ usage: usage ?? undefined,
+ level: level ?? undefined,
+ statusMessage: statusMessage ?? undefined,
parent: parentObservationId
? { connect: { id: parentObservationId } }
: undefined,
diff --git a/src/pages/api/public/spans.ts b/src/pages/api/public/spans.ts
index a7158f302f..4d52c04a97 100644
--- a/src/pages/api/public/spans.ts
+++ b/src/pages/api/public/spans.ts
@@ -1,5 +1,5 @@
import { prisma } from "@/src/server/db";
-import { ObservationType } from "@prisma/client";
+import { ObservationLevel, ObservationType } from "@prisma/client";
import { type NextApiRequest, type NextApiResponse } from "next";
import { z } from "zod";
import { cors, runMiddleware } from "./cors";
@@ -7,14 +7,16 @@ import { verifyAuthHeaderAndReturnScope } from "@/src/features/publicApi/server/
import { checkApiAccessScope } from "@/src/features/publicApi/server/apiScope";
const SpanPostSchema = z.object({
- traceId: z.string(),
- name: z.string(),
- startTime: z.string().datetime(),
+ traceId: z.string().nullish(),
+ name: z.string().nullish(),
+ startTime: z.string().datetime().nullish(),
endTime: z.string().datetime().nullish(),
- metadata: z.record(z.string(), z.any()),
- input: z.record(z.string(), z.any()).nullish(),
- output: z.record(z.string(), z.any()).nullish(),
+ metadata: z.unknown().nullish(),
+ input: z.unknown().nullish(),
+ output: z.unknown().nullish(),
parentObservationId: z.string().nullish(),
+ level: z.nativeEnum(ObservationLevel).nullish(),
+ statusMessage: z.string().nullish(),
});
const SpanPatchSchema = z.object({
@@ -54,11 +56,13 @@ export default async function handler(
input,
output,
parentObservationId,
+ level,
+ statusMessage,
} = SpanPostSchema.parse(req.body);
// CHECK ACCESS SCOPE
const accessCheck = await checkApiAccessScope(authCheck.scope, [
- { type: "trace", id: traceId },
+ ...(traceId ? [{ type: "trace" as const, id: traceId }] : []),
...(parentObservationId
? [{ type: "observation" as const, id: parentObservationId }]
: []),
@@ -72,14 +76,25 @@ export default async function handler(
const newObservation = await prisma.observation.create({
data: {
- trace: { connect: { id: traceId } },
+ ...(traceId
+ ? { trace: { connect: { id: traceId } } }
+ : {
+ trace: {
+ create: {
+ name: name,
+ project: { connect: { id: authCheck.scope.projectId } },
+ },
+ },
+ }),
type: ObservationType.SPAN,
name,
- startTime: new Date(startTime),
+ startTime: startTime ? new Date(startTime) : undefined,
endTime: endTime ? new Date(endTime) : undefined,
- metadata,
+ metadata: metadata ?? undefined,
input: input ?? undefined,
output: output ?? undefined,
+ level: level ?? undefined,
+ statusMessage: statusMessage ?? undefined,
parent: parentObservationId
? { connect: { id: parentObservationId } }
: undefined,
diff --git a/src/pages/api/public/traces.ts b/src/pages/api/public/traces.ts
index e9e40d0fdc..aff2e5ea3b 100644
--- a/src/pages/api/public/traces.ts
+++ b/src/pages/api/public/traces.ts
@@ -5,8 +5,8 @@ import { prisma } from "@/src/server/db";
import { verifyAuthHeaderAndReturnScope } from "@/src/features/publicApi/server/apiAuth";
const CreateTraceSchema = z.object({
- name: z.string(),
- metadata: z.record(z.string(), z.any()).optional(),
+ name: z.string().nullish(),
+ metadata: z.unknown().nullish(),
});
export default async function handler(
@@ -46,8 +46,8 @@ export default async function handler(
data: {
timestamp: new Date(),
projectId: authCheck.scope.projectId,
- name,
- metadata,
+ name: name ?? undefined,
+ metadata: metadata ?? undefined,
},
});