Loading README.md +13 −0 Original line number Diff line number Diff line Loading @@ -38,8 +38,21 @@ Telemetry.init(BuildConfig.SENTRY_DSN, this) Telemetry.reportMessage("sample message") ``` - To get sentry user id, we need to add the following code: ```kotlin Telemetry.getSentryUserId() ``` # How to force telemetry to be enabled without manual action in settings? Use adb command: `adb shell settings put system e_telemetry 1` # How to get/change sentry user id? Use adb command: `adb shell settings get secure sentry_userid` `adb shell settings put secure sentry_userid 2163681a-0980-41f6-8044-7db50c580986` lib/src/main/java/foundation/e/lib/telemetry/Constants.kt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package foundation.e.lib.telemetry internal object Constants { const val SETTINGS_TELEMETRY_FIELD = "e_telemetry" const val SENTRY_USERID = "sentry_userid"; const val TAG_E_VERSION = "e_version" const val PROPERTY_OS_VERSION = "ro.lineage.version" } lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ object Telemetry { private lateinit var application: Application private var enableOsTag: Boolean = true private var isTelemetryEnabled: Boolean = false private var userSentryId: String = "" /** * Call this function in `onCreate()` of custom Application class. Loading @@ -30,6 +31,7 @@ object Telemetry { this.application = application this.enableOsTag = enableOsTag this.isTelemetryEnabled = checkTelemetryDeveloperOption() this.userSentryId = getSentryUserId(application) val sentryDsn = if (isTelemetryEnabled) { Loading Loading @@ -110,6 +112,16 @@ object Telemetry { } } private fun getSentryUserId(application: Application): String { return try { Settings.Secure.getString(application.contentResolver, Constants.SENTRY_USERID) } catch (e: Settings.SettingNotFoundException) { "" } catch (_: Exception) { "" } } /** * It is possible that the telemetry option in developer options is different from * the current state of the library. It is possible if the app is open and Loading @@ -122,6 +134,12 @@ object Telemetry { @JvmStatic fun isReportingTelemetry() = isTelemetryEnabled /** * Return a unique id for a device, that can be used for sentry. */ @JvmStatic fun getSentryUserId() = userSentryId /** * Read from OS developer options. * Pass false by default. Loading Loading
README.md +13 −0 Original line number Diff line number Diff line Loading @@ -38,8 +38,21 @@ Telemetry.init(BuildConfig.SENTRY_DSN, this) Telemetry.reportMessage("sample message") ``` - To get sentry user id, we need to add the following code: ```kotlin Telemetry.getSentryUserId() ``` # How to force telemetry to be enabled without manual action in settings? Use adb command: `adb shell settings put system e_telemetry 1` # How to get/change sentry user id? Use adb command: `adb shell settings get secure sentry_userid` `adb shell settings put secure sentry_userid 2163681a-0980-41f6-8044-7db50c580986`
lib/src/main/java/foundation/e/lib/telemetry/Constants.kt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package foundation.e.lib.telemetry internal object Constants { const val SETTINGS_TELEMETRY_FIELD = "e_telemetry" const val SENTRY_USERID = "sentry_userid"; const val TAG_E_VERSION = "e_version" const val PROPERTY_OS_VERSION = "ro.lineage.version" }
lib/src/main/java/foundation/e/lib/telemetry/Telemetry.kt +18 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ object Telemetry { private lateinit var application: Application private var enableOsTag: Boolean = true private var isTelemetryEnabled: Boolean = false private var userSentryId: String = "" /** * Call this function in `onCreate()` of custom Application class. Loading @@ -30,6 +31,7 @@ object Telemetry { this.application = application this.enableOsTag = enableOsTag this.isTelemetryEnabled = checkTelemetryDeveloperOption() this.userSentryId = getSentryUserId(application) val sentryDsn = if (isTelemetryEnabled) { Loading Loading @@ -110,6 +112,16 @@ object Telemetry { } } private fun getSentryUserId(application: Application): String { return try { Settings.Secure.getString(application.contentResolver, Constants.SENTRY_USERID) } catch (e: Settings.SettingNotFoundException) { "" } catch (_: Exception) { "" } } /** * It is possible that the telemetry option in developer options is different from * the current state of the library. It is possible if the app is open and Loading @@ -122,6 +134,12 @@ object Telemetry { @JvmStatic fun isReportingTelemetry() = isTelemetryEnabled /** * Return a unique id for a device, that can be used for sentry. */ @JvmStatic fun getSentryUserId() = userSentryId /** * Read from OS developer options. * Pass false by default. Loading