Menu
Cloudflare Worker SDK API Reference
Cloudflare Worker SDK
Highlight's Cloudflare Worker SDK lets you track your errors and responses in Cloudflare Workers with no impact on performance..
Just getting started?
Check out our getting started guide to get up and running quickly.
H.consumeError
H.consumeError() reports an error and its corresponding stack trace to Highlight. The session is inferred based on the incoming network request headers.
Method Parameters
import { H } from "@highlight-run/cloudflare";
export default {
async fetch(request: Request, env: {}, ctx: ExecutionContext) {
try {
// do something...
return new Response('hello!')
} catch (e: any) {
H.consumeError(request, { HIGHLIGHT_PROJECT_ID: 'YOUR_PROJECT_ID' }, ctx, e)
throw e
}
},
}
H.sendResponse
H.sendResponse() traces a response from your backend. This allows tracking incoming and outgoing headers and bodies.
Method Parameters
import { H } from "@highlight-run/cloudflare";
export default {
async fetch(request: Request, env: {}, ctx: ExecutionContext) {
const response = return new Response('hello!')
H.sendResponse(request, { HIGHLIGHT_PROJECT_ID: 'YOUR_PROJECT_ID' }, ctx, response)
return response
},
}