grazies / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 1 forks source link

Code Example for User Timing in iOS SDK Is Broken #351

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Name of related component: iOS SDK Documentation

URL of the documentation page: 
https://developers.google.com/analytics/devguides/collection/ios/v3/usertimings

Issue summary:
The code example on the user timings page accepts and passes incorrect 
parameters to GAIDictionaryBuilder.

1) The example method takes a (NSTimeInterval *). NSTimeInterval shouldn't be 
used as a pointer, the method signature should be
/*
 * Called after a list of high scores finishes loading.
 *
 * @param loadTime The time it takes to load a resource.
 */
- (void)onLoad:(NSTimeInterval)loadTime 

2) NSTimeInterval stores time values in seconds, not milliseconds, so the 
headerdoc is incorrect, and the value should be multiplied by 1000.

3) createTimingWithCategory:interval:name:label: takes an NSNumber* as its 
interval parameter, not an NSTimeInterval*. The method call should be as 
follows:
[tracker send:[GAIDictionaryBuilder createTimingWithCategory:@"resources"    // 
Timing category (required)
                                                      interval:@(loadTime * 1000)        // Timing interval (required)
                                                          name:@"high scores"  // Timing name
                                                         label:nil] build];    // Timing label

Original issue reported on code.google.com by wetz...@gmail.com on 17 Oct 2013 at 9:01

GoogleCodeExporter commented 8 years ago
Oh look, I missed that the method brackets are also mismatched in the example, 
they should be

[tracker send:[[GAIDictionaryBuilder createTimingWithCategory:@"resources"    
// Timing category (required)
                                                      interval:@(loadTime * 1000)        // Timing interval (required)
                                                          name:@"high scores"  // Timing name
                                                         label:nil] build]];    // Timing label

Original comment by wetz...@gmail.com on 17 Oct 2013 at 9:04

GoogleCodeExporter commented 8 years ago

Original comment by pfrise...@google.com on 10 Oct 2014 at 5:57