@bufferapp/buffer-tracking-node-ts

Segment tracking library for Buffer node (typescript) projects

Usage no npm install needed!

<script type="module">
  import bufferappBufferTrackingNodeTs from 'https://cdn.skypack.dev/@bufferapp/buffer-tracking-node-ts';
</script>

README

Buffer Tracker - Node (Typescript)

Strongly-typed analytics app for use in Node Typescript projects.

You will need to have configured segment as per these instructions before using this package.

You can install this by running:

npm i @bufferapp/buffer-tracking-node-ts

Next you'll need to add the dependency to the desired file, alongside the existing segment configuration:

import {BufferTracker} from '@bufferapp/buffer-tracking-node-ts'
import Analytics from 'analytics-node'
let analytics = new Analytics('YOUR_WRITE_KEY')

You'll then need to provide our typewriter app with a reference to the segment analytics-node reference:

typewriter.setTypewriterOptions({
  analytics: analytics
})

And finally, you can use the typewriter reference to call the desired tracking functions:

typewriter.shopGridLinkRemoved({
  userId: userId,
  properties: {
    product: 'publish',
    channel: 'instagram',
    channelId: '12345679',
    channelServiceId: '987654567898',
    linkText: 'hiii',
    linkURL: 'www.buffer.com'
  }
})

Product / Client Typings

If you need access to Product or Client typings, you can import them like so:

import {Product, Client} from '@bufferapp/buffer-tracking-node-ts'

If there is a Product or Client that is not included, let us know in the #data-governance slack channel and it can be added :)


Gotchas

There is currently no Type support for the requirement of a userId or anonymous ID when triggering a tracking event. We are working on adding support for this in the near future, but for now it's important to note that either one of these must be added when tracking!

Latest plan changes not reflected in the library

If the library does not reflect the latest tracking changes then you can trigger a rebuild manually. Head over to this URL and select the Run Workflow option. After a few minutes, the latest release should be pushed to NPM.

Screenshot 2021-06-01 at 14 25 51