Skip to content

Commit

Permalink
Renamed middleware methods to match a.js naming. (#896)
Browse files Browse the repository at this point in the history
* Renamed middleware methods to match a.js naming.

* Updated a comment re integration/destination.

Co-authored-by: Brandon Sneed <brandon.sneed@segment.com>
  • Loading branch information
bsneed and Brandon Sneed authored May 29, 2020
1 parent 7f2feed commit 7197a8e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Analytics/Classes/Integrations/SEGIntegrationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ - (void)setCachedSettings:(NSDictionary *)settings
- (nonnull NSArray<id<SEGMiddleware>> *)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];
}
Expand Down
4 changes: 2 additions & 2 deletions Analytics/Classes/Middlewares/SEGMiddleware.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ typedef void (^RunMiddlewaresCallback)(BOOL earlyExit, NSArray<id<SEGMiddleware>

@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<id<SEGMiddleware>> *middleware;
- (instancetype _Nonnull)initWithKey:(NSString * _Nonnull)integrationKey middleware:(NSArray<id<SEGMiddleware>> * _Nonnull)middleware;
Expand Down
2 changes: 1 addition & 1 deletion Analytics/Classes/Middlewares/SEGMiddleware.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "SEGMiddleware.h"


@implementation SEGIntegrationMiddleware
@implementation SEGDestinationMiddleware
- (instancetype)initWithKey:(NSString *)integrationKey middleware:(NSArray<id<SEGMiddleware>> *)middleware
{
if (self = [super init]) {
Expand Down
6 changes: 3 additions & 3 deletions Analytics/Classes/SEGAnalyticsConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -148,9 +148,9 @@ typedef NSString *_Nonnull (^SEGAdSupportBlock)(void);
@property (nonatomic, strong, nullable) NSArray<id<SEGMiddleware>> *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<SEGIntegrationMiddleware *> *integrationMiddleware;
@property (nonatomic, strong, nullable) NSArray<SEGDestinationMiddleware *> *destinationMiddleware;

/**
* Register a factory that can be used to create an integration.
Expand Down
6 changes: 3 additions & 3 deletions AnalyticsTests/MiddlewareTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

Expand All @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion Examples/CarthageExample/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "segmentio/analytics-ios" "4.0.0-beta.0"
github "segmentio/analytics-ios" "4.0.0-beta.1"

0 comments on commit 7197a8e

Please sign in to comment.