A tool for encrypting and sending user logs to the internal Automattic's service.
We use it to increase privacy of our users by not sharing their logs with any 3rd party company like crash logging services or support SDKs.
Originally, this feature was implemented as a part of WordPress-FluxC-Android. To allow other clients to use Encrypted Logging as well, we decided to extract it to a separate library. It was done using git filter-repo
tool, so the Git history is preserved (although it's relative to the original, WordPress-FluxC-Android repository).
- Add a dependency
dependency {
implementation "com.automattic:encryptedlogging:<newest_version>"
}
- Provide App Secret and Encryption Key. Because the SDK uses event bus, the
AutomatticEncryptedLogging
should be a singleton.
@Provides
@Singleton
fun provideEncryptedLogging(
@ApplicationContext context: Context
): EncryptedLogging {
return AutomatticEncryptedLogging(
context,
// Can be found in secrets
encryptedLoggingKey = BuildConfig.ENCRYPTION_KEY,
// Ping Apps Infrastructure about this one
clientSecret = BuildConfig.APP_SECRET
)
}
- Initialize SDK in Application
class MyApplication : Application() {
@Inject lateinit var encryptedLogging: EncryptedLogging
override fun onCreate() {
super.onCreate()
// Reset upload state in case app was closed during the upload of previous logs
encryptedLogging.resetUploadStates()
// Launch upload of stored logs in app's coroutine scope
applicationScope.launch {
encryptedLogging.uploadEncryptedLogs()
}
}
}
- Enqueue sending logs
class SupportForm() {
fun sendLogs(): String {
val uuid = UUID.randomUUID().toString()
encryptedLogging.enqueueSendingEncryptedLogs(
uuid,
<log file>,
shouldUploadImmediately = true
)
// Attach UUID to support ticket or crashlogging issue
return uuid
}
}