Skip to content

Commit c754ade

Browse files
authored
feat: internal usage attribution ID (#581)
1 parent 22075ce commit c754ade

9 files changed

Lines changed: 154 additions & 2 deletions

File tree

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ android {
5555

5656
dependencies {
5757
implementation 'com.facebook.react:react-native:+'
58+
implementation 'androidx.startup:startup-runtime:1.2.0'
5859
implementation "androidx.car.app:app:1.4.0"
5960
implementation "androidx.car.app:app-projected:1.4.0"
6061
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

android/src/main/AndroidManifest.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:tools="http://schemas.android.com/tools">
1819

1920
<uses-permission android:name="android.permission.INTERNET" />
2021
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
2122
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
2223
<application>
24+
<provider
25+
android:name="androidx.startup.InitializationProvider"
26+
android:authorities="${applicationId}.androidx-startup"
27+
android:exported="false"
28+
tools:node="merge">
29+
<meta-data
30+
android:name="com.google.android.react.navsdk.NavSdkInitializer"
31+
android:value="androidx.startup" />
32+
</provider>
2333
<service
2434
android:name="com.google.android.react.navsdk.NavInfoReceivingService"
2535
android:exported="false" />
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.android.react.navsdk;
18+
19+
interface MapViewControllerReadyListener {
20+
void onMapViewControllerReady(int viewId);
21+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2026 Google LLC
3+
*
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.google.android.react.navsdk;
15+
16+
import android.content.Context;
17+
import androidx.annotation.NonNull;
18+
import androidx.startup.Initializer;
19+
import com.google.android.gms.maps.MapsApiSettings;
20+
import java.util.Collections;
21+
import java.util.List;
22+
23+
/** Registers the Navigation SDK internal usage attribution ID at application startup. */
24+
public final class NavSdkInitializer implements Initializer<Void> {
25+
26+
@NonNull
27+
@Override
28+
public Void create(@NonNull Context context) {
29+
MapsApiSettings.addInternalUsageAttributionId(
30+
context.getApplicationContext(), SdkVersion.ATTRIBUTION_ID);
31+
return null;
32+
}
33+
34+
@NonNull
35+
@Override
36+
public List<Class<? extends Initializer<?>>> dependencies() {
37+
return Collections.emptyList();
38+
}
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.android.react.navsdk;
18+
19+
/** SDK version constants for internal usage attribution. */
20+
public final class SdkVersion {
21+
public static final String VERSION = "0.15.1"; // {x-release-please-version}
22+
23+
public static final String ATTRIBUTION_ID =
24+
"gmp_git_reactnativenavigationsdk_v" + VERSION + "_android";
25+
26+
private SdkVersion() {}
27+
}

ios/react-native-navigation-sdk/NavModule.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
*/
1616

1717
#import "NavModule.h"
18+
#import <GoogleMaps/GoogleMaps.h>
1819
#import "NavAutoModule.h"
1920
#import "NavViewModule.h"
2021
#import "ObjectTranslationUtil.h"
22+
#import "SdkVersion.h"
2123

2224
using namespace JS::NativeNavModule;
2325

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import <GoogleMaps/GoogleMaps.h>
16+
#import "SdkVersion.h"
17+
18+
@interface RNNavSdkAttribution : NSObject
19+
@end
20+
21+
@implementation RNNavSdkAttribution
22+
23+
+ (void)load {
24+
NSString *attributionId =
25+
[NSString stringWithFormat:@"gmp_git_reactnativenavigationsdk_v%@_ios", kRNNavSdkVersion];
26+
[GMSServices addInternalUsageAttributionID:attributionId];
27+
}
28+
29+
@end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
static NSString *const kRNNavSdkVersion = @"0.15.1"; // x-release-please-version

release-please-config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"packages": {
99
".": {
1010
"package-name": "@googlemaps/react-native-navigation-sdk",
11-
"changelog-path": "CHANGELOG.md"
11+
"changelog-path": "CHANGELOG.md",
12+
"extra-files": [
13+
"android/src/main/java/com/google/android/react/navsdk/SdkVersion.java",
14+
"ios/react-native-navigation-sdk/SdkVersion.h"
15+
]
1216
}
1317
}
1418
}

0 commit comments

Comments
 (0)