Search in sources :

Example 1 with Session

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistence method synthesizeReportFile.

private void synthesizeReportFile(@NonNull File reportFile, @NonNull List<Event> events, long sessionEndTime, boolean isHighPriorityReport, @Nullable String userId) {
    try {
        CrashlyticsReport report = TRANSFORM.reportFromJson(readTextFile(reportFile)).withSessionEndFields(sessionEndTime, isHighPriorityReport, userId).withEvents(ImmutableList.from(events));
        final Session session = report.getSession();
        if (session == null) {
            // This shouldn't happen, but is a valid state for NDK-based reports
            return;
        }
        File finalizedReportFile = isHighPriorityReport ? fileStore.getPriorityReport(session.getIdentifier()) : fileStore.getReport(session.getIdentifier());
        writeTextFile(finalizedReportFile, TRANSFORM.reportToJson(report));
    } catch (IOException e) {
        Logger.getLogger().w("Could not synthesize final report file for " + reportFile, e);
    }
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) IOException(java.io.IOException) File(java.io.File) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 2 with Session

use of com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistence method persistReport.

public void persistReport(@NonNull CrashlyticsReport report) {
    final Session session = report.getSession();
    if (session == null) {
        Logger.getLogger().d("Could not get session for report");
        return;
    }
    final String sessionId = session.getIdentifier();
    try {
        final String json = TRANSFORM.reportToJson(report);
        writeTextFile(fileStore.getSessionFile(sessionId, REPORT_FILE_NAME), json);
        writeTextFile(fileStore.getSessionFile(sessionId, SESSION_START_TIMESTAMP_FILE_NAME), "", session.getStartedAt());
    } catch (IOException e) {
        Logger.getLogger().d("Could not persist report for session " + sessionId, e);
    }
}
Also used : IOException(java.io.IOException) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Aggregations

Session (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)2 IOException (java.io.IOException)2 CrashlyticsReport (com.google.firebase.crashlytics.internal.model.CrashlyticsReport)1 File (java.io.File)1