Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-metrics-service

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-metrics-service

React adapter for metrics services like Google Analytics, Tealium or Comcast.

  • 0.0.9-beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
Maintainers
1
Weekly downloads
 
Created
Source

react-metrics-service

npm version dependency status build status

React adapter for metrics services like Google Analytics, Tealium or Comcast.

Usage

WIP

First create your metrics-service module (eg. using google analytics) in the file my-metrics.js:

// my-metrics.js

import { createClient, googleAnalytics } from 'react-metrics-service'

const client = createClient()
client.addDispatcher(googleAnalytics({ trackingID: 'UA-000000-01' }))

export default client

Add metricsServiceContext high order component to your app root component:

import { metricsServiceContext } from 'react-metrics-service'
import myClient from 'my-metrics'

const App = (
  // ... your app here
)

export default metricsServiceContext({ client: myClient })(App)

Then you can use one of the helper high order components like:

import { metricsServiceClick } from 'react-metrics-service'
import MyComponent from 'my-component.js'

export default metricsServiceClick('gaSend', 'event', 'Video', 'play')(MyComponent)

Or use the service directly like:

import myClient from 'my-metrics'

export default () => {
  // ...
  myClient.gaSend('event', 'Video', 'play')
  // ...
}

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!

  1. Fork it.
  2. Create a feature branch - git checkout -b more_magic
  3. Add tests and make your changes
  4. Check if tests are ok - npm test
  5. Commit changes - git commit -am "Added more magic"
  6. Push to Github - git push origin more_magic
  7. Send a pull request! :heart: :sparkling_heart: :heart:

Keywords

FAQs

Package last updated on 30 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc