Search in sources :

Example 1 with CrashlyticsReportWithSessionId

use of com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId in project GreenHouse by utsanjan.

the class DataTransportCrashlyticsReportSender method sendReport.

public Task<CrashlyticsReportWithSessionId> sendReport(CrashlyticsReportWithSessionId reportWithSessionId) {
    CrashlyticsReport report = reportWithSessionId.getReport();
    TaskCompletionSource<CrashlyticsReportWithSessionId> tcs = new TaskCompletionSource<>();
    this.transport.schedule(Event.ofUrgent(report), DataTransportCrashlyticsReportSender$$Lambda$1.lambdaFactory$(tcs, reportWithSessionId));
    return tcs.getTask();
}
Also used : TaskCompletionSource(com.google.android.gms.tasks.TaskCompletionSource) CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)

Example 2 with CrashlyticsReportWithSessionId

use of com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId in project firebase-android-sdk by firebase.

the class DataTransportCrashlyticsReportSender method sendReport.

@NonNull
public Task<CrashlyticsReportWithSessionId> sendReport(@NonNull CrashlyticsReportWithSessionId reportWithSessionId) {
    final CrashlyticsReport report = reportWithSessionId.getReport();
    TaskCompletionSource<CrashlyticsReportWithSessionId> tcs = new TaskCompletionSource<>();
    transport.schedule(Event.ofUrgent(report), error -> {
        if (error != null) {
            tcs.trySetException(error);
            return;
        }
        tcs.trySetResult(reportWithSessionId);
    });
    return tcs.getTask();
}
Also used : TaskCompletionSource(com.google.android.gms.tasks.TaskCompletionSource) CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId) NonNull(androidx.annotation.NonNull)

Example 3 with CrashlyticsReportWithSessionId

use of com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testLoadFinalizedReports_reportWithUserId_returnsReportWithProperUserId.

public void testLoadFinalizedReports_reportWithUserId_returnsReportWithProperUserId() {
    final String sessionId = "testSession";
    final String userId = "testUser";
    final CrashlyticsReport testReport = makeTestReport(sessionId, userId);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId);
    reportPersistence.finalizeReports("skippedSession", 0L);
    final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
    assertEquals(1, finalizedReports.size());
    final CrashlyticsReport finalizedReport = finalizedReports.get(0).getReport();
    assertNotNull(finalizedReport.getSession().getUser());
    assertEquals(userId, finalizedReport.getSession().getUser().getIdentifier());
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 4 with CrashlyticsReportWithSessionId

use of com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testLoadFinalizedReports_reportThenEvent_returnsReportWithEvent.

public void testLoadFinalizedReports_reportThenEvent_returnsReportWithEvent() {
    final String sessionId = "testSession";
    final CrashlyticsReport testReport = makeTestReport(sessionId);
    final CrashlyticsReport.Session.Event testEvent = makeTestEvent();
    reportPersistence.persistReport(testReport);
    reportPersistence.persistEvent(testEvent, sessionId);
    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(testReport.withSessionEndFields(endedAt, false, null).withEvents(ImmutableList.from(testEvent)), finalizedReport);
}
Also used : CrashlyticsReport(com.google.firebase.crashlytics.internal.model.CrashlyticsReport) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId) Event(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event) Session(com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)

Example 5 with CrashlyticsReportWithSessionId

use of com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId in project firebase-android-sdk by firebase.

the class CrashlyticsReportPersistenceTest method testFinalizeReports_removesOldestReportsFirst.

public void testFinalizeReports_removesOldestReportsFirst() throws IOException {
    reportPersistence = new CrashlyticsReportPersistence(fileStore, createSettingsProviderMock(4, VERY_LARGE_UPPER_LIMIT));
    for (int i = 0; i < 8; i++) {
        String sessionId = "testSession" + i;
        persistReportWithEvent(reportPersistence, sessionId, true);
    }
    reportPersistence.finalizeReports("skippedSession", 0L);
    final List<CrashlyticsReportWithSessionId> finalizedReports = reportPersistence.loadFinalizedReports();
    assertEquals(4, finalizedReports.size());
    List<String> reportIdentifiers = new ArrayList<>();
    for (CrashlyticsReportWithSessionId finalizedReport : finalizedReports) {
        reportIdentifiers.add(finalizedReport.getSessionId());
    }
    List<String> expectedSessions = Arrays.asList("testSession4", "testSession5", "testSession6", "testSession7");
    List<String> unexpectedSessions = Arrays.asList("testSession0", "testSession1", "testSession2", "testSession3");
    assertTrue(reportIdentifiers.containsAll(expectedSessions));
    for (String unexpectedSession : unexpectedSessions) {
        assertFalse(reportIdentifiers.contains(unexpectedSession));
    }
}
Also used : ArrayList(java.util.ArrayList) CrashlyticsReportWithSessionId(com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)

Aggregations

CrashlyticsReportWithSessionId (com.google.firebase.crashlytics.internal.common.CrashlyticsReportWithSessionId)21 CrashlyticsReport (com.google.firebase.crashlytics.internal.model.CrashlyticsReport)14 Event (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session.Event)8 Session (com.google.firebase.crashlytics.internal.model.CrashlyticsReport.Session)7 ArrayList (java.util.ArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)3 Test (org.junit.Test)3 NonNull (androidx.annotation.NonNull)2 TaskCompletionSource (com.google.android.gms.tasks.TaskCompletionSource)2 Settings (com.google.firebase.crashlytics.internal.settings.Settings)2 FeatureFlagData (com.google.firebase.crashlytics.internal.settings.Settings.FeatureFlagData)2 SettingsProvider (com.google.firebase.crashlytics.internal.settings.SettingsProvider)2 File (java.io.File)2 IOException (java.io.IOException)2 DecimalFormat (java.text.DecimalFormat)2 Logger (com.google.firebase.crashlytics.internal.Logger)1 HashSet (java.util.HashSet)1