-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from amco/demo_project
Demo project added. Demo excluded in podspec. Resolves #14.
- Loading branch information
Showing
18 changed files
with
1,011 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Xcode | ||
.DS_Store | ||
*.xcuserstate | ||
*.xcbkptlist | ||
*.xcuserstate | ||
*/build/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
*.xcworkspace | ||
!default.xcworkspace | ||
xcuserdata | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
.idea/ | ||
*.hmap | ||
*.xcuserstate | ||
*.xcbkptlist | ||
|
||
# cocoapods | ||
Pods | ||
Podfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
platform :ios, '6.0' | ||
|
||
pod 'librato-iOS', :path => '../librato-iOS.podspec' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# librato-iOS Demo | ||
|
||
This simple but direct project showcases some simple uses of the `librato-iOS` library. | ||
|
||
# Usage | ||
|
||
Because this demo project uses the `podspec` in the main library you'll need to grab the entire repo. | ||
|
||
* Clone the `librato-iOS` repo (`$ git clone [email protected]:amco/librato-iOS.git`) | ||
* Navigate into the Demo directory and install the Pods (`cd librato-iOS/Demo && pod install`) | ||
* Open the workspace (`open librato-iOS\ Demo.xcworkspace`) | ||
* Open `LibratoDemoAppDelegate.m` to select which demos to run | ||
* Open `LibratoDemoEventTracker.m` to see how each demo is created | ||
|
||
# Copyright | ||
|
||
Copyright (c) 2013 Amco International Education Services, LLC. See LICENSE for more details. |
Large diffs are not rendered by default.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
Demo/librato-iOS Demo/Images.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Demo/librato-iOS Demo/Images.xcassets/LaunchImage.launchimage/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "iphone", | ||
"subtype" : "retina4", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"orientation" : "landscape", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"orientation" : "portrait", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"orientation" : "landscape", | ||
"idiom" : "ipad", | ||
"extent" : "full-screen", | ||
"minimum-system-version" : "7.0", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// LibratoDemoAppDelegate.h | ||
// librato-iOS Demo | ||
// | ||
// Created by Adam Yanalunas on 10/7/13. | ||
// Copyright (c) 2013 Amco International Education Services, LLC. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface LibratoDemoAppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// LibratoDemoAppDelegate.m | ||
// librato-iOS Demo | ||
// | ||
// Created by Adam Yanalunas on 10/7/13. | ||
// Copyright (c) 2013 Amco International Education Services, LLC. All rights reserved. | ||
// | ||
|
||
#import "LibratoDemoAppDelegate.h" | ||
#import "LibratoDemoEventTracker.h" | ||
|
||
@implementation LibratoDemoAppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | ||
// Override point for customization after application launch. | ||
self.window.backgroundColor = [UIColor whiteColor]; | ||
[self.window makeKeyAndVisible]; | ||
|
||
LibratoDemoEventTracker *eventTracker = LibratoDemoEventTracker.new; | ||
[eventTracker counterMetricExample]; | ||
[eventTracker multipleMetricSubmissionExample]; | ||
[eventTracker dictionaryCreationExample]; | ||
[eventTracker gaugeMetricExample]; | ||
|
||
return YES; | ||
} | ||
|
||
- (void)applicationWillResignActive:(UIApplication *)application | ||
{ | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | ||
} | ||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application | ||
{ | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application | ||
{ | ||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
{ | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
- (void)applicationWillTerminate:(UIApplication *)application | ||
{ | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// LibratoDemoEventTracker.h | ||
// librato-iOS Demo | ||
// | ||
// Created by Adam Yanalunas on 10/7/13. | ||
// Copyright (c) 2013 Amco International Education Services, LLC. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@class Librato; | ||
|
||
|
||
@interface LibratoDemoEventTracker : NSObject | ||
|
||
+ (Librato *)sharedInstance; | ||
|
||
- (void)counterMetricExample; | ||
- (void)multipleMetricSubmissionExample; | ||
- (void)dictionaryCreationExample; | ||
- (void)gaugeMetricExample; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// LibratoDemoEventTracker.m | ||
// librato-iOS Demo | ||
// | ||
// Created by Adam Yanalunas on 10/7/13. | ||
// Copyright (c) 2013 Amco International Education Services, LLC. All rights reserved. | ||
// | ||
|
||
#import "LibratoDemoEventTracker.h" | ||
#import "Librato.h" | ||
|
||
|
||
NSString *const libratoEmail = @"<Librato email>"; | ||
NSString *const libratoToken = @"<Librato token>"; | ||
NSString *const libratoPrefix = @"demo"; | ||
|
||
|
||
@interface LibratoDemoEventTracker () | ||
|
||
- (NSNumber *)randomNumber; | ||
|
||
@end | ||
|
||
|
||
@implementation LibratoDemoEventTracker | ||
|
||
|
||
#pragma mark - Lifecycle | ||
/* | ||
Simple non-threadsafe singleton creator | ||
*/ | ||
+ (Librato *)sharedInstance | ||
{ | ||
static dispatch_once_t onceToken; | ||
static Librato *_librato; | ||
|
||
dispatch_once(&onceToken, ^{ | ||
_librato = [Librato.alloc initWithEmail:libratoEmail token:libratoToken prefix:libratoPrefix]; | ||
}); | ||
|
||
return _librato; | ||
} | ||
|
||
|
||
#pragma mark - Examples | ||
/* | ||
Creates a "counter" metric and shows that you can change values via the options or with property accessors | ||
*/ | ||
- (void)counterMetricExample | ||
{ | ||
LibratoMetric *simpleMetric = [LibratoMetric metricNamed:@"works" valued:self.randomNumber options:@{@"source": @"demo app"}]; | ||
simpleMetric.measureTime = [NSDate dateWithTimeIntervalSinceNow:-(3600 * 24)]; | ||
|
||
NSLog(@"%@", simpleMetric); | ||
|
||
[LibratoDemoEventTracker.sharedInstance submit:simpleMetric]; | ||
} | ||
|
||
|
||
/* | ||
Creates two different metrics but submits them simultaneously | ||
*/ | ||
- (void)multipleMetricSubmissionExample | ||
{ | ||
LibratoMetric *memoryMetric = [LibratoMetric metricNamed:@"memory.available" valued:self.randomNumber options:nil]; | ||
LibratoMetric *storageMetric = [LibratoMetric metricNamed:@"storage.available" valued:self.randomNumber options:nil]; | ||
|
||
NSLog(@"%@", memoryMetric); | ||
NSLog(@"%@", storageMetric); | ||
|
||
[LibratoDemoEventTracker.sharedInstance submit:@[memoryMetric, storageMetric]]; | ||
} | ||
|
||
|
||
/* | ||
Creates and auto-submits two counter metrics: "meaning" and "plutonium", the latter using an NSDictionary to set the value and source simultaneously | ||
*/ | ||
- (void)dictionaryCreationExample | ||
{ | ||
[LibratoDemoEventTracker.sharedInstance submit:@{@"meaning": self.randomNumber, @"plutonium": @{@"value": @238, @"source": @"Russia, with love"}}]; | ||
} | ||
|
||
|
||
/* | ||
Creates a series of counter measurements and submits them as a gague metric | ||
*/ | ||
- (void)gaugeMetricExample | ||
{ | ||
LibratoMetric *metric1 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric2 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric3 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric4 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric5 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric6 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric7 = [LibratoMetric metricNamed:@"bagels" valued:self.randomNumber options:nil]; | ||
LibratoMetric *metric8 = [LibratoMetric metricNamed:@"bagels" valued:@0 options:nil]; | ||
|
||
NSArray *bagels = @[metric1, metric2, metric3, metric4, metric5, metric6, metric7, metric8]; | ||
NSLog(@"%@", bagels); | ||
LibratoGaugeMetric *bagelGuage = [LibratoGaugeMetric metricNamed:@"bagel_guage" measurements:bagels]; | ||
|
||
[LibratoDemoEventTracker.sharedInstance submit:bagelGuage]; | ||
} | ||
|
||
|
||
#pragma mark - Helpers | ||
- (NSNumber *)randomNumber | ||
{ | ||
return @(abs(rand() % 100)); | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Localized versions of Info.plist keys */ | ||
|
Oops, something went wrong.