Skip to content

Commit b53486a

Browse files
authored
Add FIID and new proto fields to Crashlytics (#10645)
1 parent ab444d0 commit b53486a

17 files changed

+154
-74
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- [added] Updated Crashlytics to include the Firebase Installation ID for consistency with other products (#10645).
3+
14
# 8.13.0
25
- [added] Updated upload-symbols to 3.11 and added logic to process Flutter project information (#9379)
36
- [fixed] Added native support for ARM / M1 Macs in upload-symbols (#8965)

Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
@property(nonatomic, readonly) NSOperationQueue *operationQueue;
2929
@property(nonatomic, readonly) FIRCLSFileManager *fileManager;
30+
@property(nonatomic, copy) NSString *fiid;
3031

3132
- (void)prepareAndSubmitReport:(FIRCLSInternalReport *)report
3233
dataCollectionToken:(FIRCLSDataCollectionToken *)dataCollectionToken

Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.m

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,11 @@ - (void)prepareAndSubmitReport:(FIRCLSInternalReport *)report
8787
// symbolication operation may be computationally intensive.
8888
FIRCLSApplicationActivity(
8989
FIRCLSApplicationActivityDefault, @"Crashlytics Crash Report Processing", ^{
90-
// Run this only once because it can be run multiple times in succession,
91-
// and if it's slow it could delay crash upload too much without providing
92-
// user benefit.
93-
static dispatch_once_t regenerateOnceToken;
94-
dispatch_once(&regenerateOnceToken, ^{
95-
// Check to see if the FID has rotated before we construct the payload
96-
// so that the payload has an updated value.
97-
[self.installIDModel regenerateInstallIDIfNeeded];
98-
});
90+
// Check to see if the FID has rotated before we construct the payload
91+
// so that the payload has an updated value.
92+
[self.installIDModel regenerateInstallIDIfNeededWithBlock:^(NSString *_Nonnull newFIID) {
93+
self.fiid = [newFIID copy];
94+
}];
9995

10096
// Run on-device symbolication before packaging if we should process
10197
if (shouldProcess) {
@@ -177,7 +173,8 @@ - (void)uploadPackagedReportAtPath:(NSString *)path
177173

178174
FIRCLSReportAdapter *adapter = [[FIRCLSReportAdapter alloc] initWithPath:path
179175
googleAppId:self.googleAppID
180-
installIDModel:self.installIDModel];
176+
installIDModel:self.installIDModel
177+
fiid:self.fiid];
181178

182179
GDTCOREvent *event = [self.googleTransport eventForTransport];
183180
event.dataObject = adapter;

Crashlytics/Crashlytics/Helpers/FIRCLSDefines.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
// These macros generate a function to force a symbol for the containing .o, to work around an issue
2424
// where strip will not strip debug information without a symbol to strip.
2525
#define DUMMY_FUNCTION_NAME(x) CONCAT(fircls_strip_this_, x)
26-
#define INJECT_STRIP_SYMBOL(x) \
27-
void DUMMY_FUNCTION_NAME(x)(void) { \
28-
}
26+
#define INJECT_STRIP_SYMBOL(x) \
27+
void DUMMY_FUNCTION_NAME(x)(void) {}
2928

3029
// These make some target os types available to previous versions of xcode that do not yet have them
3130
// in their SDKs

Crashlytics/Crashlytics/Models/FIRCLSInstallIdentifierModel.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@ NS_ASSUME_NONNULL_BEGIN
3636
* To support end-users rotating Install IDs, this will check and rotate the Install ID,
3737
* which can be a slow operation. This should be run in an Activity or
3838
* background thread.
39+
*
40+
* This method has 2 concerns:
41+
* - Concern 1: We have the old Crashlytics Install ID that needs to regenerate when the FIID
42+
* changes. If we get a null FIID, we don't want to rotate because we don't know if it changed or
43+
* not.
44+
* - Concern 2: Whatever the FIID is, we should send it with the Crash report so we're in sync with
45+
* Sessions and other Firebase SDKs
3946
*/
40-
- (BOOL)regenerateInstallIDIfNeeded;
47+
- (BOOL)regenerateInstallIDIfNeededWithBlock:(void (^)(NSString *fiid))block;
4148

4249
@end
4350

Crashlytics/Crashlytics/Models/FIRCLSInstallIdentifierModel.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@ - (NSString *)generateInstallationUUID {
9898

9999
#pragma mark Privacy Shield
100100

101-
- (BOOL)regenerateInstallIDIfNeeded {
101+
- (BOOL)regenerateInstallIDIfNeededWithBlock:(void (^)(NSString *fiid))block {
102102
BOOL __block didRotate = false;
103103

104104
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
105105

106106
// This runs Completion async, so wait a reasonable amount of time for it to finish.
107107
[self.installations
108108
installationIDWithCompletion:^(NSString *_Nullable currentIID, NSError *_Nullable error) {
109+
// Provide the IID to the callback. For this case we don't care
110+
// if the FIID is null because it's the best we can do - we just want
111+
// to send up the same FIID that is sent by other SDKs (eg. the Sessions SDK).
112+
block(currentIID);
113+
109114
didRotate = [self rotateCrashlyticsInstallUUIDWithIID:currentIID error:error];
110115

111116
if (didRotate) {

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
/// @param installIDModel for pulling the Crashlytics Installation UUID
3535
- (instancetype)initWithPath:(NSString *)folderPath
3636
googleAppId:(NSString *)googleAppID
37-
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel;
37+
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel
38+
fiid:(NSString *)fiid;
3839
@end

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,22 @@
2929
@interface FIRCLSReportAdapter ()
3030

3131
@property(nonatomic, strong) FIRCLSInstallIdentifierModel *installIDModel;
32+
@property(nonatomic, copy) NSString *fiid;
3233

3334
@end
3435

3536
@implementation FIRCLSReportAdapter
3637

3738
- (instancetype)initWithPath:(NSString *)folderPath
3839
googleAppId:(NSString *)googleAppID
39-
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel {
40+
installIDModel:(FIRCLSInstallIdentifierModel *)installIDModel
41+
fiid:(NSString *)fiid {
4042
self = [super init];
4143
if (self) {
4244
_folderPath = folderPath;
4345
_googleAppID = googleAppID;
4446
_installIDModel = installIDModel;
47+
_fiid = [fiid copy];
4548

4649
[self loadMetaDataFile];
4750

@@ -151,6 +154,7 @@ - (google_crashlytics_Report)protoReport {
151154
report.gmp_app_id = FIRCLSEncodeString(self.googleAppID);
152155
report.platform = [self protoPlatformFromString:self.host.platform];
153156
report.installation_uuid = FIRCLSEncodeString(self.installIDModel.installID);
157+
report.firebase_installation_id = FIRCLSEncodeString(self.fiid);
154158
report.build_version = FIRCLSEncodeString(self.application.build_version);
155159
report.display_version = FIRCLSEncodeString(self.application.display_version);
156160
report.apple_payload = [self protoFilesPayload];

Crashlytics/ProtoSupport/Protos/crashlytics.options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
google_crashlytics.Report.sdk_version type:FT_POINTER
1919
google_crashlytics.Report.gmp_app_id type:FT_POINTER
2020
google_crashlytics.Report.installation_uuid type:FT_POINTER
21+
google_crashlytics.Report.firebase_installation_id type:FT_POINTER
22+
google_crashlytics.Report.app_quality_session_id type:FT_POINTER
2123
google_crashlytics.Report.build_version type:FT_POINTER
2224
google_crashlytics.Report.display_version type:FT_POINTER
2325
google_crashlytics.FilesPayload.File.filename type:FT_POINTER

Crashlytics/ProtoSupport/Protos/crashlytics.proto

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum Platforms {
2323
MAC_OS_X = 5;
2424
}
2525

26+
// Next tag: 18
2627
message Report {
2728
// SDK version that generated this session
2829
string sdk_version = 1;
@@ -33,9 +34,16 @@ message Report {
3334
// General device type which generated the Event
3435
Platforms platform = 4;
3536

36-
// Unique device generated guid for application install.
37+
// Unique Crashlytics-specific device generated guid for application install.
38+
// Equivalent to Session.app.installation_uuid
3739
string installation_uuid = 5;
3840

41+
// Unique device generated ID from the FirebaseInstallations SDK
42+
string firebase_installation_id = 16;
43+
44+
// The last Session ID associated with the crash report.
45+
string app_quality_session_id = 17;
46+
3947
// App build version.
4048
string build_version = 6;
4149

@@ -53,4 +61,4 @@ message FilesPayload {
5361
}
5462

5563
repeated File files = 1;
56-
}
64+
}

0 commit comments

Comments
 (0)