1.6.0 • Published 4 years ago

@fabrix/spool-segment v1.6.0

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

spool-segment

Gitter NPM version Build Status Test Coverage Dependency Status Follow @FabrixApp on Twitter

:package: Segment Spool

Implements Segment as a Fabrix spool

Analytics.js

This spool watches the segment flush property and will emit a fabrix event (spool:segment:flushed) when a flush happens. It will also flush the segment que when unloaded to prevent data loss.

Install

$ npm install --save @fabrix/spool-segment

Configure

// config/main.ts
import { SegmentSpool } from '@fabrix/spool-segment'
export const main = {
  spools: [
    // ... other spools
    SegmentSpool
  ]
}

Configuration

 // config/segment.ts
export const segment = {
  write_key: '<YOUR WRITE KEY>',
  flush_at: 1,
  flush_interval: 1000
}

For more information about segment (type and configuration) please see the segment documentation.

Usage

const data = {...}

// You can use the extension directly...
this.app.segment.track(data)

// Or as a Promise from the SegmentService...
return this.app.services.SegmentService.track(data)

SegmentService Methods

Identify

Track

Page

Group

Alias

Flush