From e0a704ec517fcbfabdc395077941030d780f1faa Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 25 Oct 2018 16:50:06 -0400 Subject: [PATCH] adobe track alert --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h | 2 ++ MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m | 2 ++ MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m | 6 ++++-- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h | 1 + MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m | 3 ++- .../MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h | 2 ++ MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h | 1 + MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m | 6 ++++++ 8 files changed, 20 insertions(+), 3 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h index 977911f..7d7aa25 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.h @@ -12,5 +12,7 @@ @interface MVMCoreAlertController : UIAlertController @property (nonatomic, readonly, getter=isVisible) BOOL visible; +@property (nullable, nonatomic, copy) NSString *alertPageType; +@property (nullable, nonatomic, weak) id delegate; @end diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m index 89352a4..3a67b54 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertController.m @@ -7,6 +7,7 @@ // #import "MVMCoreAlertController.h" +#import "MVMCoreLoggingHandler.h" @interface MVMCoreAlertController () @@ -22,6 +23,7 @@ [self willChangeValueForKey:@"isVisible"]; self.visible = YES; [self didChangeValueForKey:@"isVisible"]; + [MVMCoreLoggingHandler logAlertForAlertPageType:self.alertPageType delegate:self.delegate]; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m index bbbda62..2be088e 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertHandler.m @@ -80,7 +80,7 @@ return [self showAlertWithTitle:title message:message actions:actions alertStyle:UIAlertControllerStyleAlert isGreedy:isGreedy alertDelegate:alertDelegate]; } -- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { +- (nonnull UIAlertController *)showAlertWithTitle:(nullable NSString *)title message:(nullable NSString *)message pageType:(nullable NSString *)pageType actions:(nullable NSArray*)actions alertStyle:(UIAlertControllerStyle)alertStyle isGreedy:(BOOL)isGreedy alertDelegate:(nullable NSObject *)alertDelegate { // It's a greedy alert! Clear all alerts that are queued up and the one that is showing if (isGreedy) { @@ -89,6 +89,8 @@ // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; + alertController.alertPageType = pageType; + alertController.delegate = alertDelegate; for (NSUInteger i = 0; i < [actions count]; i++) { UIAlertAction *action = [actions objectAtIndex:i ofType:[UIAlertAction class]]; if (action) { @@ -102,7 +104,7 @@ } - (nonnull UIAlertController *)showAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject { - return [self showAlertWithTitle:alertObject.title message:alertObject.message actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; + return [self showAlertWithTitle:alertObject.title message:alertObject.message pageType:alertObject.pageType actions:alertObject.actions alertStyle:alertObject.alertStyle isGreedy:alertObject.isGreedy alertDelegate:alertObject.alertDelegate]; } - (void)removeAllAlertViews { diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h index 4b9d12c..b730e60 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.h @@ -29,6 +29,7 @@ typedef void (^TextFieldErrorHandler)(NSArray * _Nonnull fieldErrors); @property (nullable, strong, nonatomic) NSString *title; @property (nullable, strong, nonatomic) NSString *message; +@property (nullable, strong, nonatomic) NSString *pageType; @property (nonnull, strong, nonatomic) NSArray *actions; @property (nonatomic) BOOL isGreedy; @property (nonatomic) UIAlertControllerStyle alertStyle; diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m index 5599049..424616b 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject.m @@ -71,7 +71,6 @@ // Perform a popup. alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; - // Check if we have a popup driven by page object (otherwise by default it will just use response info title message with an OK button). NSString *pageTypeForPopup = [responseInfo stringForKey:@"popupPageType"]; [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { @@ -88,6 +87,8 @@ alert = popupAlert; } }]; + alert.pageType = pageTypeForPopup; + alert.alertDelegate = actionDelegate; } else if (messageStyle.length == 0 && pageType) { // No message style! diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h index fc0e353..476c497 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreLoggingDelegateProtocol.h @@ -24,4 +24,6 @@ // Log that the load has finished. - (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; +// Log alert +- (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h index 48700ec..e15d1f2 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.h @@ -20,5 +20,6 @@ + (void)logDebugMessageWithDelegate:(nullable NSString *)message; + (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra; + (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController *)loadedViewController error:(nullable MVMCoreErrorObject *)error; ++ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate; @end diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index 3c1daf8..b2026da 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -35,5 +35,11 @@ } } ++ (void)logAlertForAlertPageType:(nullable NSString *)pageType delegate:(_Nullable id)delegate { + if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertPageType:delegate:)]) { + [[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertPageType:pageType delegate:delegate]; + } +} + @end