1.0.0 • Published 2 years ago

apollo-link-segment v1.0.0

Weekly downloads
40
License
MIT
Repository
github
Last release
2 years ago

apollo-link-segment

Auto analytics for apollo apps

Installing / Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

A quick introduction of the minimal setup you need to get a hello world up & running.

npm install apollo-link-segment

Prerequisites

  • Apollo Link.

Usage

By default the link assumes segment is ready for use at window.analytics.

import apolloSegment from "apollo-link-segment";

ApolloLink.from([apolloSegment()]);

But you can pass a custom analytics instance to use

const segmentInstance = require("analytics.js-loader")({
  writeKey: YOUR_SEGMENT_WRITE_KEY,
});

import apolloSegment from "apollo-link-segment";

ApolloLink.from([
  apolloSegment({
    analytics: segmentInstance,
  }),
]);

By default all operation types will be tracked by you can optionally provide a whitelist.

import apolloSegment from "apollo-link-segment";

ApolloLink.from([
  apolloSegment({
    // only mutations will be tracked
    operationWhitelist: ["mutation"],
  }),
]);

By default the analytics.track will be called with the operation name as the event name and the operation as the event metadata.

For example the following query:

query GetUser {
  user {
    id
    name
  }
}

Will result in the following analytics.js call:

analytics.track('GetUser', <GraphqlOperationDetails>)
1.0.0

2 years ago

1.0.0-0

2 years ago

1.0.0-2

2 years ago

0.1.8

4 years ago

0.1.7

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago