Repository navigation
feat(library): Integrate internal usage attribution ID - #77
LoyalAbbas wants to merge 1 commit into
Conversation
kikoso
left a comment
There was a problem hiding this comment.
Can you take a look at the comments, @LoyalAbbas ? The main one is about the 2D vs 3D SDK, the rest are mostly nits. Thanks!
| @Keep | ||
| internal class AttributionIdInitializer : Initializer<Unit> { | ||
| override fun create(context: Context) { | ||
| MapsApiSettings.addInternalUsageAttributionId( |
There was a problem hiding this comment.
Hi @LoyalAbbas . Just to understand it: MapsApiSettings belongs to the 2D Maps SDK, and none of the samples in this repo creates a 2D map (they only use play-services-maps3d). Is the attribution ID also picked up by the Maps 3D SDK? I could not find an equivalent API in play-services-maps3d, so I suspect the ID is never sent.
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.play.services.maps) |
There was a problem hiding this comment.
Related to the comment above: this pulls play-services-maps into all 8 sample apps only for this call. If the 3D SDK does not read the ID, should we drop it?
| } | ||
|
|
||
| allprojects { | ||
| // {x-release-please-start-version} |
There was a problem hiding this comment.
This repo is released with semantic-release (see .releaserc), not release-please, so these markers are not doing anything. The .releaserc replacement already covers the version = line. Could we remove them?
| include(":visual-testing") | ||
|
|
||
| // Attribution Library | ||
| include(":library") |
There was a problem hiding this comment.
nit: :library is a bit generic for a samples repo, specially next to maps3d-compose. What about :attribution?
| val dir = outputDir.get().asFile | ||
| val packageName = "com.example.maps3dsamples.library.utils.meta" | ||
| val packagePath = packageName.replace('.', '/') | ||
| val outputFile = File(dir, "$packagePath/ArtifactId.kt") |
There was a problem hiding this comment.
nit: the generated object is AttributionId, so the file name could match:
| val outputFile = File(dir, "$packagePath/ArtifactId.kt") | |
| val outputFile = File(dir, "$packagePath/AttributionId.kt") |
|
|
||
| ## Internal usage attribution ID | ||
|
|
||
| This library calls the `addInternalUsageAttributionId` method, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided below. |
There was a problem hiding this comment.
This is a samples repo, so a developer copying one of the samples will not get the :library module. What about rephrasing it slightly?
| This library calls the `addInternalUsageAttributionId` method, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided below. | |
| These samples call the `addInternalUsageAttributionId` method, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided below. |
| * and samples are helpful to developers, such as usage of this library. | ||
| * To opt out of sending the usage attribution ID, please remove this initializer from your manifest. | ||
| */ | ||
| @Keep |
There was a problem hiding this comment.
nit: androidx.startup already ships the keep rules for Initializer implementations, so the @Keep and the empty consumer-rules.pro are not needed.
|
It is unlikely that we will need this change for the maps 3D SDK for the near term. Let's come back to this at a later date if it is needed. |
Summary
Integrates internal usage attribution ID tracking (
gmp_git_androidmaps3dsamples_v1.13.0) across all sample and demo application modules in this repository usingandroidx.startup:startup-runtimeChanges
:libraryModule (com.example.maps3dsamples.library):GenerateArtifactIdTask(generateArtifactIdFile) wired intoandroidComponentsto generateAttributionId.VALUE = "gmp_git_androidmaps3dsamples_v${version.get()}".AttributionIdInitializer(androidx.startup.Initializer<Unit>) to registerAttributionId.VALUEviaMapsApiSettings.addInternalUsageAttributionId.AndroidManifest.xmlwithandroidx.startup.InitializationProvider(tools:node="merge").AttributionIdInitializerTest) verifying attribution ID registration on startup.version = "1.13.0"in the rootbuild.gradle.kts(allprojects) as a single source of truth for:library, sample apps, and.releaserc.:libraryinsettings.gradle.ktsand wiredimplementation(project(":library"))across all 8 application modules (ApiDemos:kotlin-app,ApiDemos:java-app,ComposeDemos:app,advanced:app,PlacesUIKit3D,maps3d-compose-demo,snippets:kotlin-app, andsnippets:java-app).startup-runtime,play-services-maps, andmockkdependencies togradle/libs.versions.toml.AndroidManifest.xmlinstructions toREADME.md.Testing
./gradlew :library:testDebugUnitTest :library:spotlessCheckprocessDebugMainManifest) across all sample and demo application modules.