From fc321a1d584fb2af60d307da2ab02e33f789bb01 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Thu, 3 Nov 2022 09:23:13 -0600 Subject: [PATCH] Check whether or not Plausible is enabled before sending events --- .../java/com/wbrawner/plausible/android/PlausibleClient.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plausible/src/main/java/com/wbrawner/plausible/android/PlausibleClient.kt b/plausible/src/main/java/com/wbrawner/plausible/android/PlausibleClient.kt index 7401ed6..b28dca2 100644 --- a/plausible/src/main/java/com/wbrawner/plausible/android/PlausibleClient.kt +++ b/plausible/src/main/java/com/wbrawner/plausible/android/PlausibleClient.kt @@ -14,7 +14,6 @@ import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody import java.io.File import java.io.IOException -import java.net.URL import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException @@ -134,6 +133,10 @@ internal class NetworkFirstPlausibleClient(private val config: PlausibleConfig) } private suspend fun postEvent(event: Event) { + if (!config.enable) { + Log.w("Plausible", "Plausible disabled, not sending event: $event") + return + } val body = event.toJson().toRequestBody("application/json".toMediaType()) val url = config.host .toHttpUrl()