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();
}
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();
}
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());
}
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);
}
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));
}
}
Aggregations