Skip to content

Commit a6722d4

Browse files
committed
feat(webhook): add event picker
1 parent 7c0b3ad commit a6722d4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

apps/api/src/controllers/v1/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export const webhookSchema = z.preprocess(
317317
url: z.string().url(),
318318
headers: z.record(z.string(), z.string()).default({}),
319319
metadata: z.record(z.string(), z.string()).default({}),
320+
events: z.array(z.enum(["completed", "failed", "page", "started"])).default(["completed", "failed", "page", "started"]),
320321
})
321322
.strict(strictMessage),
322323
);

apps/api/src/services/webhook.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export const callWebhook = async (
1616
eventType: WebhookEventType = "crawl.page",
1717
awaitWebhook: boolean = false,
1818
) => {
19+
if (specified) {
20+
let subType = eventType.split(".")[1];
21+
if (!specified.events.includes(subType as any)) {
22+
return false;
23+
}
24+
}
25+
1926
try {
2027
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace(
2128
"{{JOB_ID}}",

apps/js-sdk/firecrawl/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export interface CrawlParams {
168168
url: string;
169169
headers?: Record<string, string>;
170170
metadata?: Record<string, string>;
171+
events?: ["completed", "failed", "page", "started"][number][];
171172
};
172173
deduplicateSimilarURLs?: boolean;
173174
ignoreQueryParameters?: boolean;

0 commit comments

Comments
 (0)