DavidWells / DavidWells/analytics
Plugin methods API issues
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 267
- PR merge metrics
- No merged PRs in 30d
Description
Obsevations:
- The analytics instance is provided as a field
instanceon this when calling a method - this is shown in examples but not documented - The analytics instance is provided as an additional parameter beyond the supplied ones when calling a method - this is not documented anywhere from what I can tell, and it could cause some bugs. For example I was making a method called
gtagto push arguments into the Google Tag Manager but it has to just generically push all its arguments - the extra argument could have caused some confusion here. - Plugin config is typically passed to all the event handlers on a plugin, but isn't passed into the method implementations, so I can take advantage of those options in the method. For example, if I wanted to use the
dataLayerNameoption in a method, I can't do that.
Potential improvements:
- Update the docs to clarify what is passed into these things
- Make the config available somehow as well (maybe also on
thisalthoughthis-based APIs are kind of weird IMO) - Maybe the
methodscould be a function that takes an object withinstance, andconfig, and returns the method implementation functions bound to thatconfigandinstancefrom scope? That could help get around the issue with passing inconfigand avoid usingthisto supply arguments
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the plugin methods API and the examples referenced in the issue, then trace how instance, supplied arguments, and plugin config reach event handlers and method implementations. Before coding, clarify whether the goal is documentation only or an API redesign; done should include an agreed behavior for config access and documented argument handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100