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

feat: MetricsProvider should provide interface to accumulate events #61

Closed
whizzzkid opened this issue Jan 18, 2023 · 1 comment · Fixed by #65
Closed

feat: MetricsProvider should provide interface to accumulate events #61

whizzzkid opened this issue Jan 18, 2023 · 1 comment · Fixed by #65
Assignees
Labels

Comments

@whizzzkid
Copy link
Collaborator

Countly allows:

Countly.q.push(['add_event',{
  "key": "click",
  "count": 1,
  "sum": 1.5,
  "dur": 30,
  "segmentation": {
    "key1": "value1",
    "key2": "value2"
  }
}]);

a new interface needs to be added:

MetricsProvider.accumulate.event(event: CountlyEvent, flush: boolean)
// event can be indexed by key,
// flush forces a flush to event queue.
accumulatedEvents = Record<key: string, event: CountlyEvent>;

Internally, events can be represented as a hash-map of events by key where:

  • count represents the sum of count from each event.
  • sum represents the sum of events accumulated.
  • dur represents the duration over which the events were accumulated, defaults to 5 mins, but can be flushed earlier using flush param.

Optionally, an additional helper method can be provided to force flush the accumulated events synchronously. which can be hooked on the beforunload event.

MetricsProvider.accumulate.flush(key: string)
// this method is called when flush is set to true in `event` call.
// this will be a synchronous call:
Countly.add_event(accumulatedEvents[key])
@whizzzkid whizzzkid self-assigned this Jan 18, 2023
@whizzzkid whizzzkid changed the title MetricsProvider should provide interface to accumulate events feat: MetricsProvider should provide interface to accumulate events Jan 19, 2023
@github-actions
Copy link

🎉 This issue has been resolved in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

1 participant