1.0.4 • Published 7 years ago
picku-track-sdk v1.0.4
PickU Analytics
Install
Install using npm.
$ npm install picku-track-sdk --save##Attention
In the latest version(v1.0.8), we added a option named allowReNameOption valued true by default.
In this case, we change the property value and the keys to snake style with '_'.
eg:
trackEvent('user-id', 'userHappy', {
'$appVersion': '1.0.0',
'orderId': '123'
})
// then we get the data
{
...
'event': 'user_happy'
'properties': {
'$app_version': '1.0.0',
'order_id': '123'
}
...
}Usage
Basic Usage
Parse User Agent
Node SDK supports parsing client OS, OS version, Browser, Browser version, Browser Engine, Model from client's User Agent
router.post('/api/new-order', (req, res) => {
trackEvent(req.session.userId, 'newOrder', { $userAgent: req.get('user-agent') })
// ...
})Batch Submit
WARN Batch submit is not supported by debug or dryRun mode. It causes 400 bad-request error
Suppose
import {trackEvent,initTrackEvent} from 'picku-track-sdk'
initTrackEvent({
mode: 'dryRun', // track(生产环境使用),debug(校验数据并上传),dryRun(只校验数据,不上传)
isReportPk: true, //是否上报picku数据后台
gzip: true, // 是否采用gzip方式上报
timeout: 10 * 1000, //http 超时时间,单位ms
})
trackEvent('user-id', 'testEvent', {
'$appVersion': '1.0.0',
'orderId': '123',
})More Detail
For more detail, checkout Microsoft's Rx documentation
License
MIT