GithubHelp home page GithubHelp logo

dakror / gdx-gameanalytics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrstahlfelge/gdx-gameanalytics

0.0 2.0 0.0 137 KB

Gameanalytics.com client implementation for libGDX

License: Apache License 2.0

Java 100.00%

gdx-gameanalytics's Introduction

gdx-gameanalytics

gameanalytics.com REST API client implementation for libGDX

Checkout gameanalytics.com for information about their service.

Why you should use this implementation instead of official implementations?

This implementation works without changes on Android, Desktop, iOS/RoboVM and GWT. The official Android implementation needs Play Services to work, which are not available on Amazon devices and bloat your apk file.

Besides, this implementation does not send any identifiable user data. For returning user recognition, a random UUID specific for your game is generated and used.

Installation

This project is published to the Sonatype Maven repository. You can integrate the lib into your project by just adding the dependencies to your build.gradle file.

Define the version of this API right after the gdxVersion:

gdxVersion = '1.9.6' //or another gdx version you use
gaVersion = '0.1.3'

Then add the needed dependencies to each subproject:

Core:

compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-core:$gaVersion"

Android:

compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-android:$gaVersion"

HTML:

compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-core:$gaVersion:sources"
compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-html:$gaVersion"
compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-html:$gaVersion:sources"

iOS-RoboVM:

compile "de.golfgl.gdxgameanalytics:gdx-gameanalytics-ios:$gaVersion"

Building from source

To build from source, clone or download this repository, then open it in Android Studio. Perform the following command to compile and upload the library in your local repository:

gradlew clean uploadArchives -PLOCAL=true

See build.gradle file for current version to use in your dependencies.

GWT project setup

If you want to use GameAnalytics with a GWT project, you need some more steps. Add the following line to your gwt.xml:

<inherits name="de.golfgl.gdxgameanalytics.gdxgameanalytics"/>

You also need to add a crypto JS lib to your project. Add the following to your index.html within the body tags:

 <script src="sjcl.js"></script>

Of course, you also need to get a copy of the lib from https://github.com/bitwiseshiftleft/sjcl/

Usage

Initialize GameAnalytics client in your game's create() method:

protected void initGameAnalytics(Preferences lbPrefs) {
    gameAnalytics = new GameAnalytics();
    gameAnalytics.setPlatformVersionString("1");

    gameAnalytics.setGameBuildNumber(GAME_DEVMODE ? "debug" : String.valueOf(GAME_VERSIONNUMBER));

    gameAnalytics.setPrefs(Gdx.app.getPreferences(...));
    gameAnalytics.setGameKey(GA_APP_KEY);
    gameAnalytics.setGameSecretKey(GA_SECRET_KEY);
    gameAnalytics.startSession();
}

Don't forget to add calls to stopSession() and startSession() in your game's pause() and resume() methods.

On Android, you can use the convinience class AndroidGameAnalytics which sets up platform, version and device information for you. If you want to use GA for crash reporting, call its registerUncaughtExceptionHandler() method. The same applies to iOS/RoboVM with IosGameAnalytics class.

Submit events with the public submit... methods.

News & Community

You can get help on the libgdx discord.

License

The project is licensed under the Apache 2 License, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. We love to get (non-mandatory) credit in case you release a game or app using this project!

gdx-gameanalytics's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.