Skip to content

Commit

Permalink
3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Jul 31, 2023
2 parents 31d9b61 + 634d8e0 commit 115b2d1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Piano Analytics SDK for Android

## v3.3.1
* Fixed setting properties `av_previous_position`, `av_position` and `av_duration`
* Added `PianoAnalytics.EventProcessorCallback` as a replacement for previous `OnWorkListener`

## v3.3.0
* Changed package and artifact group: `io.piano.analytics` -> `io.piano.android.analytics`
* Rewritten to Kotlin 1.8
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/com/example/pianoanalytics/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ class App: Application() {
site = 552987,
visitorIDType = VisitorIDType.ADVERTISING_ID
).ignoreLimitedAdTracking(true).build()
PianoAnalytics.init(applicationContext, configuration)
PianoAnalytics.init(applicationContext, configuration).apply {
// just an example of callback
eventProcessorCallback = PianoAnalytics.EventProcessorCallback { events ->
events.forEach { event ->
val eventData = event.properties.joinToString(
prefix = "[",
postfix = "]"
) { p -> "${p.name.key}=${p.value}" }
Timber.d("Visitor ID = '${visitorId}, event name = '${event.name}', event data = '$eventData'")
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
# Plugins
kotlin = "1.8.22"
android = "8.0.2"
android = "8.1.0"
versionUpdater = "0.47.0"
ktlint = "11.5.0"
dokka = "1.8.20"
Expand Down
2 changes: 1 addition & 1 deletion piano-analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ kotlin {
}

ktlint {
version.set("0.49.1")
version.set("0.50.0")
android.set(true)
}

Expand Down
2 changes: 1 addition & 1 deletion piano-analytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=3.3.0
VERSION_NAME=3.3.1
GROUP=io.piano.android
POM_NAME=Analytics
POM_ARTIFACT_ID=analytics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class PianoAnalytics internal constructor(
@Suppress("unused", "MemberVisibilityCanBePrivate") // Public API.
val customEventProcessors: MutableList<EventProcessor> = customEventProcessorsGroup

/**
* Callback, which will be called after all events' processors and before sending event.
*/
var eventProcessorCallback: EventProcessorCallback = EventProcessorCallback { _ -> }

/**
* Sets current screen name.
* It will be automatically added as property for event [Event.PAGE_DISPLAY]
Expand Down Expand Up @@ -119,6 +124,7 @@ class PianoAnalytics internal constructor(
{
val processedEvents = eventProcessorsGroup.process(events.toList())
eventRepository.putEvents(processedEvents)
eventProcessorCallback.onProcess(processedEvents)
if (configuration.offlineStorageMode != OfflineStorageMode.ALWAYS) {
sendTask.run()
}
Expand Down Expand Up @@ -148,6 +154,10 @@ class PianoAnalytics internal constructor(
}
}

fun interface EventProcessorCallback {
fun onProcess(events: List<Event>)
}

companion object {
/**
* Initializes Piano Analytics SDK
Expand Down

0 comments on commit 115b2d1

Please sign in to comment.