@basicrum/basicrum-astro is an Astro 7 integration for Basicrum real user monitoring.
It injects one of the two Basicrum Boomerang loaders as an inline classic head
script and serves the vendored Boomerang bundle from /_basicrum/.
- Implementation source is TypeScript in
src/.npm run buildusestscto generate JavaScript and declarations indist/, preserving module paths and function names.dist/is ignored by Git and is the published code.npm ciandnpm packbuild it through thepreparelifecycle. Tests and examples consume the generated code.src/env.d.tsonly declares Vite's?rawimports; public API declarations are generated, never hand-edited. src/index.tsis the Astro adapter: it reads Astro'sbaseandcommand, injects the prerendered asset route (src/boomerang-endpoint.ts) and the head script.src/client.tsis the browser entry re-exportingsetConsent().src/core/is framework-neutral:options.tsvalidates options,bootstrap.tsgenerates the head script,assets.tsis the only core module that knows the Boomerang version and vendored file names (the Astro endpoint repeats the bundle name in its static?rawimport, which a unit test keeps in sync),consent.tsapplies a consent decision. Adapters import onlysrc/core/index.tsandsrc/core/consent.ts. Unit tests enforce the boundary in both directions;src/core/README.mdholds the checklist for extracting the core into its own package.vendor/holds the loaders and the Boomerang build, copied unchanged from the WordPress plugin.vendor/provenance.jsonrecords the source commit and SHA-256 digests.- Tests:
tests/unit/(Node test runner),tests/browser/(Playwright integration: SSR, dev server,ClientRouter, races),tests/e2e/(readable per-loader workflows).tests/serve-fixtures.jsbuilds the fixture site into.test-output/and serves it on ports 43211 to 43221, with a local collector on 43218 for tests that need unload traffic. docs/reviews/holds dated review records. Each starts with a status list; update it when a finding is fixed.
- Tracked text files are plain ASCII: hyphens instead of dashes, straight
quotes, words instead of arrows.
tools/verify-ascii.shenforces it. - Pin development dependencies to exact versions. Pin GitHub Actions to full 40-character commit SHAs with the reviewed tag in the adjacent comment, and update pins through reviewed Dependabot pull requests.
- Keep
versioninpackage.jsonandpackage-lock.jsonand the topCHANGELOG.mdentry identical. Release tags use thev<version>form. - Never modify the vendored Boomerang build or the loaders. Behaviour that
the integration needs lives in the bootstrap's own plugins or in the
adapter;
vendor/changes only by copying a newer WordPress release. - Upgrade the vendored Boomerang build and loaders together with
vendor/provenance.json,THIRD-PARTY-NOTICES.mdandBOOMERANG_VERSIONinsrc/core/assets.ts. The unit, browser and end-to-end tests assert the literal version as well. Run the consent withdrawal tests before releasing. - Tests never send beacons to a real collector. Fixtures use the intercepted
host
collector.basicrum.test; the example usescollector.example.invalid. - Required public options are
brumSiteId,beaconEndpointandloader. Loader modes are"non-consent"(immediate collection without a consent decision) and"consent"(waits for the site's consent manager). loaderstays required with no implicit consent default. There is noscriptUrloverride: the loaders and thebasicRumBoomerangConfigcontract ship together.enableddefaults to true for builds and false forastro dev.- A second
basicrum()registration failsastro:config:setup; there is no order-dependent winner. The former@basicrum/astrointegration name also counts, so mixing old and new packages fails configuration. - The bootstrap is serialized from
configure()insrc/core/bootstrap.tsand runs as a classic script: keep it free of module syntax, keep the generator name (p_gen) a parameter, and never restore configuration that a consent withdrawal cleared. - Documentation states behavior the tests prove. When a claim in the README changes, change or add the test that proves it.
npm ci
npx playwright install chromium
npm run conventions
npm run typecheck
npm run lint
npm run lint:package
npm run test:unit
npm run test:browser
npm run verify:packagenpm test builds the package, checks conventions, types, source lint and strict
package lint, and runs the unit and browser tests. npm run lint:package
builds before checking npm's published file selection with publint; warnings
are errors. npm run verify:package packs and strictly lints the exact tarball,
installs the tarball into a temporary Astro
consumer, checks the installed declarations and builds both loader modes with
a non-root base; it needs network access. CI runs all of them on every push to
main and on every pull request.
- Move the
Unreleasednotes inCHANGELOG.mdunder a new## [X.Y.Z] - YYYY-MM-DDheading and update the comparison links. - Run
npm version X.Y.Z --no-git-tag-versionto updatepackage.jsonandpackage-lock.json, thennpm run conventions. - Commit, tag with
git tag -a vX.Y.Z -m "Basicrum Astro vX.Y.Z", and pushmainand the tag. - The Release workflow refuses a tag whose commit is not on
main, verifies the tag against the version, runs every check, strictly lints the final release tarball before calculating its SHA-256, attaches both to a GitHub Release, and publishes to npm only when theNPM_TOKENrepository secret exists. Verification and packaging run in a job without secrets; only the separate publish job, bound to thereleaseenvironment, receives the npm credential, and only in its publish step. Add required reviewers or deployment branch rules to that environment in the repository settings to gate publication. Do not create the GitHub Release or publish manually. The 0.1.2 publish step also deprecates the former@basicrum/astroversions through 0.1.1 after the renamed package is published, if the old package still exists. A removed package does not block the release. To recover a partially completed release, dispatch the Release workflow frommainwith the existing tag. It checks out that tag, reruns all verification, and checks that an already published npm archive matches before completing the GitHub Release. Never move a published version's tag.