Skip to content

Cloudflare.Rum reference

Source: src/Cloudflare/Rum/Rule.ts

A Cloudflare Web Analytics (RUM) rule.

Rules include or exclude traffic from Web Analytics measurement by hostname and path patterns. They live under the implicit ruleset of a zone-based (orange-clouded) Site — pass the site’s rulesetId attribute. Host, paths, inclusive, and isPaused are all mutable in place; changing rulesetId triggers a replacement.

Web Analytics is available on free accounts.

const zone = yield* Cloudflare.Zone.Zone("Zone", { name: "example.com" });
const site = yield* Cloudflare.Rum.Site("Analytics", {
zoneTag: zone.zoneId,
autoInstall: true,
});
yield* Cloudflare.Rum.Rule("ExcludeAdmin", {
rulesetId: site.rulesetId.as<string>(),
host: "example.com",
paths: ["/admin/*"],
inclusive: false,
});
yield* Cloudflare.Rum.Rule("ExcludeAdmin", {
rulesetId: site.rulesetId.as<string>(),
host: "example.com",
paths: ["/admin/*"],
inclusive: false,
isPaused: true,
});

Source: src/Cloudflare/Rum/Site.ts

A Cloudflare Web Analytics (RUM) site.

A site measures real-user performance for either a plain hostname (gray-clouded — embed the produced snippet yourself) or a Cloudflare zone (orange-clouded — set autoInstall to inject the snippet at the edge). The site is identified by its auto-assigned siteTag; host and autoInstall are mutable in place, while switching between host and zoneTag identity models (or changing zoneTag) triggers a replacement.

Web Analytics is available on free accounts.

const site = yield* Cloudflare.Rum.Site("Analytics", {
host: "example.com",
});
// Embed in your HTML — contains the site token:
const snippet = site.snippet;

Orange-clouded site with automatic snippet injection

const zone = yield* Cloudflare.Zone.Zone("Zone", { name: "example.com" });
yield* Cloudflare.Rum.Site("ZoneAnalytics", {
zoneTag: zone.zoneId,
autoInstall: true,
});

Skip injection for EU visitors

yield* Cloudflare.Rum.Site("ZoneAnalytics", {
zoneTag: zone.zoneId,
autoInstall: true,
lite: true,
});