Socket
Socket
Sign inDemoInstall

@bufferapp/buffer-tracking-browser-ts

Package Overview
Dependencies
Maintainers
32
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufferapp/buffer-tracking-browser-ts

Segment tracking library for browser based Buffer Typescript projects


Version published
Weekly downloads
1.6K
increased by39.95%
Maintainers
32
Weekly downloads
 
Created
Source

buffer-tracking-app-browser-ts

A Strongly-typed segment tracking companion for use in Browser Typescript projects. Under the hood this uses the Buffer segment tracking plan, acting as a type-safe wrapper for clients. With this, there is no need to pull in or reference the tracking plan!

You can install this by running:

npm install @bufferapp/buffer-tracking-browser-ts

Before using, you'll need to ensure that your project is configured to access to segment. You can follow this guide here.

Next you'll need to add the typewriter import to the desired file:

import typewriter from '@bufferapp/buffer-tracking-browser-ts'

With the dependency added, you can use the typewriter reference to call the desired tracking functions:

typewriter.draftSubmitted({
  product: 'publish',
  channel: 'instagram',
  channelType: 'business',
  postId: '58edaj782102dff',
  channelId: '12345679',
  channelServiceId: '987654567898'
})

When calling these functions, any violations or errors will be logged as warnings to your console. if you wish for these to throw errors (maybe during development), then you can configure options on the typewriter reference to enable this:

typewriter.setTypewriterOptions({
  onViolation: (msg, violations) => {
    const issues = violations.map(v => v.keyword === 'type' ? `${v.message}: '${v.dataPath}'` : `${v.message}`)
    throw new Error(
      `"${msg.event}" Fired with Tracking Plan Violation\n    ${issues.join('\n    ')}`
    )
  }
})

Keywords

FAQs

Package last updated on 18 Jan 2021

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