DavidWells / DavidWells/analytics

Instance.On listener is inconsistent with Lifecycle Events

Open
#357 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Description

Based on that the events: track, page, etc. work with async functions and wait as expected this behaviour should be consistent across the functions. Looking at the implementation for on it makes sense why the lack of support is present, but how could we world to establish either an instance.on that supports async or a new method such as instance.asyncOn.

Here is a link to a code sandbox demonstrating the inconsistent behaviour.

Acceptance Criteria

  • Async behaviour is consistent between on and plugin lifecycle functions
  • Typed appropriately
  • Tests demonstrating this behaviour is working as expected

If this is meant to be this way so be it, there are some workarounds, but curious how others felt about the inconsistency. Thank you for your time and if @DavidWells would like a hand making this change I would be open to making a PR and getting your support along the way.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the instance.on implementation and the plugin lifecycle functions, then reproduce the inconsistency in the linked CodeSandbox. Decide how async behavior should be exposed, ensure the API is typed appropriately, and add tests showing consistent behavior between on and lifecycle functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.