Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Analytics to Flank Wrapper #2085

Merged
merged 6 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/Modules.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object Modules {
const val COMMON = ":common"
const val ANALYTICS = ":tool:analytics"
const val MIXPANEL_ANALYTICS = ":tool:analytics:mixpanel"
}
4 changes: 2 additions & 2 deletions corellium/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dependencies {
api(project(":tool:instrument:log"))
api(project(":tool:junit"))
api(project(":tool:log"))
api(project(":tool:analytics"))
api(project(":tool:analytics:mixpanel"))
api(project(Modules.ANALYTICS))
api(project(Modules.MIXPANEL_ANALYTICS))

testImplementation(Dependencies.JUNIT)
testImplementation(project(":corellium:adapter"))
Expand Down
4 changes: 2 additions & 2 deletions flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.9.22"
version = "1.9.23"
group = "com.github.flank"

application {
Expand Down Expand Up @@ -93,7 +93,7 @@ repositories {

dependencies {
implementation(Dependencies.KOTLIN_SERIALIZATION)
implementation(project(":common"))
implementation(project(Modules.COMMON))
implementation(Dependencies.CLIKT)
implementation(Dependencies.JCABI_GITHUB)
implementation(Dependencies.SLF4J_NOP)
Expand Down
5 changes: 3 additions & 2 deletions flank_wrapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.1.0"
version = "1.2.0"
group = "com.github.flank"

repositories {
Expand Down Expand Up @@ -75,7 +75,8 @@ publishing {
}

dependencies {
implementation(project(":common"))
implementation(project(Modules.MIXPANEL_ANALYTICS))
implementation(project(Modules.COMMON))
implementation(Dependencies.SENTRY)
implementation(Dependencies.Fuel.CORE)
testImplementation(Dependencies.JUNIT)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.flank.wrapper.internal

import flank.common.config.isTest
import flank.tool.analytics.mixpanel.sessionId
import io.sentry.Sentry
import java.util.UUID

private const val SESSION_ID = "session.id"
private const val OS_NAME = "os.name"
Expand All @@ -17,7 +17,7 @@ fun setupCrashReporter() {
}

logTags(
SESSION_ID to sessionID,
SESSION_ID to sessionId,
OS_NAME to osName,
FLANK_WRAPPER_VERSION to flankWrapperVersion,
)
Expand All @@ -28,8 +28,6 @@ private fun logTags(vararg tags: Pair<String, String>) {
tags.forEach { (key, value) -> Sentry.setTag(key, value) }
}

private val sessionID by lazy { UUID.randomUUID().toString() }

private val osName: String
get() = System.getProperty("os.name")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ internal fun downloadLatestFlankVersion() {
sourceUrl = FLANK_JAR_REMOTE_PATH,
destination = flankRunnerPath
)
sendAnalyticsNewFlankVersionDownloaded()
}

private const val FLANK_JAR_REMOTE_PATH = "https://github.com/Flank/flank/releases/latest/download/flank.jar"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.github.flank.wrapper.internal
import kotlin.system.exitProcess

internal fun executeFlank(args: Array<out String>) {
sendAnalyticsFlankRun()

ProcessBuilder()
.command(buildRunCommand(args))
.inheritIO()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.flank.wrapper.internal

import flank.tool.analytics.mixpanel.send
import flank.tool.analytics.mixpanel.toEvent

private const val FLANK_WRAPPER = "flank_wrapper"
private const val EVENT_RUN = "flank run"
private const val EVENT_NEW_FLANK_VERSION_DOWNLOADED = "new_version_downloaded"

internal fun sendAnalyticsNewFlankVersionDownloaded() {
eventWithoutProperties(EVENT_NEW_FLANK_VERSION_DOWNLOADED).send()
}

internal fun sendAnalyticsFlankRun() {
eventWithoutProperties(EVENT_RUN).send()
}

private fun eventWithoutProperties(
eventName: String
) = emptyMap<String, Any>().toEvent(FLANK_WRAPPER, eventName)
2 changes: 1 addition & 1 deletion flank_wrapper/src/main/resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0
2 changes: 1 addition & 1 deletion integration_tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
}

dependencies {
implementation(project(":common"))
implementation(project(Modules.COMMON))
testImplementation(Dependencies.JUNIT)
testImplementation(Dependencies.JACKSON_XML)
testImplementation(Dependencies.JACKSON_KOTLIN)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include(
":corellium:adapter",
":corellium:client",
":corellium:sandbox",

":tool:apk",
":tool:config",
":tool:filter",
Expand Down
8 changes: 4 additions & 4 deletions test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ tasks.withType<Test> {
}

dependencies {
implementation(project(":common"))
implementation(project(Modules.COMMON))
implementation(project(Modules.MIXPANEL_ANALYTICS))
implementation(Dependencies.SENTRY)
implementation(Dependencies.MIXPANEL)

implementation(Dependencies.DD_PLIST)
implementation(Dependencies.DEX_TEST_PARSER)
Expand Down Expand Up @@ -212,8 +212,8 @@ dependencies {

implementation(project(":corellium:cli"))

implementation(project(":tool:analytics"))
implementation(project(":tool:analytics:mixpanel"))
implementation(project(Modules.ANALYTICS))
implementation(project(Modules.MIXPANEL_ANALYTICS))

testImplementation(Dependencies.JUNIT)
testImplementation(Dependencies.SYSTEM_RULES)
Expand Down
Empty file removed tool/analytics/README.md
Empty file.
4 changes: 2 additions & 2 deletions tool/analytics/mixpanel/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies {
implementation(Dependencies.MIXPANEL)
implementation(Dependencies.JACKSON_KOTLIN)
implementation(Dependencies.JACKSON_YAML)
implementation(project(":common"))
implementation(project(":tool:analytics"))
implementation(project(Modules.COMMON))
implementation(project(Modules.ANALYTICS))

testImplementation(Dependencies.JUNIT)
}