예제 #1
0
void HelloWorld::eventMenuCallback(CCObject* pSender)
{
    CCMenuItemLabel* pMenuItem = (CCMenuItemLabel*)pSender;
    AnalyticsUmeng* pUmeng = dynamic_cast<AnalyticsUmeng*>(g_pAnalytics);
    AnalyticsFlurry* pFlurry = dynamic_cast<AnalyticsFlurry*>(g_pAnalytics);

    switch (pMenuItem->getTag())
    {
    case TAG_LOG_EVENT_ID:
        {
            g_pAnalytics->logEvent("click");
            g_pAnalytics->logEvent("music");
        }
        break;
    case TAG_LOG_EVENT_ID_KV:
        {
            LogEventParamMap paramMap;
            paramMap.insert(LogEventParamPair("type", "popular"));
            paramMap.insert(LogEventParamPair("artist", "JJLin"));
            g_pAnalytics->logEvent("music", &paramMap);
        }
        break;
    case TAG_LOG_ONLINE_CONFIG:
        {
            if (pUmeng != NULL)
            {
                CCLog("Online config = %s", pUmeng->getConfigParams("abc"));           
            }
            else
            {
                CCLog("Now is not using umeng!");
            }
        }
        break;
    case TAG_LOG_EVENT_ID_DURATION:
        {
            if (pUmeng != NULL)
            {
                pUmeng->logEventWithDuration("book", 12000);
                pUmeng->logEventWithDuration("book", 23000, "chapter1");
                LogEventParamMap paramMap;
                paramMap.insert(LogEventParamPair("type", "popular"));
                paramMap.insert(LogEventParamPair("artist", "JJLin"));
                pUmeng->logEventWithDuration("music", 2330000, &paramMap);
            }
            else
            {
                CCLog("Now is not using umeng!");
            }
        }
        break;
    case TAG_LOG_EVENT_BEGIN:
        {
            g_pAnalytics->logTimedEventBegin("music");

            LogEventParamMap paramMap;
            paramMap.insert(LogEventParamPair("type", "popular"));
            paramMap.insert(LogEventParamPair("artist", "JJLin"));

            if (pUmeng != NULL)
            {
                pUmeng->logTimedEventWithLabelBegin("music", "one");
                pUmeng->logTimedKVEventBegin("music", "flag0", &paramMap);
            }
            else if (pFlurry != NULL)
            {
                pFlurry->logTimedEventBegin("music-kv", &paramMap);
            }
        }
        break;
    case TAG_LOG_EVENT_END:
        {
            g_pAnalytics->logTimedEventEnd("music");
            if (pUmeng != NULL)
            {          
                pUmeng->logTimedEventWithLabelEnd("music", "one");
                pUmeng->logTimedKVEventEnd("music", "flag0");
            }
            else if (pFlurry != NULL)
            {
                pFlurry->logTimedEventEnd("music-kv");
            }
        }
        break;
    case TAG_MAKE_ME_CRASH:
        {
            char* pNull = NULL;
            *pNull = 0;
        }
        break;
    default:
        break;
    }
}
void TestAnalytics::eventMenuCallback(Object* pSender)
{
    MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;

    switch (pMenuItem->getTag())
    {
    case TAG_LOG_EVENT_ID:
        {
            _pluginAnalytics->logEvent("click");
            _pluginAnalytics->logEvent("music");
        }
        break;
    case TAG_LOG_EVENT_ID_KV:
        {
            LogEventParamMap paramMap;
            paramMap.insert(LogEventParamPair("type", "popular"));
            paramMap.insert(LogEventParamPair("artist", "JJLin"));
            _pluginAnalytics->logEvent("music", &paramMap);
        }
        break;
    case TAG_LOG_ONLINE_CONFIG:
        {
            PluginParam param("abc");
            log("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", &param, NULL).c_str());
        }
        break;
    case TAG_LOG_EVENT_ID_DURATION:
        {
            PluginParam event1("book");
            PluginParam dura1(12000);
            _pluginAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL);

            PluginParam event2("book");
            PluginParam dura2(12000);
            PluginParam label("chapter1");
            _pluginAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL);

            PluginParam event3("music");
            PluginParam dura3(2330000);
            LogEventParamMap paramMap;
            paramMap.insert(LogEventParamPair("type", "popular"));
            paramMap.insert(LogEventParamPair("artist", "JJLin"));
            PluginParam mapValue(paramMap);
            _pluginAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL);
        }
        break;
    case TAG_LOG_EVENT_BEGIN:
        {
            _pluginAnalytics->logTimedEventBegin("music");

            PluginParam event1("music");
            PluginParam label1("one");
            _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL);

            PluginParam event2("music");
            PluginParam label2("flag0");
            LogEventParamMap paramMap;
            paramMap.insert(LogEventParamPair("type", "popular"));
            paramMap.insert(LogEventParamPair("artist", "JJLin"));
            PluginParam mapValue(paramMap);
            _pluginAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL);

            PluginParam event3("music-kv");
            _pluginAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL);
        }
        break;
    case TAG_LOG_EVENT_END:
        {
            _pluginAnalytics->logTimedEventEnd("music");

            PluginParam event1("music");
            PluginParam label1("one");
            _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL);

            PluginParam event2("music");
            PluginParam label2("flag0");
            _pluginAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL);

            PluginParam event3("music-kv");
            _pluginAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL);
        }
        break;
    case TAG_MAKE_ME_CRASH:
        {
            char* pNull = NULL;
            *pNull = 0;
        }
        break;
    default:
        break;
    }
}