Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added placements support, refactored event emitter #74

Merged
merged 14 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation 'com.apphud:ApphudSDK-Android:2.8.4'
implementation 'com.apphud:ApphudSDK-Android:2.9.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.android.billingclient:billing:7.1.1'
}
57 changes: 57 additions & 0 deletions android/src/main/java/com/reactnativeapphudsdk/ApphudDataMapper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.reactnativeapphudsdk

import com.apphud.sdk.ApphudAttributionData
import com.apphud.sdk.ApphudAttributionProvider
import com.facebook.react.bridge.ReadableMap

internal data class AttributionParams(
val identifier: String?,
val provider: ApphudAttributionProvider,
val data: ApphudAttributionData
)

private fun Map<String, Any?>.removeNullableValues(): Map<String, Any> {
val map = mutableMapOf<String, Any>()

for (pair in this) {
pair.value?.let {
map[pair.key] = it
}
}

return map
}

internal fun ReadableMap.getAttributionParams(): AttributionParams? {
val identifier = getString("identifier")

val provider = getString("attributionProviderId")?.let { attributionProviderId ->
ApphudAttributionProvider.entries.find {
it.value == attributionProviderId
}
} ?: return null

val data = getMap("data") ?: return null

val rawData = data
.getMap("rawData")
?.toHashMap()
?.toMap()
?.removeNullableValues() ?: emptyMap()

return AttributionParams(
identifier = identifier,
provider = provider,
data = ApphudAttributionData(
rawData = rawData,
adNetwork = data.getString("adNetwork"),
channel = data.getString("channel"),
campaign = data.getString("campaign"),
adSet = data.getString("adSet"),
creative = data.getString("creative"),
keyword = data.getString("keyword"),
custom1 = data.getString("custom1"),
custom2 = data.getString("custom2")
)
)
}
Loading