Skip to content

Commit 78a6abc

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/default-prefix
# Conflicts: # README.md # lib/src/test/java/com/telemetrydeck/sdk/TelemetryDeckTests.kt
2 parents 7e06b62 + 510a897 commit 78a6abc

File tree

11 files changed

+124
-58
lines changed

11 files changed

+124
-58
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
name: Publish to Maven Central
2-
3-
on:
4-
push:
5-
tags:
6-
- "[0-9]+.[0-9]+.[0-9]+*"
7-
8-
jobs:
9-
publish:
10-
name: Publish to Sonatype
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
15-
16-
- name: Configure JDK
17-
uses: actions/setup-java@v4
18-
with:
19-
distribution: 'temurin'
20-
java-version: '17'
21-
22-
- name: Setup Gradle
23-
uses: gradle/actions/setup-gradle@v4
24-
25-
- name: Upload Artifacts
26-
# gradle.properties must be set with SONATYPE_HOST=CENTRAL_PORTAL and RELEASE_SIGNING_ENABLED=true
27-
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
28-
env:
29-
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
30-
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
31-
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
32-
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyId }}
33-
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyPassword }}
1+
#name: Publish to Maven Central
2+
#
3+
#on:
4+
# push:
5+
# tags:
6+
# - "[0-9]+.[0-9]+.[0-9]+*"
7+
#
8+
#jobs:
9+
# publish:
10+
# name: Publish to Sonatype
11+
# runs-on: ubuntu-latest
12+
# steps:
13+
# - name: Checkout
14+
# uses: actions/checkout@v4
15+
#
16+
# - name: Configure JDK
17+
# uses: actions/setup-java@v4
18+
# with:
19+
# distribution: 'temurin'
20+
# java-version: '17'
21+
#
22+
# - name: Setup Gradle
23+
# uses: gradle/actions/setup-gradle@v4
24+
#
25+
# - name: Upload Artifacts
26+
# # gradle.properties must be set with SONATYPE_HOST=CENTRAL_PORTAL and RELEASE_SIGNING_ENABLED=true
27+
# run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
28+
# env:
29+
# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
30+
# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
31+
# ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
32+
# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyId }}
33+
# ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyPassword }}

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Kotlin SDK for TelemetryDeck is available from Maven Central and can be used
1010

1111
```groovy
1212
dependencies {
13-
implementation 'com.telemetrydeck:kotlin-sdk:4.0.2'
13+
implementation 'com.telemetrydeck:kotlin-sdk:4.0.5'
1414
}
1515
```
1616

@@ -148,6 +148,21 @@ By default, Kotlin SDK for TelemetryDeck will include the following environment
148148

149149
See [Custom Telemetry](#custom-telemetry) on how to implement your own parameter enrichment.
150150

151+
## Default Parameters
152+
153+
If there are parameters you would like to include with every outgoing signal, you can use `DefaultParameterProvider` instead of passing them with every call.
154+
155+
```kotlin
156+
// create an instance of [DefaultParameterProvider] and pass the key value you wish to be appended to every signal
157+
val provider = DefaultParameterProvider(mapOf("key" to "value"))
158+
159+
// add the provider when configuring an instance of TelemetryDeck
160+
161+
val builder = TelemetryDeck.Builder()
162+
.appID("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
163+
.addProvider(provider)
164+
```
165+
151166
## Default prefix
152167

153168
If you find yourself prepending the same prefix for to your custom signals or parameters,
@@ -167,7 +182,7 @@ val builder = TelemetryDeck.Builder()
167182

168183
## Custom Telemetry
169184

170-
Another way to send signals is to register a custom `TelemetryDeckProvider`.
185+
Another way to send signals is to implement a custom `TelemetryDeckProvider`.
171186
A provider uses the TelemetryDeck client in order to queue or send signals based on environment or other triggers.
172187

173188

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ plugins {
22
alias(libs.plugins.androidLibrary) apply false
33
alias(libs.plugins.kotlin.android) apply false
44
alias(libs.plugins.kotlin.serialization) apply false
5-
alias(libs.plugins.kotlin.compose) apply false
65
alias(libs.plugins.vanniktech.publish) apply false
76
}

gradle/libs.versions.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[versions]
2-
agp = "8.7.3"
2+
agp = "8.8.0"
33
kotlin = "2.0.20"
4-
coreKtx = "1.13.1"
4+
coreKtx = "1.15.0"
55
junit = "4.13.2"
66
junitVersion = "1.2.1"
77
espressoCore = "3.6.1"
88
lifecycleRuntimeKtx = "2.8.7"
9-
activityCompose = "1.9.3"
10-
composeBom = "2024.10.00"
9+
activityCompose = "1.10.0"
10+
composeBom = "2024.04.01"
1111
ktor = "3.0.2"
1212
kotlinx = "1.7.3"
13-
coroutines = "1.9.0"
13+
coroutines = "1.10.1"
1414
vanniktech-publish = "0.30.0"
1515
appcompat = "1.7.0"
1616
mockk = "1.13.13"
@@ -48,5 +48,4 @@ mockk-android = {group = "io.mockk", name = "mockk-android", version.ref = "mock
4848
androidLibrary = { id = "com.android.library", version.ref = "agp" }
4949
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
5050
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
51-
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-publish" }
52-
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
51+
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-publish" }

lib/build.gradle.kts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
alias(libs.plugins.androidLibrary)
66
alias(libs.plugins.kotlin.android)
77
alias(libs.plugins.kotlin.serialization)
8-
alias(libs.plugins.kotlin.compose)
98
alias(libs.plugins.vanniktech.publish)
109
}
1110

@@ -44,7 +43,7 @@ android {
4443
jvmTarget = "11"
4544
}
4645
buildFeatures {
47-
compose = true
46+
compose = false
4847
buildConfig = true
4948
}
5049

@@ -68,10 +67,6 @@ dependencies {
6867
implementation(libs.androidx.core.ktx)
6968
implementation(libs.androidx.lifecycle.runtime.ktx)
7069
implementation(libs.androidx.lifecycle.process)
71-
// explicit dependency on compose seems to be required to use the compose compiler
72-
// this is not used by the library atm
73-
implementation(libs.androidx.activity.compose)
74-
implementation(platform(libs.androidx.compose.bom))
7570
implementation(libs.androidx.appcompat)
7671
implementation(libs.ktor.client.core)
7772
implementation(libs.kotlinx.coroutines.core)
@@ -86,13 +81,15 @@ dependencies {
8681

8782
testImplementation(libs.junit)
8883
testImplementation(libs.androidx.arch.core)
89-
84+
// As of Kotlin 2.0, the Compose Compiler and runtime are required in the classpath https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html
85+
testImplementation(libs.androidx.activity.compose)
86+
testImplementation(platform(libs.androidx.compose.bom))
9087
androidTestImplementation(libs.androidx.junit)
9188
androidTestImplementation(libs.androidx.espresso.core)
9289
androidTestImplementation(platform(libs.androidx.compose.bom))
9390
androidTestImplementation(libs.androidx.ui.test.junit4)
94-
debugImplementation(libs.androidx.ui.tooling)
95-
debugImplementation(libs.androidx.ui.test.manifest)
91+
androidTestImplementation(libs.androidx.ui.tooling)
92+
androidTestImplementation(libs.androidx.ui.test.manifest)
9693

9794
testImplementation(libs.mockk)
9895
testImplementation(libs.mockk.android)
@@ -101,7 +98,7 @@ dependencies {
10198
}
10299

103100
mavenPublishing {
104-
coordinates("com.telemetrydeck", "kotlin-sdk", "4.0.2")
101+
coordinates("com.telemetrydeck", "kotlin-sdk", "4.0.5")
105102

106103
pom {
107104
name = "TelemetryDeck SDK"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.telemetrydeck.sdk.providers
2+
3+
import android.app.Application
4+
import com.telemetrydeck.sdk.TelemetryDeckProvider
5+
import com.telemetrydeck.sdk.TelemetryDeckSignalProcessor
6+
7+
8+
/**
9+
* [DefaultParameterProvider] is a [TelemetryDeckProvider] that adds default parameters
10+
* to every telemetry signal. It ensures that signals are enriched with predefined data,
11+
* unless the signal already contains a value for the same key.
12+
*
13+
* @property defaultParameters A map of key-value pairs representing the default parameters
14+
* that will be added to each telemetry signal.
15+
*/
16+
class DefaultParameterProvider(val defaultParameters: Map<String, String>): TelemetryDeckProvider {
17+
override fun register(ctx: Application?, client: TelemetryDeckSignalProcessor) {
18+
// nothing to do
19+
}
20+
21+
override fun stop() {
22+
// nothing to do
23+
}
24+
25+
override fun enrich(
26+
signalType: String,
27+
clientUser: String?,
28+
additionalPayload: Map<String, String>
29+
): Map<String, String> {
30+
val signalPayload = additionalPayload.toMutableMap()
31+
for (item in defaultParameters) {
32+
if (!signalPayload.containsKey(item.key)) {
33+
signalPayload[item.key] = item.value
34+
}
35+
}
36+
return signalPayload
37+
}
38+
}

lib/src/main/java/com/telemetrydeck/sdk/providers/EnvironmentParameterProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.telemetrydeck.sdk.params.SDK
2020
* - information about the device running the application, such as operating system, model name, or architecture.
2121
* - information about the TelemetryDeck SDK, such as its name or version number.
2222
*/
23-
internal class EnvironmentParameterProvider : TelemetryDeckProvider, TelemetryProviderFallback {
23+
class EnvironmentParameterProvider : TelemetryDeckProvider, TelemetryProviderFallback {
2424
private var enabled: Boolean = true
2525
private var metadata = mutableMapOf<String, String>()
2626

@@ -30,7 +30,7 @@ internal class EnvironmentParameterProvider : TelemetryDeckProvider, TelemetryPr
3030
private val platform: String = "Android"
3131
private val os: String = "Android"
3232
private val sdkName: String = "KotlinSDK"
33-
private val sdkVersion: String = "4.0.2"
33+
private val sdkVersion: String = "4.0.5"
3434

3535
override fun fallbackRegister(ctx: Application?, client: TelemetryDeckSignalProcessor) {
3636
register(ctx, client)

lib/src/main/java/com/telemetrydeck/sdk/providers/PlatformContextProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import com.telemetrydeck.sdk.platform.getLocaleName
1313
import com.telemetrydeck.sdk.platform.getTimeZone
1414
import java.lang.ref.WeakReference
1515

16-
internal class PlatformContextProvider : TelemetryDeckProvider, TelemetryProviderFallback {
16+
class PlatformContextProvider : TelemetryDeckProvider, TelemetryProviderFallback {
1717
private var enabled: Boolean = true
1818
private var manager: WeakReference<TelemetryDeckSignalProcessor>? = null
1919
private var appContext: WeakReference<Application?>? = null

lib/src/main/java/com/telemetrydeck/sdk/providers/SessionActivityProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import java.lang.ref.WeakReference
1515
/**
1616
* Emits signals for application and activity lifecycle events.
1717
*/
18-
internal class SessionActivityProvider : TelemetryDeckProvider,
18+
class SessionActivityProvider : TelemetryDeckProvider,
1919
Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver, TelemetryProviderFallback {
2020
private var manager: WeakReference<TelemetryDeckSignalProcessor>? = null
2121

lib/src/main/java/com/telemetrydeck/sdk/providers/SessionAppProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.lang.ref.WeakReference
1414
/**
1515
* Monitors the app lifecycle in order to broadcast the NewSessionBegan signal.
1616
*/
17-
internal class SessionAppProvider : TelemetryDeckProvider, DefaultLifecycleObserver,
17+
class SessionAppProvider : TelemetryDeckProvider, DefaultLifecycleObserver,
1818
TelemetryProviderFallback {
1919
private var manager: WeakReference<TelemetryDeckSignalProcessor>? = null
2020

0 commit comments

Comments
 (0)