Skip to content

Commit 804af9a

Browse files
author
flowcore-platform
committed
fix(index): 🎨 Update events type to array for consistency in ingestion
1 parent e0f1aa2 commit 804af9a

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ server.tool(
204204
if (values.apiKey) {
205205
server.tool(
206206
"ingest",
207-
"Ingest events into an event type. This is useful for ingesting events into an event type, and then using the get_events tool to get the events for a specific time bucket. The events are stored in time buckets, and can be fetched by using the get_time_buckets tool. When you fetch events from a time bucket, you can use the cursor to paginate through the events. When ingesting events, you can ingest a single event or an array of events. The format of the event can be anything you want, as long as it's valid JSON. It will be the payload of the event.",
207+
"Ingest events into an event type. This is useful for ingesting events into an event type, and then using the get_events tool to get the events for a specific time bucket. The events are stored in time buckets, and can be fetched by using the get_time_buckets tool. When you fetch events from a time bucket, you can use the cursor to paginate through the events. When ingesting events, you can ingest an array of events. The data you send should be in JSON format. It will be the payload of the event.",
208208
{
209209
tenant: z.string().describe("The tenant name to ingest events for"),
210210
dataCoreId: z.string().describe("The data core ID to ingest events for"),
211211
flowTypeName: z.string().describe("The flow type name to ingest events for"),
212212
eventTypeName: z.string().describe("The event type name to ingest events for"),
213213
events: z
214-
.union([z.array(z.unknown()), z.unknown()])
215-
.describe("The events to ingest in the format of an array of events or a single event"),
214+
.array(z.any())
215+
.describe("The events to ingest in the format of an array of events in JSON format"),
216216
},
217217
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
218218
ingestHandler(values.apiKey as string) as any,

src/tools/ingest.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export type IngestInput = {
33
dataCoreId: string
44
flowTypeName: string
55
eventTypeName: string
6-
events: unknown[] | unknown
6+
events: unknown[]
77
}
88

99
export const ingestHandler = (apiKey: string) => async ({
@@ -14,13 +14,7 @@ export const ingestHandler = (apiKey: string) => async ({
1414
events,
1515
}: IngestInput) => {
1616
try {
17-
let type = "event"
18-
19-
if (Array.isArray(events)) {
20-
type = "events"
21-
}
22-
23-
const webhookUrl = `https://webhook.api.flowcore.io/${type}/${tenant}/${dataCoreId}/${flowTypeName}/${eventTypeName}`
17+
const webhookUrl = `https://webhook.api.flowcore.io/events/${tenant}/${dataCoreId}/${flowTypeName}/${eventTypeName}`
2418

2519
// Execute the command manually since it's a custom command
2620
const response = await fetch(webhookUrl, {

0 commit comments

Comments
 (0)