From 85bfe259b4d15a59550c228d5eef1425aa203760 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 30 Apr 2026 13:20:26 +0300 Subject: [PATCH] feat: add internal usage attibution ID --- .DS_Store | Bin 6148 -> 0 bytes android/build.gradle | 1 + android/src/main/AndroidManifest.xml | 14 +++++- .../react/driversdk/DriverSdkInitializer.java | 42 ++++++++++++++++++ .../android/react/driversdk/SdkVersion.java | 27 +++++++++++ example/.DS_Store | Bin 6148 -> 0 bytes example/LMFS/.DS_Store | Bin 6148 -> 0 bytes example/ODRD/.DS_Store | Bin 6148 -> 0 bytes ios/.DS_Store | Bin 8196 -> 0 bytes ios/RNDriverSdkAttribution.m | 29 ++++++++++++ ios/SdkVersion.h | 19 ++++++++ release-please-config.json | 6 ++- 12 files changed, 135 insertions(+), 3 deletions(-) delete mode 100644 .DS_Store create mode 100644 android/src/main/java/com/google/android/react/driversdk/DriverSdkInitializer.java create mode 100644 android/src/main/java/com/google/android/react/driversdk/SdkVersion.java delete mode 100644 example/.DS_Store delete mode 100644 example/LMFS/.DS_Store delete mode 100644 example/ODRD/.DS_Store delete mode 100644 ios/.DS_Store create mode 100644 ios/RNDriverSdkAttribution.m create mode 100644 ios/SdkVersion.h diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1d3821b840d07d58e03fe92e9f0774d421dd032c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOG*Pl6s$G@18%Z(*;nueO^7GR1)?U1FlNLMaXG7;%cEKEvoMTq0&YS*cwOB! zuezC9%$o*K7KhCpFb6PW8sccfIPAIQD6Wz*EWXDZI&3%lr|z*IRsT+y_8MD!;sLMt zq3=6xi3wiNWB;*w-*x@&nT)XtIUon*fEcAwHbL;>2%s=k`ry{N7fE>6e2g-E0S}yoX*;_|1XT7#E*G#MV sVp?$S5)R&uiQbO6uy%awMNwC6&gU(02y{7lmlO3fV7@5iz<)dN4TS_6HUIzs diff --git a/android/build.gradle b/android/build.gradle index 9451d42..92420bc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -62,6 +62,7 @@ repositories { dependencies { implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-driver:7.0.0' + implementation 'androidx.startup:startup-runtime:1.2.0' implementation 'com.facebook.react:react-native:+' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' api 'com.google.guava:guava:31.0.1-android' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index efbaa22..365a671 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -15,7 +15,17 @@ limitations under the License. --> + xmlns:tools="http://schemas.android.com/tools" + package="com.google.android.react.driversdk"> + + + - + \ No newline at end of file diff --git a/android/src/main/java/com/google/android/react/driversdk/DriverSdkInitializer.java b/android/src/main/java/com/google/android/react/driversdk/DriverSdkInitializer.java new file mode 100644 index 0000000..ed79f6a --- /dev/null +++ b/android/src/main/java/com/google/android/react/driversdk/DriverSdkInitializer.java @@ -0,0 +1,42 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.react.driversdk; + +import android.content.Context; +import androidx.annotation.NonNull; +import androidx.startup.Initializer; +import com.google.android.gms.maps.MapsApiSettings; +import java.util.Collections; +import java.util.List; + +/** Registers the Driver SDK internal usage attribution ID at application startup. */ +public final class DriverSdkInitializer implements Initializer { + + @NonNull + @Override + public Void create(@NonNull Context context) { + MapsApiSettings.addInternalUsageAttributionId( + context.getApplicationContext(), SdkVersion.ATTRIBUTION_ID); + return null; + } + + @NonNull + @Override + public List>> dependencies() { + return Collections.emptyList(); + } +} diff --git a/android/src/main/java/com/google/android/react/driversdk/SdkVersion.java b/android/src/main/java/com/google/android/react/driversdk/SdkVersion.java new file mode 100644 index 0000000..0bab386 --- /dev/null +++ b/android/src/main/java/com/google/android/react/driversdk/SdkVersion.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.react.driversdk; + +/** SDK version constants for internal usage attribution. */ +public final class SdkVersion { + public static final String VERSION = "0.4.0"; // {x-release-please-version} + + public static final String ATTRIBUTION_ID = + "gmp_git_reactnativedriversdk_v" + VERSION + "_android"; + + private SdkVersion() {} +} diff --git a/example/.DS_Store b/example/.DS_Store deleted file mode 100644 index ab35450ef1536a43bc9f7efdb33f2e841b125f76..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c!5S)c8BGIIz^e^xSR&-DiMIt|dAZ4T!i2f?Ri%(l3#UXzXqHrBQmtAHOFHAN@_ONvm~>d&%ya5ys}9BDcE($z!+N4dDIf(d z6}Zji+Ux%#eWCxqBxxlDq`;q2z=m-@Zuq3Ct+U5@t!?yIy61e;-8c^lhbYIyD92oQ fIlhmi%xga9elMI7gU)!+iTW9EU1U<=w-xvS1k4xg diff --git a/example/LMFS/.DS_Store b/example/LMFS/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0khz#e~ZX@_YY*U*P-t z1ZQSfmAy_;tRlo^w%VQ5diMDE%-GJj0Nl~)nII{~C ziqo@mU!v}Cskb(o0;WJy0jb^Z;Sejl$7!v8A7R3^97}x00ZyM~`DC2sWBSW2cF2D4 zT^nbcVVp-8-y)1Idi-{fVU7>9a^BaRPw^3t$zwq_OWKToaMaXz7n>)Bo22rc5aHH*;p@RZu*n5jAga`5r1GA?k!uQLtZG?rg0 zvFxrPkKC5SpM!1T-i|16nPhas~a_%#wU?fJGF-7xw zHLmSZqU&@L&nij>FEPd$xyyYsBpYE+FdmW@bMjl@mCmvzCyA%KQ;R_xw1}HT)P1R- z-N%5+3>)`XH9KCY@+-}sMviE{Rj;-^;yRAiE8Ytn2h>V3;Fx#Ph$_yh+YCQtCplMB zuMJkjOLDA+wNGB2QBh;m?%Bj=$uB^SxiSZ9s7y&~roe^@-12^1ssH=efB)YQ&D=}@ zQ{Zn@z-{-Adq-p*YU{=|NUfc)zhRdqex$Nt^)u7 diff --git a/ios/RNDriverSdkAttribution.m b/ios/RNDriverSdkAttribution.m new file mode 100644 index 0000000..a22cc1b --- /dev/null +++ b/ios/RNDriverSdkAttribution.m @@ -0,0 +1,29 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#import "SdkVersion.h" + +@interface RNDriverSdkAttribution : NSObject +@end + +@implementation RNDriverSdkAttribution + ++ (void)load { + NSString *attributionId = + [NSString stringWithFormat:@"gmp_git_reactnativedriversdk_v%@_ios", kRNDriverSdkVersion]; + [GMSServices addInternalUsageAttributionID:attributionId]; +} + +@end diff --git a/ios/SdkVersion.h b/ios/SdkVersion.h new file mode 100644 index 0000000..95c0966 --- /dev/null +++ b/ios/SdkVersion.h @@ -0,0 +1,19 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +static NSString *const kRNDriverSdkVersion = @"0.4.0"; // x-release-please-version diff --git a/release-please-config.json b/release-please-config.json index 8d74708..20da18b 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -8,7 +8,11 @@ "packages": { ".": { "package-name": "@googlemaps/react-native-driver-sdk", - "changelog-path": "CHANGELOG.md" + "changelog-path": "CHANGELOG.md", + "extra-files": [ + "android/src/main/java/com/google/android/react/driversdk/SdkVersion.java", + "ios/SdkVersion.h" + ] } } }