use of com.microsoft.azure.mobile.analytics.ingestion.models.PageLog in project mobile-center-sdk-android by Microsoft.
the class Analytics method queuePage.
/**
* Send a page.
*
* @param name page name.
* @param properties optional properties.
*/
private synchronized void queuePage(String name, Map<String, String> properties) {
if (isInactive())
return;
PageLog pageLog = new PageLog();
pageLog.setName(name);
pageLog.setProperties(properties);
mChannel.enqueue(pageLog, ANALYTICS_GROUP);
}
use of com.microsoft.azure.mobile.analytics.ingestion.models.PageLog in project mobile-center-sdk-android by Microsoft.
the class AnalyticsTest method startSessionAfterUserApproval.
@Test
public void startSessionAfterUserApproval() {
/*
* Disable analytics while in background to set up the initial condition
* simulating the optin use case.
*/
Analytics analytics = Analytics.getInstance();
Channel channel = mock(Channel.class);
analytics.onStarted(mock(Context.class), "", channel);
Analytics.setEnabled(false);
/* App in foreground: no log yet, we are disabled. */
analytics.onActivityResumed(new Activity());
verify(channel, never()).enqueue(any(Log.class), eq(analytics.getGroupName()));
/* Enable: start session sent retroactively. */
Analytics.setEnabled(true);
verify(channel).enqueue(argThat(new ArgumentMatcher<Log>() {
@Override
public boolean matches(Object argument) {
return argument instanceof StartSessionLog;
}
}), eq(analytics.getGroupName()));
verify(channel).enqueue(argThat(new ArgumentMatcher<Log>() {
@Override
public boolean matches(Object argument) {
return argument instanceof PageLog;
}
}), eq(analytics.getGroupName()));
/* Go background. */
analytics.onActivityPaused(new Activity());
/* Disable/enable: nothing happens on background. */
Analytics.setEnabled(false);
Analytics.setEnabled(true);
/* No additional log. */
verify(channel, times(2)).enqueue(any(Log.class), eq(analytics.getGroupName()));
}
Aggregations