Skip to content

Commit ada4b85

Browse files
authored
Merge pull request #20 from BranchMetrics/qi_support_events_exclusion_list
Support excluding events by names from AdobeBranchExtension
2 parents f6ed851 + 45235e2 commit ada4b85

File tree

9 files changed

+109
-21
lines changed

9 files changed

+109
-21
lines changed

AdobeBranchExtension.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "AdobeBranchExtension"
3-
s.version = "1.3.2"
3+
s.version = "1.3.3"
44
s.summary = "The Branch extension for Adobe Cloud Platform on iOS."
55

66
s.description = <<-DESC

AdobeBranchExtension/Classes/AdobeBranchExtensionClass.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ FOUNDATION_EXPORT NSString*const ABEBranchEventType;
2323
/// Branch extension event source
2424
FOUNDATION_EXPORT NSString*const ABEBranchEventSource;
2525

26+
/// Branch extension error code
27+
typedef NS_ENUM(NSInteger, ABEBranchErrorCode) {
28+
ABEBranchConflictConfiguration = 2000,
29+
};
30+
2631
/**
2732
This is the class defines the root Adobe / Branch integration for deep linking and events.
2833
*/
@@ -36,6 +41,10 @@ FOUNDATION_EXPORT NSString*const ABEBranchEventSource;
3641

3742
+ (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventSources:(nullable NSArray<NSString *> *)eventSources;
3843

44+
+ (BOOL)configureEventExclusionList:(nullable NSArray<NSString *> *)eventNames error:(NSError * __autoreleasing *)configError;
45+
46+
+ (BOOL)configureEventAllowList:(nullable NSArray<NSString *> *)eventNames error:(NSError * __autoreleasing *)configError;
47+
3948
- (void)handleEvent:(ACPExtensionEvent*)event;
4049

4150
@end

AdobeBranchExtension/Classes/AdobeBranchExtensionClass.m

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
NSString*const ABEBranchEventType = @"com.branch.eventType";
1717
NSString*const ABEBranchEventSource = @"com.branch.eventSource";
1818

19+
// Adobe Launch Branch extension error domain
20+
NSString*const AdobeBranchExtensionErrorDomain = @"io.branch.adobe_launch_extension.error";
21+
1922
// 1. events of this type and source
2023
NSString *const ABEAdobeHubEventType = @"com.adobe.eventType.hub";
2124
NSString *const ABEAdobeSharedStateEventSource = @"com.adobe.eventSource.sharedState";
@@ -93,6 +96,34 @@ + (void)configureEventTypes:(nullable NSArray<NSString *> *)eventTypes andEventS
9396
}
9497
}
9598

99+
+ (BOOL)configureEventExclusionList:(nullable NSArray<NSString *> *)eventNames error:(NSError * __autoreleasing *)configError {
100+
if (eventNames) {
101+
// If already configured allowList
102+
if ([AdobeBranchExtensionConfig instance].allowList.count != 0) {
103+
*configError = [NSError errorWithDomain:AdobeBranchExtensionErrorDomain code:ABEBranchConflictConfiguration userInfo:@{NSLocalizedFailureReasonErrorKey: @"Already configured allowList for AdobeBranchExtensionConfig"}];
104+
BNCLogError([NSString stringWithFormat:@"AdobeBranchExtensionConfig error: %@.", *configError]);
105+
return NO;
106+
} else {
107+
[AdobeBranchExtensionConfig instance].exclusionList = eventNames;
108+
}
109+
}
110+
return YES;
111+
}
112+
113+
+ (BOOL)configureEventAllowList:(nullable NSArray<NSString *> *)eventNames error:(NSError * __autoreleasing *)configError {
114+
if (eventNames) {
115+
// If already configured allowList
116+
if ([AdobeBranchExtensionConfig instance].exclusionList.count != 0) {
117+
*configError = [NSError errorWithDomain:AdobeBranchExtensionErrorDomain code:ABEBranchConflictConfiguration userInfo:@{NSLocalizedFailureReasonErrorKey: @"Already configured exclusionList for AdobeBranchExtensionConfig"}];
118+
BNCLogError([NSString stringWithFormat:@"AdobeBranchExtensionConfig error: %@.", *configError]);
119+
return NO;
120+
} else {
121+
[AdobeBranchExtensionConfig instance].allowList = eventNames;
122+
}
123+
}
124+
return YES;
125+
}
126+
96127
- (instancetype)init {
97128
self = [super init];
98129
if (!self) return self;
@@ -221,11 +252,24 @@ - (void) trackEvent:(ACPExtensionEvent*)event {
221252
NSString *eventName = eventData[@"action"];
222253
if (!eventName.length) eventName = eventData[@"state"];
223254
if (!eventName.length) return;
255+
if (![self isValidEventForBranch:eventName]) return;
224256
NSDictionary *content = [eventData objectForKey:@"contextdata"];
225257
BranchEvent *branchEvent = [self.class branchEventFromAdobeEventName:eventName dictionary:content];
226258
[branchEvent logEvent];
227259
}
228260

261+
- (BOOL)isValidEventForBranch:(NSString*)eventName {
262+
if ([AdobeBranchExtensionConfig instance].exclusionList.count == 0 && [AdobeBranchExtensionConfig instance].allowList.count == 0) {
263+
return YES;
264+
} else if ([AdobeBranchExtensionConfig instance].allowList.count != 0 && [[AdobeBranchExtensionConfig instance].allowList containsObject: eventName]) {
265+
return YES;
266+
} else if ([AdobeBranchExtensionConfig instance].exclusionList.count != 0 && ![[AdobeBranchExtensionConfig instance].exclusionList containsObject: eventName]) {
267+
return YES;
268+
}
269+
270+
return NO;
271+
}
272+
229273
- (void) passAdobeIdsToBranch:(ACPExtensionEvent*)eventToProcess {
230274
NSError *error = nil;
231275
NSDictionary *configSharedState = [self.api getSharedEventState:eventToProcess.eventData[ABEAdobeEventDataKey_StateOwner]

AdobeBranchExtension/Classes/AdobeBranchExtensionConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
1212
@interface AdobeBranchExtensionConfig : NSObject
1313
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventTypes;
1414
@property (nonatomic, strong, readwrite) NSArray<NSString *> *eventSources;
15+
@property (nonatomic, strong, readwrite) NSArray<NSString *> *exclusionList;
16+
@property (nonatomic, strong, readwrite) NSArray<NSString *> *allowList;
1517

1618
+ (AdobeBranchExtensionConfig *)instance;
1719

AdobeBranchExtension/Classes/AdobeBranchExtensionConfig.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ - (instancetype)init {
2424
// default event type and source to track, client can override
2525
self.eventTypes = @[ @"com.adobe.eventType.generic.track" ];
2626
self.eventSources = @[ @"com.adobe.eventSource.requestContent" ];
27+
self.exclusionList = [NSArray new];
28+
self.allowList = [NSArray new];
2729
}
2830
return self;
2931
}

Examples/AdobeBranchExample/AdobeBranchExample.xcodeproj/project.pbxproj

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 51;
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
1C32DC67D5A305502173C088 /* libPods-AdobeBranchExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FFBBC7A62D08C7161630F13C /* libPods-AdobeBranchExample.a */; };
10+
3228F43713344BCB4F316B9A /* Pods_AdobeBranchExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0EA9C30991048D8A522C726 /* Pods_AdobeBranchExample.framework */; };
1111
4D16DBA421AF037F00E362A2 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4D16DBA321AF037F00E362A2 /* Launch Screen.storyboard */; };
1212
4D16DBA721AF5B6300E362A2 /* TextViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D16DBA621AF5B6300E362A2 /* TextViewController.m */; };
1313
4DE097FD219CEABE008AC401 /* Products.json in Resources */ = {isa = PBXBuildFile; fileRef = 4DE097FC219CEABE008AC401 /* Products.json */; };
@@ -60,9 +60,9 @@
6060
ACF671D721534E4F00CDC900 /* ACPCore_iOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ACPCore_iOS.framework; path = Pods/ACPCoreBeta/ACPCore_iOS.framework; sourceTree = "<group>"; };
6161
ACF671D821534E4F00CDC900 /* ACPSignal_iOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ACPSignal_iOS.framework; path = Pods/ACPCoreBeta/ACPSignal_iOS.framework; sourceTree = "<group>"; };
6262
ACF671D921534E4F00CDC900 /* ACPLifecycle_iOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ACPLifecycle_iOS.framework; path = Pods/ACPCoreBeta/ACPLifecycle_iOS.framework; sourceTree = "<group>"; };
63+
B0EA9C30991048D8A522C726 /* Pods_AdobeBranchExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AdobeBranchExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6364
F8688AE753553EE80251EE11 /* Pods-adobe-branch-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-adobe-branch-example.release.xcconfig"; path = "Pods/Target Support Files/Pods-adobe-branch-example/Pods-adobe-branch-example.release.xcconfig"; sourceTree = "<group>"; };
6465
FD81B1B19DDC0E314016948F /* Pods-adobe-branch-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-adobe-branch-example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-adobe-branch-example/Pods-adobe-branch-example.debug.xcconfig"; sourceTree = "<group>"; };
65-
FFBBC7A62D08C7161630F13C /* libPods-AdobeBranchExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AdobeBranchExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6666
/* End PBXFileReference section */
6767

6868
/* Begin PBXFrameworksBuildPhase section */
@@ -76,7 +76,7 @@
7676
ACAE812F2122644F0049505B /* libz.tbd in Frameworks */,
7777
ACAE812D212264480049505B /* libstdc++.tbd in Frameworks */,
7878
ACAE812B2122643A0049505B /* libsqlite3.tbd in Frameworks */,
79-
1C32DC67D5A305502173C088 /* libPods-AdobeBranchExample.a in Frameworks */,
79+
3228F43713344BCB4F316B9A /* Pods_AdobeBranchExample.framework in Frameworks */,
8080
);
8181
runOnlyForDeploymentPostprocessing = 0;
8282
};
@@ -152,7 +152,7 @@
152152
ACAE812C212264480049505B /* libstdc++.tbd */,
153153
ACAE812A2122643A0049505B /* libsqlite3.tbd */,
154154
2E21CAD8A1C925AAF24986BC /* libPods-adobe-branch-example.a */,
155-
FFBBC7A62D08C7161630F13C /* libPods-AdobeBranchExample.a */,
155+
B0EA9C30991048D8A522C726 /* Pods_AdobeBranchExample.framework */,
156156
);
157157
name = Frameworks;
158158
sourceTree = "<group>";
@@ -168,6 +168,7 @@
168168
ACAE8100212263F30049505B /* Sources */,
169169
ACAE8101212263F30049505B /* Frameworks */,
170170
ACAE8102212263F30049505B /* Resources */,
171+
7312F033701CC016ACD11288 /* [CP] Embed Pods Frameworks */,
171172
);
172173
buildRules = (
173174
);
@@ -185,7 +186,7 @@
185186
isa = PBXProject;
186187
attributes = {
187188
CLASSPREFIX = ABE;
188-
LastUpgradeCheck = 0940;
189+
LastUpgradeCheck = 1240;
189190
ORGANIZATIONNAME = "Branch Metrics";
190191
TargetAttributes = {
191192
ACAE8103212263F30049505B = {
@@ -231,6 +232,23 @@
231232
/* End PBXResourcesBuildPhase section */
232233

233234
/* Begin PBXShellScriptBuildPhase section */
235+
7312F033701CC016ACD11288 /* [CP] Embed Pods Frameworks */ = {
236+
isa = PBXShellScriptBuildPhase;
237+
buildActionMask = 2147483647;
238+
files = (
239+
);
240+
inputFileListPaths = (
241+
"${PODS_ROOT}/Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
242+
);
243+
name = "[CP] Embed Pods Frameworks";
244+
outputFileListPaths = (
245+
"${PODS_ROOT}/Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
246+
);
247+
runOnlyForDeploymentPostprocessing = 0;
248+
shellPath = /bin/sh;
249+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AdobeBranchExample/Pods-AdobeBranchExample-frameworks.sh\"\n";
250+
showEnvVarsInLog = 0;
251+
};
234252
80D4725CEFFA1CA56A0BB493 /* [CP] Check Pods Manifest.lock */ = {
235253
isa = PBXShellScriptBuildPhase;
236254
buildActionMask = 2147483647;
@@ -305,6 +323,7 @@
305323
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
306324
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
307325
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
326+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
308327
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
309328
CLANG_WARN_STRICT_PROTOTYPES = YES;
310329
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -330,7 +349,7 @@
330349
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
331350
GCC_WARN_UNUSED_FUNCTION = YES;
332351
GCC_WARN_UNUSED_VARIABLE = YES;
333-
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
352+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
334353
MTL_ENABLE_DEBUG_INFO = YES;
335354
ONLY_ACTIVE_ARCH = YES;
336355
SDKROOT = iphoneos;
@@ -363,6 +382,7 @@
363382
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
364383
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
365384
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
385+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
366386
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
367387
CLANG_WARN_STRICT_PROTOTYPES = YES;
368388
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -382,7 +402,7 @@
382402
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
383403
GCC_WARN_UNUSED_FUNCTION = YES;
384404
GCC_WARN_UNUSED_VARIABLE = YES;
385-
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
405+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
386406
MTL_ENABLE_DEBUG_INFO = NO;
387407
SDKROOT = iphoneos;
388408
VALIDATE_PRODUCT = YES;
@@ -399,7 +419,7 @@
399419
CODE_SIGN_STYLE = Automatic;
400420
DEVELOPMENT_TEAM = R63EM248DP;
401421
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
402-
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
422+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
403423
LD_RUNPATH_SEARCH_PATHS = (
404424
"$(inherited)",
405425
"@executable_path/Frameworks",
@@ -421,7 +441,7 @@
421441
CODE_SIGN_STYLE = Automatic;
422442
DEVELOPMENT_TEAM = R63EM248DP;
423443
INFOPLIST_FILE = "$(SRCROOT)/AdobeBranchExample/Info.plist";
424-
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
444+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
425445
LD_RUNPATH_SEARCH_PATHS = (
426446
"$(inherited)",
427447
"@executable_path/Frameworks",

Examples/AdobeBranchExample/AdobeBranchExample.xcworkspace/xcshareddata/xcschemes/AdobeBranchExample.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1120"
3+
LastUpgradeVersion = "1240"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Examples/AdobeBranchExample/AdobeBranchExample/AppDelegate.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010

1111
#import "ACPCore.h"
1212
#import "ACPAnalytics.h"
13-
#import "ACPIdentity.h"
14-
#import "ACPLifecycle.h"
13+
#import <ACPCore/ACPIdentity.h>
14+
#import <ACPCore/ACPLifecycle.h>
1515
#import "ACPSignal.h"
1616
#import "ACPUserProfile.h"
1717

1818
#import "ProductViewController.h"
19-
2019
#import "AdobeBranchExtension.h"
2120

2221
@interface AppDelegate ()
@@ -47,6 +46,19 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4746
[ACPIdentity registerExtension];
4847
[ACPLifecycle registerExtension];
4948

49+
// NOTE! following code will enable you to configure exclusion list or allow list, but you can't define both! If you don't configure any, all events will send to Branch which is not ideal!
50+
// Define the exclusion list of the events names
51+
// if ([AdobeBranchExtension configureEventExclusionList:@[@"VIEW"] error:&error]) {
52+
// NSLog(@"AdobeBranchExtension AllowList configured");
53+
// } else {
54+
// NSLog(@"%@", error);
55+
// }
56+
// Define the allow list of the events names
57+
if ([AdobeBranchExtension configureEventAllowList:@[@"VIEW"] error:&error]) {
58+
NSLog(@"AdobeBranchExtension AllowList configured");
59+
} else {
60+
NSLog(@"%@", error);
61+
}
5062
// register AdobeBranchExtension
5163
if ([ACPCore registerExtension:[AdobeBranchExtension class] error:&error]) {
5264
NSLog(@"AdobeBranchExtension Registered");
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
source 'https://github.com/CocoaPods/Specs.git'
2-
platform :ios, '10.0'
3-
41
target 'AdobeBranchExample' do
5-
pod 'ACPCore', '~> 2.0'
6-
pod 'ACPAnalytics', '~> 2.0'
7-
pod 'ACPUserProfile', '~> 2.0'
2+
use_frameworks!
3+
pod 'Branch'
4+
pod 'ACPCore'
5+
pod 'ACPAnalytics'
6+
pod 'ACPUserProfile'
87

98
pod 'AdobeBranchExtension', :path => '../../'
109
end

0 commit comments

Comments
 (0)