-
Notifications
You must be signed in to change notification settings - Fork 217
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
Wrongly typed newTracker()
function within the "@snowplow/browser-tracker" package
#1167
Labels
type:defect
Bugs or weaknesses. The issue has to contain steps to reproduce.
Comments
Merged in v4. :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The exposed
newTracker()
function from the @snowplow/browser-tracker package returnsBrowserTracker | null
. The current interface definition hints to a return type ofBrowserTracker
only.This is misleading and does not represent the current implementation correctly.
To Reproduce
newTracker()
with a specified tracker identifier e.g. "my-test"newTracker()
with the sametrackerId
null
Expected behavior
I would expect that either the types will tell that the function could possibly return null.
Or that the function would return the already initialized tracker, even though this could be misleading due to the function naming "new".
"Screenshots"
@snowplow/browser-tracker:
newTracker()
https://github.com/snowplow/snowplow-javascript-tracker/blob/master/trackers/browser-tracker/src/index.ts#L59
@snowplow/browser-tracker-core:
addTracker()
https://github1s.com/snowplow/snowplow-javascript-tracker/blob/master/libraries/browser-tracker-core/src/snowplow.ts#L88
Additional context
We implemented the browser tracker within a React ecosystem and run into an issue where we called
newTracker()
twice due to an unexpected rerender. We used the returned tracker to add further tracker configurations; but were not able to do so after the second render / initialization.We prevent calling the
newTracker()
function twice; and realized while debugging that the provided interface / type definitions are currently wrong.The text was updated successfully, but these errors were encountered: