Skip to content

Commit b02cc4f

Browse files
authored
Revert "Crashlytics Add Internal Keys feature for Unity Metadata (#2671)"
This reverts commit 79c1305.
1 parent 3145da7 commit b02cc4f

File tree

10 files changed

+70
-212
lines changed

10 files changed

+70
-212
lines changed

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common/MetaDataStoreTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -222,33 +222,6 @@ public void testWriteKeys_readDifferentSession() {
222222
assertEquals(0, readKeys.size());
223223
}
224224

225-
// Ensures the Internal Keys and User Custom Keys are stored separately
226-
public void testWriteKeys_readSeparateFromUser() {
227-
final Map<String, String> keys =
228-
new HashMap<String, String>() {
229-
{
230-
put(KEY_1, VALUE_1);
231-
}
232-
};
233-
234-
final Map<String, String> internalKeys =
235-
new HashMap<String, String>() {
236-
{
237-
put(KEY_2, VALUE_2);
238-
put(KEY_3, VALUE_3);
239-
}
240-
};
241-
242-
storeUnderTest.writeKeyData(SESSION_ID_1, keys);
243-
storeUnderTest.writeKeyData(SESSION_ID_1, internalKeys, /*isInternal=*/ true);
244-
245-
final Map<String, String> readKeys = storeUnderTest.readKeyData(SESSION_ID_1);
246-
final Map<String, String> readInternalKeys = storeUnderTest.readKeyData(SESSION_ID_1, true);
247-
248-
assertEqualMaps(keys, readKeys);
249-
assertEqualMaps(internalKeys, readInternalKeys);
250-
}
251-
252225
public void testReadKeys_noStoredData() {
253226
final Map<String, String> readKeys = storeUnderTest.readKeyData(SESSION_ID_1);
254227
assertEquals(0, readKeys.size());

firebase-crashlytics/src/androidTest/java/com/google/firebase/crashlytics/internal/common/SessionReportingCoordinatorTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,11 @@ public void testNonFatalEvent_addsSortedKeysToEvent() {
229229
ImmutableList.from(customAttribute1, customAttribute2);
230230

231231
when(reportMetadata.getCustomKeys()).thenReturn(attributes);
232-
when(reportMetadata.getInternalKeys()).thenReturn(attributes);
233232

234233
reportingCoordinator.onBeginSession(sessionId, timestamp);
235234
reportingCoordinator.persistNonFatalEvent(mockException, mockThread, sessionId, timestamp);
236235

237236
verify(mockEventAppBuilder).setCustomAttributes(expectedCustomAttributes);
238-
verify(mockEventAppBuilder).setInternalKeys(expectedCustomAttributes);
239237
verify(mockEventAppBuilder).build();
240238
verify(mockEventBuilder).setApp(mockEventApp);
241239
verify(mockEventBuilder).build();
@@ -290,13 +288,11 @@ public void testFatalEvent_addsSortedKeysToEvent() {
290288
ImmutableList.from(customAttribute1, customAttribute2);
291289

292290
when(reportMetadata.getCustomKeys()).thenReturn(attributes);
293-
when(reportMetadata.getInternalKeys()).thenReturn(attributes);
294291

295292
reportingCoordinator.onBeginSession(sessionId, timestamp);
296293
reportingCoordinator.persistFatalEvent(mockException, mockThread, sessionId, timestamp);
297294

298295
verify(mockEventAppBuilder).setCustomAttributes(expectedCustomAttributes);
299-
verify(mockEventAppBuilder).setInternalKeys(expectedCustomAttributes);
300296
verify(mockEventAppBuilder).build();
301297
verify(mockEventBuilder).setApp(mockEventApp);
302298
verify(mockEventBuilder).build();
@@ -465,7 +461,6 @@ private void mockEventInteractions() {
465461
when(mockEvent.getApp()).thenReturn(mockEventApp);
466462
when(mockEventApp.toBuilder()).thenReturn(mockEventAppBuilder);
467463
when(mockEventAppBuilder.setCustomAttributes(any())).thenReturn(mockEventAppBuilder);
468-
when(mockEventAppBuilder.setInternalKeys(any())).thenReturn(mockEventAppBuilder);
469464
when(mockEventAppBuilder.build()).thenReturn(mockEventApp);
470465
when(dataCapture.captureEventData(
471466
any(Throwable.class),

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/CrashlyticsController.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -434,28 +434,14 @@ void setCustomKey(String key, String value) {
434434
return;
435435
}
436436
}
437-
cacheKeyData(userMetadata.getCustomKeys(), false);
437+
cacheKeyData(userMetadata.getCustomKeys());
438438
}
439439

440440
void setCustomKeys(Map<String, String> keysAndValues) {
441441
// Write all the key/value pairs before doing anything computationally expensive.
442442
userMetadata.setCustomKeys(keysAndValues);
443443
// Once all the key/value pairs are added, update the cache.
444-
cacheKeyData(userMetadata.getCustomKeys(), false);
445-
}
446-
447-
void setInternalKey(String key, String value) {
448-
try {
449-
userMetadata.setInternalKey(key, value);
450-
} catch (IllegalArgumentException ex) {
451-
if (context != null && CommonUtils.isAppDebuggable(context)) {
452-
throw ex;
453-
} else {
454-
Logger.getLogger().e("Attempting to set custom attribute with null key, ignoring.");
455-
return;
456-
}
457-
}
458-
cacheKeyData(userMetadata.getInternalKeys(), true);
444+
cacheKeyData(userMetadata.getCustomKeys());
459445
}
460446

461447
/**
@@ -489,13 +475,13 @@ public Void call() throws Exception {
489475
* crash happens immediately after setting a value. If this becomes a problem, we can investigate
490476
* writing synchronously, or potentially add an explicit user-facing API for synchronous writes.
491477
*/
492-
private void cacheKeyData(final Map<String, String> keyData, boolean isInternal) {
478+
private void cacheKeyData(final Map<String, String> keyData) {
493479
backgroundWorker.submit(
494480
new Callable<Void>() {
495481
@Override
496482
public Void call() throws Exception {
497483
final String currentSessionId = getCurrentSessionId();
498-
new MetaDataStore(getFilesDir()).writeKeyData(currentSessionId, keyData, isInternal);
484+
new MetaDataStore(getFilesDir()).writeKeyData(currentSessionId, keyData);
499485
return null;
500486
}
501487
});

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/CrashlyticsCore.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public boolean onPreExecute(AppData appData, SettingsDataProvider settingsProvid
131131
initializationMarker = new CrashlyticsFileMarker(INITIALIZATION_MARKER_FILE_NAME, fileStore);
132132

133133
final UserMetadata userMetadata = new UserMetadata();
134+
134135
final LogFileDirectoryProvider logFileDirectoryProvider =
135136
new LogFileDirectoryProvider(fileStore);
136137
final LogFileManager logFileManager = new LogFileManager(context, logFileDirectoryProvider);
@@ -346,22 +347,6 @@ public void setCustomKeys(Map<String, String> keysAndValues) {
346347
controller.setCustomKeys(keysAndValues);
347348
}
348349

349-
/**
350-
* Set a value to be associated with a given key for your crash data. The key/value pairs will be
351-
* reported with any crash that occurs in this session. A maximum of 64 key/value pairs can be
352-
* stored for any type. New keys added over that limit will be ignored. Keys and values are
353-
* trimmed ({@link String#trim()}), and keys or values that exceed 1024 characters will be
354-
* truncated.
355-
*
356-
* <p>IMPORTANT: This method is accessed via reflection and JNI. Do not change the type without
357-
* updating the SDKs that depend on it.
358-
*
359-
* @throws NullPointerException if key is null.
360-
*/
361-
public void setInternalKey(String key, String value) {
362-
controller.setInternalKey(key, value);
363-
}
364-
365350
// endregion
366351

367352
// region Package-protected getters

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/KeysMap.java

Lines changed: 0 additions & 104 deletions
This file was deleted.

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/MetaDataStore.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class MetaDataStore {
4141

4242
private static final String USERDATA_SUFFIX = "user";
4343
private static final String KEYDATA_SUFFIX = "keys";
44-
private static final String INTERNAL_KEYDATA_SUFFIX = "internal-keys";
4544
private static final String METADATA_EXT = ".meta";
4645

4746
private static final String KEY_USER_ID = "userId";
@@ -86,12 +85,7 @@ public UserMetadata readUserData(String sessionId) {
8685
}
8786

8887
public void writeKeyData(String sessionId, Map<String, String> keyData) {
89-
writeKeyData(sessionId, keyData, false);
90-
}
91-
92-
void writeKeyData(String sessionId, Map<String, String> keyData, boolean isInternal) {
93-
final File f =
94-
isInternal ? getInternalKeysFileForSession(sessionId) : getKeysFileForSession(sessionId);
88+
final File f = getKeysFileForSession(sessionId);
9589
Writer writer = null;
9690
try {
9791
final String keyDataString = keysDataToJson(keyData);
@@ -106,12 +100,7 @@ void writeKeyData(String sessionId, Map<String, String> keyData, boolean isInter
106100
}
107101

108102
public Map<String, String> readKeyData(String sessionId) {
109-
return readKeyData(sessionId, false);
110-
}
111-
112-
Map<String, String> readKeyData(String sessionId, boolean isInternal) {
113-
final File f =
114-
isInternal ? getInternalKeysFileForSession(sessionId) : getKeysFileForSession(sessionId);
103+
final File f = getKeysFileForSession(sessionId);
115104
if (!f.exists()) {
116105
return Collections.emptyMap();
117106
}
@@ -138,11 +127,6 @@ public File getKeysFileForSession(String sessionId) {
138127
return new File(filesDir, sessionId + KEYDATA_SUFFIX + METADATA_EXT);
139128
}
140129

141-
@NonNull
142-
public File getInternalKeysFileForSession(String sessionId) {
143-
return new File(filesDir, sessionId + INTERNAL_KEYDATA_SUFFIX + METADATA_EXT);
144-
}
145-
146130
private static UserMetadata jsonToUserData(String json) throws JSONException {
147131
final JSONObject dataObj = new JSONObject(json);
148132
UserMetadata metadata = new UserMetadata();

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/SessionReportingCoordinator.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,13 @@ private void persistEvent(
220220

221221
final List<CustomAttribute> sortedCustomAttributes =
222222
getSortedCustomAttributes(reportMetadata.getCustomKeys());
223-
final List<CustomAttribute> sortedInternalKeys =
224-
getSortedCustomAttributes(reportMetadata.getInternalKeys());
225223

226224
if (!sortedCustomAttributes.isEmpty()) {
227225
eventBuilder.setApp(
228226
capturedEvent
229227
.getApp()
230228
.toBuilder()
231229
.setCustomAttributes(ImmutableList.from(sortedCustomAttributes))
232-
.setInternalKeys(ImmutableList.from(sortedInternalKeys))
233230
.build());
234231
}
235232

0 commit comments

Comments
 (0)