ackee-tracker icon indicating copy to clipboard operation
ackee-tracker copied to clipboard

Log ignored records/actions on localhost?

Open merrywhether opened this issue 3 years ago • 1 comments

Currently when ignoreLocalhost is set to false, there is a single console.warn message but no other info for troubleshooting your app. When you are new to Ackee or using it a new framework or pattern, it would be nice if you could get some indication of what would have been tracked. For example, you could console.info something like:

ackee record <domainId> - <recordId>
ackee record update - <recordId>
ackee action <key> - <recordId>
ackee action update - <recordId>

(unsure if the updates should be logged, but seems right at least for actions whose updates will be manually driven)

Would you accept a PR adding functionality along these lines? If so, design questions follow.

What is your preferred API for this?

  • Expanding existing key: ignoreLocalhost: true | false | 'log' (most straightforward)
  • New key: ignoreLocalhostBehavior: 'log' | 'silent' or logOnIgnoreLocalhost: true | false etc (or verbose: true | false which could be independent from ignore if people want this in prod for some reason)

Would you prefer updates be logged? Or just creates? Configurable (logOnIgnoreLocalhost: 'create' | 'all' | false)?

Would you prefer the logging instance augment all of the standard behavior? Maybe something like

// new function with same API as send
const log = function(url, body, options, next) {
  // probably inspect body.variables to determine what mutation type is happening, though could also parse query string
}

export const create = function(server, options) {
  // added to body of create and replaces existing direct calls to `send` in this function
  const _send = options.ignoreLocalhost === 'log' ? log : send;
  ...

I think this is probably the right path forward for best simulation, and it means calls to stop don't need to be logged since the intervals will just stop happening.

This would also be useful in something like https://github.com/electerious/use-ackee/pull/10.

merrywhether avatar Jan 17 '22 23:01 merrywhether

I like the verbose: true | false idea where ackee-tracker logs what it tracks and what it would have tracked when not on localhost. PR welcome!

electerious avatar Apr 30 '22 13:04 electerious