Skip to content

Commit

Permalink
Refine google statics data
Browse files Browse the repository at this point in the history
  • Loading branch information
willings committed Jun 29, 2019
1 parent 6f1dd76 commit 7b7f9a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/kotlin/org/dicthub/page/TranslationPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,16 @@ class TranslationPage(private val userPreference: UserPreference,
return
}

val pluginVersion = userPreference.enabledPlugins.firstOrNull { it.id == translationResult.pluginId }?.version ?: ""
ga("send", "event", "PluginVersion", translationResult.pluginId, pluginVersion)

val action = if (translationResult.success) "TranslationSuccess" else "TranslationFailure"
val label = "${translationResult.query.getFrom().code}_${translationResult.query.getTo().code}"
ga("send", "event", action, translationResult.pluginId, label, 1)
val fromLangToLang = "${translationResult.query.getFrom().code}_${translationResult.query.getTo().code}"
ga("send", "event", action, translationResult.pluginId, fromLangToLang, 1)
if (!translationResult.success) {
// Send failed query for debugging
ga("send", "event", "PluginFailure-${translationResult.pluginId}", fromLangToLang, translationResult.query.getText())
}
}

private fun isTranslationResultUnsafe(result: TranslationResult) = result.htmlContent.contains("<script>")
Expand Down

0 comments on commit 7b7f9a1

Please sign in to comment.