Skip to content

Commit

Permalink
refactor: re-indent 😇
Browse files Browse the repository at this point in the history
  • Loading branch information
kkostov committed Feb 1, 2022
1 parent 3173a6a commit f403a8a
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/src/main/java/com/telemetrydeck/sdk/TelemetryManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ class TelemetryManager(
suspend fun send(
signals: List<Signal>
) {
val client = TelemetryClient(configuration.telemetryAppID, configuration.apiBaseURL, configuration.showDebugLogs, logger)
val client = TelemetryClient(
configuration.telemetryAppID,
configuration.apiBaseURL,
configuration.showDebugLogs,
logger
)
client.send(signals)
}

Expand All @@ -94,18 +99,18 @@ class TelemetryManager(
val hashedUser = hashString(userValue, "SHA-256")
val payload = SignalPayload(additionalPayload = enrichedPayload)
val signal = Signal(
appID=configuration.telemetryAppID,
type=signalType,
clientUser=hashedUser,
payload=payload.asMultiValueDimension,
appID = configuration.telemetryAppID,
type = signalType,
clientUser = hashedUser,
payload = payload.asMultiValueDimension,
isTestMode = configuration.testMode
)
signal.sessionID = this.configuration.sessionID.toString()
logger?.debug("Created a signal ${signal.type}, session ${signal.sessionID}, test ${signal.isTestMode}")
return signal
}

private fun hashString(input: String, algorithm: String): String {
private fun hashString(input: String, algorithm: String): String {
return MessageDigest.getInstance(algorithm)
.digest(input.toByteArray())
.fold("", { str, it -> str + "%02x".format(it) })
Expand Down Expand Up @@ -332,7 +337,8 @@ class TelemetryManager(
} else {
// do not change testMode if it was provided through a configuration object
if (initConfiguration) {
config.testMode = 0 != (context?.applicationInfo?.flags ?: 0) and ApplicationInfo.FLAG_DEBUGGABLE
config.testMode = 0 != (context?.applicationInfo?.flags
?: 0) and ApplicationInfo.FLAG_DEBUGGABLE
}
}

Expand All @@ -358,9 +364,10 @@ class TelemetryManager(
manager.logger = logger
manager.installProviders(context)

val broadcaster = TelemetryBroadcastTimer(WeakReference(manager), WeakReference(manager.logger))
broadcaster.start()
manager.broadcastTimer = broadcaster
val broadcaster =
TelemetryBroadcastTimer(WeakReference(manager), WeakReference(manager.logger))
broadcaster.start()
manager.broadcastTimer = broadcaster

if (context != null) {
manager.cache = PersistentSignalCache(context.cacheDir, logger)
Expand Down

0 comments on commit f403a8a

Please sign in to comment.