Skip to content

Commit

Permalink
Split events into chunks before sending
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Oct 19, 2023
1 parent 7abbf9b commit f5beab5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Piano Analytics SDK for Android

## v3.3.4-SNAPSHOT
* Updated dependencies:
- com.squareup.okhttp3:okhttp [4.11.0 -> 4.12.0]
https://square.github.io/okhttp/

## v3.3.3
* Added `track` function to `MediaHelper` for tracking custom media events.
* Changed behavior: `extraProps` in `MediaHelper` are added to all events, not only to "heartbeat" events.
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
# Plugins
kotlin = "1.8.22"
android = "8.1.1"
versionUpdater = "0.47.0"
ktlint = "11.5.1"
android = "8.1.2"
versionUpdater = "0.49.0"
ktlint = "11.6.1"
dokka = "1.8.20"
mavenRelease = "0.25.3"
moshiIR = "0.22.1"
Expand All @@ -18,7 +18,7 @@ materialLibrary = "1.9.0"
googleAdsId = "18.0.1"
huaweiAdsId = "3.4.26.303"
retrofit = "2.6.4"
okhttp = "4.11.0"
okhttp = "4.12.0"
moshi = "1.15.0"
timber = "5.0.1"
viewBindingProperty = "1.5.9"
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.3
VERSION_NAME=3.3.4-SNAPSHOT
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 @@ -28,7 +28,9 @@ internal class SendTask(
Timber.w("Can't send events - no connection")
return
}
send(eventRepository.getNotSentEvents())
eventRepository.getNotSentEvents().chunked(CHUNK_SIZE).forEach {
send(it)
}
}

internal fun send(events: List<EventRecord>) {
Expand Down Expand Up @@ -58,5 +60,6 @@ internal class SendTask(

companion object {
internal val MEDIA_TYPE by lazy(LazyThreadSafetyMode.NONE) { "application/json; charset=UTF-8".toMediaType() }
private const val CHUNK_SIZE = 50
}
}

0 comments on commit f5beab5

Please sign in to comment.