Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Source ABTesting #3507

Merged
merged 4 commits into from Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion .travis.yml
Expand Up @@ -42,7 +42,14 @@ jobs:
script:
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec --use-libraries
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseCore.podspec --use-modular-headers

- stage: test
env:
- PROJECT=ABTesting PLATFORM=iOS METHOD=pod-lib-lint
script:
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=ios
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=tvos
- travis_retry ./scripts/if_changed.sh ./scripts/pod_lib_lint.rb FirebaseABTesting.podspec --platforms=macos

- stage: test
env:
Expand Down
51 changes: 51 additions & 0 deletions FirebaseABTesting.podspec
@@ -0,0 +1,51 @@
Pod::Spec.new do |s|
s.name = 'FirebaseABTesting'
s.version = '3.1.0'
s.summary = 'Firebase ABTesting for iOS'

s.description = <<-DESC
A/B testing is a Firebase service that lets you run experiments across users of
your iOS and Android apps. It lets you learn how well one or more changes to
your app work with a smaller set of users before you roll out changes to all
users. You can run experiments to find the most effective ways to use
Firebase Cloud Messaging and Firebase Remote Config in your app.
DESC

s.homepage = 'https://firebase.google.com'
s.license = { :type => 'Apache', :file => 'LICENSE' }
s.authors = 'Google, Inc.'

s.source = {
:git => 'https://github.com/firebase/firebase-ios-sdk.git',
:tag => 'ABTesting-' + s.version.to_s
}
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '10.0'

s.cocoapods_version = '>= 1.4.0'
s.static_framework = true
s.prefix_header_file = false

base_dir = "FirebaseABTesting/Sources/"
s.source_files = base_dir + '**/*.[mh]'
s.requires_arc = base_dir + '*.m'
s.public_header_files = base_dir + 'Public/*.h'
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'GCC_PREPROCESSOR_DEFINITIONS' =>
'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 ' +
'FIRABTesting_VERSION=' + String(s.version),
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
}
s.dependency 'FirebaseAnalyticsInterop', '~> 1.3'
s.dependency 'FirebaseCore', '~> 6.1'
s.dependency 'Protobuf', '~> 3.8'

s.test_spec 'unit' do |unit_tests|
unit_tests.source_files = 'FirebaseABTesting/Tests/Unit/*.[mh]'
unit_tests.requires_app_host = true
unit_tests.dependency 'OCMock'
end
end
11 changes: 11 additions & 0 deletions FirebaseABTesting/README.md
@@ -0,0 +1,11 @@
# Firebase ABTesting SDK for iOS

A/B testing is a Firebase service that lets you run experiments across users of
your iOS and Android apps. It lets you learn how well one or more changes to
your app work with a smaller set of users before you roll out changes to all
users. You can run experiments to find the most effective ways to use
Firebase Cloud Messaging and Firebase Remote Config in your app.

Please visit [our developer site]
(https://firebase.google.com/docs/ab-testing/) for integration instructions,
documentations, support information, and terms of service.
80 changes: 80 additions & 0 deletions FirebaseABTesting/Sources/ABTConditionalUserPropertyController.h
@@ -0,0 +1,80 @@
// Copyright 2019 Google
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>

#import "FirebaseABTesting/Sources/Protos/developers/mobile/abt/proto/ExperimentPayload.pbobjc.h"

#import <FirebaseAnalyticsInterop/FIRAnalyticsInterop.h>

NS_ASSUME_NONNULL_BEGIN

@class FIRLifecycleEvents;

/// This class dynamically calls Firebase Analytics API to collect or update experiments
/// information.
/// The experiment in Firebase Analytics is named as conditional user property (CUP) object defined
/// in FIRAConditionalUserProperty.h.
@interface ABTConditionalUserPropertyController : NSObject

/// Returns the ABTConditionalUserPropertyController singleton.
+ (instancetype)sharedInstanceWithAnalytics:(id<FIRAnalyticsInterop> _Nullable)analytics;

/// Returns the list of currently set experiments from Firebase Analytics for the provided origin.
- (NSArray *)experimentsWithOrigin:(NSString *)origin;

/// Returns the experiment ID from Firebase Analytics given an experiment object. Returns empty
/// string if can't find Firebase Analytics service.
- (NSString *)experimentIDOfExperiment:(nullable id)experiment;

/// Returns the variant ID from Firebase Analytics given an experiment object. Returns empty string
/// if can't find Firebase Analytics service.
- (NSString *)variantIDOfExperiment:(nullable id)experiment;

/// Returns whether the experiment is the same as the one in the provided payload.
- (BOOL)isExperiment:(id)experiment theSameAsPayload:(ABTExperimentPayload *)payload;

/// Clears the experiment in Firebase Analytics.
/// @param experimentID Experiment ID to clear.
/// @param variantID Variant ID to clear.
/// @param origin Impacted originating service, it is defined at Firebase Analytics
/// FIREventOrigins.h.
/// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
/// ID and variant ID as the experiment to clear.
/// @param events Events name for clearing the experiment.
- (void)clearExperiment:(NSString *)experimentID
variantID:(NSString *)variantID
withOrigin:(NSString *)origin
payload:(nullable ABTExperimentPayload *)payload
events:(FIRLifecycleEvents *)events;

/// Sets the experiment in Firebase Analytics.
/// @param origin Impacted originating service, it is defined at Firebase Analytics
/// FIREventOrigins.h.
/// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
/// ID and variant ID as the experiment to set.
/// @param events Events name for setting the experiment.
/// @param policy Overflow policy when the number of experiments is over the limit.
- (void)setExperimentWithOrigin:(NSString *)origin
payload:(ABTExperimentPayload *)payload
events:(FIRLifecycleEvents *)events
policy:(ABTExperimentPayload_ExperimentOverflowPolicy)policy;

/**
* Unavailable. Use sharedInstanceWithAnalytics: instead.
*/
- (instancetype)init __attribute__((unavailable("Use +sharedInstanceWithAnalytics: instead.")));
@end

NS_ASSUME_NONNULL_END