Skip to content

Commit

Permalink
Revert "Use ConfigManager in GA"
Browse files Browse the repository at this point in the history
This reverts commit 74e8958
  • Loading branch information
ia3andy committed Nov 22, 2019
1 parent 21c7de4 commit c638171
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package io.quarkus.code.analytics
import com.brsanthu.googleanalytics.GoogleAnalytics
import com.brsanthu.googleanalytics.GoogleAnalyticsConfig
import com.brsanthu.googleanalytics.request.DefaultRequest
import io.quarkus.code.services.CodeQuarkusConfigManager
import javax.inject.Singleton
import io.quarkus.runtime.StartupEvent
import org.eclipse.microprofile.config.inject.ConfigProperty
import java.util.logging.Logger
import javax.enterprise.event.Observes
import javax.inject.Inject



@Singleton
Expand All @@ -19,24 +18,24 @@ open class GoogleAnalyticsService {
private val log = Logger.getLogger(GoogleAnalyticsService::class.java.name)
}

@Inject
lateinit var config: CodeQuarkusConfigManager
@ConfigProperty(name = "io.quarkus.code.ga-tracking-id", defaultValue = "")
lateinit var googleTrackingId: String

var googleAnalytics: GoogleAnalytics? = null

fun onStart(@Observes e: StartupEvent) {
if (googleAnalytics == null && config.gaTrackingId.isNotEmpty()) {
if (googleAnalytics == null && googleTrackingId.isNotEmpty()) {
val defaultRequest = DefaultRequest()

defaultRequest.documentHostName("code.quarkus.io")
defaultRequest.documentReferrer("https://code.quarkus.io")

googleAnalytics = GoogleAnalytics.builder()
.withDefaultRequest(defaultRequest)
.withTrackingId(config.gaTrackingId)
.withTrackingId(googleTrackingId)
.withConfig(GoogleAnalyticsConfig().setBatchSize(30).setBatchingEnabled(true))
.build()
log.info("GoogleAnalytics is enabled, trackingId: ${config.gaTrackingId}")
log.info("GoogleAnalytics is enabled, trackingId: $googleTrackingId")
} else {
log.info("GoogleAnalytics is disabled")
}
Expand Down

0 comments on commit c638171

Please sign in to comment.