Skip to content

Commit

Permalink
RUM-1822: Add version code information to the mapping file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnm committed Nov 28, 2023
1 parent 373dde9 commit 0ba08f5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class DdAndroidGradlePlugin @Inject constructor(

uploadTask.site = extensionConfiguration.site ?: ""
uploadTask.versionName = extensionConfiguration.versionName ?: variant.versionName
uploadTask.versionCode = variant.versionCode
uploadTask.serviceName = extensionConfiguration.serviceName ?: variant.applicationId
uploadTask.remoteRepositoryUrl = extensionConfiguration.remoteRepositoryUrl ?: ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ open class DdMappingFileUploadTask
@get:Input
var versionName: String = ""

/**
* The version code of the application.
*/
@get:Input
var versionCode: Int = 0

/**
* The service name of the application (by default, it is your app's package name).
*/
Expand Down Expand Up @@ -174,6 +180,7 @@ open class DdMappingFileUploadTask
DdAppIdentifier(
serviceName = serviceName,
version = versionName,
versionCode = versionCode,
variant = variantName,
buildId = buildId.get()
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ package com.datadog.gradle.plugin.internal
internal data class DdAppIdentifier(
val serviceName: String,
val version: String,
val versionCode: Int,
val variant: String,
val buildId: String
) {

override fun toString(): String {
return "`service:$serviceName`, `version:$version`, `variant:$variant`, `buildId:$buildId`"
return "`service:$serviceName`, `version:$version`, `versionCode:$versionCode`," +
" `variant:$variant`, `buildId:$buildId`"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ internal class OkHttpUploader : Uploader {
eventJson.put("service", identifier.serviceName)
eventJson.put("variant", identifier.variant)
eventJson.put("buildId", identifier.buildId)
eventJson.put("versionCode", identifier.versionCode)
eventJson.put("type", TYPE_JVM_MAPPING_FILE)

val builder = MultipartBody.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.datadog.gradle.plugin.internal.DdAppIdentifier
import com.datadog.gradle.plugin.internal.Uploader
import fr.xgouchet.elmyr.Forge
import fr.xgouchet.elmyr.annotation.Forgery
import fr.xgouchet.elmyr.annotation.IntForgery
import fr.xgouchet.elmyr.annotation.StringForgery
import fr.xgouchet.elmyr.junit5.ForgeConfiguration
import fr.xgouchet.elmyr.junit5.ForgeExtension
Expand Down Expand Up @@ -70,6 +71,9 @@ internal class DdMappingFileUploadTaskTest {
@StringForgery
lateinit var fakeVersion: String

@IntForgery(min = 0)
var fakeVersionCode: Int = 0

@StringForgery
lateinit var fakeService: String

Expand Down Expand Up @@ -115,6 +119,7 @@ internal class DdMappingFileUploadTaskTest {
testedTask.apiKeySource = fakeApiKey.source
testedTask.variantName = fakeVariant
testedTask.versionName = fakeVersion
testedTask.versionCode = fakeVersionCode
testedTask.serviceName = fakeService
testedTask.site = fakeSite.name
testedTask.buildId = mock<Provider<String>>().apply { whenever(get()) doReturn fakeBuildId }
Expand Down Expand Up @@ -149,6 +154,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
),
Expand Down Expand Up @@ -196,6 +202,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
)
Expand Down Expand Up @@ -246,6 +253,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
)
Expand Down Expand Up @@ -300,6 +308,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
)
Expand Down Expand Up @@ -335,6 +344,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
),
Expand Down Expand Up @@ -370,6 +380,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
),
Expand Down Expand Up @@ -466,6 +477,7 @@ internal class DdMappingFileUploadTaskTest {
DdAppIdentifier(
serviceName = fakeService,
version = fakeVersion,
versionCode = fakeVersionCode,
variant = fakeVariant,
buildId = fakeBuildId
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class IdentifierForgeryFactory : ForgeryFactory<DdAppIdentifier> {
return DdAppIdentifier(
serviceName = forge.aStringMatching("[a-z]{3}(\\.[a-z]{5,10}){2,4}"),
version = forge.aStringMatching("\\d\\.\\d{1,2}\\.\\d{1,3}"),
versionCode = forge.aPositiveInt(),
variant = forge.anAlphabeticalString(),
buildId = forge.getForgery<UUID>().toString()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -222,7 +223,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -269,7 +271,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -317,7 +320,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -374,7 +378,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -428,7 +433,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -498,7 +504,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -556,7 +563,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down Expand Up @@ -613,7 +621,8 @@ internal class OkHttpUploaderTest {
"\"variant\":\"${fakeIdentifier.variant}\"," +
"\"buildId\":\"${fakeIdentifier.buildId}\"," +
"\"type\":\"${OkHttpUploader.TYPE_JVM_MAPPING_FILE}\"," +
"\"version\":\"${fakeIdentifier.version}\"}",
"\"version\":\"${fakeIdentifier.version}\"," +
"\"versionCode\":${fakeIdentifier.versionCode}}",
"application/json; charset=utf-8"
)
.containsMultipartFile(
Expand Down

0 comments on commit 0ba08f5

Please sign in to comment.