-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,032 additions
and
228 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
14 changes: 14 additions & 0 deletions
14
.../Classes/BusinessLogicLayer/Services/ConcreteServices/AnalyticsService/AnalyticsService.h
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,14 @@ | ||
// | ||
// AnalyticsService.h | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
@import Foundation; | ||
|
||
@protocol AnalyticsService <NSObject> | ||
- (void) trackBannerShown; | ||
- (void) trackBannerClicked; | ||
@end |
21 changes: 21 additions & 0 deletions
21
...essLogicLayer/Services/ConcreteServices/AnalyticsService/AnalyticsServiceImplementation.h
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,21 @@ | ||
// | ||
// AnalyticsServiceImplementation.h | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
#import "AnalyticsService.h" | ||
|
||
@class AnalyticsOperationFactory; | ||
@protocol OperationScheduler; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface AnalyticsServiceImplementation : NSObject <AnalyticsService> | ||
@property (nonatomic, strong) AnalyticsOperationFactory *analyticsOperationFactory; | ||
@property (nonatomic, strong) id <OperationScheduler> operationScheduler; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
103 changes: 103 additions & 0 deletions
103
...essLogicLayer/Services/ConcreteServices/AnalyticsService/AnalyticsServiceImplementation.m
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,103 @@ | ||
// | ||
// AnalyticsServiceImplementation.m | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
@import CoreTelephony; | ||
|
||
#import "AnalyticsServiceImplementation.h" | ||
|
||
#import "OperationScheduler.h" | ||
#import "CompoundOperationBase.h" | ||
|
||
#import "AnalyticsOperationFactory.h" | ||
|
||
#import "AnalyticsQuery.h" | ||
#import "AnalyticsBody.h" | ||
|
||
@interface AnalyticsServiceImplementation () | ||
@property (nonatomic, strong) NSString *iso; | ||
@end | ||
|
||
@implementation AnalyticsServiceImplementation | ||
|
||
- (void) trackBannerShown { | ||
AnalyticsQuery *query = [self _obtainQuery]; | ||
AnalyticsBody *body = [self _obtainBodyWithEvent:@"iOS-MEWconnectApp-Banner-shown"]; | ||
|
||
CompoundOperationBase *compoundOperation = [self.analyticsOperationFactory analyticsWithQuery:query body:body]; | ||
[self.operationScheduler addOperation:compoundOperation]; | ||
} | ||
|
||
- (void) trackBannerClicked { | ||
AnalyticsQuery *query = [self _obtainQuery]; | ||
AnalyticsBody *body = [self _obtainBodyWithEvent:@"iOS-MEWconnectApp-Banner-FreeUpgrade-clicked"]; | ||
|
||
CompoundOperationBase *compoundOperation = [self.analyticsOperationFactory analyticsWithQuery:query body:body]; | ||
[self.operationScheduler addOperation:compoundOperation]; | ||
} | ||
|
||
#pragma mark - Private | ||
|
||
- (AnalyticsQuery *) _obtainQuery { | ||
AnalyticsQuery *query = [[AnalyticsQuery alloc] init]; | ||
query.iso = self.iso; | ||
return query; | ||
} | ||
|
||
- (AnalyticsBody *) _obtainBodyWithEvent:(NSString *)event { | ||
AnalyticsBody *body = [[AnalyticsBody alloc] init]; | ||
|
||
NSISO8601DateFormatter *dateFormatter = [[NSISO8601DateFormatter alloc] init]; | ||
dateFormatter.formatOptions = NSISO8601DateFormatWithFullDate | NSISO8601DateFormatWithFullTime; | ||
if (@available(iOS 11.0, *)) { | ||
dateFormatter.formatOptions |= NSISO8601DateFormatWithFractionalSeconds; | ||
} | ||
|
||
NSString *timestamp = [dateFormatter stringFromDate:[NSDate date]]; | ||
if (@available(iOS 11.0, *)) { | ||
//do nothing | ||
} else { | ||
if ([timestamp length] > 1) { | ||
NSMutableString *timestampWithFractionalSeconds = [timestamp mutableCopy]; | ||
[timestampWithFractionalSeconds insertString:@".000" atIndex:[timestamp length] - 1]; | ||
timestamp = [timestampWithFractionalSeconds copy]; | ||
} | ||
} | ||
|
||
body.events = @[ | ||
@{ | ||
@"id": event, | ||
@"timestamp": timestamp | ||
} | ||
]; | ||
return body; | ||
} | ||
|
||
#pragma mark - Override | ||
|
||
- (NSString *)iso { | ||
if (!_iso) { | ||
CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init]; | ||
CTCarrier *carrier = networkInfo.subscriberCellularProvider; | ||
NSString *cellularISO = carrier.isoCountryCode.lowercaseString; | ||
if ([cellularISO length] > 0) { | ||
_iso = cellularISO; | ||
return _iso; | ||
} | ||
|
||
NSString *localeISO = [[NSLocale currentLocale] countryCode].lowercaseString; | ||
if ([localeISO length] > 0) { | ||
_iso = localeISO; | ||
return _iso; | ||
} | ||
|
||
_iso = @"__"; | ||
} | ||
return _iso; | ||
} | ||
|
||
@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
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
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
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
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
13 changes: 13 additions & 0 deletions
13
...ents/BodyTransformers/ConcreteClasses/AnalyticsBodyTransformer/AnalyticsBodyTransformer.h
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,13 @@ | ||
// | ||
// AnalyticsBodyTransformer.h | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
#import "BodyTransformerBase.h" | ||
|
||
@interface AnalyticsBodyTransformer : BodyTransformerBase | ||
|
||
@end |
20 changes: 20 additions & 0 deletions
20
...ents/BodyTransformers/ConcreteClasses/AnalyticsBodyTransformer/AnalyticsBodyTransformer.m
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,20 @@ | ||
// | ||
// AnalyticsBodyTransformer.m | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
#import "AnalyticsBodyTransformer.h" | ||
#import "AnalyticsBody.h" | ||
|
||
static NSString *const kAnalyticsBodyEventKey = @"events"; | ||
|
||
@implementation AnalyticsBodyTransformer | ||
|
||
- (NSData *)deriveDataFromBody:(AnalyticsBody *)body { | ||
return [NSJSONSerialization dataWithJSONObject:@{kAnalyticsBodyEventKey: body.events} options:0 error:nil]; | ||
} | ||
|
||
@end |
13 changes: 13 additions & 0 deletions
13
...s/QueryTransformers/ConcreteClasses/AnalyticsQueryTransformer/AnalyticsQueryTransformer.h
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,13 @@ | ||
// | ||
// AnalyticsQueryTransformer.h | ||
// MyEtherWallet-iOS | ||
// | ||
// Created by Mikhail Nikanorov on 3/10/20. | ||
// Copyright © 2020 MyEtherWallet, Inc. All rights reserved. | ||
// | ||
|
||
#import "QueryTransformerBase.h" | ||
|
||
@interface AnalyticsQueryTransformer : QueryTransformerBase | ||
|
||
@end |
Oops, something went wrong.