use of com.microsoft.appcenter.ingestion.models.StartServiceLog in project mobile-center-sdk-android by Microsoft.
the class AppCenter method sendStartServiceLog.
/**
* Queue start service log.
*/
@WorkerThread
private void sendStartServiceLog() {
if (!mStartedServicesNamesToLog.isEmpty() && isInstanceEnabled()) {
List<String> allServiceNamesToStart = new ArrayList<>(mStartedServicesNamesToLog);
mStartedServicesNamesToLog.clear();
StartServiceLog startServiceLog = new StartServiceLog();
startServiceLog.setServices(allServiceNamesToStart);
startServiceLog.oneCollectorEnabled(mTransmissionTargetToken != null);
mChannel.enqueue(startServiceLog, CORE_GROUP, Flags.DEFAULTS);
}
}
use of com.microsoft.appcenter.ingestion.models.StartServiceLog in project mobile-center-sdk-android by Microsoft.
the class AppCenter method sendStartServiceLog.
/**
* Queue start service log.
*
* @param serviceNames the services to send.
*/
@WorkerThread
private void sendStartServiceLog(List<String> serviceNames) {
if (isInstanceEnabled()) {
StartServiceLog startServiceLog = new StartServiceLog();
startServiceLog.setServices(serviceNames);
mChannel.enqueue(startServiceLog, CORE_GROUP);
} else {
if (mStartedServicesNamesToLog == null) {
mStartedServicesNamesToLog = new ArrayList<>();
}
mStartedServicesNamesToLog.addAll(serviceNames);
}
}
use of com.microsoft.appcenter.ingestion.models.StartServiceLog in project AppCenter-SDK-Android by Microsoft.
the class LogSerializerAndroidTest method startServiceLog.
@Test
public void startServiceLog() throws JSONException {
StartServiceLog log = new StartServiceLog();
List<String> services = new ArrayList<>();
services.add("FIRST");
services.add("SECOND");
log.setServices(services);
UUID sid = UUIDUtils.randomUUID();
log.setSid(sid);
log.setTimestamp(new Date());
/* Verify serialize and deserialize. */
LogSerializer serializer = new DefaultLogSerializer();
serializer.addLogFactory(StartServiceLog.TYPE, new StartServiceLogFactory());
String payload = serializer.serializeLog(log);
Log actualContainer = serializer.deserializeLog(payload);
Assert.assertEquals(log, actualContainer);
}
use of com.microsoft.appcenter.ingestion.models.StartServiceLog in project AppCenter-SDK-Android by Microsoft.
the class SessionTrackerTest method ignoreStartService.
@Test
public void ignoreStartService() {
Log startServiceLog = spy(new StartServiceLog());
mSessionTracker.onEnqueuingLog(startServiceLog, TEST_GROUP);
verify(mChannel, never()).enqueue(any(Log.class), anyString());
verify(startServiceLog, never()).setSid(any(UUID.class));
}
use of com.microsoft.appcenter.ingestion.models.StartServiceLog in project AppCenter-SDK-Android by Microsoft.
the class SessionTracker method onEnqueuingLog.
@Override
public void onEnqueuingLog(@NonNull Log log, @NonNull String groupName) {
/*
* Since we enqueue start session logs, skip them to avoid infinite loop.
* Also skip start service log as it's always sent and should not trigger a session.
*/
if (log instanceof StartSessionLog || log instanceof StartServiceLog) {
return;
}
/*
* If the log has already specified a timestamp, try correlating with a past session.
* Note that it can also find the current session but that's ok: in that case that means
* its a log that will be associated to current session but won't trigger expiration logic.
*/
Date timestamp = log.getTimestamp();
if (timestamp != null) {
SessionContext.SessionInfo pastSession = SessionContext.getInstance().getSessionAt(timestamp.getTime());
if (pastSession != null) {
log.setSid(pastSession.getSessionId());
}
} else /* If the log does not have a timestamp yet, then we just correlate with current session. */
{
/* Send a new start session log if needed. */
sendStartSessionIfNeeded();
/* Set current session identifier. */
log.setSid(mSid);
/* Record queued time only if the log is using current session. */
mLastQueuedLogTime = SystemClock.elapsedRealtime();
}
}
Aggregations