1.1.0 • Published 3 years ago

@smartlook/nodejs-sdk v1.1.0

Weekly downloads
702
License
MIT
Repository
github
Last release
3 years ago

Smartlook Node.js SDK

This small zero-dependency library can be used to send custom events to Smartlook from your backend Node.js services.

These events can be then views in the events tab and you can use them to create funnels.

If you need to use these events to filter the recordings, you have to send smartlook.vid and smartlook.sid provided by the frontend Smartlook library in the request to your backend service.

However it is not required and you can use the events to track something not related to the user sessions or someting that happens outside of user session. Set the event vid to whatever you want to be identified as a source of the event (eg. your internal user id or job id).

You could have for example a background sequence of jobs that should trigger a user activity in the end. You can track with Smartlook how successful this process is. Such case would be checking last user activity on your web, sending an email to remind them your service or let them know about some news and the last event would be user login.

Usage

$ npm install @smartlook/nodejs-sdk
const smartlook = require('@smartlook/nodejs-sdk')

// set the key directly or with SMARTLOOK_KEY env variable
smartlook.init({
	key: '<PROJECT KEY>',
})

smartlook.event({
	vid: '<SOURCE ID>',
	name: '<EVENT NAME>',
})

Check out a bit more comprehensive example.

API

smartlook.init

Initializes the SDK with your deploy key and starts batch uploading of the events every flushIntervalMillis.

ParameterEnvironment variableDefaultAllowed
keySMARTLOOK_KEYnullstring
flushIntervalMillisSMARTLOOK_FLUSH_INTERVAL_MILLIS10000integer
logLevelSMARTLOOK_LOG_LEVELerrormute/trace/debug/info/error

smartlook.stop

Uploads pending events and stops recording of new events.

smartlook.event

Creates a new custom event.

ParameterTypeDescription
vidstring(required) Event source entity identifier
namestring(required) Event name
valuestringEvent value
propsobjectEvent key/value properties
sidstringUser session id obtained from the frontend Smarltook library

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

MIT

1.1.0

3 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

1.0.0-rc3

6 years ago

1.0.0-rc2

6 years ago

1.0.0-rc1

6 years ago