@danetix/sentinel
v1.0.3
Published
Danetix device intelligence SDK
Downloads
486
Maintainers
Readme
Get Started
Create a free account at danetix.com to get your API key.
NPM
npm install @danetix/sentinelimport Sentinel from '@danetix/sentinel'
// Initialize at application startup
const stl = Sentinel.start({
apiKey: 'your-api-key',
endpoint: 'https://your-domain.com/ingest'
})
// Get the device identifier when you need it
const result = await stl.get()
console.log(result.deviceId) // → "Abs2d8F0gTk9l..."CDN
<script>
const stlPromise = import('https://your-domain.com/stl.esm.min.js')
.then(S => S.start({
apiKey: 'your-api-key',
endpoint: '/ingest'
}))
stlPromise
.then(stl => stl.get())
.then(result => console.log(result.deviceId))
</script>Caching
Enable caching to avoid redundant requests in single-page applications:
const stl = Sentinel.start({
apiKey: 'your-api-key',
endpoint: '/ingest',
cache: {
ttl: 300, // seconds
location: 'sessionStorage' // or 'memory' (default), 'localStorage'
}
})await stl.get() // → server request
await stl.get() // → instant (cached)
await stl.get({ ignoreCache: true }) // → force fresh request
stl.clearCache() // → invalidate manuallyAPI Reference
Sentinel.start(options)
Returns a SentinelInstance.
| Parameter | Type | Required | Description |
|:----------|:-----|:---------|:------------|
| apiKey | string | Yes | Your API key |
| endpoint | string | Yes | Ingest endpoint URL |
| cache.ttl | number | — | Cache lifetime in seconds |
| cache.location | string | — | 'memory' | 'localStorage' | 'sessionStorage' |
stl.get(options?)
Returns Promise<Result>.
| Parameter | Type | Description |
|:----------|:-----|:------------|
| ignoreCache | boolean | Skip cache |
| linkedId | string | Link to your own user/session ID |
| tag | object | Attach custom metadata |
Result
{
requestId: "abc123...", // unique event ID
deviceId: "Abs2d8F0gTk9l...", // stable device identifier
signedDeviceToken: "eyJ..." // signed token for verification
}Browser Support
| | Chrome | Firefox | Safari | Edge | Samsung Internet | |:-|:------:|:-------:|:------:|:----:|:----------------:| | Version | 80+ | 113+ | 16.4+ | 80+ | 14+ |
