{"id":20617685,"url":"https://github.com/goldfire/gameanalytics-node-sdk","last_synced_at":"2025-04-15T11:31:05.931Z","repository":{"id":52162342,"uuid":"133852269","full_name":"goldfire/gameanalytics-node-sdk","owner":"goldfire","description":"Unofficial GameAnalytics Node.js SDK using the REST API.","archived":false,"fork":false,"pushed_at":"2023-01-26T11:00:39.000Z","size":25,"stargazers_count":7,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:37:47.604Z","etag":null,"topics":["analytics","analytics-tracking","gameanalytics","gameanalytics-node-sdk"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goldfire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-17T18:20:31.000Z","updated_at":"2022-02-13T21:20:36.000Z","dependencies_parsed_at":"2023-02-14T16:45:28.484Z","dependency_job_id":null,"html_url":"https://github.com/goldfire/gameanalytics-node-sdk","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldfire%2Fgameanalytics-node-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldfire%2Fgameanalytics-node-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldfire%2Fgameanalytics-node-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goldfire%2Fgameanalytics-node-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goldfire","download_url":"https://codeload.github.com/goldfire/gameanalytics-node-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249060929,"owners_count":21206421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","analytics-tracking","gameanalytics","gameanalytics-node-sdk"],"created_at":"2024-11-16T12:05:41.694Z","updated_at":"2025-04-15T11:31:05.915Z","avatar_url":"https://github.com/goldfire.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Description\nGameAnalytics Node SDK is a server-side wrapper for the [GameAnalytics](https://gameanalytics.com/) v2 REST API. This library offers full support for all of the event types outlined in the REST API documentation. It also covers the best practices specified including automatic batching of events, GZIP compression and validation of event data.\n\n## Installation\n* Install with [npm](https://www.npmjs.com/package/gameanalytics-node-sdk): `npm install gameanalytics-node-sdk`\n* Install with [Yarn](https://yarnpkg.com/en/package/gameanalytics-node-sdk): `yarn add gameanalytics-node-sdk`\n\n## Examples\nFirst, create a free account at [https://gameanalytics.com](https://gameanalytics.com/). Then, setup a game and get your key and secret to setup your SDK connection. In this example, we setup the SDK, start a new user session (must be the first thing you do) and track a design tutorial event (the events are just pseudocode).\n\n```javascript\nconst GameAnalytics = require('gameanalytics-node-sdk');\n\n// Setup the SDK.\nconst GA = new GameAnalytics({\n  key: 'GAME_KEY',\n  secret: 'GAME_SECRET',\n  build: '1.2.3',\n  sandbox: false,\n});\n\n// Handle a player logging in.\ngame.on('login', (userId, client) =\u003e {\n  GA.sessionStart(userId, {\n    ua: client.ua,\n    ip: client.ip,\n    device: client.device,\n    manufacturer: client.manufacturer,\n    session_num: client.session_num,\n  });\n});\n\n// Track a tutorial design event.\ngame.on('tutorial', (userId, step) =\u003e {\n  GA.track('design', userId, {\n    event_id: `Tutorial:${step}`,\n  });\n});\n```\n\n## API\n### Constructor\n```javascript\nnew GameAnalytics({\n  key: 'GAME_KEY', // Your GameAnalytics game key.\n  secret: 'GAME_SECRET', // Your GameAnalytics game secret.\n  build: '1.2.3', // The current build version of your game.\n  sandbox: false, // Whether or not to use the sandbox for testing.\n});\n```\n\n### Methods\n#### sessionStart(user, data)\nMust be the first thing called to initialize the user session.\n* **user**: `String` The unique user ID that identifies this player.\n* **data**: `Object` The data to send with this event (minimum required are `platform`, `os_version` and `sdk_version` as found in the [REST API docs](https://gameanalytics.com/docs/rest-api-doc#init) for `init`).\n\n#### sessionEnd(user)\nShould be the last thing called for a user to identify the end of their game session. This will flush all pending events before this final event is sent.\n* **user**: `String` The unique user ID that identifies this player.\n\n#### track(type, user, data)\nEverything that happens between session start and end happens with this method to track any type of event.\n* **type**: `String` This can be a value of `business`, `resource`, `progression`, `design` or `error`.\n* **user**: `String` The unique user ID that identifies this player.\n* **data**: `Object` The data to send with this event. Check the [REST API docs](https://gameanalytics.com/docs/rest-api-doc#event-types) for each event type to see what is required for an event.\n\n### Properties\nThere are a list of default properties that can be sent with any event, which can be found in the [REST API docs](https://gameanalytics.com/docs/rest-api-doc#default-annotations-shared). Some of these properties are required; however, if they are passed with the `sessionStart` method, they will get automatically sent with each event during the player's session.\n\nThe `platform` and `os_version` can be identified automatically if you pass the `ua` property the User Agent string from the browser to `sessionStart`.\n\n## License\nCopyright (c) 2018 [James Simpson](https://twitter.com/GoldFireStudios) and [GoldFire Studios, Inc.](https://goldfirestudios.com)\n\nReleased under the [MIT License](https://github.com/goldfire/gameanalytics-node-sdk/blob/master/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldfire%2Fgameanalytics-node-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoldfire%2Fgameanalytics-node-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoldfire%2Fgameanalytics-node-sdk/lists"}