Skip to content

Commit 24e9edb

Browse files
committedOct 9, 2013
Tap into custom UA.
1 parent 6ffd437 commit 24e9edb

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed
 

‎Demo/librato-iOS Demo/LibratoDemoEventTracker.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
- (void)groupContextExample;
2424
- (void)gaugeMetricExample;
2525
- (void)notificationExample;
26+
- (void)customUAExample;
2627

2728
@end

‎Demo/librato-iOS Demo/LibratoDemoEventTracker.m

+13
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ - (void)gaugeMetricExample
164164
}
165165

166166

167+
/*
168+
You can add a custom string the User Agent sent with all of the Librato requests
169+
WARNING: Setting a custom UA will reset your client's connection so do not do this arbitrarily
170+
*/
171+
- (void)customUAExample
172+
{
173+
Librato *l = LibratoDemoEventTracker.sharedInstance;
174+
l.customUserAgent = @"Demo UA";
175+
176+
[l submit:@{@"ua.custom.instances": @1}];
177+
}
178+
179+
167180
#pragma mark - Helpers
168181
- (NSNumber *)randomNumber
169182
{

‎librato-iOS/Classes/LibratoClient.m

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ - (instancetype)init
3131
return self;
3232
}
3333

34-
// TODO: Implelement
35-
- (NSString *)agentIdentifier
36-
{
37-
return @"";
38-
}
39-
4034

4135
- (void)authenticateEmail:(NSString *)emailAddress APIKey:(NSString *)apiKey
4236
{

‎librato-iOS/Librato.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ typedef void (^LibratoNotificationContext)(NSNotification *notification);
3838
- (void)authenticateEmail:(NSString *)emailAddress APIKey:(NSString *)apiKey;
3939
- (NSString *)APIEndpoint;
4040
- (void)setAPIEndpoint:(NSString *)APIEndpoint;
41+
- (LibratoConnection *)connection;
42+
- (NSString *)customUserAgent;
43+
- (void)setCustomUserAgent:(NSString *)userAgent;
4144
- (NSString *)persistence;
4245
- (void)setPersistence:(NSString *)persistence;
4346
- (id<LibratoPersister>)persister;
44-
- (LibratoConnection *)connection;
4547
- (void)getMetric:(NSString *)name options:(NSDictionary *)options;
4648
- (void)getMeasurements:(NSString *)named options:(NSDictionary *)options;
4749
- (void)updateMetricsNamed:(NSString *)name options:(NSDictionary *)options;

‎librato-iOS/Librato.m

+18-6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ - (void)setAPIEndpoint:(NSString *)APIEndpoint
7070
}
7171

7272

73+
- (LibratoConnection *)connection
74+
{
75+
return self.client.connection;
76+
}
77+
78+
79+
- (NSString *)customUserAgent
80+
{
81+
return self.client.customUserAgent;
82+
}
83+
84+
85+
- (void)setCustomUserAgent:(NSString *)userAgent
86+
{
87+
self.client.customUserAgent = userAgent;
88+
}
89+
90+
7391
- (NSString *)persistence
7492
{
7593
return self.client.persistence;
@@ -88,12 +106,6 @@ - (void)setPersistence:(NSString *)persistence
88106
}
89107

90108

91-
- (LibratoConnection *)connection
92-
{
93-
return self.client.connection;
94-
}
95-
96-
97109
- (void)getMetric:(NSString *)name options:(NSDictionary *)options
98110
{
99111
[self.client getMetric:name options:options];

0 commit comments

Comments
 (0)