-
Notifications
You must be signed in to change notification settings - Fork 123
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Suggestion: Add type-safe tracking helpers #77
Comments
Hey @garbles thanks for posting this issue and bringing it to my attention. We do not (currently) use TypeScript at NYT, so we haven't felt this pain, but I could definitely see how this is problematic for TypeScript based projects. Please correct me if I'm wrong here, but I think the interface you described there is generally how it is now, with the exception of the Would you be interested/would it make sense to update the RE: Introducing |
Hello! We're using this library to integrate tracking into our React front-end, but we use TypeScript and trying to type the
track
function is a nightmare. The type definitions (@types/react-tracking
) do not work as expected and we've resorted to wrappingtrack
(typed asany
) in several other functions to get some type safety. What we ended up with were:TrackingProvider
: Component to wrap the entire applicationwithTracking
: HOF to augment component props withtracking.trackEvents
trackOnMount
: HOF to dispatch a tracking event on mount (only accepts a function with props so that it works similar to how Apollo populates query arguments with prop values)track
: Method decorator (also only accepts a function with props)Are you interested in moving toward a more static interface like this? Where one function can only do one thing? It would make integrating with TypeScript projects a lot easier. Of course, NYTimes may not have this problem though. LMK! 🙂
One more note: Introducing
TrackingProvider
might be necessary anyway with the new context API?¯\_(ツ)_/¯
The text was updated successfully, but these errors were encountered: