Hello! I'm trying out analytics engine

Hello! I'm trying out analytics engine in my worker. But whatever I do, I always run into the Cannot read properties of undefined (reading 'writeDataPoint') error. It's a Typescript worker, and I'm simply calling env.VIEW_COUNTER.writeDataPoint() with
[[analytics_engine_datasets]]
binding = "VIEW_COUNTER"
dataset = "viewCounter"
[[analytics_engine_datasets]]
binding = "VIEW_COUNTER"
dataset = "viewCounter"
in my wrangler.toml Wrangler correctly identifies env.VIEW_COUNTER as a analytics engine dataset when generating the types;
interface Env {
VIEW_COUNTER: AnalyticsEngineDataset;
}
interface Env {
VIEW_COUNTER: AnalyticsEngineDataset;
}
Analytics Engine is enabled in CloudFlare. What am I missing?
1 Reply
Tim de Pater
Tim de PaterOP•2mo ago
Oh, I just fixed it by changing the config in wranger.toml to;
analytics_engine_datasets = [{ binding = "VIEW_COUNTER", dataset = "viewCounter" }]
analytics_engine_datasets = [{ binding = "VIEW_COUNTER", dataset = "viewCounter" }]
🤔
Want results from more Discord servers?
Add your server