📦 Segment Spool
Implements Segment as a Fabrix spool
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.
$ npm install --save @fabrix/spool-segment
// config/main.ts
import { SegmentSpool } from '@fabrix/spool-segment'
export const main = {
spools: [
// ... other spools
SegmentSpool
]
}
// 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.
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)