Skip to content

About

Example project using Cloudflare for deploying datafiles

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Eventvisor with Cloudflare Pages

An Eventvisor v1 project which builds, tests, and deploys a web Target to Cloudflare Pages.

Use this repository as a reference for hosting generated Eventvisor datafiles on your own Cloudflare Pages project.

Accessing datafiles

The generated web datafile from this repository is available at:

The web Target selects definitions tagged with web. Eventvisor v1 generates datafiles for Targets rather than tags, so the output is eventvisor-web.json.

Usage with Eventvisor SDK

Install the v1 SDK and the Console module in your application:

npm install @eventvisor/sdk@1 @eventvisor/module-console@1

Load the deployed datafile and create an Eventvisor instance:

import { createEventvisor } from "@eventvisor/sdk";
import { createConsoleModule } from "@eventvisor/module-console";

const DATAFILE_URL =
  "https://eventvisor-example-cloudflare.pages.dev/eventvisor-web.json";

const datafileContent = await fetch(DATAFILE_URL).then((res) => res.json());

const eventvisor = createEventvisor({
  datafile: datafileContent,
  modules: [createConsoleModule()],
});

await eventvisor.onReady();

await eventvisor.track("page_view", {
  url: window.location.href,
});

Learn more in the JavaScript SDK documentation.

Installation

This project uses Node.js 24 and Eventvisor CLI v1. Install its locked dependencies with:

npm ci

Usage

Lint

npm run lint

Build datafiles

npm run build

The build writes datafiles/eventvisor-web.json.

Test

npm test

Tests cover the page_view event schema and its transformed body for the browser destination.

Cloudflare

The publish workflow builds the project and uploads the datafiles directory to Cloudflare Pages.

Create a Cloudflare Pages project named eventvisor-example-cloudflare, or update the project name in the publish workflow.

GitHub Actions

GitHub Actions lint, test, and build every change. Pushes to the default branch also deploy the generated datafile and commit the updated Eventvisor revision.

You can use the same commands with any other CI provider.

Settings

Enable Read and write permissions under Settings > Actions > General > Workflow permissions so the publish workflow can commit the updated revision.

Workflows

The workflows live in .github/workflows:

  • checks.yml validates branches before merging.
  • publish.yml validates and deploys pushes to main or master.

Secrets

Follow Cloudflare's direct upload guide and add these repository secrets under Settings > Secrets and variables > Actions:

  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_API_TOKEN

Further reading

About

Example project using Cloudflare for deploying datafiles

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages