Skip to content

Commit a8f8dd9

Browse files
authored
Fix Crashlytics user id serialization bug (#3160)
This fixes a bug caught in post-commit validation of PR #3143. The bug never shipped. Before the earlier refactor, the user id was serialized in two different files on disk: one as a raw id and the other in JSON. In the refactor, this was inadvertedly consolidated to one file path. The result is that when generating a Crashlytics report, the SDK expects a plain text user id in the file, and instead sends up the entire JSON blob as the user id. A follow-on refactor is already underway which will elliminate the need for the redundant file. Until that change is ready, we'll return to using distinct file paths for the two files.
1 parent 5bc0fef commit a8f8dd9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MetaDataStore {
4040

4141
private static final Charset UTF_8 = Charset.forName("UTF-8");
4242

43-
private static final String USERDATA_FILENAME = "user";
43+
private static final String USERDATA_FILENAME = "user-data";
4444
private static final String KEYDATA_FILENAME = "keys";
4545
private static final String INTERNAL_KEYDATA_FILENAME = "internal-keys";
4646

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/persistence/CrashlyticsReportPersistence.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class CrashlyticsReportPersistence {
5454
private static final int MAX_OPEN_SESSIONS = 8;
5555

5656
private static final String REPORT_FILE_NAME = "report";
57-
private static final String USER_FILE_NAME = "user";
57+
private static final String USER_ID_FILE_NAME = "user-id";
5858
// We use the lastModified timestamp of this file to quickly store and access the startTime in ms
5959
// of a session.
6060
private static final String SESSION_START_TIMESTAMP_FILE_NAME = "start-time";
@@ -142,7 +142,7 @@ public void persistEvent(
142142

143143
public void persistUserIdForSession(@NonNull String userId, @NonNull String sessionId) {
144144
try {
145-
writeTextFile(fileStore.getSessionFile(sessionId, USER_FILE_NAME), userId);
145+
writeTextFile(fileStore.getSessionFile(sessionId, USER_ID_FILE_NAME), userId);
146146
} catch (IOException e) {
147147
// Session directory is not guaranteed to exist
148148
Logger.getLogger().w("Could not persist user ID for session " + sessionId, e);
@@ -322,7 +322,7 @@ private void synthesizeReport(String sessionId, long sessionEndTime) {
322322
}
323323

324324
String userId = null;
325-
final File userIdFile = fileStore.getSessionFile(sessionId, USER_FILE_NAME);
325+
final File userIdFile = fileStore.getSessionFile(sessionId, USER_ID_FILE_NAME);
326326
if (userIdFile.isFile()) {
327327
try {
328328
userId = readTextFile(userIdFile);

0 commit comments

Comments
 (0)