Skip to content

cloudflareWebAnalytics

The cloudflareWebAnalytics registry script. It loads https://static.cloudflareinsights.com/beacon.min.js for the input of the example. Call useScriptCloudflareWebAnalytics(input, options?) from @hamur/scripts/<library> in a component, or list it under scripts.registry.cloudflareWebAnalytics to load it on every page.

Config keyscripts.registry.cloudflareWebAnalytics
FunctionuseScriptCloudflareWebAnalytics of @hamur/scripts/<library>
Input keystoken (required), spa
Default triggerclient
Scripthttps://static.cloudflareinsights.com/beacon.min.js
Hostsstatic.cloudflareinsights.com, cloudflareinsights.com
Bundleyes: scripts.bundle: ["cloudflareWebAnalytics"]
Collection proxyno
Consentnone

Example

ts
import { defineConfig } from "hamur";
import scripts from "@hamur/scripts";

export default defineConfig({
  framework: "react",
  modules: [scripts],
  scripts: {
    registry: {
      cloudflareWebAnalytics: { token: "0123456789abcdef0123456789abcdef" },
    },
  },
});

It loads after the app mounted and the first idle callback. List cloudflareWebAnalytics in scripts.bundle and the build serves the file from your origin with a SHA-384 integrity (see Bundling). The script sends its own requests to the vendor.

Every key is checked when the config loads and again in useScriptCloudflareWebAnalytics: a wrong value stops the build with a message that starts with scripts.registry.cloudflareWebAnalytics. The registry list is on the registry page, and the shared options are in Scripts.