sensorsdata-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

SDK for Sensorsdata

Features

  • Function close for graceful shutdown
  • Backpressure by Nodejs Stream
  • Disable allowReNameOption by default

Usage

Server side tracking

const sa = new SensorsAnalytics(URL, {
    mode: 'track',
    timeout: 5000
    buffCount: 20,
    buffTimeSecs: 5,
})

sa.track(DISTINCT_ID, EVENT, {})
sa.profileSet(DISTINCT_ID, {})

// shut down
await sa.close()

Streaming style

const stream = new Readable({
    objectMode: true,
    _read(){}
})
stream.pipe(sa)

stream.push({
    type: 'track',
    event: 'a',
    distinctId: DISTINCT_ID,
    properties: {}
})
stream.push({
    type: 'track_sign_up',
    event: '$SignUp',
    distinctId: DISTINCT_ID,
    originalId: DEVICE_ID,
    properties: {}
})

/sensorsdata-sdk/

    Package Sidebar

    Install

    npm i sensorsdata-sdk

    Weekly Downloads

    2

    Version

    0.1.3

    License

    none

    Unpacked Size

    80.1 kB

    Total Files

    51

    Last publish

    Collaborators

    • joway
    • renzholy
    • sorcererxw
    • sunskyxh
    • themez
    • tiant167