Skip to content

Commit ecadd93

Browse files
Update React SDK to send application version
1 parent cef84b7 commit ecadd93

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

demo/android/app/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import groovy.json.JsonSlurper
45

56
/**
67
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -120,6 +121,14 @@ def jscFlavor = 'org.webkit:android-jsc:+'
120121
*/
121122
def enableHermes = project.ext.react.get("enableHermes", false);
122123

124+
def getAppVersion() {
125+
def inputFile = new File("../../package.json")
126+
def packageJson = new JsonSlurper().parseText(inputFile.text)
127+
return packageJson["version"]
128+
}
129+
130+
def appVer = getAppVersion()
131+
123132
android {
124133
ndkVersion rootProject.ext.ndkVersion
125134

@@ -130,7 +139,7 @@ android {
130139
minSdkVersion rootProject.ext.minSdkVersion
131140
targetSdkVersion rootProject.ext.targetSdkVersion
132141
versionCode 1
133-
versionName "1.0"
142+
versionName appVer
134143
}
135144
splits {
136145
abi {

react-native-userreport-sdk.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const fireTrackingPixel = async (trackingCode, consentString) => {
9595
const idfa = await loadIdfa();
9696
const idfv = ReactNativeDeviceInfo.getUniqueId();
9797
const bundleId = ReactNativeDeviceInfo.getBundleId();
98+
const appVersion = ReactNativeDeviceInfo.getVersion();
9899

99100
const systemName = ReactNativeDeviceInfo.getSystemName();
100101
const systemVersion = ReactNativeDeviceInfo.getSystemVersion();
@@ -111,6 +112,7 @@ const fireTrackingPixel = async (trackingCode, consentString) => {
111112
+ (!useAnonymousTracking && idfa ? `&d=${encodeURIComponent(idfa)}` : '')
112113
+ (!useAnonymousTracking && idfv ? `&idfv=${encodeURIComponent(idfv)}` : '')
113114
+ `&appid=${encodeURIComponent(bundleId)}`
115+
+ `&appver=${encodeURIComponent(appVersion)}`
114116
+ `&os=${encodeURIComponent(systemName)}`
115117
+ `&osv=${encodeURIComponent(systemVersion)}`
116118
+ `&dn=${encodeURIComponent(deviceName)}`

0 commit comments

Comments
 (0)