Skip to content

Commit

Permalink
Replace snapshot dependencies (#12)
Browse files Browse the repository at this point in the history
* fix ci

* replace snapshot dependencies

* replace toBaseEvent function

* update example usage

---------

Co-authored-by: Wenxi Zeng <[email protected]>
  • Loading branch information
wenxi-zeng and Wenxi Zeng authored May 3, 2024
1 parent 27c64d0 commit e643da8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions analytics-kotlin-live/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
}
}
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -15,7 +18,7 @@ class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
analytics = Analytics(
"93EMLzmXzP6EJ3cJOhdaAgEVNnZjwRqA",
"KZrBizvzx7GOj3Ek9Gin7GPsYhezAzw6",
applicationContext
) {
this.collectDeviceId = true
Expand All @@ -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")
}

}
}
3 changes: 0 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ dependencyResolutionManagement {
mavenLocal()
google()
mavenCentral()
maven {
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
rootProject.name = "analytics-kotlin-live"
Expand Down

0 comments on commit e643da8

Please sign in to comment.