diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 322683f..b42b515 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle-core- - name: Publush release to sonatype - run: ./gradlew publishToSonatype -Prelease closeAndReleaseSonatypeStagingRepository + run: ./gradlew clean build publishToSonatype -Prelease closeAndReleaseSonatypeStagingRepository env: SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 9d3182c..6ccd79a 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -22,7 +22,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle-core- - name: Publush snapshot to sonatype - run: ./gradlew publishToSonatype + run: ./gradlew clean build publishToSonatype env: SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} diff --git a/analytics-kotlin-live/build.gradle b/analytics-kotlin-live/build.gradle index 86715e1..6d6ab92 100644 --- a/analytics-kotlin-live/build.gradle +++ b/analytics-kotlin-live/build.gradle @@ -33,8 +33,8 @@ android { dependencies { // Segment - implementation 'com.segment.analytics.kotlin:substrata:0.0.8-SNAPSHOT' - implementation 'com.segment.analytics.kotlin:android:1.15.0' + implementation 'com.segment.analytics.kotlin:substrata:1.0.0' + implementation 'com.segment.analytics.kotlin:android:1.16.0' implementation "org.jetbrains.kotlin:kotlin-reflect:1.9.20" implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1' diff --git a/analytics-kotlin-live/src/main/java/com/segment/analytics/liveplugins/kotlin/LivePlugin.kt b/analytics-kotlin-live/src/main/java/com/segment/analytics/liveplugins/kotlin/LivePlugin.kt index b38aceb..5637671 100644 --- a/analytics-kotlin-live/src/main/java/com/segment/analytics/liveplugins/kotlin/LivePlugin.kt +++ b/analytics-kotlin-live/src/main/java/com/segment/analytics/liveplugins/kotlin/LivePlugin.kt @@ -11,13 +11,11 @@ import com.segment.analytics.kotlin.core.TrackEvent import com.segment.analytics.kotlin.core.platform.EventPlugin import com.segment.analytics.kotlin.core.platform.Plugin import com.segment.analytics.kotlin.core.utilities.EncodeDefaultsJson -import com.segment.analytics.kotlin.core.utilities.LenientJson -import com.segment.analytics.kotlin.core.utilities.getString +import com.segment.analytics.kotlin.core.utilities.toBaseEvent import com.segment.analytics.substrata.kotlin.JSObject import com.segment.analytics.substrata.kotlin.JSScope import com.segment.analytics.substrata.kotlin.JsonElementConverter import kotlinx.serialization.json.Json -import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.encodeToJsonElement import kotlinx.serialization.json.jsonObject @@ -83,17 +81,4 @@ internal class LivePlugin( } return ret } - - private fun JsonObject.toBaseEvent(): BaseEvent? { - val type = getString("type") - - return when (type) { - "identify" -> LenientJson.decodeFromJsonElement(IdentifyEvent.serializer(), this) - "track" -> LenientJson.decodeFromJsonElement(TrackEvent.serializer(), this) - "screen" -> LenientJson.decodeFromJsonElement(ScreenEvent.serializer(), this) - "group" -> LenientJson.decodeFromJsonElement(GroupEvent.serializer(), this) - "alias" -> LenientJson.decodeFromJsonElement(AliasEvent.serializer(), this) - else -> null - } - } } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 744cfbd..82cfdad 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,7 +35,8 @@ android { dependencies { implementation project(':analytics-kotlin-live') - implementation 'com.segment.analytics.kotlin:android:1.15.0' + implementation 'com.segment.analytics.kotlin:substrata:1.0.0' + implementation 'com.segment.analytics.kotlin:android:1.16.0' implementation 'androidx.core:core-ktx:1.13.0' implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' diff --git a/app/src/main/java/com/segment/analytics/liveplugins/app/MainApplication.kt b/app/src/main/java/com/segment/analytics/liveplugins/app/MainApplication.kt index b115e4c..fccfbe2 100644 --- a/app/src/main/java/com/segment/analytics/liveplugins/app/MainApplication.kt +++ b/app/src/main/java/com/segment/analytics/liveplugins/app/MainApplication.kt @@ -3,8 +3,11 @@ package com.segment.analytics.liveplugins.app import android.app.Application import com.segment.analytics.kotlin.android.Analytics import com.segment.analytics.kotlin.core.Analytics +import com.segment.analytics.kotlin.core.platform.Plugin import com.segment.analytics.liveplugins.app.filters.WebhookPlugin import com.segment.analytics.liveplugins.kotlin.LivePlugins +import com.segment.analytics.liveplugins.kotlin.LivePluginsDependent +import com.segment.analytics.substrata.kotlin.JSScope import java.util.concurrent.Executors class MainApplication : Application() { @@ -15,7 +18,7 @@ class MainApplication : Application() { override fun onCreate() { super.onCreate() analytics = Analytics( - "93EMLzmXzP6EJ3cJOhdaAgEVNnZjwRqA", + "KZrBizvzx7GOj3Ek9Gin7GPsYhezAzw6", applicationContext ) { this.collectDeviceId = true @@ -25,11 +28,29 @@ class MainApplication : Application() { this.flushInterval = 0 } - analytics.add(WebhookPlugin("https://webhook.site/5fefa55b-b5cf-4bd5-abe6-9234a003baa8", Executors.newSingleThreadExecutor())) +// analytics.add(WebhookPlugin("https://webhook.site/5fefa55b-b5cf-4bd5-abe6-9234a003baa8", Executors.newSingleThreadExecutor())) val backup = resources.openRawResource(R.raw.default_liveplugins) val livePlugins = LivePlugins(backup, true) analytics.add(livePlugins) + analytics.add(Signals) } + object Signals: Plugin, LivePluginsDependent { + override lateinit var analytics: Analytics + override val type: Plugin.Type = Plugin.Type.After + override fun setup(analytics: Analytics) { + super.setup(analytics) + + analytics.find(LivePlugins::class)?.addDependent(this) + } + override fun prepare(engine: JSScope) { + println("prepare called") + } + + override fun readyToStart() { + println("readyToStart called") + } + + } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 61712dc..09341ec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,9 +11,6 @@ dependencyResolutionManagement { mavenLocal() google() mavenCentral() - maven { - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } } } rootProject.name = "analytics-kotlin-live"