electerious / Ackee

Self-hosted, Node.js based analytics tool for those who care about privacy.
https://ackee.electerious.com
MIT License
4.27k stars 359 forks source link

Allow negative values on events #327

Closed trezy closed 2 years ago

trezy commented 2 years ago

🐣 Is your feature request related to a problem? Please describe.

I'm creating events to track a user's interactions with various reactions on my blog. When a user clicks a reaction, it adds one, but if they click it again, it subtracts one. This is easy enough to handle during a single session by using instance.updateAction() to set the value of the event back to 0.

The issue is that if the user returns to the site later and decides to change or remove their reaction, there's no way for me to represent that. The best solution I see at the moment would be to provide a negative value for the reaction (e.g. { key: 'articlename', value: -1 }.

💡 Describe the solution you'd like

I'd like the positive number requirement on the value field to be removed from Ackee's events system.

trezy commented 2 years ago

Actually, I lied. This is not true:

This is easy enough to handle during a single session by using instance.updateAction() to set the value of the event back to 0.

since 0 is not considered positive, this also fails.

electerious commented 2 years ago

Support for negative values isn't planned as Ackee can only display positive values in its bar chart presentation.

since 0 is not considered positive, this also fails.

You can reset the value of a action to null.

instance.updateAction('24776c2b-c5d6-4fac-852a-067d086dc4af', {
    key: 'Subscription',
    value: null
})

The issue is that if the user returns to the site later and decides to change or remove their reaction, there's no way for me to represent that. The best solution I see at the moment would be to provide a negative value for the reaction (e.g. { key: 'articlename', value: -1 }.

It sounds like you're already storing the information that something has a reaction. My idea would be to also store the id of the action so you can reset it later.