Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log ignored records/actions on localhost? #42

Open
merrywhether opened this issue Jan 17, 2022 · 1 comment
Open

Log ignored records/actions on localhost? #42

merrywhether opened this issue Jan 17, 2022 · 1 comment

Comments

@merrywhether
Copy link

merrywhether commented Jan 17, 2022

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 electerious/use-ackee#10.

@electerious
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants