github nytimes/react-tracking v0.9.0
v0.9.0 - Simplified API

latest releases: v9.3.2, v9.3.1, v9.3.0...
7 years ago

There's now a single decorator ( #6 ) that's a default export of this library that you can use instead of the two named exports, withTracking and trackEvent. Those two methods are still named exports so this version is backwards compatible with previous versions, but the single decorator is now the preferred method and we may deprecate the named exports in the future.

This single decorator works on Classes, class methods and stateless functional components in the same way.

So, instead of:

import React, { Component } from 'react';
import { withTracking, trackEvent } from 'nyt-react-tracking';

@withTracking({ page: 'FooPage' })
export default class FooPage extends Component {

  @trackEvent({ action: 'click' })
  handleClick = () => {
    // ...
  }
// ...
}

You can now just do:

import React, { Component } from 'react';
import track from 'nyt-react-tracking';

@track({ page: 'FooPage' })
export default class FooPage extends Component {

  @track({ action: 'click' })
  handleClick = () => {
    // ...
  }
// ...
}

Note that since it's the default export, you can call it anything you want.

Don't miss a new react-tracking release

NewReleases is sending notifications on new releases.