Skip to content

feat(library): Integrate internal usage attribution ID - #77

Closed
LoyalAbbas wants to merge 1 commit into
mainfrom
startup_runtime_integration
Closed

LoyalAbbas wants to merge 1 commit into
mainfrom
startup_runtime_integration

Conversation

@LoyalAbbas

Copy link
Copy Markdown
Collaborator

Summary

Integrates internal usage attribution ID tracking (gmp_git_androidmaps3dsamples_v1.13.0) across all sample and demo application modules in this repository using androidx.startup:startup-runtime

Changes

  • New :library Module (com.example.maps3dsamples.library):
    • Added GenerateArtifactIdTask (generateArtifactIdFile) wired into androidComponents to generate AttributionId.VALUE = "gmp_git_androidmaps3dsamples_v${version.get()}".
    • Added AttributionIdInitializer (androidx.startup.Initializer<Unit>) to register AttributionId.VALUE via MapsApiSettings.addInternalUsageAttributionId.
    • Configured AndroidManifest.xml with androidx.startup.InitializationProvider (tools:node="merge").
    • Added Robolectric + MockK unit test (AttributionIdInitializerTest) verifying attribution ID registration on startup.
  • Project & App Module Integration:
    • Centralized version = "1.13.0" in the root build.gradle.kts (allprojects) as a single source of truth for :library, sample apps, and .releaserc.
    • Included :library in settings.gradle.kts and wired implementation(project(":library")) across all 8 application modules (ApiDemos:kotlin-app, ApiDemos:java-app, ComposeDemos:app, advanced:app, PlacesUIKit3D, maps3d-compose-demo, snippets:kotlin-app, and snippets:java-app).
    • Added startup-runtime, play-services-maps, and mockk dependencies to gradle/libs.versions.toml.
  • Documentation:
    • Added Internal usage attribution ID section and opt-out AndroidManifest.xml instructions to README.md.

Testing

  • Verified unit tests and formatting: ./gradlew :library:testDebugUnitTest :library:spotlessCheck
  • Verified manifest merging (processDebugMainManifest) across all sample and demo application modules.

@LoyalAbbas
LoyalAbbas requested review from dkhawk and kikoso October 7, 2026 03:15
@LoyalAbbas LoyalAbbas changed the title feat(library): Integrate internal usage attribution ID via AndroidX Startup feat(library): Integrate internal usage attribution ID Oct 7, 2026

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread library/build.gradle.kts
}

dependencies {
implementation(libs.play.services.maps)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread build.gradle.kts
}

allprojects {
// {x-release-please-start-version}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread settings.gradle.kts
include(":visual-testing")

// Attribution Library
include(":library")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: :library is a bit generic for a samples repo, specially next to maps3d-compose. What about :attribution?

Comment thread library/build.gradle.kts
val dir = outputDir.get().asFile
val packageName = "com.example.maps3dsamples.library.utils.meta"
val packagePath = packageName.replace('.', '/')
val outputFile = File(dir, "$packagePath/ArtifactId.kt")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the generated object is AttributionId, so the file name could match:

Suggested change
val outputFile = File(dir, "$packagePath/ArtifactId.kt")
val outputFile = File(dir, "$packagePath/AttributionId.kt")

Comment thread README.md

## 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a samples repo, so a developer copying one of the samples will not get the :library module. What about rephrasing it slightly?

Suggested change
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: androidx.startup already ships the keep rules for Initializer implementations, so the @Keep and the empty consumer-rules.pro are not needed.

@dkhawk

dkhawk commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

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.

@dkhawk dkhawk closed this Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants