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

[react-tracking] Add types for useTracking hook #35607

Merged
merged 1 commit into from
May 21, 2019

Conversation

damassi
Copy link
Contributor

@damassi damassi commented May 20, 2019

Updates types for react-tracking@7.0.0, which includes a new useTracking hook. In support of this, TrackingProp now accepts a a generic, which allows us to restrict what props are passed into tracking.trackEvent().

Example:

interface Trackables {
    page: string;
    app: string;
}

 const App = track()((props: { foo: string }) => {
    const tracking = useTracking<Trackables>();

    return <div onClick={() => {
        tracking.trackEvent({
            page: 'Home'
        });
    }}/>;
});
  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)

If changing an existing definition:

@typescript-bot
Copy link
Contributor

typescript-bot commented May 20, 2019

@damassi Thank you for submitting this PR!

🔔 @alloy - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot
Copy link
Contributor

@damassi The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot
Copy link
Contributor

typescript-bot commented May 20, 2019

@damassi The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot
Copy link
Contributor

@damassi The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@damassi damassi force-pushed the update-react-tracking-7 branch 2 times, most recently from 0c8f1e1 to f3f80aa Compare May 21, 2019 01:00
@typescript-bot typescript-bot moved this from Needs Author Attention to Waiting for Reviewers in Pull Request Status Board May 21, 2019
/**
* A React hook used to tap into the tracking context.
*/
export function useTracking<P = {}>(): TrackingProp<P>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t allow typing the function without using it, which means we’d need a wrapper function just to restrict it by default to our schema, but we can follow up with that in a later PR.

@alloy
Copy link
Collaborator

alloy commented May 21, 2019

👌

@alloy alloy merged commit 4550017 into DefinitelyTyped:master May 21, 2019
Pull Request Status Board automation moved this from Waiting for Reviewers to Done May 21, 2019
@typescript-bot
Copy link
Contributor

I just published @types/react-tracking@7.0.0 to npm.

tomasz-zablocki pushed a commit to tomasz-zablocki/DefinitelyTyped that referenced this pull request May 21, 2019
@damassi damassi deleted the update-react-tracking-7 branch May 23, 2019 00:14
iRON5 pushed a commit to iRON5/DefinitelyTyped that referenced this pull request Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants