npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gameanalytics-node-sdk

v1.1.4

Published

Unofficial GameAnalytics Node.js SDK using the REST API.

Downloads

208

Readme

Description

GameAnalytics Node SDK is a server-side wrapper for the GameAnalytics 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.

Installation

  • Install with npm: npm install gameanalytics-node-sdk
  • Install with Yarn: yarn add gameanalytics-node-sdk

Examples

First, create a free account at 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).

const GameAnalytics = require('gameanalytics-node-sdk');

// Setup the SDK.
const GA = new GameAnalytics({
  key: 'GAME_KEY',
  secret: 'GAME_SECRET',
  build: '1.2.3',
  sandbox: false,
});

// Handle a player logging in.
game.on('login', (userId, client) => {
  GA.sessionStart(userId, {
    ua: client.ua,
    ip: client.ip,
    device: client.device,
    manufacturer: client.manufacturer,
    session_num: client.session_num,
  });
});

// Track a tutorial design event.
game.on('tutorial', (userId, step) => {
  GA.track('design', userId, {
    event_id: `Tutorial:${step}`,
  });
});

API

Constructor

new GameAnalytics({
  key: 'GAME_KEY', // Your GameAnalytics game key.
  secret: 'GAME_SECRET', // Your GameAnalytics game secret.
  build: '1.2.3', // The current build version of your game.
  sandbox: false, // Whether or not to use the sandbox for testing.
});

Methods

sessionStart(user, data)

Must be the first thing called to initialize the user session.

  • user: String The unique user ID that identifies this player.
  • 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 for init).

sessionEnd(user)

Should 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.

  • user: String The unique user ID that identifies this player.

track(type, user, data)

Everything that happens between session start and end happens with this method to track any type of event.

  • type: String This can be a value of business, resource, progression, design or error.
  • user: String The unique user ID that identifies this player.
  • data: Object The data to send with this event. Check the REST API docs for each event type to see what is required for an event.

Properties

There are a list of default properties that can be sent with any event, which can be found in the REST API docs. 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.

The platform and os_version can be identified automatically if you pass the ua property the User Agent string from the browser to sessionStart.

License

Copyright (c) 2018 James Simpson and GoldFire Studios, Inc.

Released under the MIT License.