Skip to content

Commit fc89ac2

Browse files
feat: add API-level usage attribution for component tracking. (#568)
* feat: add API-level usage attribution for component tracking. * feat: add API-level usage attribution for component tracking. * feat: Update release please version to 7.0.0 * chore: Update iOS version for CI.
1 parent 55a2c59 commit fc89ac2

10 files changed

Lines changed: 90 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ jobs:
4848
run: |
4949
xcodebuild clean build analyze \
5050
-scheme GoogleMapsUtils -configuration Debug \
51-
-destination "platform=iOS Simulator,OS=18.4,name=iPhone 16" \
51+
-destination "platform=iOS Simulator,OS=26.2,name=iPhone 17" \
5252
-disableAutomaticPackageResolution | xcpretty
5353
5454
- name: Run unit tests on Swift Package
5555
run: |
5656
xcodebuild test -scheme GoogleMapsUtils \
57-
-destination "platform=iOS Simulator,OS=18.4,name=iPhone 16" \
57+
-destination "platform=iOS Simulator,OS=26.2,name=iPhone 17" \
5858
-disableAutomaticPackageResolution
5959
6060
- name: Upload test results to CodeCov
@@ -66,7 +66,7 @@ jobs:
6666

6767
# - name: Build DevApp
6868
# run: |
69-
# xcodebuild -scheme DevApp -configuration Debug -destination "platform=iOS Simulator,OS=16.2,name=iPhone 8" build | xcpretty
69+
# xcodebuild -scheme DevApp -configuration Debug -destination "platform=iOS Simulator,OS=26.2,name=iPhone 17" build | xcpretty
7070

7171
build_test_cocoapod:
7272
name: Build and test the CocoaPod spec
@@ -108,7 +108,7 @@ jobs:
108108
run: |
109109
xcodebuild -workspace samples/SwiftDemoApp/SwiftDemoApp.xcworkspace \
110110
-scheme SwiftDemoApp -configuration Debug \
111-
-destination "platform=iOS Simulator,OS=18.4,name=iPhone 16" build | xcpretty
111+
-destination "platform=iOS Simulator,OS=26.2,name=iPhone 17" build | xcpretty
112112
113113
build_objc_sample:
114114
name: Build Objective-C Sample App with CocoaPods locally
@@ -129,7 +129,7 @@ jobs:
129129
run: |
130130
xcodebuild -workspace samples/ObjCDemoApp/ObjCDemoApp.xcworkspace \
131131
-scheme ObjCDemoApp -configuration Debug \
132-
-destination "platform=iOS Simulator,OS=18.4,name=iPhone 16" build | xcpretty
132+
-destination "platform=iOS Simulator,OS=26.2,name=iPhone 17" build | xcpretty
133133
134134
test: # used as required status check
135135
runs-on: ubuntu-latest

Sources/GoogleMapsUtilsObjC/include/GMUClusterManager.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
*/
1515

1616
#import "GMUClusterManager+Testing.h"
17-
17+
#import <GoogleMaps/GoogleMaps.h>
1818
#import "GMUClusterRenderer.h"
1919
#import "GMUSimpleClusterAlgorithm.h"
20+
#import "GMUVersion.h"
2021

2122
static NSString *const kGMUCameraKeyPath = @"camera";
2223

@@ -42,6 +43,8 @@ - (instancetype)initWithMap:(GMSMapView *)mapView
4243
algorithm:(id<GMUClusterAlgorithm>)algorithm
4344
renderer:(id<GMUClusterRenderer>)renderer {
4445
if ((self = [super init])) {
46+
NSString *attributionID = [NSString stringWithFormat:@"gmp_git_iosmapsutils_v%@_cluster", GMU_VERSION];
47+
[GMSServices addInternalUsageAttributionID:attributionID];
4548
_algorithm = [[GMUSimpleClusterAlgorithm alloc] init];
4649
_mapView = mapView;
4750
_previousCamera = _mapView.camera;

Sources/GoogleMapsUtilsObjC/include/GMUGeometryRenderer.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#import "GMUGeometryRenderer.h"
17-
17+
#import <GoogleMaps/GoogleMaps.h>
1818
#import "GMUFeature.h"
1919
#import "GMUGeometryCollection.h"
2020
#import "GMUGroundOverlay.h"
@@ -23,6 +23,7 @@
2323
#import "GMUPoint.h"
2424
#import "GMUPolygon.h"
2525
#import "GMUStyle.h"
26+
#import "GMUVersion.h"
2627

2728
static NSString *const kStyleMapDefaultState = @"normal";
2829

@@ -76,6 +77,8 @@ - (instancetype)initWithMap:(GMSMapView *)map
7677
styles:(NSArray<GMUStyle *> *)styles
7778
styleMaps:(NSArray<GMUStyleMap *> *)styleMaps {
7879
if (self = [super init]) {
80+
NSString *attributionID = [NSString stringWithFormat:@"gmp_git_iosmapsutils_v%@_geometry", GMU_VERSION];
81+
[GMSServices addInternalUsageAttributionID:attributionID];
7982
_map = map;
8083
_geometryContainers = geometries;
8184
_styles = [[self class] stylesDictionaryFromArray:styles];

Sources/GoogleMapsUtilsObjC/include/GMUHeatmapTileLayer.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
#endif
1919

2020
#import "GMUHeatmapTileLayer.h"
21-
21+
#import <GoogleMaps/GoogleMaps.h>
2222
#import "GQTBounds.h"
2323
#import "GQTPointQuadTree.h"
24+
#import "GMUVersion.h"
2425

2526
static const int kGMUTileSize = 512;
2627
static const int kGMUMaxZoom = 22;
@@ -51,6 +52,8 @@ @implementation GMUHeatmapTileLayer {
5152

5253
- (instancetype)init {
5354
if ((self = [super init])) {
55+
NSString *attributionID = [NSString stringWithFormat:@"gmp_git_iosmapsutils_v%@_heatmap", GMU_VERSION];
56+
[GMSServices addInternalUsageAttributionID:attributionID];
5457
_radius = 20;
5558
_minimumZoomIntensity = 5;
5659
_maximumZoomIntensity = 10;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Copyright (c) 2026 Google Inc.
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+
* http://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+
16+
#import <Foundation/Foundation.h>
17+
18+
NS_ASSUME_NONNULL_BEGIN
19+
20+
/**
21+
* Google Maps iOS Utils library version.
22+
* This version string is used for internal usage attribution.
23+
*/
24+
#define GMU_VERSION @"7.0.0" // x-release-please-version
25+
26+
/**
27+
* Google Maps iOS Utils library version as NSString constant.
28+
* Accessible from both Objective-C and Swift code.
29+
*/
30+
extern NSString *const GMUVersionString;
31+
32+
/**
33+
* Returns the current Google Maps iOS Utils library version.
34+
* Convenient function for Swift code to get the version string.
35+
*/
36+
NSString *GMUCurrentVersion(void);
37+
38+
NS_ASSUME_NONNULL_END
39+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright (c) 2026 Google Inc.
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+
* http://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+
16+
#import "GMUVersion.h"
17+
18+
NSString *const GMUVersionString = GMU_VERSION;
19+
20+
NSString *GMUCurrentVersion(void) {
21+
return GMU_VERSION;
22+
}

Sources/GoogleMapsUtilsObjC/include/GQTPointQuadTree.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#import "GQTPointQuadTree.h"
2121
#import "GQTPointQuadTreeChild.h"
22+
#import <GoogleMaps/GoogleMaps.h>
23+
#import "GMUVersion.h"
2224

2325
@implementation GQTPointQuadTree {
2426
/**
@@ -39,6 +41,8 @@ @implementation GQTPointQuadTree {
3941

4042
- (id)initWithBounds:(GQTBounds)bounds {
4143
if (self = [super init]) {
44+
NSString *attributionID = [NSString stringWithFormat:@"gmp_git_iosmapsutils_v%@_quadtree", GMU_VERSION];
45+
[GMSServices addInternalUsageAttributionID:attributionID];
4246
bounds_ = bounds;
4347
[self clear];
4448
}

release-please-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"extra-files": [
1212
"Google-Maps-iOS-Utils.podspec",
1313
"Podfile.template",
14-
"README.md"
14+
"README.md",
15+
"Sources/GoogleMapsUtilsObjC/include/GMUVersion.h"
1516
]
1617
}
1718
}

samples/ObjCDemoApp/ObjCDemoApp/AppDelegate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "AppDelegate.h"
1717

1818
@import GoogleMaps;
19+
@import GoogleMapsUtils;
1920

2021
//#error Change this key to a valid key registered with the demo app bundle id. Then delete this line.
2122
static NSString *const kMapsAPIKey = @"";
@@ -25,7 +26,8 @@ @implementation AppDelegate
2526
- (BOOL)application:(UIApplication *)application
2627
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2728
[GMSServices provideAPIKey:kMapsAPIKey];
28-
[GMSServices addInternalUsageAttributionID:@"gmp_git_iosmapsutils_v6.2.0"];
29+
NSString *attributionID = [NSString stringWithFormat:@"gmp_git_iosmapsutils_v%@", GMU_VERSION];
30+
[GMSServices addInternalUsageAttributionID:attributionID];
2931
return YES;
3032
}
3133

samples/SwiftDemoApp/SwiftDemoApp/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
import GoogleMaps
17+
import GoogleMapsUtils
1718
import UIKit
1819

1920
// Change this key to a valid key registered with the demo app bundle id.
@@ -29,7 +30,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2930
fatalError("Please provide an API Key using mapsAPIKey")
3031
}
3132
GMSServices.provideAPIKey(mapsAPIKey)
32-
GMSServices.addInternalUsageAttributionID("gmp_git_iosmapsutils_v6.2.0")
33+
let attributionID = "gmp_git_iosmapsutils_v\(GMUCurrentVersion())"
34+
GMSServices.addInternalUsageAttributionID(attributionID)
3335
let masterViewController = MasterViewController()
3436
let navigationController = UINavigationController(rootViewController: masterViewController)
3537
window?.rootViewController = navigationController

0 commit comments

Comments
 (0)