cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.61k stars 679 forks source link

🐛 BUG: `npm run deploy` errors out with `workers.api.error.no_access_to_analytics_engine [code: 10089]` #5940

Open peter-leonov-hellofresh opened 4 months ago

peter-leonov-hellofresh commented 4 months ago

Which Cloudflare product(s) does this pertain to?

Other

What version(s) of the tool(s) are you using?

wrangler 3.57.2

What version of Node are you using?

v18.17.1

What operating system and version are you using?

14.5

Describe the Bug

Observed behavior

Deploying a worker with analytics_engine_datasets defined gives an error.

Expected behavior

There is no error and the worker starts and allows to send datapoints.

Steps to reproduce

Following the tutorial on how to use Workers Analytics Engine I've added the analytics_engine_datasets like this to my wrangler.toml file:

[[analytics_engine_datasets]]
binding = "METRICS"
dataset = "worker-dataset"

The rest is just the code generated by npm create cloudflare@latest.

Then trying to deploy using npm run deploy gives me an error: workers.api.error.no_access_to_analytics_engine [code: 10089]. Full output please see here:

% npm run deploy   

> royal-hill-87ae@0.0.0 deploy
> wrangler deploy

 ⛅️ wrangler 3.57.2
-------------------
Total Upload: 0.32 KiB / gzip: 0.24 KiB
Your worker has access to the following bindings:
- Analytics Engine Datasets:
  - METRICS: worker-dataset

✘ [ERROR] A request to the Cloudflare API (/accounts/[REDACTED]/workers/scripts/worker) failed.

  workers.api.error.no_access_to_analytics_engine [code: 10089]

  If you think this is a bug, please open an issue at:
  https://github.com/cloudflare/workers-sdk/issues/new/choose

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

✘ [ERROR] A request to the Cloudflare API (/accounts/[REDACTED]/workers/scripts/[REDACTED]) failed.

  workers.api.error.no_access_to_analytics_engine [code: 10089]

  If you think this is a bug, please open an issue at:
  https://github.com/cloudflare/workers-sdk/issues/new/choose
pnewsam commented 3 months ago

Just noting what seems to have solved the problem in my case. I had to go into Workers & Pages -> Overview, and then on the righthand panel, I had to click "Setup" under the "Analytics Engine (beta)" heading. Then on that page I had to enable Analytics Cloudflare Engine via the CTA. After doing that my wrangler deploy worked, and I am now seeing analytics data when I query.

( I had also submitted a request to be included in the Beta on this page: https://www.cloudflare.com/lp/workers-analytics-engine/ but I'm not sure whether that's related. I only mention it because I don't remember noticing that "Analytics Engine (beta)" heading before. )

rohinlohe commented 3 months ago

Hi @pnewsam. You're right, Analytics Engine currently requires enablement through the dashboard. This gate is a vestige of the beta, and we're working on removing it.

addshore commented 2 months ago

Another thing to not here for anyone finding this through google... You won't have an option to enable analytics, unless you have also already run / got a worker running. So i order to deploy via wrangler, i just made a garbage hello world deploy first, then flipped on analytics

image

andyjessop commented 1 month ago

I've removed the bug label and added polish, as this seems to be an issue with the error message more than anything else.