|
| 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