mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 13:18:58 +08:00
feat(webhook): add event picker
This commit is contained in:
parent
7c0b3ad098
commit
a6722d4a95
@ -317,6 +317,7 @@ export const webhookSchema = z.preprocess(
|
||||
url: z.string().url(),
|
||||
headers: z.record(z.string(), z.string()).default({}),
|
||||
metadata: z.record(z.string(), z.string()).default({}),
|
||||
events: z.array(z.enum(["completed", "failed", "page", "started"])).default(["completed", "failed", "page", "started"]),
|
||||
})
|
||||
.strict(strictMessage),
|
||||
);
|
||||
|
@ -16,6 +16,13 @@ export const callWebhook = async (
|
||||
eventType: WebhookEventType = "crawl.page",
|
||||
awaitWebhook: boolean = false,
|
||||
) => {
|
||||
if (specified) {
|
||||
let subType = eventType.split(".")[1];
|
||||
if (!specified.events.includes(subType as any)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const selfHostedUrl = process.env.SELF_HOSTED_WEBHOOK_URL?.replace(
|
||||
"{{JOB_ID}}",
|
||||
|
@ -168,6 +168,7 @@ export interface CrawlParams {
|
||||
url: string;
|
||||
headers?: Record<string, string>;
|
||||
metadata?: Record<string, string>;
|
||||
events?: ["completed", "failed", "page", "started"][number][];
|
||||
};
|
||||
deduplicateSimilarURLs?: boolean;
|
||||
ignoreQueryParameters?: boolean;
|
||||
|
Loading…
x
Reference in New Issue
Block a user