123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- /****************************************************************************
- Copyright (c) 2012-2013 cocos2d-x.org
- http://www.cocos2d-x.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- #import "AnalyticsUmeng.h"
- #import "MobClick.h"
- #define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
- @implementation AnalyticsUmeng
- @synthesize debug = __debug;
- - (void) startSession: (NSString*) appKey
- {
- OUTPUT_LOG(@"Umeng startSession invoked");
- [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
- [MobClick startWithAppkey:appKey];
- }
- - (void) stopSession
- {
- OUTPUT_LOG(@"Umeng stopSession in umeng not available on iOS");
- }
- - (void) setSessionContinueMillis: (long) millis
- {
- OUTPUT_LOG(@"Umeng setSessionContinueMillis in umeng not available on iOS");
- }
- - (void) setCaptureUncaughtException: (BOOL) isEnabled
- {
- OUTPUT_LOG(@"Umeng setCaptureUncaughtException invoked");
- [MobClick setCrashReportEnabled:isEnabled];
- }
- - (void) setDebugMode: (BOOL) isDebugMode
- {
- OUTPUT_LOG(@"Umeng setDebugMode invoked");
- self.debug = isDebugMode;
- [MobClick setLogEnabled:isDebugMode];
- }
- - (void) logError: (NSString*) errorId withMsg:(NSString*) message
- {
- OUTPUT_LOG(@"logError in umeng not available on iOS");
- }
- - (void) logEvent: (NSString*) eventId
- {
- OUTPUT_LOG(@"Umeng logEvent invoked");
- [MobClick event:eventId];
- }
- - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
- {
- OUTPUT_LOG(@"Umeng logEventWithParam invoked");
- if (paramMap != nil) {
- [MobClick event:eventId attributes:paramMap];
- } else {
- [MobClick event:eventId];
- }
- }
- - (void) logTimedEventBegin: (NSString*) eventId
- {
- OUTPUT_LOG(@"Umeng logTimedEventBegin invoked");
- [MobClick beginEvent:eventId];
- }
- - (void) logTimedEventEnd: (NSString*) eventId
- {
- OUTPUT_LOG(@"Umeng logTimedEventEnd invoked");
- [MobClick endEvent:eventId];
- }
- - (NSString*) getSDKVersion
- {
- return @"2.2.0";
- }
- - (NSString*) getPluginVersion
- {
- return @"0.2.0";
- }
- - (void) updateOnlineConfig
- {
- OUTPUT_LOG(@"Umeng updateOnlineConfig invoked");
- [MobClick updateOnlineConfig];
- }
- - (NSString*) getConfigParams: (NSString*) key
- {
- OUTPUT_LOG(@"Umeng getConfigParams invoked (%@)", key);
- return [MobClick getConfigParams:key];
- }
- - (void) logEventWithLabel: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logEventWithLabel invoked (%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSString* label = (NSString*) [params objectForKey:@"Param2"];
- if (label) {
- [MobClick event:eventId label:label];
- } else {
- [MobClick event:eventId];
- }
- }
- - (void) logEventWithDuration: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logEventWithDuration invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"];
- int numDur = [duration intValue];
- [MobClick event:eventId durations:numDur];
- }
- - (void) logEventWithDurationLabel:(NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logEventWithDurationLabel invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"];
- NSString* label = (NSString*) [params objectForKey:@"Param3"];
- int numDur = [duration intValue];
- if (! label) {
- [MobClick event:eventId durations:numDur];
- } else {
- [MobClick event:eventId label:label durations:numDur];
- }
- }
- - (void) logEventWithDurationParams: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logEventWithDurationParams invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSNumber* duration = (NSNumber*) [params objectForKey:@"Param2"];
- NSMutableDictionary* paramMap = (NSMutableDictionary*) [params objectForKey:@"Param3"];
- int numDur = [duration intValue];
- if (! paramMap) {
- [MobClick event:eventId durations:numDur];
- } else {
- [MobClick event:eventId attributes:paramMap durations:numDur];
- }
- }
- - (void) logTimedEventWithLabelBegin: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logTimedEventWithLabelBegin invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSString* label = (NSString*) [params objectForKey:@"Param2"];
- if (! label) {
- [MobClick beginEvent:eventId];
- } else {
- [MobClick beginEvent:eventId label:label];
- }
- }
- - (void) logTimedEventWithLabelEnd: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logTimedEventWithLabelEnd invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSString* label = (NSString*) [params objectForKey:@"Param2"];
- if (! label) {
- [MobClick endEvent:eventId];
- } else {
- [MobClick endEvent:eventId label:label];
- }
- }
- - (void) logTimedKVEventBegin: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logTimedKVEventBegin invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSString* label = (NSString*) [params objectForKey:@"Param2"];
- NSMutableDictionary* paramMap = (NSMutableDictionary*) [params objectForKey:@"Param3"];
- if (! label || ! paramMap) {
- [MobClick beginEvent:eventId];
- } else {
- [MobClick beginEvent:eventId primarykey:label attributes:paramMap];
- }
- }
- - (void) logTimedKVEventEnd: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng logTimedKVEventEnd invoked(%@)", [params debugDescription]);
- NSString* eventId = (NSString*) [params objectForKey:@"Param1"];
- NSString* label = (NSString*) [params objectForKey:@"Param2"];
- if (! label) {
- [MobClick endEvent:eventId];
- } else {
- [MobClick endEvent:eventId primarykey:label];
- }
- }
- - (void) startSessionWithParams: (NSMutableDictionary*) params
- {
- OUTPUT_LOG(@"Umeng startSessionWithParams invoked(%@)", [params debugDescription]);
- NSString* appKey = (NSString*) [params objectForKey:@"Param1"];
- NSNumber* policy = (NSNumber*) [params objectForKey:@"Param2"];
- NSString* channelId = (NSString*) [params objectForKey:@"Param3"];
- int nPolicy = [policy intValue];
- [[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
- [MobClick startWithAppkey:appKey reportPolicy:(ReportPolicy)nPolicy channelId:channelId];
- }
- - (void) checkUpdate
- {
- OUTPUT_LOG(@"Umeng checkUpdate invoked");
- [MobClick checkUpdate];
- }
- @end
|