log remote

This commit is contained in:
Milos Kozak 2019-04-11 10:16:52 +02:00
parent 3adbce1aff
commit 1286aabb5b
4 changed files with 28 additions and 1 deletions

View file

@ -45,6 +45,22 @@ def generateGitBuild = { ->
return stringBuilder.toString()
}
def generateGitRemote = { ->
StringBuilder stringBuilder = new StringBuilder();
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'remote', 'get-url', 'origin'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
stringBuilder.append('NoGitSystemAvailable')
}
return stringBuilder.toString()
}
def generateDate = { ->
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm'))
@ -67,6 +83,7 @@ android {
version "2.2.3-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote()+ '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// if you change minSdkVersion to less than 11, you need to change executeTask for wear

View file

@ -125,7 +125,6 @@ public class MainApp extends Application {
try {
if (FabricPrivacy.fabricEnabled()) {
Fabric.with(this, new Crashlytics());
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
}
} catch (Exception e) {
log.error("Error with Fabric init! " + e);
@ -137,6 +136,7 @@ public class MainApp extends Application {
log.info("Version: " + BuildConfig.VERSION_NAME);
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
log.info("Remote: " + BuildConfig.REMOTE);
String extFilesDir = LoggerUtils.getLogDirectory();
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");

View file

@ -222,6 +222,7 @@ public class MaintenancePlugin extends PluginBase {
builder.append("NSCLIENT" + System.lineSeparator());
builder.append("Build: " + BuildConfig.BUILDVERSION + System.lineSeparator());
builder.append("Remote: " + BuildConfig.REMOTE + System.lineSeparator());
builder.append("Flavor: " + BuildConfig.FLAVOR + BuildConfig.BUILD_TYPE + System.lineSeparator());
builder.append(MainApp.gs(R.string.configbuilder_nightscoutversion_label) + " " + NSSettingsStatus.getInstance().nightscoutVersionName + System.lineSeparator());
if (MainApp.engineeringMode)

View file

@ -111,11 +111,20 @@ public class FabricPrivacy {
if (!fabricEnabled()) return;
String closedLoopEnabled = MainApp.getConstraintChecker().isClosedLoopAllowed().value() ? "CLOSED_LOOP_ENABLED" : "CLOSED_LOOP_DISABLED";
// Size is limited to 36 chars
String remote = BuildConfig.REMOTE
.replace("https://","")
.replace("http://","")
.replace(".git", "")
.replace(".com/", ":")
.replace(".org/", ":")
.replace(".net/", ":");
MainApp.getFirebaseAnalytics().setUserProperty("Mode", BuildConfig.APPLICATION_ID + "-" + closedLoopEnabled);
MainApp.getFirebaseAnalytics().setUserProperty("Language", LocaleHelper.getLanguage(MainApp.instance()));
MainApp.getFirebaseAnalytics().setUserProperty("Version", BuildConfig.VERSION);
MainApp.getFirebaseAnalytics().setUserProperty("HEAD", BuildConfig.HEAD);
MainApp.getFirebaseAnalytics().setUserProperty("Remote", remote);
if (ConfigBuilderPlugin.getPlugin().getActivePump() != null)
MainApp.getFirebaseAnalytics().setUserProperty("Pump", ConfigBuilderPlugin.getPlugin().getActivePump().getClass().getSimpleName());
if (ConfigBuilderPlugin.getPlugin().getActiveAPS() != null)