From 101a95aa4d551c4855040c37c43918a468675f42 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 29 May 2020 13:43:40 -0700 Subject: [PATCH 1/2] Renamed middleware methods to match a.js naming. --- Analytics/Classes/Integrations/SEGIntegrationsManager.m | 2 +- Analytics/Classes/Middlewares/SEGMiddleware.h | 4 ++-- Analytics/Classes/Middlewares/SEGMiddleware.m | 2 +- Analytics/Classes/SEGAnalyticsConfiguration.h | 4 ++-- AnalyticsTests/MiddlewareTests.swift | 6 +++--- Examples/CarthageExample/Cartfile.resolved | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Analytics/Classes/Integrations/SEGIntegrationsManager.m b/Analytics/Classes/Integrations/SEGIntegrationsManager.m index e64a1e658..9e98992e2 100644 --- a/Analytics/Classes/Integrations/SEGIntegrationsManager.m +++ b/Analytics/Classes/Integrations/SEGIntegrationsManager.m @@ -357,7 +357,7 @@ - (void)setCachedSettings:(NSDictionary *)settings - (nonnull NSArray> *)middlewareForIntegrationKey:(NSString *)key { NSMutableArray *result = [[NSMutableArray alloc] init]; - for (SEGIntegrationMiddleware *container in self.configuration.integrationMiddleware) { + for (SEGDestinationMiddleware *container in self.configuration.destinationMiddleware) { if ([container.integrationKey isEqualToString:key]) { [result addObjectsFromArray:container.middleware]; } diff --git a/Analytics/Classes/Middlewares/SEGMiddleware.h b/Analytics/Classes/Middlewares/SEGMiddleware.h index 2f05fe9f7..435af3e55 100644 --- a/Analytics/Classes/Middlewares/SEGMiddleware.h +++ b/Analytics/Classes/Middlewares/SEGMiddleware.h @@ -57,8 +57,8 @@ typedef void (^RunMiddlewaresCallback)(BOOL earlyExit, NSArray @end -// Container object for middlewares for a specific integration. -@interface SEGIntegrationMiddleware : NSObject +// Container object for middlewares for a specific destination. +@interface SEGDestinationMiddleware : NSObject @property (nonatomic, strong, nonnull, readonly) NSString *integrationKey; @property (nonatomic, strong, nullable, readonly) NSArray> *middleware; - (instancetype _Nonnull)initWithKey:(NSString * _Nonnull)integrationKey middleware:(NSArray> * _Nonnull)middleware; diff --git a/Analytics/Classes/Middlewares/SEGMiddleware.m b/Analytics/Classes/Middlewares/SEGMiddleware.m index 88dc50943..a63b05827 100644 --- a/Analytics/Classes/Middlewares/SEGMiddleware.m +++ b/Analytics/Classes/Middlewares/SEGMiddleware.m @@ -10,7 +10,7 @@ #import "SEGMiddleware.h" -@implementation SEGIntegrationMiddleware +@implementation SEGDestinationMiddleware - (instancetype)initWithKey:(NSString *)integrationKey middleware:(NSArray> *)middleware { if (self = [super init]) { diff --git a/Analytics/Classes/SEGAnalyticsConfiguration.h b/Analytics/Classes/SEGAnalyticsConfiguration.h index 915c97d38..c8a1f2b93 100644 --- a/Analytics/Classes/SEGAnalyticsConfiguration.h +++ b/Analytics/Classes/SEGAnalyticsConfiguration.h @@ -27,7 +27,7 @@ typedef NSString *_Nonnull (^SEGAdSupportBlock)(void); @protocol SEGMiddleware; @class SEGAnalyticsExperimental; -@class SEGIntegrationMiddleware; +@class SEGDestinationMiddleware; /** * This object provides a set of properties to control various policies of the analytics client. Other than `writeKey`, these properties can be changed at any time. @@ -150,7 +150,7 @@ typedef NSString *_Nonnull (^SEGAdSupportBlock)(void); /** * Set custom integration middleware. Will be run before the associated integration. */ -@property (nonatomic, strong, nullable) NSArray *integrationMiddleware; +@property (nonatomic, strong, nullable) NSArray *destinationMiddleware; /** * Register a factory that can be used to create an integration. diff --git a/AnalyticsTests/MiddlewareTests.swift b/AnalyticsTests/MiddlewareTests.swift index 8655de103..84746cb09 100644 --- a/AnalyticsTests/MiddlewareTests.swift +++ b/AnalyticsTests/MiddlewareTests.swift @@ -89,7 +89,7 @@ class IntegrationMiddlewareTests: QuickSpec { it("receives events") { let config = SEGAnalyticsConfiguration(writeKey: "TESTKEY") let passthrough = SEGPassthroughMiddleware() - config.integrationMiddleware = [SEGIntegrationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [passthrough])] + config.destinationMiddleware = [SEGDestinationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [passthrough])] let analytics = SEGAnalytics(configuration: config) analytics.identify("testUserId1") @@ -113,7 +113,7 @@ class IntegrationMiddlewareTests: QuickSpec { it("modifies and passes event to next") { let config = SEGAnalyticsConfiguration(writeKey: "TESTKEY") let passthrough = SEGPassthroughMiddleware() - config.integrationMiddleware = [SEGIntegrationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [customizeAllTrackCalls, passthrough])] + config.destinationMiddleware = [SEGDestinationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [customizeAllTrackCalls, passthrough])] let analytics = SEGAnalytics(configuration: config) analytics.track("Purchase Success") @@ -140,7 +140,7 @@ class IntegrationMiddlewareTests: QuickSpec { it("expects event to be swallowed if next is not called") { let config = SEGAnalyticsConfiguration(writeKey: "TESTKEY") let passthrough = SEGPassthroughMiddleware() - config.integrationMiddleware = [SEGIntegrationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [eatAllCalls, passthrough])] + config.destinationMiddleware = [SEGDestinationMiddleware(key: SEGSegmentIntegrationFactory().key(), middleware: [eatAllCalls, passthrough])] let analytics = SEGAnalytics(configuration: config) analytics.track("Purchase Success") diff --git a/Examples/CarthageExample/Cartfile.resolved b/Examples/CarthageExample/Cartfile.resolved index d587cc43c..c028154cf 100644 --- a/Examples/CarthageExample/Cartfile.resolved +++ b/Examples/CarthageExample/Cartfile.resolved @@ -1 +1 @@ -github "segmentio/analytics-ios" "4.0.0-beta.0" +github "segmentio/analytics-ios" "4.0.0-beta.1" From e968fd051ca2fb7b80671d7044d71b7b98d13d50 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Fri, 29 May 2020 13:49:16 -0700 Subject: [PATCH 2/2] Updated a comment re integration/destination. --- Analytics/Classes/SEGAnalyticsConfiguration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Analytics/Classes/SEGAnalyticsConfiguration.h b/Analytics/Classes/SEGAnalyticsConfiguration.h index c8a1f2b93..f016a1093 100644 --- a/Analytics/Classes/SEGAnalyticsConfiguration.h +++ b/Analytics/Classes/SEGAnalyticsConfiguration.h @@ -148,7 +148,7 @@ typedef NSString *_Nonnull (^SEGAdSupportBlock)(void); @property (nonatomic, strong, nullable) NSArray> *sourceMiddleware; /** - * Set custom integration middleware. Will be run before the associated integration. + * Set custom destination middleware. Will be run before the associated integration for a destination. */ @property (nonatomic, strong, nullable) NSArray *destinationMiddleware;