1 |
efrain |
1 |
// Copyright 2020 Google LLC
|
|
|
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 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
18 |
|
|
|
19 |
/// Policy for handling the case where there's an overflow of experiments for an installation
|
|
|
20 |
/// instance.
|
|
|
21 |
typedef NS_ENUM(int32_t, ABTExperimentPayloadExperimentOverflowPolicy) {
|
|
|
22 |
ABTExperimentPayloadExperimentOverflowPolicyUnrecognizedValue = 999,
|
|
|
23 |
ABTExperimentPayloadExperimentOverflowPolicyUnspecified = 0,
|
|
|
24 |
ABTExperimentPayloadExperimentOverflowPolicyDiscardOldest = 1,
|
|
|
25 |
ABTExperimentPayloadExperimentOverflowPolicyIgnoreNewest = 2,
|
|
|
26 |
};
|
|
|
27 |
|
|
|
28 |
@interface ABTExperimentLite : NSObject
|
|
|
29 |
@property(nonatomic, readonly, copy) NSString *experimentId;
|
|
|
30 |
|
|
|
31 |
- (instancetype)initWithExperimentId:(NSString *)experimentId NS_DESIGNATED_INITIALIZER;
|
|
|
32 |
|
|
|
33 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
34 |
|
|
|
35 |
@end
|
|
|
36 |
|
|
|
37 |
@interface ABTExperimentPayload : NSObject
|
|
|
38 |
|
|
|
39 |
/// Unique identifier for this experiment.
|
|
|
40 |
@property(nonatomic, readonly, copy) NSString *experimentId;
|
|
|
41 |
|
|
|
42 |
/// Unique identifier for the variant to which an installation instance has been assigned.
|
|
|
43 |
@property(nonatomic, readonly, copy) NSString *variantId;
|
|
|
44 |
|
|
|
45 |
/// Epoch time that represents when the experiment was started.
|
|
|
46 |
@property(nonatomic, readonly) int64_t experimentStartTimeMillis;
|
|
|
47 |
|
|
|
48 |
/// The event that triggers this experiment into ON state.
|
|
|
49 |
@property(nonatomic, nullable, readonly, copy) NSString *triggerEvent;
|
|
|
50 |
|
|
|
51 |
/// Duration in milliseconds for which the experiment can stay in STANDBY state (un-triggered).
|
|
|
52 |
@property(nonatomic, readonly) int64_t triggerTimeoutMillis;
|
|
|
53 |
|
|
|
54 |
/// Duration in milliseconds for which the experiment can stay in ON state (triggered).
|
|
|
55 |
@property(nonatomic, readonly) int64_t timeToLiveMillis;
|
|
|
56 |
|
|
|
57 |
/// The event logged when impact service sets the experiment.
|
|
|
58 |
@property(nonatomic, readonly, copy) NSString *setEventToLog;
|
|
|
59 |
|
|
|
60 |
/// The event logged when an experiment goes to the ON state.
|
|
|
61 |
@property(nonatomic, readonly, copy) NSString *activateEventToLog;
|
|
|
62 |
|
|
|
63 |
/// The event logged when an experiment is cleared.
|
|
|
64 |
@property(nonatomic, readonly, copy) NSString *clearEventToLog;
|
|
|
65 |
|
|
|
66 |
/// The event logged when an experiment times out after `triggerTimeoutMillis` milliseconds.
|
|
|
67 |
@property(nonatomic, readonly, copy) NSString *timeoutEventToLog;
|
|
|
68 |
|
|
|
69 |
/// The event logged when an experiment times out after `timeToLiveMillis` milliseconds.
|
|
|
70 |
@property(nonatomic, readonly, copy) NSString *ttlExpiryEventToLog;
|
|
|
71 |
|
|
|
72 |
@property(nonatomic, readonly) ABTExperimentPayloadExperimentOverflowPolicy overflowPolicy;
|
|
|
73 |
|
|
|
74 |
/// A list of all other ongoing (started, and not yet stopped) experiments at the time this
|
|
|
75 |
/// experiment was started. Does not include this experiment; only the others.
|
|
|
76 |
@property(nonatomic, readonly) NSArray<ABTExperimentLite *> *ongoingExperiments;
|
|
|
77 |
|
|
|
78 |
/// Parses an ABTExperimentPayload directly from JSON data.
|
|
|
79 |
/// @param data JSON object as NSData. Must be reconstructible as an NSDictionary<NSString* , id>.
|
|
|
80 |
+ (nullable instancetype)parseFromData:(NSData *)data;
|
|
|
81 |
|
|
|
82 |
/// Initializes an ABTExperimentPayload from a dictionary with experiment metadata.
|
|
|
83 |
- (instancetype)initWithDictionary:(NSDictionary<NSString *, id> *)dictionary
|
|
|
84 |
NS_DESIGNATED_INITIALIZER;
|
|
|
85 |
|
|
|
86 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
87 |
|
|
|
88 |
/// Clears the trigger event associated with this payload.
|
|
|
89 |
- (void)clearTriggerEvent;
|
|
|
90 |
|
|
|
91 |
/// Checks if the overflow policy is a valid enum object.
|
|
|
92 |
- (BOOL)overflowPolicyIsValid;
|
|
|
93 |
|
|
|
94 |
@end
|
|
|
95 |
|
|
|
96 |
NS_ASSUME_NONNULL_END
|