-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move Mixpanel metrics to tools:analytics (#2086)
- Loading branch information
1 parent
f44162e
commit ace7b16
Showing
36 changed files
with
259 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package flank.common | ||
|
||
import org.json.JSONObject | ||
|
||
fun Map<*, *>.toJSONObject() = JSONObject(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test_runner/src/main/kotlin/ftl/analytics/InitUsageStatistics.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ftl.analytics | ||
|
||
import flank.tool.analytics.mixpanel.initializeStatisticsClient | ||
import ftl.args.AndroidArgs | ||
import ftl.args.IArgs | ||
import ftl.args.IosArgs | ||
import ftl.util.isGoogleAnalyticsDisabled | ||
|
||
internal fun IArgs.initUsageStatistics() { | ||
initializeStatisticsClient( | ||
disableUsageStatistics || isGoogleAnalyticsDisabled(flank.common.userHome), | ||
AndroidArgs::class, | ||
IosArgs::class, | ||
IArgs::class | ||
) | ||
} |
21 changes: 0 additions & 21 deletions
21
test_runner/src/main/kotlin/ftl/analytics/PrepareConfiguration.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ftl.analytics | ||
|
||
import flank.tool.analytics.mixpanel.ANDROID | ||
import flank.tool.analytics.mixpanel.APP_ID | ||
import flank.tool.analytics.mixpanel.DEVICE_TYPE | ||
import flank.tool.analytics.mixpanel.IOS | ||
import flank.tool.analytics.mixpanel.sendConfiguration | ||
import ftl.args.AndroidArgs | ||
import ftl.args.IArgs | ||
|
||
fun IArgs.sendAppId(appId: String) { | ||
initUsageStatistics() | ||
when (this) { | ||
is AndroidArgs -> sendConfiguration(project, mapOf(APP_ID to appId, DEVICE_TYPE to ANDROID), eventName = APP_ID) | ||
else -> sendConfiguration(project, mapOf(APP_ID to appId, DEVICE_TYPE to IOS), eventName = APP_ID) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
test_runner/src/main/kotlin/ftl/analytics/SendConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ftl.analytics | ||
|
||
import com.google.common.annotations.VisibleForTesting | ||
import flank.tool.analytics.mixpanel.filterSensitiveValues | ||
import flank.tool.analytics.mixpanel.objectToMap | ||
import flank.tool.analytics.mixpanel.removeNotNeededKeys | ||
import flank.tool.analytics.mixpanel.sendConfiguration | ||
import ftl.args.AndroidArgs | ||
import ftl.args.IArgs | ||
import ftl.args.IosArgs | ||
|
||
fun AndroidArgs.sendConfiguration() { | ||
initUsageStatistics() | ||
sendConfiguration(project = project, events = createEventMap()) | ||
} | ||
|
||
internal fun AndroidArgs.createEventMap() = | ||
toArgsMap().plus(commonArgs.toArgsMap()).removeNotNeededKeys().filterSensitiveValues() | ||
|
||
fun IosArgs.sendConfiguration() { | ||
initUsageStatistics() | ||
sendConfiguration(project = project, events = createEventMap()) | ||
} | ||
|
||
private fun IosArgs.createEventMap() = | ||
toArgsMap().plus(commonArgs.toArgsMap()).removeNotNeededKeys().filterSensitiveValues() | ||
|
||
private fun IArgs.toArgsMap() = objectToMap().filterNonCommonArgs() | ||
|
||
@VisibleForTesting | ||
internal fun Map<String, Any>.filterNonCommonArgs() = filter { it.key != COMMON_ARGS } | ||
|
||
private const val COMMON_ARGS = "commonArgs" |
37 changes: 0 additions & 37 deletions
37
test_runner/src/main/kotlin/ftl/analytics/SendUsageStatistics.kt
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
test_runner/src/main/kotlin/ftl/analytics/UsageStatistics.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.