summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/src/MGLMetricsManager.h5
-rw-r--r--platform/darwin/src/MGLMetricsManager.m8
-rw-r--r--platform/darwin/src/MGLMetricsManager_Private.h4
-rw-r--r--platform/darwin/src/MGLNetworkConfiguration.m7
4 files changed, 15 insertions, 9 deletions
diff --git a/platform/darwin/src/MGLMetricsManager.h b/platform/darwin/src/MGLMetricsManager.h
index 73756cebed..29fd5c79f8 100644
--- a/platform/darwin/src/MGLMetricsManager.h
+++ b/platform/darwin/src/MGLMetricsManager.h
@@ -7,10 +7,13 @@ typedef NS_ENUM(NSUInteger, MGLMetricType) {
MGLMetricTypePerformance = 0,
};
+FOUNDATION_EXTERN MGL_EXPORT NSString* MGLStringFromMetricType(MGLMetricType metricType);
+
+@class MGLMetricsManager;
@protocol MGLMetricsDelegate <NSObject>
- (BOOL)shouldHandleMetric:(MGLMetricType)metricType;
-- (void)didCollectMetric:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes;
+- (void)metricsManager:(MGLMetricsManager *)metricsManager didCollectMetric:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes;
@end
diff --git a/platform/darwin/src/MGLMetricsManager.m b/platform/darwin/src/MGLMetricsManager.m
index 75dc593aa7..cdc392ce40 100644
--- a/platform/darwin/src/MGLMetricsManager.m
+++ b/platform/darwin/src/MGLMetricsManager.m
@@ -5,6 +5,10 @@
NSString * const kMGLPerformanceMetric = @"mobile.performance_trace";
+NSString* MGLStringFromMetricType(MGLMetricType metricType) {
+ return [@[kMGLPerformanceMetric] objectAtIndex:metricType];
+}
+
@implementation MGLMetricsManager
+ (instancetype)sharedManager
@@ -17,9 +21,9 @@ NSString * const kMGLPerformanceMetric = @"mobile.performance_trace";
return sharedConfiguration;
}
-- (void)handleMetricEvent:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes {
+- (void)handleMetricsEvent:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes {
if ([self.delegate shouldHandleMetric:metricType]) {
- [self.delegate didCollectMetric:metricType withAttributes:attributes];
+ [self.delegate metricsManager:self didCollectMetric:metricType withAttributes:attributes];
}
}
diff --git a/platform/darwin/src/MGLMetricsManager_Private.h b/platform/darwin/src/MGLMetricsManager_Private.h
index 4a32710925..a2b2d9548c 100644
--- a/platform/darwin/src/MGLMetricsManager_Private.h
+++ b/platform/darwin/src/MGLMetricsManager_Private.h
@@ -2,11 +2,11 @@
NS_ASSUME_NONNULL_BEGIN
-extern NSString *const kMGLPerformanceMetric;
+FOUNDATION_EXTERN MGL_EXPORT NSString *const kMGLPerformanceMetric;
@interface MGLMetricsManager (Private)
-- (void)handleMetricEvent:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes;
+- (void)handleMetricsEvent:(MGLMetricType)metricType withAttributes:(NSDictionary *)attributes;
@end
diff --git a/platform/darwin/src/MGLNetworkConfiguration.m b/platform/darwin/src/MGLNetworkConfiguration.m
index 5682e0bc1e..f938bcc753 100644
--- a/platform/darwin/src/MGLNetworkConfiguration.m
+++ b/platform/darwin/src/MGLNetworkConfiguration.m
@@ -1,7 +1,6 @@
#import "MGLNetworkConfiguration_Private.h"
#import "MGLMetricsManager_Private.h"
-NSString * const kMGLDownloadPerformanceEvent = @"mobile.performance_trace";
static NSString * const MGLStartTime = @"start_time";
static NSString * const MGLResourceType = @"resource_type";
@@ -73,7 +72,7 @@ static NSString * const MGLResourceType = @"resource_type";
{
if (urlString && [self.events objectForKey:urlString]) {
NSDictionary *eventAttributes = [self eventAttributesForURL:urlString withAction:action];
- [[MGLMetricsManager sharedManager] handleMetricEvent:MGLMetricTypePerformance withAttributes:eventAttributes];
+ [[MGLMetricsManager sharedManager] handleMetricsEvent:MGLMetricTypePerformance withAttributes:eventAttributes];
[self.events removeObjectForKey:urlString];
}
}
@@ -94,9 +93,9 @@ static NSString * const MGLResourceType = @"resource_type";
if (action) {
[attributes addObject:@{ @"name" : @"action" , @"value" : action }];
}
-
+ NSString *event = MGLStringFromMetricType(MGLMetricTypePerformance);
return @{
- @"event" : kMGLPerformanceMetric,
+ @"event" : event,
@"created" : createdDate,
@"sessionId" : [NSUUID UUID].UUIDString,
@"counters" : @[ @{ @"name" : @"elapsed_time" , @"value" : @(elapsedTime) } ],