Giter Site home page Giter Site logo

diwu / analyticx Goto Github PK

View Code? Open in Web Editor NEW
71.0 19.0 37.0 22.66 MB

A C++ wrapper of Flurry for Cocos2d-X. Supports Android and iOS.

License: Other

C++ 74.62% Objective-C++ 3.38% C 7.81% Objective-C 11.43% Makefile 0.30% CMake 0.02% Shell 0.12% Java 2.30%

analyticx's Introduction

Flurry Icon -X Icon

AnalyticX - With the latest 6.7.0 Flurry lib!!!

A C++ wrapper of Flurry for Cocos2d-X. Supports Android and iOS.

Changelog

  • Updated Flurry iOS SDK to version 6.7.0 and Flurry Android SDK to 5.3.0
  • Added reflection to AnalyticXStringUtil

Environment

cocos2d-2.0-rc0a-x-0.1.0 or higher is recommended. Lower versions are not tested. Due to the underlying difference in the CCDictionary implementation, there may be compatibility issues when running on lower versions.

Flurry SDK Version

  1. Android: v5.3.0
  2. iOS: v6.7.0

Example Project

  1. iOS: ./AnalyticX.xcodeproj
  2. Android: ./AnalyticX/proj.android/

You need to change the build script (such as build_native.sh for Mac OSX) according to your own environment before compiling.

Add to Your Own Project - iOS (in Add-To-Your-Own-Project folder)

  1. Add FlurryAnalytics.h and libFlurryAnalytics.a to your Xcode project
  2. Add AnalyticX.h and AnalyticX.mm to your Xcode project
  3. Add AnalyticXStringUtil.h and AnalyticXStringUtil.mm to your Xcode project
  4. Add AnalyticXMacros.h to your XCode project

Add to Your Own Project - Android (in Add-To-Yout-Own-Project folder)

  1. Add com.diwublog.AnalyticX the package and its AnalyticXBridge.java to your Eclipse project

  2. Add FlurryAnalytics.jar as an external jar to your Eclipse project

  3. Drop AnalyticX.h and AnalyticX.cpp to your Classes folder

  4. Drop AnalyticXStringUtilAndroid and AnalyticXStringUtilAndroid.cpp to your Classes folder

  5. Add AnalyticX.cpp and AnalyticXStringUtilAndroid.cpp to your jni's Android.mk

  6. Add AnalyticXMacros.h to your XCode project

  7. In the java implementation of your main activity (which should have been created by the Cocos2d-X script), import com.diwublog.AnalyticX.AnalyticXBridge

  8. At the beginning of onCreate(Bundle savedInstanceState), right after super.onCreate(savedInstanceState), add one line:

     AnalyticXBridge.sessionContext = this.getApplicationContext();
    
  9. In the project manifest, add one line:

     <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    

Add to Your Own Project - Hybrid

  1. Follow the iOS and Android set up steps separately

  2. iOS and Android will share the same AnalyticX.h and AnalyticXMacros.h header file

  3. Use Separate Flurry Api Keys for Android and iOS

     #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
     	AnalyticX::flurryStartSession("YOUR_FLURRY_API_KEY_FOR_IPHONE_BUILD");
     #endif
    
     #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
     	AnalyticX::flurryStartSession("YOUR_FLURRY_API_KEY_FOR_ANDROID_BUILD");
     #endif
    
  4. For Android, you need to end the session when the app goes in the background or when you manually quit the application, else the events may not be recorded on Flurry website. First, add the calls in your AppDelegate.cpp :

     void AppDelegate::applicationDidEnterBackground()
     {
     	AnalyticX::flurryEndSession();
     	//Your code
     }
    
     void AppDelegate::applicationDidEnterForeground()
     {
     	AnalyticX::flurryStartSession("YOUR_FLURRY_API_KEY_FOR_ANDROID_BUILD");
     	//Your code
     }
    
  5. After that, before any call to exit(0), add this code :

     AnalyticX::flurryEndSession();
    

Best Practice Using Analytic Service or Any Third Party Framework

  1. Define FLURRY at the top of source code, or the source code that starts first before other

     #define FLURRY
    
  2. Or, you can define FLURRY as per project-based. For XCode, go to Build Setting->Apple LLVM 6.0 - Preprocessing, then add "FLURRY" with not double quotation to target build.

  3. In code, wrap the flurry related calls with

     #ifdef FLURRY
         ...
         AnalyticX::flurryLogEvent("event_3");
         AnalyticX::flurryLogEventTimed(" log event timed test...", false);
         ...
     #endif
    
  4. But if using macros in AnalyticXMacros.h, there's no need to wrap the code like in no.3. Just directly call like following.

     FLURRYLogEvent("event_logging_via_macro");
     FLURRYLogEvent("event_logging_via_macro dummy-num: %d - %d", 1, 2);
    

APIs Supported on both Android and iOS

static void flurrySetAppVersion(const char * version);
static const char * flurryGetFlurryAgentVersion();
static void flurrySetDebugLogEnabled(bool value);
static void flurrySetSessionContinueSeconds(int seconds);//The param is in second. Will be converted to millisecond internally.

static void flurryStartSession(const char * apiKey);

static AXFlurryEventRecordStatus flurryLogEvent(const char * eventName);
static AXFlurryEventRecordStatus flurryLogEventWithParameters(const char * eventName, cocos2d::CCDictionary * parameters);
static AXFlurryEventRecordStatus flurryLogEventTimed(const char * eventName, bool timed);
static AXFlurryEventRecordStatus flurryLogEventWithParametersTimed(const char * eventName, cocos2d::CCDictionary * parameters, bool timed);
static void flurryEndTimedEventWithParameters(const char * eventName, cocos2d::CCDictionary * parameters);
static void flurryLogPageView();

static void flurrySetUserID(const char * userID);
static void flurrySetAge(int age);
static void flurrySetGender(const char * gender);//"m" for male, "f" for female

APIs Supported only on iOS

When running on an Android device, these APIs will have no effect. They are safe and won't crash.

static void flurrySetShowErrorInLogEnabled(bool value);
static void flurrySetLatitudeLongitudeHorizontalAccuracyVerticalAccuracy(double latitude, double longitude, float horizontalAccuracy, float verticalAccuracy);
static void flurrySetSessionReportsOnCloseEnabled(bool sendSessionReportsOnClose);
static void flurrySetSessionReportsOnPauseEnabled(bool setSessionReportsOnPauseEnabled);
static void flurrySetEventLoggingEnabled(bool value);

APIs Supported only on Android

When running on an iOS device, these APIs will have no effect. They are safe and won't crash.

static void flurryEndSession();
static void flurrySetReportLocation(bool reportLocation);

Note

  • Add-To-Your-Own-Project contains files necessary to copy to your own project. All of files required for Xcode project are there. But for Android, there're the package folder, a bridge file, and .jar file that you need to look into Android project folder and copy them yourself. They're left there for a reason.
  • copyResults.sh is a shell script to copy files to Add-To-Your-Own-Project folder automatically after the project is successfully built. This is meant to prevent mistake if developers do manual copy. It is included as Run Script phase inside XCode project.

You're welcome to contribute. ;-)

Contributors

  • Di Wu
  • Anton Turko
  • François Dupayrat
  • Wasin Thonkaew

analyticx's People

Contributors

bryant1410 avatar diwu avatar francoisdupayrat avatar haxpor avatar leandros avatar p-m-j avatar sburavtsov avatar wolves3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analyticx's Issues

“Package R does not exist”

When I try build android version I get this error.
Also In Cocos2dx 3.5 activity (Cocos2dxActivity) doesn't have method:

setPackageName(String packageName)

java.lang.ArrayStoreException

Hi, have you ever encounter java.lang.ArrayStoreException when logging event with CCDictionary?

in my case, it only occurs in samsung devices :|

thanks mate !

AXFlurryEventRecordStatus cannot be resolved to a type

I just downloaded the newest version and I started getting this error in AnalyticXBridge.java.
This error is also present when I load the supplied example project.
I tried to find the AXFlurryEventRecordStatus in the code but I could only find it for C++ in the header file.
Where is the AXFlurryEventRecordStatus definition for Java?

JNI should DeleteLocalRef !?

Hi~~The AnalyticX.cpp file should DeleteLocalRef when method is done?

Just like

if (!isHave) {
//do nothing
} else {
jstring stringArg0 = minfo.env->NewStringUTF("flurryLogEvent");
jstring stringArg1 = minfo.env->NewStringUTF(eventName);
jstring stringArg2 = minfo.env->NewStringUTF("false");

minfo.env->CallStaticVoidMethod(minfo.classID, minfo.methodID, stringArg0, stringArg1, stringArg2);

minfo.env->DeleteLocalRef(stringArg0);
minfo.env->DeleteLocalRef(stringArg1);
minfo.env->DeleteLocalRef(stringArg2);
minfo.env->DeleteLocalRef(minfo.classID);

}

integration in android failed cocos2d 2.2.2

in analytix.java in detectopengles20() the block seems to be for previous version of cocos2d-x like before 2.0. Could you update on how I could change this for the newer versions???

setpackage and settextfield name is undefined for package cocos2dxactivity.

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.