Search in sources :

Example 1 with Event

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());
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)

Example 2 with Event

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);
}
Also used : ArrayList(java.util.ArrayList) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) IOException(java.io.IOException) File(java.io.File)

Aggregations

Event (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event)2 CrashlyticsReportWithSessionId (com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)1 CrashlyticsReport (com.google.firebase.crashlytics.internal.model.CrashlyticsReport)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1