Skip to content

Commit a436ef8

Browse files
authored
Remove org id in crash report payload when sending with GDT (#5189)
1 parent c4a8681 commit a436ef8

File tree

10 files changed

+25
-39
lines changed

10 files changed

+25
-39
lines changed

Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,15 @@ - (FBLPromise *)deleteUnsentReports {
395395
FIRCLSDebugLog(@"Sending unsent reports.");
396396
FIRCLSDataCollectionToken *dataCollectionToken =
397397
[FIRCLSDataCollectionToken validToken];
398+
399+
// For the new report endpoint, the orgID is not needed.
400+
// For the legacy report endpoint, wait on settings if orgID is not available.
401+
BOOL waitForSetting =
402+
!self.settings.shouldUseNewReportEndpoint && !self.settings.orgID;
403+
398404
[self startNetworkRequestsWithToken:dataCollectionToken
399405
preexistingReportPaths:preexistingReportPaths
400-
waitForSettingsRequest:YES
406+
waitForSettingsRequest:waitForSetting
401407
blockingSend:NO
402408
report:report];
403409

Crashlytics/Crashlytics/Controllers/FIRCLSReportUploader.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ - (BOOL)prepareAndSubmitReport:(FIRCLSInternalReport *)report
7979
return NO;
8080
}
8181

82-
if (!self.dataSource.settings.orgID) {
83-
FIRCLSDebugLog(@"Skipping report with id '%@' this run of the app because Organization ID was "
84-
@"nil. Report will upload once settings are download successfully",
85-
report.identifier);
82+
if (!self.dataSource.settings.orgID && !self.dataSource.settings.shouldUseNewReportEndpoint) {
83+
FIRCLSDebugLog(
84+
@"Skipping report with id '%@' this run of the app because Organization ID was "
85+
@"nil. Report via the legacy endpoint will upload once settings are download successfully",
86+
report.identifier);
8687
return YES;
8788
}
8889

@@ -214,9 +215,7 @@ - (BOOL)uploadPackagedReportAtPath:(NSString *)path
214215
}
215216

216217
FIRCLSReportAdapter *adapter =
217-
[[FIRCLSReportAdapter alloc] initWithPath:path
218-
googleAppId:self.dataSource.googleAppID
219-
orgId:self.dataSource.settings.orgID];
218+
[[FIRCLSReportAdapter alloc] initWithPath:path googleAppId:self.dataSource.googleAppID];
220219

221220
GDTCOREvent *event = [self.dataSource.googleTransport eventForTransport];
222221
event.dataObject = adapter;

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
/// Initializer
3030
/// @param folderPath Path where the persisted crash files reside
31-
- (instancetype)initWithPath:(NSString *)folderPath
32-
googleAppId:(NSString *)googleAppID
33-
orgId:(NSString *)orgID;
31+
- (instancetype)initWithPath:(NSString *)folderPath googleAppId:(NSString *)googleAppID;
3432

3533
@end

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@
2828

2929
@implementation FIRCLSReportAdapter
3030

31-
- (instancetype)initWithPath:(NSString *)folderPath
32-
googleAppId:(NSString *)googleAppID
33-
orgId:(NSString *)orgID {
31+
- (instancetype)initWithPath:(NSString *)folderPath googleAppId:(NSString *)googleAppID {
3432
self = [super init];
3533
if (self) {
3634
_folderPath = folderPath;
3735
_googleAppID = googleAppID;
38-
_orgID = orgID;
3936

4037
[self loadMetaDataFile];
4138

@@ -175,7 +172,6 @@ - (google_crashlytics_FilesPayload)protoFilesPayload {
175172

176173
apple_payload.files = files;
177174
apple_payload.files_count = (pb_size_t)clsRecords.count;
178-
apple_payload.org_id = FIRCLSEncodeString(self.orgID);
179175

180176
return apple_payload;
181177
}

Crashlytics/Crashlytics/Models/Record/FIRCLSReportAdapter_Private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pb_bytes_array_t *FIRCLSEncodeData(NSData *data);
2929

3030
@property(nonatomic, strong) NSString *folderPath;
3131
@property(nonatomic, strong) NSString *googleAppID;
32-
@property(nonatomic, strong) NSString *orgID;
3332

3433
// From metadata.clsrecord
3534
@property(nonatomic, strong) FIRCLSRecordIdentity *identity;

Crashlytics/ProtoSupport/Protos/crashlytics.options

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ google_crashlytics.Report.display_version type:FT_POINTER
2323
google_crashlytics.FilesPayload.File.filename type:FT_POINTER
2424
google_crashlytics.FilesPayload.File.contents type:FT_POINTER
2525
google_crashlytics.FilesPayload.files type:FT_POINTER
26-
google_crashlytics.FilesPayload.org_id type:FT_POINTER

Crashlytics/ProtoSupport/Protos/crashlytics.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,4 @@ message FilesPayload {
5353
}
5454

5555
repeated File files = 1;
56-
string org_id = 2;
5756
}

Crashlytics/Protogen/nanopb/crashlytics.nanopb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ const pb_field_t google_crashlytics_Report_fields[8] = {
3737
PB_LAST_FIELD
3838
};
3939

40-
const pb_field_t google_crashlytics_FilesPayload_fields[3] = {
40+
const pb_field_t google_crashlytics_FilesPayload_fields[2] = {
4141
PB_FIELD( 1, MESSAGE , REPEATED, POINTER , FIRST, google_crashlytics_FilesPayload, files, files, &google_crashlytics_FilesPayload_File_fields),
42-
PB_FIELD( 2, BYTES , SINGULAR, POINTER , OTHER, google_crashlytics_FilesPayload, org_id, files, 0),
4342
PB_LAST_FIELD
4443
};
4544

Crashlytics/Protogen/nanopb/crashlytics.nanopb.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ typedef enum _google_crashlytics_Platforms {
4242
typedef struct _google_crashlytics_FilesPayload {
4343
pb_size_t files_count;
4444
struct _google_crashlytics_FilesPayload_File *files;
45-
pb_bytes_array_t *org_id;
4645
/* @@protoc_insertion_point(struct:google_crashlytics_FilesPayload) */
4746
} google_crashlytics_FilesPayload;
4847

@@ -67,15 +66,14 @@ typedef struct _google_crashlytics_Report {
6766

6867
/* Initializer values for message structs */
6968
#define google_crashlytics_Report_init_default {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_default}
70-
#define google_crashlytics_FilesPayload_init_default {0, NULL, NULL}
69+
#define google_crashlytics_FilesPayload_init_default {0, NULL}
7170
#define google_crashlytics_FilesPayload_File_init_default {NULL, NULL}
7271
#define google_crashlytics_Report_init_zero {NULL, NULL, _google_crashlytics_Platforms_MIN, NULL, NULL, NULL, google_crashlytics_FilesPayload_init_zero}
73-
#define google_crashlytics_FilesPayload_init_zero {0, NULL, NULL}
72+
#define google_crashlytics_FilesPayload_init_zero {0, NULL}
7473
#define google_crashlytics_FilesPayload_File_init_zero {NULL, NULL}
7574

7675
/* Field tags (for use in manual encoding/decoding) */
7776
#define google_crashlytics_FilesPayload_files_tag 1
78-
#define google_crashlytics_FilesPayload_org_id_tag 2
7977
#define google_crashlytics_FilesPayload_File_filename_tag 1
8078
#define google_crashlytics_FilesPayload_File_contents_tag 2
8179
#define google_crashlytics_Report_sdk_version_tag 1
@@ -88,7 +86,7 @@ typedef struct _google_crashlytics_Report {
8886

8987
/* Struct field encoding specification for nanopb */
9088
extern const pb_field_t google_crashlytics_Report_fields[8];
91-
extern const pb_field_t google_crashlytics_FilesPayload_fields[3];
89+
extern const pb_field_t google_crashlytics_FilesPayload_fields[2];
9290
extern const pb_field_t google_crashlytics_FilesPayload_File_fields[3];
9391

9492
/* Maximum encoded size of messages (where known) */

Crashlytics/UnitTests/FIRCLSReportAdapterTests.m

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ - (void)testSendProtoReport {
4040

4141
FIRCLSReportAdapter *adapter =
4242
[[FIRCLSReportAdapter alloc] initWithPath:minCrash
43-
googleAppId:@"1:17586535263:ios:83778f4dc7e8a26ef794ea"
44-
orgId:@"5bec84f69ea6961d03000dc5"];
43+
googleAppId:@"1:17586535263:ios:83778f4dc7e8a26ef794ea"];
4544

4645
GDTCORTransport *transport = [[GDTCORTransport alloc] initWithMappingID:@"1206"
4746
transformers:nil
@@ -59,8 +58,7 @@ - (void)testProtoOutput {
5958

6059
FIRCLSReportAdapter *adapter =
6160
[[FIRCLSReportAdapter alloc] initWithPath:minCrash
62-
googleAppId:@"1:17586535263:ios:83778f4dc7e8a26ef794ea"
63-
orgId:@"5bec84f69ea6961d03000dc5"];
61+
googleAppId:@"1:17586535263:ios:83778f4dc7e8a26ef794ea"];
6462

6563
NSData *data = adapter.transportBytes;
6664

@@ -81,8 +79,7 @@ - (void)testProtoOutput {
8179
/// Verify various invalid input cases.
8280
- (void)testInvalidRecordCases {
8381
id adapter __unused = [[FIRCLSReportAdapter alloc] initWithPath:@"nonExistentPath"
84-
googleAppId:@"appID"
85-
orgId:@"orgID"];
82+
googleAppId:@"appID"];
8683

8784
id application __unused = [[FIRCLSRecordApplication alloc] initWithDict:nil];
8885
id host __unused = [[FIRCLSRecordHost alloc] initWithDict:nil];
@@ -125,7 +122,6 @@ - (void)testReportProto {
125122
equalToString:adapter.application.display_version]);
126123

127124
// Files payload
128-
XCTAssertTrue([self isPBData:report.apple_payload.org_id equalToString:@"orgID"]);
129125
XCTAssertEqual(report.apple_payload.files_count, 10);
130126

131127
NSArray<NSString *> *clsRecords = adapter.clsRecordFilePaths;
@@ -144,24 +140,21 @@ + (FIRCLSReportAdapter *)adapterForAllCrashes {
144140
return [[FIRCLSReportAdapter alloc]
145141
initWithPath:[[FIRCLSReportAdapterTests resourcePath]
146142
stringByAppendingPathComponent:@"ios_all_files_crash"]
147-
googleAppId:@"appID"
148-
orgId:@"orgID"];
143+
googleAppId:@"appID"];
149144
}
150145

151146
+ (FIRCLSReportAdapter *)adapterForCorruptMetadata {
152147
return [[FIRCLSReportAdapter alloc]
153148
initWithPath:[[FIRCLSReportAdapterTests resourcePath]
154149
stringByAppendingPathComponent:@"corrupt_metadata"]
155-
googleAppId:@"appID"
156-
orgId:@"orgID"];
150+
googleAppId:@"appID"];
157151
}
158152

159153
+ (FIRCLSReportAdapter *)adapterForValidMetadata {
160154
return [[FIRCLSReportAdapter alloc]
161155
initWithPath:[[FIRCLSReportAdapterTests resourcePath]
162156
stringByAppendingPathComponent:@"valid_metadata"]
163-
googleAppId:@"appID"
164-
orgId:@"orgID"];
157+
googleAppId:@"appID"];
165158
}
166159

167160
+ (NSString *)resourcePath {

0 commit comments

Comments
 (0)