Skip to content

Commit 3b0ed0e

Browse files
authored
Open Source ABTesting (#3507)
* CI for ABTesting * README update
1 parent c706ce9 commit 3b0ed0e

22 files changed

+2401
-7
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ jobs:
4242
script:
4343
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec
4444
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec --use-libraries
45-
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec --use-modular-headers
45+
46+
- stage: test
47+
env:
48+
- PROJECT=ABTesting PLATFORM=iOS METHOD=pod-lib-lint
49+
script:
50+
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=ios
51+
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=tvos
52+
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=macos
4653

4754
- stage: test
4855
env:

FirebaseABTesting.podspec

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'FirebaseABTesting'
3+
s.version = '3.1.0'
4+
s.summary = 'Firebase ABTesting for iOS'
5+
6+
s.description = <<-DESC
7+
A/B testing is a Firebase service that lets you run experiments across users of
8+
your iOS and Android apps. It lets you learn how well one or more changes to
9+
your app work with a smaller set of users before you roll out changes to all
10+
users. You can run experiments to find the most effective ways to use
11+
Firebase Cloud Messaging and Firebase Remote Config in your app.
12+
DESC
13+
14+
s.homepage = 'https://firebase.google.com'
15+
s.license = { :type => 'Apache', :file => 'LICENSE' }
16+
s.authors = 'Google, Inc.'
17+
18+
s.source = {
19+
:git => 'https://github.com/firebase/firebase-ios-sdk.git',
20+
:tag => 'ABTesting-' + s.version.to_s
21+
}
22+
s.social_media_url = 'https://twitter.com/Firebase'
23+
s.ios.deployment_target = '8.0'
24+
s.osx.deployment_target = '10.11'
25+
s.tvos.deployment_target = '10.0'
26+
27+
s.cocoapods_version = '>= 1.4.0'
28+
s.static_framework = true
29+
s.prefix_header_file = false
30+
31+
base_dir = "FirebaseABTesting/Sources/"
32+
s.source_files = base_dir + '**/*.[mh]'
33+
s.requires_arc = base_dir + '*.m'
34+
s.public_header_files = base_dir + 'Public/*.h'
35+
s.pod_target_xcconfig = {
36+
'GCC_C_LANGUAGE_STANDARD' => 'c99',
37+
'GCC_PREPROCESSOR_DEFINITIONS' =>
38+
'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 ' +
39+
'FIRABTesting_VERSION=' + String(s.version),
40+
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
41+
}
42+
s.dependency 'FirebaseAnalyticsInterop', '~> 1.3'
43+
s.dependency 'FirebaseCore', '~> 6.1'
44+
s.dependency 'Protobuf', '~> 3.8'
45+
46+
s.test_spec 'unit' do |unit_tests|
47+
unit_tests.source_files = 'FirebaseABTesting/Tests/Unit/*.[mh]'
48+
unit_tests.requires_app_host = true
49+
unit_tests.dependency 'OCMock'
50+
end
51+
end

FirebaseABTesting/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Firebase ABTesting SDK for iOS
2+
3+
A/B testing is a Firebase service that lets you run experiments across users of
4+
your iOS and Android apps. It lets you learn how well one or more changes to
5+
your app work with a smaller set of users before you roll out changes to all
6+
users. You can run experiments to find the most effective ways to use
7+
Firebase Cloud Messaging and Firebase Remote Config in your app.
8+
9+
Please visit [our developer site]
10+
(https://firebase.google.com/docs/ab-testing/) for integration instructions,
11+
documentations, support information, and terms of service.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2019 Google
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#import <Foundation/Foundation.h>
16+
17+
#import "FirebaseABTesting/Sources/Protos/developers/mobile/abt/proto/ExperimentPayload.pbobjc.h"
18+
19+
#import <FirebaseAnalyticsInterop/FIRAnalyticsInterop.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@class FIRLifecycleEvents;
24+
25+
/// This class dynamically calls Firebase Analytics API to collect or update experiments
26+
/// information.
27+
/// The experiment in Firebase Analytics is named as conditional user property (CUP) object defined
28+
/// in FIRAConditionalUserProperty.h.
29+
@interface ABTConditionalUserPropertyController : NSObject
30+
31+
/// Returns the ABTConditionalUserPropertyController singleton.
32+
+ (instancetype)sharedInstanceWithAnalytics:(id<FIRAnalyticsInterop> _Nullable)analytics;
33+
34+
/// Returns the list of currently set experiments from Firebase Analytics for the provided origin.
35+
- (NSArray *)experimentsWithOrigin:(NSString *)origin;
36+
37+
/// Returns the experiment ID from Firebase Analytics given an experiment object. Returns empty
38+
/// string if can't find Firebase Analytics service.
39+
- (NSString *)experimentIDOfExperiment:(nullable id)experiment;
40+
41+
/// Returns the variant ID from Firebase Analytics given an experiment object. Returns empty string
42+
/// if can't find Firebase Analytics service.
43+
- (NSString *)variantIDOfExperiment:(nullable id)experiment;
44+
45+
/// Returns whether the experiment is the same as the one in the provided payload.
46+
- (BOOL)isExperiment:(id)experiment theSameAsPayload:(ABTExperimentPayload *)payload;
47+
48+
/// Clears the experiment in Firebase Analytics.
49+
/// @param experimentID Experiment ID to clear.
50+
/// @param variantID Variant ID to clear.
51+
/// @param origin Impacted originating service, it is defined at Firebase Analytics
52+
/// FIREventOrigins.h.
53+
/// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
54+
/// ID and variant ID as the experiment to clear.
55+
/// @param events Events name for clearing the experiment.
56+
- (void)clearExperiment:(NSString *)experimentID
57+
variantID:(NSString *)variantID
58+
withOrigin:(NSString *)origin
59+
payload:(nullable ABTExperimentPayload *)payload
60+
events:(FIRLifecycleEvents *)events;
61+
62+
/// Sets the experiment in Firebase Analytics.
63+
/// @param origin Impacted originating service, it is defined at Firebase Analytics
64+
/// FIREventOrigins.h.
65+
/// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
66+
/// ID and variant ID as the experiment to set.
67+
/// @param events Events name for setting the experiment.
68+
/// @param policy Overflow policy when the number of experiments is over the limit.
69+
- (void)setExperimentWithOrigin:(NSString *)origin
70+
payload:(ABTExperimentPayload *)payload
71+
events:(FIRLifecycleEvents *)events
72+
policy:(ABTExperimentPayload_ExperimentOverflowPolicy)policy;
73+
74+
/**
75+
* Unavailable. Use sharedInstanceWithAnalytics: instead.
76+
*/
77+
- (instancetype)init __attribute__((unavailable("Use +sharedInstanceWithAnalytics: instead.")));
78+
@end
79+
80+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)