Search in sources :

Example 6 with PageLog

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);
}
Also used : PageLog(com.microsoft.azure.mobile.analytics.ingestion.models.PageLog)

Example 7 with PageLog

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()));
}
Also used : Context(android.content.Context) StartSessionLog(com.microsoft.azure.mobile.analytics.ingestion.models.StartSessionLog) MobileCenterLog(com.microsoft.azure.mobile.utils.MobileCenterLog) Log(com.microsoft.azure.mobile.ingestion.models.Log) PageLog(com.microsoft.azure.mobile.analytics.ingestion.models.PageLog) StartSessionLog(com.microsoft.azure.mobile.analytics.ingestion.models.StartSessionLog) EventLog(com.microsoft.azure.mobile.analytics.ingestion.models.EventLog) PageLog(com.microsoft.azure.mobile.analytics.ingestion.models.PageLog) Channel(com.microsoft.azure.mobile.channel.Channel) ArgumentMatcher(org.mockito.ArgumentMatcher) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PageLog (com.microsoft.azure.mobile.analytics.ingestion.models.PageLog)7 Context (android.content.Context)4 EventLog (com.microsoft.azure.mobile.analytics.ingestion.models.EventLog)4 StartSessionLog (com.microsoft.azure.mobile.analytics.ingestion.models.StartSessionLog)4 Channel (com.microsoft.azure.mobile.channel.Channel)4 Test (org.junit.Test)4 ArgumentMatcher (org.mockito.ArgumentMatcher)4 Log (com.microsoft.azure.mobile.ingestion.models.Log)3 MobileCenterLog (com.microsoft.azure.mobile.utils.MobileCenterLog)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Log (android.util.Log)1 AnalyticsListener (com.microsoft.azure.mobile.analytics.channel.AnalyticsListener)1 EventLogFactory (com.microsoft.azure.mobile.analytics.ingestion.models.json.EventLogFactory)1 PageLogFactory (com.microsoft.azure.mobile.analytics.ingestion.models.json.PageLogFactory)1 StartSessionLogFactory (com.microsoft.azure.mobile.analytics.ingestion.models.json.StartSessionLogFactory)1 Device (com.microsoft.azure.mobile.ingestion.models.Device)1 LogContainer (com.microsoft.azure.mobile.ingestion.models.LogContainer)1 LogWithProperties (com.microsoft.azure.mobile.ingestion.models.LogWithProperties)1 DefaultLogSerializer (com.microsoft.azure.mobile.ingestion.models.json.DefaultLogSerializer)1 LogSerializer (com.microsoft.azure.mobile.ingestion.models.json.LogSerializer)1