ABTConditionalUserPropertyController.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #import <Foundation/Foundation.h>
  15. #import "FirebaseABTesting/Sources/Protos/developers/mobile/abt/proto/ExperimentPayload.pbobjc.h"
  16. #import "Interop/Analytics/Public/FIRAnalyticsInterop.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRLifecycleEvents;
  19. /// This class dynamically calls Firebase Analytics API to collect or update experiments
  20. /// information.
  21. /// The experiment in Firebase Analytics is named as conditional user property (CUP) object defined
  22. /// in FIRAConditionalUserProperty.h.
  23. @interface ABTConditionalUserPropertyController : NSObject
  24. /// Returns the ABTConditionalUserPropertyController singleton.
  25. + (instancetype)sharedInstanceWithAnalytics:(id<FIRAnalyticsInterop> _Nullable)analytics;
  26. /// Returns the list of currently set experiments from Firebase Analytics for the provided origin.
  27. - (NSArray *)experimentsWithOrigin:(NSString *)origin;
  28. /// Returns the experiment ID from Firebase Analytics given an experiment object. Returns empty
  29. /// string if can't find Firebase Analytics service.
  30. - (NSString *)experimentIDOfExperiment:(nullable id)experiment;
  31. /// Returns the variant ID from Firebase Analytics given an experiment object. Returns empty string
  32. /// if can't find Firebase Analytics service.
  33. - (NSString *)variantIDOfExperiment:(nullable id)experiment;
  34. /// Returns whether the experiment is the same as the one in the provided payload.
  35. - (BOOL)isExperiment:(id)experiment theSameAsPayload:(ABTExperimentPayload *)payload;
  36. /// Clears the experiment in Firebase Analytics.
  37. /// @param experimentID Experiment ID to clear.
  38. /// @param variantID Variant ID to clear.
  39. /// @param origin Impacted originating service, it is defined at Firebase Analytics
  40. /// FIREventOrigins.h.
  41. /// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
  42. /// ID and variant ID as the experiment to clear.
  43. /// @param events Events name for clearing the experiment.
  44. - (void)clearExperiment:(NSString *)experimentID
  45. variantID:(NSString *)variantID
  46. withOrigin:(NSString *)origin
  47. payload:(nullable ABTExperimentPayload *)payload
  48. events:(FIRLifecycleEvents *)events;
  49. /// Sets the experiment in Firebase Analytics.
  50. /// @param origin Impacted originating service, it is defined at Firebase Analytics
  51. /// FIREventOrigins.h.
  52. /// @param payload Payload to overwrite event name in events. DO NOT use payload's experiment
  53. /// ID and variant ID as the experiment to set.
  54. /// @param events Events name for setting the experiment.
  55. /// @param policy Overflow policy when the number of experiments is over the limit.
  56. - (void)setExperimentWithOrigin:(NSString *)origin
  57. payload:(ABTExperimentPayload *)payload
  58. events:(FIRLifecycleEvents *)events
  59. policy:(ABTExperimentPayload_ExperimentOverflowPolicy)policy;
  60. /**
  61. * Unavailable. Use sharedInstanceWithAnalytics: instead.
  62. */
  63. - (instancetype)init __attribute__((unavailable("Use +sharedInstanceWithAnalytics: instead.")));
  64. @end
  65. NS_ASSUME_NONNULL_END