1.0.11 • Published 4 years ago

@siteone/react-analytics v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

React analytics

Set of tools to provide better analytics events.

Sends actions to redux on desired events.

ApolloServerRouter

Export consists of few HoC:

  • withTrackOnPageView: calls ONE TIME action from props props.analytics.send and binds every action in props.analytics
  • withTrackOnRender: calls ON EVERY RENDER (debounced and prevented to call twice same event) action from props props.analytics.send and binds every action in props.analytics
  • withAnalytics: not calling any event, only binds every action in props.analytics
Example:
import React from 'react'
import { withProps } from 'recompose'
import { withTrackOnPageView } from '@siteone/react-analytics'

const Component = ({ analytics }) => (
  <div>
    Hello World
    <button onClick={analytics.onClick}>Measure click!</button>
  </div>
)

const withAnalyticsData = withProps((props) => ({
  analytics: {
    // OPTIONAL: if you want do to fire event after data is loaded
    isReady: !props.countryData.loading,
    // "send" will be called automatically
    send: { type: 'TRACK_PAGEVIEW' }, // action may be action object to be dispatched to redux
    // OPTIONAL: you can define any variables (like "click") and their will be bounded to redux
    onClick: (...args) => { type: 'CLICK', ...args }, // it also accepts function, that will return action object
  }
}))

export default compose(withAnalyticsData, withTrackOnPageView)(Component)

Version: 1.3.6

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago