react-metrics-service
React adapter for metrics services like Google Analytics, Tealium or Comcast.
Usage
First create your metrics-service module (eg. using google analytics) in the file my-metrics.js
:
// my-metrics.js const client = client
You can create your own metrics-service module, check some examples in src/dispatchers
Using the client directly
Use the service directly like:
{ // ... myClient // ...}
With Proxy support you can also write:
{ // ... myClient // ...}
Using the high order component (HOC)
Add metricsServiceContext
high order component to your app root component:
const App = // ... your app here client: myClient App
Then you can use the withMetricsServiceClient
HOC:
const Component = metricsServiceClient // ... metricsServiceClient // ... Component
Or the metricsServiceClick
HOC:
'gaSend' 'event' 'Video' 'play'MyComponent
Builtin supported clients
- google analytics
- google analytics legacy
- google tag manager
- tealium
- debug log
const client = clientclientclientclientclient
TODO
- Event pool that can wait for dispatchers to boot
- Render hook support on dispatchers
- Standardize a isReady call on dispatchers
Contributing
First of all, thank you for wanting to help!
- Fork it.
- Create a feature branch -
git checkout -b more_magic
- Add tests and make your changes
- Check if tests are ok -
npm test
- Commit changes -
git commit -am "Added more magic"
- Push to Github -
git push origin more_magic
- Send a pull request! ❤️ 💖 ❤️