Skip to content

Commit

Permalink
Create new initUser method to optionally update in-memory store witho…
Browse files Browse the repository at this point in the history
…ut sending a new init
  • Loading branch information
goldfire committed Jun 26, 2019
1 parent dea7aa3 commit 239128c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gameanalytics-node-sdk",
"description": "Unofficial GameAnalytics Node.js SDK using the REST API.",
"homepage": "https://github.com/goldfire/gameanalytics-node-sdk",
"version": "1.0.14",
"version": "1.1.0",
"keywords": [
"GameAnalytics",
"game analytics",
Expand Down
16 changes: 13 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class GameAnalytics {
}

/**
* Start a new user session (this also handles calling init before any events are processed).
* Initialize the user data before sending the request to GameAnalytics.
* This data will be used for all tracking requests.
* @param {String} user User ID.
* @param {Object} data Data to send with the user event.
* @return {Promise}
*/
sessionStart(user, data) {
initUser(user, data) {
// If the user agent was passed, use it to get platform details.
if (data.ua) {
const uaData = UAParser(data.ua);
Expand Down Expand Up @@ -127,6 +127,16 @@ class GameAnalytics {
this._flush(user);
}, 10000),
};
}

/**
* Start a new user session (this also handles calling init before any events are processed).
* @param {String} user User ID.
* @param {Object} data Data to send with the user event.
* @return {Promise}
*/
sessionStart(user, data) {
this.initUser(user, data);

// Send the init request.
return this._request('init', null, {
Expand Down

0 comments on commit 239128c

Please sign in to comment.