Rollbar integration plugin for Cloudflare Pages
  • JavaScript 100%
Find a file
renovate[bot] ed4d0a7fdc
Update dependency @cloudflare/workers-types to v4.20260329.1 (#18)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-29 08:50:56 +00:00
.github Create FUNDING.yml 2025-07-12 19:04:03 +02:00
.yarn/releases v1.1.0 2025-01-22 08:21:03 +01:00
functions v1.1.1 2025-01-22 08:33:22 +01:00
lib v1.1.1 2025-01-22 08:33:22 +01:00
.gitignore v1.1.1 2025-01-22 08:33:22 +01:00
.yarnrc.yml v1.1.0 2025-01-22 08:21:03 +01:00
biome.json Update dependency @biomejs/biome to v2.4.9 (#12) 2026-03-25 17:29:41 +00:00
index.d.ts Fixed type definition 2025-01-22 09:08:33 +01:00
LICENSE v1.1.0 2025-01-22 08:21:03 +01:00
package.json Update dependency @cloudflare/workers-types to v4.20260329.1 (#18) 2026-03-29 08:50:56 +00:00
README.md Update README.md 2025-02-05 04:52:42 +01:00
renovate.json v1.1.0 2025-01-22 08:21:03 +01:00
tsconfig.json v1.1.0 2025-01-22 08:21:03 +01:00
yarn.lock Update dependency @cloudflare/workers-types to v4.20260329.1 (#18) 2026-03-29 08:50:56 +00:00

cloudflare-pages-plugin-rollbar

NPM Version GitHub License

Rollbar integration plugin for Cloudflare Pages

Installation

yarn add @hckr_/cloudflare-pages-plugin-rollbar
npm install @hckr_/cloudflare-pages-plugin-rollbar

Usage

// functions/_middleware.js
import rollbarPlugin from "@hckr_/cloudflare-pages-plugin-rollbar";

/**
 * @param {EventContext<Env>} context
 * @returns {Promise<Response>}
 */
export async function rollbar(context) {
  return rollbarPlugin({ token: context.env.ROLLBAR_TOKEN })(context);
}

export const onRequest = [rollbar];

The Plugin takes an object with two properties: the Rollbar Project Access token with post_server_item scope and optional custom for adding custom properties into logged payload.

This plugin catches unhandled exceptions and logs them into Rollbar. It gathers request data and Cloudflare metadata with exception details.

You can access Rollbar logger instance via the context.data.rollbar property. There are debug, info, warn and error methods for corresponding levels. First three take message and attributes as parameters. error takes exception and descrition.

interface Rollbar {
    debug(message: string, attributes: Record<string, any>): Promise;
    info(message: string, attributes: Record<string, any>): Promise;
    warn(message: string, attributes: Record<string, any>): Promise;
    error(exception: Error, description: string): Promise;
}

Publish

yarn build
yarn npm publish --access public --tag latest