Skip to content

Commit

Permalink
Analytics: Fix SDK Version Bug (#304)
Browse files Browse the repository at this point in the history
* Fix issue where analytics version wasn't being set in BuildConfig.

* Fix all subproject build configs to use rootProjection.version variable for release.

* Update CHANGELOG.md

* Add guard rails to prevent null version.

* Always send tracking events to live environment.
  • Loading branch information
sshropshire authored Dec 4, 2024
1 parent b5c9f73 commit d6028a0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# PayPal Android SDK Release Notes

## unreleased
* CorePayments
* Fix issue that causes analytics version number to always be `null`

## 2.0.0-beta1 (2024-11-20)
* Breaking Changes
* PayPalNativePayments
Expand Down
2 changes: 1 addition & 1 deletion CardPayments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {

buildTypes {
release {
version = android.defaultConfig.versionName // had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down
9 changes: 7 additions & 2 deletions CorePayments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ android {
targetSdkVersion modules.androidTargetVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
buildConfigField "String", "CLIENT_SDK_VERSION", "\"$versionName\""
buildConfigField "String", "CLIENT_SDK_VERSION", "\"${requireExists(rootProject.version)}\""
}

buildTypes {
release {
version = android.defaultConfig.versionName // had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down Expand Up @@ -82,6 +82,11 @@ dependencies {
androidTestImplementation libs.kotlinx.coroutinesTest
}

static def requireExists(String value) {
if (value) return value
throw new Exception("Error in CorePayments/build.gradle: Variable does not exist.")
}

project.ext.name = "core-payments"
project.ext.version = rootProject.version
project.ext.pom_name = "PayPal SDK - CorePayments"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ internal class TrackingEventsAPI constructor(
private val coreConfig: CoreConfig,
private val restClient: RestClient
) {

// api-m.sandbox.paypal.com does not currently send FPTI events to BigQuery/Looker
constructor(coreConfig: CoreConfig) :
this(coreConfig, RestClient(coreConfig))
this(coreConfig, RestClient(toLiveConfig(coreConfig)))

suspend fun sendEvent(event: AnalyticsEventData, deviceData: DeviceData): HttpResponse {
val apiRequest = createAPIRequestForEvent(event, deviceData)
Expand Down Expand Up @@ -79,5 +81,8 @@ internal class TrackingEventsAPI constructor(

const val KEY_EVENT_PARAMETERS = "event_params"
const val KEY_EVENTS = "events"

fun toLiveConfig(config: CoreConfig): CoreConfig =
CoreConfig(config.clientId, environment = Environment.LIVE)
}
}
2 changes: 1 addition & 1 deletion FraudProtection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

buildTypes {
release {
version = android.defaultConfig.versionName // had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down
2 changes: 1 addition & 1 deletion PayPalWebPayments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

buildTypes {
release {
version = android.defaultConfig.versionName // had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down
2 changes: 1 addition & 1 deletion PaymentButtons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {

buildTypes {
release {
version = android.defaultConfig.versionName // had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down
3 changes: 1 addition & 2 deletions Venmo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ android {

buildTypes {
release {
version = android.defaultConfig.versionName
// had to add this to get the version in the build
version = rootProject.version
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down

0 comments on commit d6028a0

Please sign in to comment.