Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stream-analytics

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-analytics

Analytics JS client for GetStream.io.

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.1K
decreased by-1.16%
Maintainers
1
Weekly downloads
 
Created
Source

Get the library

# via npm
$ npm install stream-analytics

Or load the library from our CDN:

<script src="//d2j1fszo1axgmp.cloudfront.net/latest/stream-analytics.min.js" type="text/javascript"></script>

Configure an instance for your project

var client = new StreamAnalytics({
  projectId: "YOUR_PROJECT_ID",
  writeKey: "YOUR_WRITE_KEY"
});

Set current user

client.setUser('user:Thierry');

Track impressions

Every activity (eg. messages) shown to the user should be tracked as an impression.

var impression = {
    activityIds: ['message:34349698', 'message:34349699'],
    feedId: 'user:ChartMill'
};

// track impression for two messages presented to the user
client.trackImpression(impression);

Engagement tracking

Every meaningful user interactions should be tracked with content (activity_id) and source (sourceFeedId) information and provide a label and a score (the score) for the engagement. score is a signed integer. Positive values boost source and content for the user that trigger the engagement, negative values work as a discount for the same context. The value of the score can be used to differentiate engagements according to their importants (eg. sharing a message is probably more important than just clicking it).

engagement = {...}
// Sends one engagement event to the APIs
client.trackEngagement(engagement);

// Click on a message
var engagement = {
    label: 'click',
    score: 10,
    activityId: 'message:34349698',
    feedId: 'user:ChartMill',
};
client.trackEngagement(engagement);

// Share message
var engagement = {
    label: 'share',
    score: 100,
    activityId: 'message:34349698',
    feedId: 'user:ChartMill',
};
client.trackEngagement(engagement);

Update user data

this allows for storing extra information about the current user such as public profiles

var userData = {
    twitterId: '15875029',
    facebookId: '784785430'
};
client.updateUserData(userData);

Keywords

FAQs

Package last updated on 23 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc