krakenjs/beaver-logger

Improve `.metric()` API

jamischarles opened this issue · 1 comments

The .metric() API feels very awkward atm.

https://github.com/krakenjs/beaver-logger/blob/main/src/logger.js#L291-L304

Currently it's:

function metric(metricPayload: Metric){}

Which requires a .name property for the metric name.

I'm torn on how low-level to make this but maybe having a rawMetric(payload) and another method makes sense.

So it'd be

.rawMetric(payload);

.metric(eventName, namespace, dimensions);

.metric("weasley.flow.started", "pp.xo.weasley.custom", {
  app: 'weasley',
  isWPS: false,
  country: 'US',
  currencyCode: 'USD',
  releaseHash: 'e1fnrnd'
})

Then in sfx this would show up under the pp.xo.weasley.custom metric, with the event_name dimension set to weasley.flow.started

Maybe something like this. Still kind of torn on this, but wanted to raise it up. @westeezy

Nevermind. Forgot that this needs to be generic and backend agnostic.