diff --git a/README.md b/README.md index 20dfcdb..42d8814 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,10 @@ HypGA A Google Analytics native extension for NME ----------------------------- -This NME native extension allows you to integrate Google Analytics ( v2 Beta 4 ) into your NME application. -The supported compilation targets are [iOS](https://developers.google.com/analytics/devguides/collection/ios/v2/) & [Android](https://developers.google.com/analytics/devguides/collection/android/v2/) +This OpenFL native extension allows you to integrate Google Analytics into your OpenFL application. +The supported compilation targets are +* [iOS](https://developers.google.com/analytics/devguides/collection/ios/v3/) +* [Android](https://developers.google.com/analytics/devguides/collection/android/v2/) Installation ------------ @@ -22,10 +24,11 @@ Usage ----- Just call the public methods on the HypGA class. -For iOS you need to link the Google Analytics class package to your XCode project. -Just drag & drop on your project the HypGA folder. ( [your_export_folder]/ios/[ProjectName]/HypGA ) +For iOS, put the following libs (from GA v3 SDK) into projects/iPhone/libs: +* libAdIdAccess.a +* libGoogleAnalyticsServices.a -Baisc reference +Basic reference --------------- First start the session via : diff --git a/include.nmml b/include.nmml index c921201..c3902ce 100644 --- a/include.nmml +++ b/include.nmml @@ -11,10 +11,13 @@ - - - - + + + + + + + @@ -24,4 +27,4 @@ - \ No newline at end of file + diff --git a/ndll/iPhone/libHypGA.iphoneos-v7.a b/ndll/iPhone/libHypGA.iphoneos-v7.a old mode 100755 new mode 100644 index 7795766..48e4eec Binary files a/ndll/iPhone/libHypGA.iphoneos-v7.a and b/ndll/iPhone/libHypGA.iphoneos-v7.a differ diff --git a/ndll/iPhone/libHypGA.iphoneos.a b/ndll/iPhone/libHypGA.iphoneos.a old mode 100755 new mode 100644 index a1eb9e1..4fd236e Binary files a/ndll/iPhone/libHypGA.iphoneos.a and b/ndll/iPhone/libHypGA.iphoneos.a differ diff --git a/ndll/iPhone/libHypGA.iphonesim.a b/ndll/iPhone/libHypGA.iphonesim.a old mode 100755 new mode 100644 index d89617a..4960464 Binary files a/ndll/iPhone/libHypGA.iphonesim.a and b/ndll/iPhone/libHypGA.iphonesim.a differ diff --git a/project/.DS_Store b/project/.DS_Store deleted file mode 100644 index 047376c..0000000 Binary files a/project/.DS_Store and /dev/null differ diff --git a/project/iPhone/HypGA.mm b/project/iPhone/HypGA.mm index 7124016..17f2654 100644 --- a/project/iPhone/HypGA.mm +++ b/project/iPhone/HypGA.mm @@ -2,6 +2,8 @@ #import #import "GAI.h" +#import "GAIDictionaryBuilder.h" +#import "GAIFields.h" #import "GAITracker.h" namespace hypga { @@ -18,7 +20,8 @@ void startNewSession( const char *sUID , int iPeriod ){ void sendView( const char *sPage ){ NSString *NSPage = [[NSString alloc] initWithUTF8String:sPage]; NSLog( @"sendView %@" , NSPage ); - [tracker sendView:NSPage]; + [tracker set:kGAIScreenName value:NSPage]; + [tracker send:[[GAIDictionaryBuilder createAppView] build]]; } void sendEvent( const char *sCat , const char *sAction , const char *sLabel , int iValue ){ @@ -26,32 +29,43 @@ void sendEvent( const char *sCat , const char *sAction , const char *sLabel , in NSString *NS_Act = [ [NSString alloc] initWithUTF8String:sAction]; NSString *NS_Lab = [ [NSString alloc] initWithUTF8String:sLabel]; NSLog( @"SendEvent cat:%@ act:%@ label:%@ val%i" , NS_Cat , NS_Act , NS_Lab , iValue ); - [tracker sendEventWithCategory:NS_Cat withAction:NS_Act withLabel:NS_Lab withValue:[NSNumber numberWithInt:iValue]]; + [tracker send:[[GAIDictionaryBuilder createEventWithCategory:NS_Cat + action:NS_Act + label:NS_Lab + value:[NSNumber numberWithInt:iValue]] + build]]; } void setCustom_dimension( int iIndex , const char *sValue ){ NSString *NS_Val = [[NSString alloc] initWithUTF8String:sValue]; NSLog( @"setCustom_dimension index:%i value:%s" , iIndex , sValue ); - [tracker setCustom:iIndex dimension:NS_Val]; + [tracker set:[GAIFields customDimensionForIndex:iIndex] value:NS_Val]; } void setCustom_metric( int iIndex , int iMetric ){ NSLog( @"setCustom_metric index:%i metrid:%i",iIndex,iMetric); - [tracker setCustom:iIndex metric:[NSNumber numberWithInt:iMetric]]; + [tracker set:[GAIFields customMetricForIndex:iIndex] value:[NSString stringWithFormat:@"%d", iMetric]]; } void sendTiming( const char *sCat , int iInterval , const char *sName , const char *sLabel ){ NSString *NS_Cat = [ [NSString alloc] initWithUTF8String:sCat]; NSString *NS_Name = [ [NSString alloc] initWithUTF8String:sName]; NSString *NS_Label = [ [NSString alloc] initWithUTF8String:sLabel]; - [tracker sendTimingWithCategory:NS_Cat withValue:iInterval withName:NS_Name withLabel:NS_Label]; + [tracker send:[[GAIDictionaryBuilder createTimingWithCategory:NS_Cat + interval:[NSNumber numberWithInt:iInterval] + name:NS_Name + label:NS_Label] + build]]; } void sendSocial( const char *sSocial_network , const char *sAction , const char *sTarget ){ NSString *NS_Net = [ [NSString alloc] initWithUTF8String:sSocial_network]; NSString *NS_Act = [ [NSString alloc] initWithUTF8String:sAction]; NSString *NS_Tgt = [ [NSString alloc] initWithUTF8String:sTarget]; - [tracker sendSocial:NS_Net withAction:NS_Act withTarget:NS_Tgt]; + [tracker send:[[GAIDictionaryBuilder createSocialWithNetwork:NS_Net + action:NS_Act + target:NS_Tgt] + build]]; } void stopSession( ){ diff --git a/project/iPhone/include/GAI.h b/project/iPhone/include/GAI.h index f900201..d9e60e4 100644 --- a/project/iPhone/include/GAI.h +++ b/project/iPhone/include/GAI.h @@ -1,11 +1,12 @@ /*! @header GAI.h @abstract Google Analytics iOS SDK Header - @version 2.0 - @copyright Copyright 2011 Google Inc. All rights reserved. + @version 3.0 + @copyright Copyright 2013 Google Inc. All rights reserved. */ #import +#import "GAILogger.h" #import "GAITracker.h" #import "GAITrackedViewController.h" @@ -49,11 +50,9 @@ typedef enum { @property(nonatomic, assign) id defaultTracker; /*! - If true, Google Analytics debug messages will be logged with `NSLog()`. This is - useful for debugging calls to the Google Analytics SDK. - - By default, this flag is set to `NO`. */ -@property(nonatomic, assign) BOOL debug; + The GAILogger to use. + */ +@property(nonatomic, retain) id logger; /*! When this is true, no tracking information will be gathered; tracking calls @@ -69,14 +68,9 @@ typedef enum { @property(nonatomic, assign) BOOL optOut; /*! - If this value is negative, tracking information must be sent manually by - calling dispatch. If this value is zero, tracking information will - automatically be sent as soon as possible (usually immediately if the device - has Internet connectivity). If this value is positive, tracking information - will be automatically dispatched every dispatchInterval seconds. - - When the dispatchInterval is non-zero, setting it to zero will cause any queued - tracking information to be sent immediately. + If this value is positive, tracking information will be automatically + dispatched every dispatchInterval seconds. Otherwise, tracking information must + be sent manually by calling dispatch. By default, this is set to `120`, which indicates tracking information should be dispatched automatically every 120 seconds. @@ -94,31 +88,72 @@ typedef enum { */ @property(nonatomic, assign) BOOL trackUncaughtExceptions; +/*! + When this is 'YES', no tracking information will be sent. Defaults to 'NO'. + */ +@property(nonatomic, assign) BOOL dryRun; + /*! Get the shared instance of the Google Analytics for iOS class. */ + (GAI *)sharedInstance; /*! - Create or retrieve a GAITracker implementation with the specified tracking - ID. If the tracker for the specified tracking ID does not already exist, then + Creates or retrieves a GAITracker implementation with the specified name and + tracking ID. If the tracker for the specified name does not already exist, then it will be created and returned; otherwise, the existing tracker will be - returned. If defaultTracker is not set, it will be set to the tracker instance - returned here. + returned. If the existing tracker for the respective name has a different + tracking ID, that tracking ID is not changed by this method. If defaultTracker + is not set, it will be set to the tracker instance returned here. + + @param name The name of this tracker. Must not be `nil` or empty. - @param trackingId The tracking ID (a string that begins with "UA-"). Must not - be `nil` or empty. + @param trackingID The tracking ID to use for this tracker. It should be of + the form `UA-xxxxx-y`. - @return A GAITracker associated with the specified tracking ID. The tracker + @return A GAITracker associated with the specified name. The tracker can be used to send tracking data to Google Analytics. The first time this - method is called with a particular tracking ID, the tracker for that tracking - ID will be returned, and subsequent calls with the same tracking ID will return - the same instance. It is not necessary to retain the tracker because the - tracker will be retained internally by the library. + method is called with a particular name, the tracker for that name will be + returned, and subsequent calls with the same name will return the same + instance. It is not necessary to retain the tracker because the tracker will be + retained internally by the library. - If an error occurs or the tracker ID is not valid, this method will return + If an error occurs or the name is not valid, this method will return + `nil`. + */ +- (id)trackerWithName:(NSString *)name + trackingId:(NSString *)trackingId; + +/*! + Creates or retrieves a GAITracker implementation with name equal to + the specified tracking ID. If the tracker for the respective name does not + already exist, it is created, has it's tracking ID set to |trackingId|, + and is returned; otherwise, the existing tracker is returned. If the existing + tracker for the respective name has a different tracking ID, that tracking ID + is not changed by this method. If defaultTracker is not set, it is set to the + tracker instance returned here. + + @param trackingID The tracking ID to use for this tracker. It should be of + the form `UA-xxxxx-y`. The name of the tracker will be the same as trackingID. + + @return A GAITracker associated with the specified trackingID. The tracker + can be used to send tracking data to Google Analytics. The first time this + method is called with a particular trackingID, the tracker for the respective + name will be returned, and subsequent calls with the same trackingID + will return the same instance. It is not necessary to retain the tracker + because the tracker will be retained internally by the library. + + If an error occurs or the trackingId is not valid, this method will return `nil`. */ - (id)trackerWithTrackingId:(NSString *)trackingId; +/*! + Remove a tracker from the trackers dictionary. If it is the default tracker, + clears the default tracker as well. + + @param name The name of the tracker. + */ +- (void)removeTrackerByName:(NSString *)name; + /*! Dispatches any pending tracking information. diff --git a/project/iPhone/include/GAIDictionaryBuilder.h b/project/iPhone/include/GAIDictionaryBuilder.h new file mode 100644 index 0000000..20adff8 --- /dev/null +++ b/project/iPhone/include/GAIDictionaryBuilder.h @@ -0,0 +1,178 @@ +/*! + @header GAIDictionaryBuilder.h + @abstract Google Analytics iOS SDK Hit Format Header + @copyright Copyright 2013 Google Inc. All rights reserved. + */ + +#import + +/*! + * Helper class to build a dictionary of hit parameters and values. + *
+ * Examples: + * + * id t = // get a tracker. + * [t send:[[[GAIDictionaryBuilder createEventWithCategory:@"EventCategory" + * action:@"EventAction" + * label:nil + * value:nil] + * set:@"dimension1" forKey:[GAIFields customDimensionForIndex:1]] build]]; + * + * This will send an event hit type with the specified parameters + * and a custom dimension parameter. + *
+ * If you want to send a parameter with all hits, set it on GAITracker directly. + * + * [t set:kGAIScreenName value:@"Home"]; + * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" + * action:@"PlusOne" + * target:@"SOME_URL"] build]]; + * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" + * action:@"Share" + * target:@"SOME_POST"] build]]; + * [t send:[[GAIDictionaryBuilder createSocialWithNetwork:@"Google+" + * action:@"HangOut" + * target:@"SOME_CIRCLE"] + * build]]; + * + * You can override a value set on the tracker by adding it to the dictionary. + * + * [t set:kGAIScreenName value:@"Home"]; + * [t send:...]; + * [t send[[[GAIDictionaryBuilder createEventWithCategory:@"click" + * action:@"popup" + * label:nil + * value:nil] + * set:@"popup title" forKey:kGAIScreenName] build]]; + * + * The values set via [GAIDictionaryBuilder set] or + * [GAIDictionaryBuilder setAll] will override any existing values in the + * GAIDictionaryBuilder object (i.e. initialized by + * [GAIDictionaryBuilder createXYZ]). e.g. + * + * GAIDictionaryBuilder *m = + * GAIDictionaryBuilder createTimingWithCategory:@"category" + * interval:@0 + * name:@"name" + * label:nil]; + * [t send:[m.set:@"10" forKey:kGAITimingVar] build]; + * [t send:[m.set:@"20" forKey:kGAITimingVar] build]; + * + */ +@interface GAIDictionaryBuilder : NSObject + +- (GAIDictionaryBuilder *)set:(NSString *)value + forKey:(NSString *)key; + +/*! + * Copies all the name-value pairs from params into this object, ignoring any + * keys that are not NSString and any values that are neither NSString or + * NSNull. + */ +- (GAIDictionaryBuilder *)setAll:(NSDictionary *)params; + +/*! + * Returns the value for the input parameter paramName, or nil if paramName + * is not present. + */ +- (NSString *)get:(NSString *)paramName; + +/*! + * Return an NSMutableDictionary object with all the parameters set in this + */ +- (NSMutableDictionary *)build; + +/*! + * Parses and translates utm campaign parameters to analytics campaign param + * and returns them as a map. + * + * @param params url containing utm campaign parameters. + * + * Valid campaign parameters are: + *
    + *
  • utm_id
  • + *
  • utm_campaign
  • + *
  • utm_content
  • + *
  • utm_medium
  • + *
  • utm_source
  • + *
  • utm_term
  • + *
  • dclid
  • + *
  • gclid
  • + *
  • gmob_t
  • + *
+ *

+ * Example: + * http://my.site.com/index.html?utm_campaign=wow&utm_source=source + * utm_campaign=wow&utm_source=source. + *

+ * For more information on auto-tagging, see + * http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55590 + *

+ * For more information on manual tagging, see + * http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55518 + */ +- (GAIDictionaryBuilder *)setCampaignParametersFromUrl:(NSString *)urlString; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to an appview + hit. + + Note that using this method will not set the screen name for followon hits. To + do that you need to call set:kGAIDescription value: on the + GAITracker instance. + */ ++ (GAIDictionaryBuilder *)createAppView; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to an event hit. + */ ++ (GAIDictionaryBuilder *)createEventWithCategory:(NSString *)category + action:(NSString *)action + label:(NSString *)label + value:(NSNumber *)value; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to an exception + hit. + */ ++ (GAIDictionaryBuilder *)createExceptionWithDescription:(NSString *)description + withFatal:(NSNumber *)fatal; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to an item hit. + */ ++ (GAIDictionaryBuilder *)createItemWithTransactionId:(NSString *)transactionId + name:(NSString *)name + sku:(NSString *)sku + category:(NSString *)category + price:(NSNumber *)price + quantity:(NSNumber *)quantity + currencyCode:(NSString *)currencyCode; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to a social hit. + */ ++ (GAIDictionaryBuilder *)createSocialWithNetwork:(NSString *)network + action:(NSString *)action + target:(NSString *)target; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to a timing hit. + */ ++ (GAIDictionaryBuilder *)createTimingWithCategory:(NSString *)category + interval:(NSNumber *)intervalMillis + name:(NSString *)name + label:(NSString *)label; + +/*! + Returns a GAIDictionaryBuilder object with parameters specific to a transaction + hit. + */ ++ (GAIDictionaryBuilder *)createTransactionWithId:(NSString *)transactionId + affiliation:(NSString *)affiliation + revenue:(NSNumber *)revenue + tax:(NSNumber *)tax + shipping:(NSNumber *)shipping + currencyCode:(NSString *)currencyCode; + +@end diff --git a/project/iPhone/include/GAIFields.h b/project/iPhone/include/GAIFields.h new file mode 100644 index 0000000..c4961b1 --- /dev/null +++ b/project/iPhone/include/GAIFields.h @@ -0,0 +1,127 @@ +/*! + @header GAIFields.h + @abstract Google Analytics iOS SDK Hit Format Header + @copyright Copyright 2013 Google Inc. All rights reserved. + */ + +#import + +/*! + These fields can be used for the wire format parameter names required by + the |GAITracker| get, set and send methods as well as the set methods in the + |GAIDictionaryBuilder| class. + */ +extern NSString *const kGAIUseSecure; + +extern NSString *const kGAIHitType; +extern NSString *const kGAITrackingId; +extern NSString *const kGAIClientId; +extern NSString *const kGAIAnonymizeIp; +extern NSString *const kGAISessionControl; +extern NSString *const kGAIScreenResolution; +extern NSString *const kGAIViewportSize; +extern NSString *const kGAIEncoding; +extern NSString *const kGAIScreenColors; +extern NSString *const kGAILanguage; +extern NSString *const kGAIJavaEnabled; +extern NSString *const kGAIFlashVersion; +extern NSString *const kGAINonInteraction; +extern NSString *const kGAIReferrer; +extern NSString *const kGAILocation; +extern NSString *const kGAIHostname; +extern NSString *const kGAIPage; +extern NSString *const kGAIDescription; // synonym for kGAIScreenName +extern NSString *const kGAIScreenName; // synonym for kGAIDescription +extern NSString *const kGAITitle; +extern NSString *const kGAIAppName; +extern NSString *const kGAIAppVersion; +extern NSString *const kGAIAppId; +extern NSString *const kGAIAppInstallerId; +extern NSString *const kGAIUserId; + +extern NSString *const kGAIEventCategory; +extern NSString *const kGAIEventAction; +extern NSString *const kGAIEventLabel; +extern NSString *const kGAIEventValue; + +extern NSString *const kGAISocialNetwork; +extern NSString *const kGAISocialAction; +extern NSString *const kGAISocialTarget; + +extern NSString *const kGAITransactionId; +extern NSString *const kGAITransactionAffiliation; +extern NSString *const kGAITransactionRevenue; +extern NSString *const kGAITransactionShipping; +extern NSString *const kGAITransactionTax; +extern NSString *const kGAICurrencyCode; + +extern NSString *const kGAIItemPrice; +extern NSString *const kGAIItemQuantity; +extern NSString *const kGAIItemSku; +extern NSString *const kGAIItemName; +extern NSString *const kGAIItemCategory; + +extern NSString *const kGAICampaignSource; +extern NSString *const kGAICampaignMedium; +extern NSString *const kGAICampaignName; +extern NSString *const kGAICampaignKeyword; +extern NSString *const kGAICampaignContent; +extern NSString *const kGAICampaignId; + +extern NSString *const kGAITimingCategory; +extern NSString *const kGAITimingVar; +extern NSString *const kGAITimingValue; +extern NSString *const kGAITimingLabel; + +extern NSString *const kGAIExDescription; +extern NSString *const kGAIExFatal; + +extern NSString *const kGAISampleRate; + +extern NSString *const kGAIIdfa; +extern NSString *const kGAIAdTargetingEnabled; + +// hit types +extern NSString *const kGAIAppView; +extern NSString *const kGAIEvent; +extern NSString *const kGAISocial; +extern NSString *const kGAITransaction; +extern NSString *const kGAIItem; +extern NSString *const kGAIException; +extern NSString *const kGAITiming; + +/*! + This class provides several fields and methods useful as wire format parameter + names. The methods are used for wire format parameter names that are indexed. + */ + +@interface GAIFields : NSObject + +/*! + Generates the correct parameter name for a content group with an index. + + @param index the index of the content group. + + @return an NSString representing the content group parameter for the index. + */ ++ (NSString *)contentGroupForIndex:(NSUInteger)index; + +/*! + Generates the correct parameter name for a custon dimension with an index. + + @param index the index of the custom dimension. + + @return an NSString representing the custom dimension parameter for the index. + */ ++ (NSString *)customDimensionForIndex:(NSUInteger)index; + +/*! + Generates the correct parameter name for a custom metric with an index. + + @param index the index of the custom metric. + + @return an NSString representing the custom metric parameter for the index. + */ ++ (NSString *)customMetricForIndex:(NSUInteger)index; + +@end diff --git a/project/iPhone/include/GAILogger.h b/project/iPhone/include/GAILogger.h new file mode 100644 index 0000000..06291f2 --- /dev/null +++ b/project/iPhone/include/GAILogger.h @@ -0,0 +1,49 @@ +/*! + @header GAILogger.h + @abstract Google Analytics iOS SDK Source + @copyright Copyright 2011 Google Inc. All rights reserved. + */ + +#import + +typedef NS_ENUM(NSUInteger, GAILogLevel) { + kGAILogLevelNone = 0, + kGAILogLevelError = 1, + kGAILogLevelWarning = 2, + kGAILogLevelInfo = 3, + kGAILogLevelVerbose = 4 +}; + +/*! + Protocol to be used for logging debug and informational messages from the SDK. + Implementations of this protocol can be provided to the |GAI| class, + to be used as the logger by the SDK. See the |logger| property in GAI.h. + */ +@protocol GAILogger +@required + +/*! + Only messages of |logLevel| and below are logged. + */ +@property (nonatomic, assign) GAILogLevel logLevel; + +/*! + Logs message with log level |kGAILogLevelVerbose|. + */ +- (void)verbose:(NSString *)message; + +/*! + Logs message with log level |kGAILogLevelInfo|. + */ +- (void)info:(NSString *)message; + +/*! + Logs message with log level |kGAILogLevelWarning|. + */ +- (void)warning:(NSString *)message; + +/*! + Logs message with log level |kGAILogLevelError|. + */ +- (void)error:(NSString *)message; +@end diff --git a/project/iPhone/include/GAITrackedViewController.h b/project/iPhone/include/GAITrackedViewController.h index 0a10070..5cbabdd 100644 --- a/project/iPhone/include/GAITrackedViewController.h +++ b/project/iPhone/include/GAITrackedViewController.h @@ -11,18 +11,14 @@ @protocol GAITracker; /*! - Extends UIViewController to generate Google Analytics view tracking calls + Extends UIViewController to generate Google Analytics appview calls whenever the view appears; this is done by overriding the `viewDidAppear:` - method. The view name must be set for any tracking calls to be made. + method. The screen name must be set for any tracking calls to be made. By default, this will use [GAI defaultTracker] for tracking calls, but one can override this by setting the tracker property. */ -@interface GAITrackedViewController : UIViewController { - @private - id tracker_; - NSString *trackedViewName_; -} +@interface GAITrackedViewController : UIViewController /*! The tracker on which view tracking calls are be made, or `nil`, in which case @@ -30,9 +26,9 @@ */ @property(nonatomic, assign) id tracker; /*! - The view name, for purposes of Google Analytics view tracking. If this is - `nil`, no tracking calls will be made. + The screen name, for purposes of Google Analytics tracking. If this is `nil`, + no tracking calls will be made. */ -@property(nonatomic, copy) NSString *trackedViewName; +@property(nonatomic, copy) NSString *screenName; @end diff --git a/project/iPhone/include/GAITracker.h b/project/iPhone/include/GAITracker.h index 35a80f6..43b5e20 100644 --- a/project/iPhone/include/GAITracker.h +++ b/project/iPhone/include/GAITracker.h @@ -1,12 +1,11 @@ /*! @header GAITracker.h @abstract Google Analytics iOS SDK Tracker Header - @version 2.0 - @copyright Copyright 2011 Google Inc. All rights reserved. + @version 3.0 + @copyright Copyright 2013 Google Inc. All rights reserved. */ #import -#import "GAITransaction.h" /*! Google Analytics tracking interface. Obtain instances of this interface from @@ -18,364 +17,19 @@ @protocol GAITracker /*! - The tracking identifier (the string that begins with "UA-") this tracker is - associated with. - - This property is read-only. - */ -@property(nonatomic, copy, readonly) NSString *trackingId; - -/*! - The application name associated with this tracker. By default, this property is - populated with the `CFBundleName` string from the application bundle. If you - wish to override this property, you must do so before making any tracking - calls. - */ -@property(nonatomic, copy) NSString *appName; - -/*! - The application identifier associated with this tracker. This should be set to - the iTunes Connect application identifier assigned to your application. By - default, this property is `nil`. If you wish to set this property, you must do - so before making any tracking calls. - - Note that this is not your app's bundle id (e.g. com.example.appname), but the - identifier used by the App Store. - */ -@property(nonatomic, copy) NSString *appId; - -/*! - The application version associated with this tracker. By default, this property - is populated with the `CFBundleShortVersionString` string from the application - bundle. If you wish to override this property, you must do so before making any - tracking calls. - */ -@property(nonatomic, copy) NSString *appVersion; - -/*! - Tracking data collected while this is true will be anonymized by the Google - Analytics servers by zeroing out some of the least significant bits of the - IP address. - - In the case of IPv4 addresses, the last octet is set to zero. For - IPv6 addresses, the last 10 octets are set to zero, although this is subject to - change in the future. - - By default, this flag is false. - */ -@property(nonatomic, assign) BOOL anonymize; - -/*! - Tracking information collected while this is true will be submitted to Google - Analytics using HTTPS connection(s); otherwise, HTTP will be used. Note that - there may be additional overhead when sending data using HTTPS in terms of - processing costs and/or battery consumption. - - By default, this flag is true. - */ -@property(nonatomic, assign) BOOL useHttps; - -/*! - The sampleRate parameter controls the probability that the visitor will be - sampled. By default, sampleRate is 100, which signifies no sampling. sampleRate - may be set to any value between 0 and 100, inclusive. A value of 90 means 90% - of visitors should be sampled (10% of visitors to be sampled out). - - When a visitor is not sampled, no data is collected by Google Analytics for iOS - library about that visitor's activity. If your application is subject to heavy - traffic spikes, you may wish to adjust the sample rate to ensure uninterrupted - report tracking. Sampling in Google Analytics occurs consistently across unique - visitors, ensuring integrity in trending and reporting even when sampling is - enabled, because unique visitors remain included or excluded from the sample, - as set from the initiation of sampling. - */ -@property(nonatomic, assign) double sampleRate; - -/*! - The client ID for the tracker. - - This is a persistent unique identifier generated the first time the library is - called and persisted unchanged thereafter. It is used to identify the client - across multiple application sessions. - */ -@property(nonatomic, copy, readonly) NSString *clientId; - -/*! - The current screen set for this tracker. - - Calling trackView: will also update this property before it dispatches tracking - information to Google Analytics. However, if you wish to update the current - screen without sending any tracking information, set this property directly. - The updated screen will be reflected in subsequent tracking information. - */ -@property(nonatomic, copy) NSString *appScreen; - -/*! - The referrer URL for this tracker. Changing this value causes it to be sent - with the next dispatch of tracking information. - */ -@property(nonatomic, copy) NSString *referrerUrl; - -/*! - The campaign URL for this tracker. This is not directly propagated to Google - Analytics, but if there are campaign parameter(s), either manually or - auto-tagged, present in this URL, the SDK will include those parameters in the - next dispatch of tracking information. Google Analytics treats tracking - information with differing campaign information as part of separate sessions. - - For more information on auto-tagging, see - http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55590 - - For more information on manual tagging, see - http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55518 + Name of this tracker. */ -@property(nonatomic, copy) NSString *campaignUrl; - -/*! - If true, indicates the start of a new session. Note that when a tracker is - first instantiated, this is initialized to true. To prevent this default - behavior, set this to `NO` when the tracker is first obtained. - - By itself, setting this does not send any data. If this is true, when the next - tracking call is made, a parameter will be added to the resulting tracking - information indicating that it is the start of a session, and this flag will be - cleared. - */ -@property(nonatomic, assign) BOOL sessionStart; - -/*! - If non-negative, indicates how long, in seconds, the application must - transition to the inactive or background state for before the tracker will - automatically indicate the start of a new session when the app becomes active - again by setting sessionStart to true. For example, if this is set to 30 - seconds, and the user receives a phone call that lasts for 45 seconds while - using the app, upon returning to the app, the sessionStart parameter will be - set to true. If the phone call instead lasted 10 seconds, sessionStart will not - be modified. - - To disable automatic session tracking, set this to a negative value. To - indicate the start of a session anytime the app becomes inactive or - backgrounded, set this to zero. - - By default, this is 30 seconds. - */ -@property(nonatomic, assign) NSTimeInterval sessionTimeout; - -/*! - Track that the current screen (as set in appScreen) was displayed. If appScreen - has not been set, this will not generate any tracking information. - - If [GAI optOut] is true, this will not generate any tracking information. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed or appScreen is not set). - */ -- (BOOL)sendView; - -/*! - This method is deprecated. See sendView. - */ -- (BOOL)trackView; - -/*! - Track that the specified view or screen was displayed. This call sets - the appScreen property and generates tracking information to be sent to Google - Analytics. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param screen The name of the screen. Must not be `nil`. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendView:(NSString *)screen; - -/*! - This method is deprecated. See sendView. - */ -- (BOOL)trackView:(NSString *)screen; - -/*! - Track an event. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param category The event category, or `nil` if none. - - @param action The event action, or `nil` if none. - - @param label The event label, or `nil` if none. - - @param value The event value, to be interpreted as a 64-bit signed integer, or - `nil` if none. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendEventWithCategory:(NSString *)category - withAction:(NSString *)action - withLabel:(NSString *)label - withValue:(NSNumber *)value; - -/*! - This method is deprecated. See sendEventWithCategory. - */ -- (BOOL)trackEventWithCategory:(NSString *)category - withAction:(NSString *)action - withLabel:(NSString *)label - withValue:(NSNumber *)value; - -/*! - Track a transaction. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param transaction The GAITransaction object. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendTransaction:(GAITransaction *)transaction; - -/*! - This method is deprecated. see sendTransaction. - */ -- (BOOL)trackTransaction:(GAITransaction *)transaction; - -/*! - Track an exception. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param isFatal A boolean indicating whether the exception is fatal. - - @param format A format string that will be used to create the exception - description. - - @param ... An optional list of arguments to be substituted using the format - string. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendException:(BOOL)isFatal - withDescription:(NSString *)format, ...; - -/*! - This method is deprecated. See sendException. - */ -- (BOOL)trackException:(BOOL)isFatal - withDescription:(NSString *)format, ...; - -/*! Convenience method for tracking an NSException that passes the exception - name to trackException:withDescription:. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param isFatal A boolean indicating whether the exception is fatal. - - @param exception The NSException exception object. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendException:(BOOL)isFatal - withNSException:(NSException *)exception; - -/*! - This method is deprecated. See sendException. - */ -- (BOOL)trackException:(BOOL)isFatal - withNSException:(NSException *)exception; - -/*! Convenience method for tracking an NSError that passes the domain, code, and - description to trackException:withDescription:. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param isFatal A boolean indicating whether the exception is fatal. - - @param error The NSError error object. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendException:(BOOL)isFatal - withNSError:(NSError *)error; - -/*! - This method is deprecated. See sendException. - */ -- (BOOL)trackException:(BOOL)isFatal - withNSError:(NSError *)error; - -/*! - Track user timing. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param category A string representing a timing category. - - @param time A timing value. - - @param name A string representing a timing name, or `nil` if none. - - @param label A string representing a timing variable label, or `nil` if none. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendTimingWithCategory:(NSString *)category - withValue:(NSTimeInterval)time - withName:(NSString *)name - withLabel:(NSString *)label; - -/*! - This method is deprecated. See sendTimingWithCategory. - */ -- (BOOL)trackTimingWithCategory:(NSString *)category - withValue:(NSTimeInterval)time - withName:(NSString *)name - withLabel:(NSString *)label; - -/*! - Track social action. - - If [GAI optOut] is true, this will not generate any tracking information. - - @param network A string representing social network. Must not be nil. - - @param action A string representing a social action. Must not be nil. - - @param target A string representing the target. May be nil. - - @return `YES` if the tracking information was queued for dispatch, or `NO` if - there was an error (e.g. the tracker was closed). - */ -- (BOOL)sendSocial:(NSString *)network - withAction:(NSString *)action - withTarget:(NSString *)target; - -/*! - This method is deprecated. See sendSocial. - */ -- (BOOL)trackSocial:(NSString *)network - withAction:(NSString *)action - withTarget:(NSString *)target; +@property(nonatomic, readonly) NSString *name; /*! Set a tracking parameter. @param parameterName The parameter name. - @param value The value to set for the parameter. If this is `nil`, the + @param value The value to set for the parameter. If this is nil, the value for the parameter will be cleared. - - @returns `YES` if the parameter was set to the given value, or `NO` if there - was an error (e.g. unknown parameter). */ -- (BOOL)set:(NSString *)parameterName +- (void)set:(NSString *)parameterName value:(NSString *)value; /*! @@ -383,7 +37,7 @@ @param parameterName The parameter name. - @returns The parameter value, or `nil` if no value for the given parameter is + @returns The parameter value, or nil if no value for the given parameter is set. */ - (NSString *)get:(NSString *)parameterName; @@ -391,51 +45,9 @@ /*! Queue tracking information with the given parameter values. - @param trackType The type of tracking information, e.g., @"appview". - @param parameters A map from parameter names to parameter values which will be - set just for this piece of tracking information. - - @return `YES` if the tracking information was queued for submission, or `NO` - if an error occurred (e.g. bad track type). - */ -- (BOOL)send:(NSString *)trackType - params:(NSDictionary *)parameters; - -/*! - Set a custom dimension value, to be sent at the next tracking call. - - @param index The index at which to set the dimension. Must be positive. - - @param dimension The dimension value, or `nil` if the dimension at the given - index is to be cleared. - - @return `YES` on success, or `NO` if an error occurred. - */ -- (BOOL)setCustom:(NSInteger)index - dimension:(NSString *)dimension; - -/*! - Set a custom metric value, to be sent at the next tracking call. - - @param index The index at which to set the metric. Must be positive. - - @param metric The metric value, which will be interpreted as a signed 64-bit - integer, or `nil` if the metric at the given index is to be cleared. - - @return `YES` on success, or `NO` if an error occurred. - */ -- (BOOL)setCustom:(NSInteger)index - metric:(NSNumber *)metric; - -/*! - Close the tracker. This will mark it as closed and remove it from the list of - trackers accessible through [GAI trackerWithTrackingId:], thus decrementing its - reference count (and causing it to be dealloced unless it has been retained by - the application). Once this method has been called, it is an error to call any - of the tracking methods, and they will not result in the generation of any - tracking information to be submitted to Google Analytics. + set just for this piece of tracking information, or nil for none. */ -- (void)close; +- (void)send:(NSDictionary *)parameters; @end diff --git a/project/iPhone/include/GAITransaction.h b/project/iPhone/include/GAITransaction.h deleted file mode 100644 index 9e081e3..0000000 --- a/project/iPhone/include/GAITransaction.h +++ /dev/null @@ -1,78 +0,0 @@ -/*! - @header GAITransaction.h - @abstract Google Analytics iOS SDK Transaction Header - @version 2.0 - @copyright Copyright 2011 Google Inc. All rights reserved. - */ - -#import -#import "GAITransactionItem.h" - -/*! A simple class to hold transaction data. */ -@interface GAITransaction : NSObject - -/*! Transaction ID. */ -@property(nonatomic, copy, readonly) NSString *transactionId; - -/*! Transaction affiliation. */ -@property(nonatomic, copy, readonly) NSString *affiliation; - -/*! Revenue in micros (millionths of a currency unit). Note that this must be - set manually because it is not updated when items are added. */ -@property(nonatomic, assign) int64_t revenueMicros; - -/*! Tax in micros (millionths of a currency unit). Note that this must be set - * manually because it is not updated when items are added. */ -@property(nonatomic, assign) int64_t taxMicros; - -/*! Shipping cost in micros (millionths of a currency unit). Note that - this must be set manually because it is not updated when items are added. */ -@property(nonatomic, assign) int64_t shippingMicros; - -/*! Transaction items, as an immutable array. */ -@property(nonatomic, readonly) NSArray *items; - -/*! - Create and initialize a transaction. - - @param transactionId The transaction ID. Required (must not be `nil`). - - @param affiliation The transaction affiliation. May be `nil`. - - @return A GAITransaction object with the specified transaction ID and - affiliation. - */ -+ (GAITransaction *)transactionWithId:(NSString *)transactionId - withAffiliation:(NSString *)affiliation; - -/*! - Add an item to the transaction. If an item with the same SKU already - exists in the transaction, that item will be replaced with this one. - - @param item The GAITransactionItem to add to the transaction. - */ -- (void)addItem:(GAITransactionItem *)item; - -/*! - Add an item to the transaction. If an item with the same SKU already - exists in the transaction, that item will be replaced with this one. - - @param productCode The item product code; must not be `nil` or empty. - - @param productName The item product name; may be `nil`. - - @param productCategory The item product category; may be `nil`. - - @param priceMicros The item price, in micros (millionths of a currency unit). - - @param quantity The item quantity, as an NSInteger. - - @return The newly initialized item. - */ -- (void)addItemWithCode:(NSString *)productCode - name:(NSString *)productName - category:(NSString *)productCategory - priceMicros:(int64_t)priceMicros - quantity:(NSInteger)quantity; - -@end diff --git a/project/iPhone/include/GAITransactionItem.h b/project/iPhone/include/GAITransactionItem.h deleted file mode 100644 index e8ee3fd..0000000 --- a/project/iPhone/include/GAITransactionItem.h +++ /dev/null @@ -1,49 +0,0 @@ -/*! - @header GAITransactionItem.h - @abstract Google Analytics iOS SDK Transaction Item Header - @version 2.0 - @copyright Copyright 2011 Google Inc. All rights reserved. - */ - -#import - -/*! A simple class to hold transaction item data. */ -@interface GAITransactionItem : NSObject - -/*! The item code, as a string. */ -@property(nonatomic, copy, readonly) NSString *productCode; - -/*! The item name. */ -@property(nonatomic, copy) NSString *productName; - -/*! The item variation. */ -@property(nonatomic, copy) NSString *productCategory; - -/*! The item price in micros (millionths of a currency unit). */ -@property(nonatomic, assign) int64_t priceMicros; - -/*! The item quantity. */ -@property(nonatomic, assign) NSInteger quantity; - -/*! - Create and initialize an item. - - @param productCode The item product code; must not be `nil` or empty. - - @param productName The item product name; must not be `nil` or empty. - - @param productCategory The item product category; may be `nil`. - - @param priceMicros The item price, in micros (millionths of a currency unit). - - @param quantity The item quantity, as an NSInteger. - - @return The newly initialized item. - */ -+ (GAITransactionItem *)itemWithCode:(NSString *)productCode - name:(NSString *)productName - category:(NSString *)productCategory - priceMicros:(int64_t)priceMicros - quantity:(NSInteger)quantity; - -@end diff --git a/project/iphone.sh b/project/iphone.sh old mode 100644 new mode 100755