Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'feature/add_crash_meta_data' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Wendt committed Jul 10, 2015
2 parents 02cf94e + 19f2667 commit e90f1f6
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 22 deletions.
4 changes: 2 additions & 2 deletions ExampleGame/Assets/HockeyAppUnityAndroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.hockeyapp.ExampleGameAndroid"
android:versionName="1.0.5"
android:versionCode="6"
android:versionName="1.0.6"
android:versionCode="7"
android:installLocation="preferExternal">
<supports-screens
android:smallScreens="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Author: Christoph Wendt
*
* Version: 1.0.5
* Version: 1.0.6
*
* Copyright (c) 2013-2015 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
Expand Down Expand Up @@ -41,6 +41,7 @@ public class HockeyAppAndroid : MonoBehaviour {

protected const string HOCKEYAPP_BASEURL = "https://rink.hockeyapp.net/";
protected const string HOCKEYAPP_CRASHESPATH = "api/2/apps/[APPID]/crashes/upload";

protected const int MAX_CHARS = 199800;
protected const string LOG_FILE_DIR = "/logs/";
public string appID = "your-hockey-app-id";
Expand Down Expand Up @@ -106,18 +107,67 @@ protected void StartCrashManager(string urlString, string appID, bool updateMana
/// Get the version code of the app.
/// </summary>
/// <returns>The version code of the Android app.</returns>
protected String GetVersion(){
protected String GetVersionCode(){

string version = null;
string versionCode = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
version = jc.CallStatic<string>("getAppVersion");
versionCode = jc.CallStatic<string>("getVersionCode");
#endif

return version;
return versionCode;
}

/// <summary>
/// Get the version name of the app.
/// </summary>
/// <returns>The version name of the Android app.</returns>
protected String GetVersionName(){

string versionName = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
versionName = jc.CallStatic<string>("getVersionName");
#endif

return versionName;
}

/// <summary>
/// Get the SDK version.
/// </summary>
/// <returns>The SDK version.</returns>
protected String GetSdkVersion(){

string sdkVersion = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
sdkVersion = jc.CallStatic<string>("getSdkVersion");
#endif

return sdkVersion;
}

/// <summary>
/// Get the name of the SDK.
/// </summary>
/// <returns>The name of the SDK.</returns>
protected String GetSdkName(){

string sdkName = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
sdkName = jc.CallStatic<string>("getSdkName");
#endif

return sdkName;
}


/// <summary>
/// Collect all header fields for the custom exception report.
/// </summary>
Expand All @@ -130,8 +180,11 @@ protected virtual List<string> GetLogHeaders() {

list.Add("Package: " + packageID);

string appVersion = GetVersion();
list.Add("Version: " + appVersion);
string versionCode = GetVersionCode();
list.Add("Version Code: " + versionCode);

string versionName = GetVersionName();
list.Add("Version Name: " + versionName);

string[] versionComponents = SystemInfo.operatingSystem.Split('/');
string osVersion = "Android: " + versionComponents[0].Replace("Android OS ", "");
Expand Down Expand Up @@ -272,6 +325,12 @@ protected virtual IEnumerator SendLogs(List<string> logs){
string crashPath = HOCKEYAPP_CRASHESPATH;
string url = GetBaseURL() + crashPath.Replace("[APPID]", appID);

string sdkVersion = GetSdkVersion ();
string sdkName = GetSdkName ();
if (sdkName != null && sdkVersion != null) {
url += "?sdk=" + sdkName + "&sdk_version=" + sdkVersion;
}

foreach (string log in logs)
{
WWWForm postForm = CreateForm(log);
Expand Down
Binary file modified ExampleGame/Assets/HockeyAppUnityAndroid/hockeyappunity.jar
Binary file not shown.
Binary file modified ExampleGame/Assets/TestScene.unity
Binary file not shown.
2 changes: 1 addition & 1 deletion ExampleGame/Assets/TestUI/TestUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Author: Christoph Wendt
*
* Version: 1.0.5
* Version: 1.0.6
*
* Copyright (c) 2013-2015 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
Expand Down
17 changes: 14 additions & 3 deletions HockeyAppUnity/src/net/hockeyapp/unity/HockeyUnityPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* <pre>
* Copyright (c) 2011-2015 Bit Stadium GmbH
*
* Version 1.0.5
* Version 1.0.6
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -127,9 +127,20 @@ public void run() {
});
}

public static String getAppVersion() {

public static String getVersionCode() {
return Constants.APP_VERSION;
}

public static String getVersionName() {
return Constants.APP_VERSION_NAME;
}

public static String getSdkName() {
return Constants.SDK_NAME;
}

public static String getSdkVersion() {
return Constants.SDK_VERSION;
}

}
4 changes: 2 additions & 2 deletions Plugins/HockeyAppUnityAndroid/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="net.hockeyapp.ExampleGameAndroid"
android:versionName="1.0.5"
android:versionCode="6"
android:versionName="1.0.6"
android:versionCode="7"
android:installLocation="preferExternal">
<supports-screens
android:smallScreens="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Author: Christoph Wendt
*
* Version: 1.0.5
* Version: 1.0.6
*
* Copyright (c) 2013-2015 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
Expand Down Expand Up @@ -41,6 +41,7 @@ public class HockeyAppAndroid : MonoBehaviour {

protected const string HOCKEYAPP_BASEURL = "https://rink.hockeyapp.net/";
protected const string HOCKEYAPP_CRASHESPATH = "api/2/apps/[APPID]/crashes/upload";

protected const int MAX_CHARS = 199800;
protected const string LOG_FILE_DIR = "/logs/";
public string appID = "your-hockey-app-id";
Expand Down Expand Up @@ -106,18 +107,67 @@ protected void StartCrashManager(string urlString, string appID, bool updateMana
/// Get the version code of the app.
/// </summary>
/// <returns>The version code of the Android app.</returns>
protected String GetVersion(){
protected String GetVersionCode(){

string version = null;
string versionCode = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
version = jc.CallStatic<string>("getAppVersion");
versionCode = jc.CallStatic<string>("getVersionCode");
#endif

return version;
return versionCode;
}

/// <summary>
/// Get the version name of the app.
/// </summary>
/// <returns>The version name of the Android app.</returns>
protected String GetVersionName(){

string versionName = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
versionName = jc.CallStatic<string>("getVersionName");
#endif

return versionName;
}

/// <summary>
/// Get the SDK version.
/// </summary>
/// <returns>The SDK version.</returns>
protected String GetSdkVersion(){

string sdkVersion = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
sdkVersion = jc.CallStatic<string>("getSdkVersion");
#endif

return sdkVersion;
}

/// <summary>
/// Get the name of the SDK.
/// </summary>
/// <returns>The name of the SDK.</returns>
protected String GetSdkName(){

string sdkName = null;

#if (UNITY_ANDROID && !UNITY_EDITOR)
AndroidJavaClass jc = new AndroidJavaClass("net.hockeyapp.unity.HockeyUnityPlugin");
sdkName = jc.CallStatic<string>("getSdkName");
#endif

return sdkName;
}


/// <summary>
/// Collect all header fields for the custom exception report.
/// </summary>
Expand All @@ -130,8 +180,11 @@ protected virtual List<string> GetLogHeaders() {

list.Add("Package: " + packageID);

string appVersion = GetVersion();
list.Add("Version: " + appVersion);
string versionCode = GetVersionCode();
list.Add("Version Code: " + versionCode);

string versionName = GetVersionName();
list.Add("Version Name: " + versionName);

string[] versionComponents = SystemInfo.operatingSystem.Split('/');
string osVersion = "Android: " + versionComponents[0].Replace("Android OS ", "");
Expand Down Expand Up @@ -272,6 +325,12 @@ protected virtual IEnumerator SendLogs(List<string> logs){
string crashPath = HOCKEYAPP_CRASHESPATH;
string url = GetBaseURL() + crashPath.Replace("[APPID]", appID);

string sdkVersion = GetSdkVersion ();
string sdkName = GetSdkName ();
if (sdkName != null && sdkVersion != null) {
url += "?sdk=" + sdkName + "&sdk_version=" + sdkVersion;
}

foreach (string log in logs)
{
WWWForm postForm = CreateForm(log);
Expand Down
Binary file modified Plugins/HockeyAppUnityAndroid/hockeyappunity.jar
Binary file not shown.

0 comments on commit e90f1f6

Please sign in to comment.