Worker Analytics Beta not working

There is a. beta feature that allows you to write custom analytics from Cloudflare Workers/pages

I have enabled the analytics feature on the Pages overview.
I click on setup and follow the instructions.
I have created an entry in my toml

[[analytics_engine_datasets]]
binding = "ANALYTICS"

I have added the binding to my env so my code can call it like this
env.ANALYTICS.writeDataPoint({
blobs: ['signup', 'beta', 'failed'],
indexes: [email, firstName, lastName],
});

but I get an error when running the code locally as the local env.ANALYTICS resource being bound to doesn't seem to exist:
TypeError: Cannot read properties of undefined (reading 'writeDataPoint')

If I push it to preview it doesn't create the resource.

I have manually gone into the function settings and set the binding on
Analytics Engine bindings at the bottom of the page, still nothing.

Any ideas?
Was this page helpful?