From 9ae3f90abde335b1cb7a0567e2d02133108db9ba Mon Sep 17 00:00:00 2001 From: ijunaid Date: Fri, 6 Sep 2024 21:12:58 +0500 Subject: [PATCH 1/3] Revert "Some more fixes" This reverts commit 254a7c3479fd9cd4c7b381d2ce9bedbba3bbed8c. --- Countly.m | 7 +++---- CountlyContentBuilder.h | 8 +++----- CountlyContentBuilder.m | 9 +++------ CountlyContentBuilderInternal.h | 9 ++++----- CountlyContentBuilderInternal.m | 8 ++------ CountlyWebViewManager.h | 12 ++++++------ CountlyWebViewManager.m | 11 +++++------ PassThroughBackgroundView.h | 6 ++++-- PassThroughBackgroundView.m | 6 ++++-- 9 files changed, 34 insertions(+), 42 deletions(-) diff --git a/Countly.m b/Countly.m index 83dff794..ff61c72a 100644 --- a/Countly.m +++ b/Countly.m @@ -912,10 +912,9 @@ - (void)recordEvent:(NSString *)key segmentation:(NSDictionary *)segmentation co key = [key cly_truncatedKey:@"Event key"]; event.PEID = previousEventID ?: @""; previousEventID = event.ID; - if(CountlyViewTrackingInternal.sharedInstance.enablePreviousNameRecording) { - filteredSegmentations[kCountlyPreviousEventName] = previousEventName ?: @""; - previousEventName = key; - } + + filteredSegmentations[kCountlyPreviousEventName] = previousEventName ?: @""; + previousEventName = key; } event.key = key; event.segmentation = [self processSegmentation:filteredSegmentations eventKey:key]; diff --git a/CountlyContentBuilder.h b/CountlyContentBuilder.h index 088d58be..3614413a 100644 --- a/CountlyContentBuilder.h +++ b/CountlyContentBuilder.h @@ -6,9 +6,10 @@ #import -#if (TARGET_OS_IOS) +#import NS_ASSUME_NONNULL_BEGIN @interface CountlyContentBuilder: NSObject +#if (TARGET_OS_IOS) + (instancetype)sharedInstance; /** @@ -23,9 +24,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)exitContentZone; +#endif NS_ASSUME_NONNULL_END @end -#else -@interface CountlyContentBuilder: NSObject -@end -#endif diff --git a/CountlyContentBuilder.m b/CountlyContentBuilder.m index 9e2f45e4..6a456cea 100644 --- a/CountlyContentBuilder.m +++ b/CountlyContentBuilder.m @@ -3,12 +3,13 @@ // This code is provided under the MIT License. // // Please visit www.count.ly for more information. -#if (TARGET_OS_IOS) + #import "CountlyContentBuilder.h" #import "CountlyContentBuilderInternal.h" #import "CountlyCommon.h" @implementation CountlyContentBuilder +#if (TARGET_OS_IOS) + (instancetype)sharedInstance { if (!CountlyCommon.sharedInstance.hasStarted) @@ -45,9 +46,5 @@ - (void)changeContent:(NSArray *)tags [CountlyContentBuilder.sharedInstance changeContent:tags]; } -@end -#else -#import "CountlyContentBuilder.h" -@implementation CountlyContentBuilder -@end #endif +@end diff --git a/CountlyContentBuilderInternal.h b/CountlyContentBuilderInternal.h index cef5ce2a..905fb0b1 100644 --- a/CountlyContentBuilderInternal.h +++ b/CountlyContentBuilderInternal.h @@ -5,10 +5,11 @@ // Please visit www.count.ly for more information. #import +#import #import "CountlyCommon.h" -#if (TARGET_OS_IOS) NS_ASSUME_NONNULL_BEGIN @interface CountlyContentBuilderInternal: NSObject +#if (TARGET_OS_IOS) @property (nonatomic, strong) NSArray *currentTags; @property (nonatomic, assign) NSTimeInterval requestInterval; @property (nonatomic) ContentCallback contentCallback; @@ -19,9 +20,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)exitContentZone; - (void)changeContent:(NSArray *)tags; +#endif NS_ASSUME_NONNULL_END @end -#else -@interface CountlyContentBuilderInternal: NSObject -@end -#endif + diff --git a/CountlyContentBuilderInternal.m b/CountlyContentBuilderInternal.m index 3b43554e..4a0ef01b 100644 --- a/CountlyContentBuilderInternal.m +++ b/CountlyContentBuilderInternal.m @@ -3,9 +3,7 @@ // This code is provided under the MIT License. // // Please visit www.count.ly for more information. - #import "CountlyContentBuilderInternal.h" -#if (TARGET_OS_IOS) #import "CountlyWebViewManager.h" //TODO: improve logging, check edge cases @@ -17,6 +15,7 @@ @implementation CountlyContentBuilderInternal { NSTimer *_requestTimer; NSTimer *_minuteTimer; } +#if (TARGET_OS_IOS) + (instancetype)sharedInstance { static CountlyContentBuilderInternal *instance = nil; static dispatch_once_t onceToken; @@ -206,8 +205,5 @@ - (void)showContentWithHtmlPath:(NSString *)pathToHtml placementCoordinates:(NSD }]; }); } -@end -#else -@implementation CountlyContentBuilderInternal -@end #endif +@end diff --git a/CountlyWebViewManager.h b/CountlyWebViewManager.h index 2b496eb8..77748adb 100644 --- a/CountlyWebViewManager.h +++ b/CountlyWebViewManager.h @@ -4,11 +4,12 @@ // // Please visit www.count.ly for more information. -#if (TARGET_OS_IOS) + #import #import NS_ASSUME_NONNULL_BEGIN +#if (TARGET_OS_IOS) typedef NS_ENUM(NSUInteger, AnimationType) { AnimationTypeSlideInFromBottom, AnimationTypeSlideInFromTop, @@ -18,18 +19,17 @@ typedef NS_ENUM(NSUInteger, AnimationType) { AnimationTypeIncreaseHeightFromBottom }; +#endif + @interface CountlyWebViewManager : NSObject +#if (TARGET_OS_IOS) - (void)createWebViewWithURL:(NSURL *)url frame:(CGRect)frame appearBlock:(void(^ __nullable)(void))appearBlock dismissBlock:(void(^ __nullable)(void))dismissBlock; +#endif NS_ASSUME_NONNULL_END @end -#else -#import -@interface CountlyWebViewManager : NSObject -@end -#endif diff --git a/CountlyWebViewManager.m b/CountlyWebViewManager.m index d20d53d0..4b356df9 100644 --- a/CountlyWebViewManager.m +++ b/CountlyWebViewManager.m @@ -1,15 +1,18 @@ -#if (TARGET_OS_IOS) + #import "CountlyWebViewManager.h" #import "PassThroughBackgroundView.h" #import "CountlyCommon.h" //TODO: improve logging, check edge cases @interface CountlyWebViewManager() +#if (TARGET_OS_IOS) @property (nonatomic, strong) PassThroughBackgroundView *backgroundView; @property (nonatomic, copy) void (^dismissBlock)(void); +#endif @end @implementation CountlyWebViewManager +#if (TARGET_OS_IOS) - (void)createWebViewWithURL:(NSURL *)url frame:(CGRect)frame appearBlock:(void(^ __nullable)(void))appearBlock @@ -241,9 +244,5 @@ - (void)closeWebView { [self.backgroundView removeFromSuperview]; }); } -@end -#else -#import "CountlyWebViewManager.h" -@implementation CountlyWebViewManager -@end #endif +@end diff --git a/PassThroughBackgroundView.h b/PassThroughBackgroundView.h index 04df7fbc..78e79ffa 100644 --- a/PassThroughBackgroundView.h +++ b/PassThroughBackgroundView.h @@ -4,15 +4,17 @@ // // Please visit www.count.ly for more information. -#if (TARGET_OS_IOS) + #import #import #import "CountlyCommon.h" NS_ASSUME_NONNULL_BEGIN @interface PassThroughBackgroundView : UIView + +#if (TARGET_OS_IOS) @property (nonatomic, strong) WKWebView *webView; @property (nonatomic, strong) CLYButton *dismissButton; +#endif NS_ASSUME_NONNULL_END @end -#endif diff --git a/PassThroughBackgroundView.m b/PassThroughBackgroundView.m index d7c43e09..cd8bf876 100644 --- a/PassThroughBackgroundView.m +++ b/PassThroughBackgroundView.m @@ -3,7 +3,7 @@ // This code is provided under the MIT License. // // Please visit www.count.ly for more information. -#if (TARGET_OS_IOS) + #import "PassThroughBackgroundView.h" @implementation PassThroughBackgroundView @@ -11,6 +11,7 @@ @implementation PassThroughBackgroundView @synthesize webView; - (instancetype)initWithFrame:(CGRect)frame { +#if (TARGET_OS_IOS) self = [super initWithFrame:frame]; if (self) { } @@ -28,5 +29,6 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { return NO; } -@end + #endif +@end From 46a367f6add81f35032d5f12f7448253ca8710d3 Mon Sep 17 00:00:00 2001 From: ijunaid Date: Mon, 9 Sep 2024 11:41:43 +0500 Subject: [PATCH 2/3] Added previous event name checks --- Countly.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Countly.m b/Countly.m index ff61c72a..83dff794 100644 --- a/Countly.m +++ b/Countly.m @@ -912,9 +912,10 @@ - (void)recordEvent:(NSString *)key segmentation:(NSDictionary *)segmentation co key = [key cly_truncatedKey:@"Event key"]; event.PEID = previousEventID ?: @""; previousEventID = event.ID; - - filteredSegmentations[kCountlyPreviousEventName] = previousEventName ?: @""; - previousEventName = key; + if(CountlyViewTrackingInternal.sharedInstance.enablePreviousNameRecording) { + filteredSegmentations[kCountlyPreviousEventName] = previousEventName ?: @""; + previousEventName = key; + } } event.key = key; event.segmentation = [self processSegmentation:filteredSegmentations eventKey:key]; From 64ac554a87e1cd0b3967f63e7517e6cdf4c6e824 Mon Sep 17 00:00:00 2001 From: ijunaid Date: Mon, 9 Sep 2024 11:47:29 +0500 Subject: [PATCH 3/3] Fixes iOS macros for webview and content builder --- CountlyContentBuilder.h | 2 ++ CountlyContentBuilderInternal.h | 2 ++ CountlyWebViewManager.h | 12 +++++++----- CountlyWebViewManager.m | 5 +++-- PassThroughBackgroundView.h | 13 ++++++++++--- PassThroughBackgroundView.m | 6 ++++-- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CountlyContentBuilder.h b/CountlyContentBuilder.h index 3614413a..e1b4441f 100644 --- a/CountlyContentBuilder.h +++ b/CountlyContentBuilder.h @@ -6,7 +6,9 @@ #import +#if (TARGET_OS_IOS) #import +#endif NS_ASSUME_NONNULL_BEGIN @interface CountlyContentBuilder: NSObject #if (TARGET_OS_IOS) diff --git a/CountlyContentBuilderInternal.h b/CountlyContentBuilderInternal.h index 905fb0b1..be18530d 100644 --- a/CountlyContentBuilderInternal.h +++ b/CountlyContentBuilderInternal.h @@ -5,7 +5,9 @@ // Please visit www.count.ly for more information. #import +#if (TARGET_OS_IOS) #import +#endif #import "CountlyCommon.h" NS_ASSUME_NONNULL_BEGIN @interface CountlyContentBuilderInternal: NSObject diff --git a/CountlyWebViewManager.h b/CountlyWebViewManager.h index 77748adb..7354aa7b 100644 --- a/CountlyWebViewManager.h +++ b/CountlyWebViewManager.h @@ -4,9 +4,11 @@ // // Please visit www.count.ly for more information. - +#if (TARGET_OS_IOS) #import #import +#endif +#import "CountlyCommon.h" NS_ASSUME_NONNULL_BEGIN #if (TARGET_OS_IOS) @@ -19,17 +21,17 @@ typedef NS_ENUM(NSUInteger, AnimationType) { AnimationTypeIncreaseHeightFromBottom }; -#endif + @interface CountlyWebViewManager : NSObject -#if (TARGET_OS_IOS) - (void)createWebViewWithURL:(NSURL *)url frame:(CGRect)frame appearBlock:(void(^ __nullable)(void))appearBlock dismissBlock:(void(^ __nullable)(void))dismissBlock; -#endif -NS_ASSUME_NONNULL_END + @end +#endif +NS_ASSUME_NONNULL_END diff --git a/CountlyWebViewManager.m b/CountlyWebViewManager.m index 4b356df9..ace4249f 100644 --- a/CountlyWebViewManager.m +++ b/CountlyWebViewManager.m @@ -4,11 +4,11 @@ #import "CountlyCommon.h" //TODO: improve logging, check edge cases -@interface CountlyWebViewManager() #if (TARGET_OS_IOS) +@interface CountlyWebViewManager() + @property (nonatomic, strong) PassThroughBackgroundView *backgroundView; @property (nonatomic, copy) void (^dismissBlock)(void); -#endif @end @implementation CountlyWebViewManager @@ -246,3 +246,4 @@ - (void)closeWebView { } #endif @end +#endif diff --git a/PassThroughBackgroundView.h b/PassThroughBackgroundView.h index 78e79ffa..c0b9b79f 100644 --- a/PassThroughBackgroundView.h +++ b/PassThroughBackgroundView.h @@ -5,16 +5,23 @@ // Please visit www.count.ly for more information. +#if (TARGET_OS_IOS) #import #import +#endif + #import "CountlyCommon.h" + NS_ASSUME_NONNULL_BEGIN +#if (TARGET_OS_IOS) @interface PassThroughBackgroundView : UIView -#if (TARGET_OS_IOS) + @property (nonatomic, strong) WKWebView *webView; @property (nonatomic, strong) CLYButton *dismissButton; -#endif -NS_ASSUME_NONNULL_END + + @end +#endif +NS_ASSUME_NONNULL_END diff --git a/PassThroughBackgroundView.m b/PassThroughBackgroundView.m index cd8bf876..d6bd8328 100644 --- a/PassThroughBackgroundView.m +++ b/PassThroughBackgroundView.m @@ -6,12 +6,13 @@ #import "PassThroughBackgroundView.h" +#if (TARGET_OS_IOS) @implementation PassThroughBackgroundView @synthesize webView; - (instancetype)initWithFrame:(CGRect)frame { -#if (TARGET_OS_IOS) + self = [super initWithFrame:frame]; if (self) { } @@ -30,5 +31,6 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { return NO; } -#endif + @end +#endif