use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event in project firebase-android-sdk by firebase.
the class CrashlyticsReportPersistenceTest method testPersistReportWithAnrEvent.
public void testPersistReportWithAnrEvent() throws IOException {
reportPersistence = new CrashlyticsReportPersistence(fileStore, createSettingsProviderMock(VERY_LARGE_UPPER_LIMIT, 4));
final String sessionId = "testSession";
final CrashlyticsReport testReport = makeTestReport(sessionId);
final Event testEvent = makeTestAnrEvent();
reportPersistence.persistReport(testReport);
reportPersistence.persistEvent(testEvent, sessionId, true);
final long endedAt = System.currentTimeMillis();
reportPersistence.finalizeReports("skippedSession", endedAt);
final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
assertEquals(1, finalizedReports.size());
final CrashlyticsReport finalizedReport = finalizedReports.get(0).getReport();
assertEquals(1, finalizedReport.getSession().getEvents().size());
}
use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event in project firebase-android-sdk by firebase.
the class CrashlyticsReportPersistence method synthesizeReport.
private void synthesizeReport(String sessionId, long sessionEndTime) {
List<File> eventFiles = fileStore.getSessionFiles(sessionId, EVENT_FILE_FILTER);
// Only process the session if it has associated events
if (eventFiles.isEmpty()) {
Logger.getLogger().v("Session " + sessionId + " has no events.");
return;
}
Collections.sort(eventFiles);
final List<Event> events = new ArrayList<>();
boolean isHighPriorityReport = false;
for (File eventFile : eventFiles) {
try {
Event event = TRANSFORM.eventFromJson(readTextFile(eventFile));
events.add(event);
isHighPriorityReport = isHighPriorityReport || isHighPriorityEventFile(eventFile.getName());
} catch (IOException e) {
Logger.getLogger().w("Could not add event to report for " + eventFile, e);
}
}
// b/168902195
if (events.isEmpty()) {
Logger.getLogger().w("Could not parse event files for session " + sessionId);
return;
}
String userId = UserMetadata.readUserId(sessionId, fileStore);
final File reportFile = fileStore.getSessionFile(sessionId, REPORT_FILE_NAME);
synthesizeReportFile(reportFile, events, sessionEndTime, isHighPriorityReport, userId);
}
Aggregations