@apollosproject/ui-analytics

4.2.0 • Public • Published

Apollos UI: Analytics

Configuration

There is one configuration option available with this PR. You can add additional third party tracking libraries that are triggered anytime a track event from this library is triggered.

When implementing your provider, set the trackFunctions prop. For example, like this:

  <AnalyticsProvider trackFunctions={[console.warn]}>
    <Providers {...props} />
  </AnalyticsProvider>

This will call the console.warn function every time the analytics calls track. The properties passed are {eventName: String, properties: Object }.

You can do the same for identify using identifyFunctions. You must always pass an array of functions, even if you are only passing a single function.

Usage

From anywhere you have access to your apollo client variable...

import { track } from '@apollosproject/ui-analytics'

...

  track({ client, eventName, properties });

From anywhere in the component tree under the AnalyticsProvider.

import { AnalyticsConsumer } from '@apollosproject/ui-analytics'

...

  <AnalyticsConsumer>
  ({ track, identify }) => (
    <Something onSomethingHappened={() => track({ eventName, properties })} />
  )
  </AnalyticsConsumer

Using a component.

import { TrackEventWhenLoaded } from '@apollosproject/ui-analytics'

...

  <TrackEventWhenLoaded eventName="Something" properties={...someData} loaded={this.props.loaded} />

Package Sidebar

Install

npm i @apollosproject/ui-analytics

Weekly Downloads

653

Version

4.2.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

2.32 MB

Total Files

18

Last publish

Collaborators

  • apollosadmin
  • nathanlewis.differential
  • yungvincenzo
  • conrad_vanl
  • redreceipt
  • didevshop