use of com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog in project AppCenter-SDK-Android by Microsoft.
the class DistributeSerializerTest method serialize.
@Test
public void serialize() throws JSONException {
LogContainer expectedContainer = new LogContainer();
List<Log> logs = new ArrayList<>();
{
DistributionStartSessionLog log = new DistributionStartSessionLog();
log.setTimestamp(new Date());
logs.add(log);
}
expectedContainer.setLogs(logs);
UUID sid = UUIDUtils.randomUUID();
for (Log log : logs) {
log.setSid(sid);
}
/* Serialize and deserialize logs container. */
LogSerializer serializer = new DefaultLogSerializer();
serializer.addLogFactory(DistributionStartSessionLog.TYPE, new DistributionStartSessionLogFactory());
String payload = serializer.serializeContainer(expectedContainer);
LogContainer actualContainer = serializer.deserializeContainer(payload);
/* Verify that logs container successfully deserialized. */
Assert.assertEquals(expectedContainer, actualContainer);
}
use of com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog in project AppCenter-SDK-Android by Microsoft.
the class Distribute method enqueueDistributionStartSessionLog.
/**
* Send distribution start session log after enabling in-app updates (first app launch after installation).
*/
private synchronized void enqueueDistributionStartSessionLog() {
/*
* Session starts before in-app updates setup (using browser) so the first start session log
* is sent without distributionGroupId value.
*
* Send the distribution start session log if start session log without distributionGroupId
* value was sent before
*/
SessionContext.SessionInfo lastSession = SessionContext.getInstance().getSessionAt(System.currentTimeMillis());
if (lastSession == null || lastSession.getSessionId() == null) {
AppCenterLog.debug(DistributeConstants.LOG_TAG, "No sessions were logged before, ignore sending of the distribution start session log.");
return;
}
post(new Runnable() {
@Override
public void run() {
DistributionStartSessionLog log = new DistributionStartSessionLog();
mChannel.enqueue(log, DISTRIBUTE_GROUP);
}
});
}
use of com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog in project mobile-center-sdk-android by Microsoft.
the class DistributeSerializerTest method serialize.
@Test
public void serialize() throws JSONException {
LogContainer expectedContainer = new LogContainer();
List<Log> logs = new ArrayList<>();
{
DistributionStartSessionLog log = new DistributionStartSessionLog();
log.setTimestamp(new Date());
logs.add(log);
}
expectedContainer.setLogs(logs);
UUID sid = UUID.randomUUID();
for (Log log : logs) {
log.setSid(sid);
}
/* Serialize and deserialize logs container. */
LogSerializer serializer = new DefaultLogSerializer();
serializer.addLogFactory(DistributionStartSessionLog.TYPE, new DistributionStartSessionLogFactory());
String payload = serializer.serializeContainer(expectedContainer);
LogContainer actualContainer = serializer.deserializeContainer(payload, null);
/* Verify that logs container successfully deserialized. */
Assert.assertEquals(expectedContainer, actualContainer);
}
use of com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog in project mobile-center-sdk-android by Microsoft.
the class Distribute method enqueueDistributionStartSessionLog.
/**
* Send distribution start session log after enabling in-app updates (first app launch after installation).
*/
private synchronized void enqueueDistributionStartSessionLog() {
/*
* Session starts before in-app updates setup (using browser) so the first start session log
* is sent without distributionGroupId value.
*
* Send the distribution start session log if start session log without distributionGroupId
* value was sent before
*/
SessionContext.SessionInfo lastSession = SessionContext.getInstance().getSessionAt(System.currentTimeMillis());
if (lastSession == null || lastSession.getSessionId() == null) {
AppCenterLog.debug(LOG_TAG, "No sessions were logged before, ignore sending of the distribution start session log.");
return;
}
post(new Runnable() {
@Override
public void run() {
DistributionStartSessionLog log = new DistributionStartSessionLog();
mChannel.enqueue(log, DISTRIBUTE_GROUP, Flags.DEFAULTS);
}
});
}
Aggregations