1 |
efrain |
1 |
/*
|
|
|
2 |
* Copyright 2017 Google
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
* See the License for the specific language governing permissions and
|
|
|
14 |
* limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
#import <Foundation/Foundation.h>
|
|
|
18 |
|
|
|
19 |
/// Values for different fiam activity types.
|
|
|
20 |
typedef NS_ENUM(NSInteger, FIRIAMActivityType) {
|
|
|
21 |
FIRIAMActivityTypeFetchMessage = 0,
|
|
|
22 |
FIRIAMActivityTypeRenderMessage = 1,
|
|
|
23 |
FIRIAMActivityTypeDismissMessage = 2,
|
|
|
24 |
|
|
|
25 |
// Triggered checks
|
|
|
26 |
FIRIAMActivityTypeCheckForOnOpenMessage = 3,
|
|
|
27 |
FIRIAMActivityTypeCheckForAnalyticsEventMessage = 4,
|
|
|
28 |
FIRIAMActivityTypeCheckForFetch = 5,
|
|
|
29 |
};
|
|
|
30 |
|
|
|
31 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
32 |
@interface FIRIAMActivityRecord : NSObject <NSCoding>
|
|
|
33 |
@property(nonatomic, nonnull, readonly) NSDate *timestamp;
|
|
|
34 |
@property(nonatomic, readonly) FIRIAMActivityType activityType;
|
|
|
35 |
@property(nonatomic, readonly) BOOL success;
|
|
|
36 |
@property(nonatomic, copy, nonnull, readonly) NSString *detail;
|
|
|
37 |
|
|
|
38 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
39 |
// Current timestamp would be fetched if parameter 'timestamp' is passed in as null
|
|
|
40 |
- (instancetype)initWithActivityType:(FIRIAMActivityType)type
|
|
|
41 |
isSuccessful:(BOOL)isSuccessful
|
|
|
42 |
withDetail:(NSString *)detail
|
|
|
43 |
timestamp:(nullable NSDate *)timestamp;
|
|
|
44 |
|
|
|
45 |
- (NSString *)displayStringForActivityType;
|
|
|
46 |
@end
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* This is the class for tracking fiam flow related activity logs. Its content can later on be
|
|
|
50 |
* retrieved for debugging/reporting purpose.
|
|
|
51 |
*/
|
|
|
52 |
@interface FIRIAMActivityLogger : NSObject
|
|
|
53 |
|
|
|
54 |
// If it's NO, activity logs of certain types won't get recorded by Logger. Consult
|
|
|
55 |
// isMandatoryType implementation to tell what are the types belong to verbose mode
|
|
|
56 |
// Turn it on for debugging cases
|
|
|
57 |
@property(nonatomic, readonly) BOOL verboseMode;
|
|
|
58 |
|
|
|
59 |
- (instancetype)init NS_UNAVAILABLE;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Parameter maxBeforeReduce and sizeAfterReduce defines the shrinking behavior when we reach
|
|
|
63 |
* the size cap of log storage: when we see the number of log records goes beyond
|
|
|
64 |
* maxBeforeReduce, we would trigger a reduction action which would bring the array length to be
|
|
|
65 |
* the size as defined by sizeAfterReduce
|
|
|
66 |
*
|
|
|
67 |
* @param verboseMode see the comments for the verboseMode property
|
|
|
68 |
* @param loadFromCache loads from cache to initialize the log list if it's true. Be aware that
|
|
|
69 |
* in this case, you should not call this method in main thread since reading the cache file
|
|
|
70 |
* can take time.
|
|
|
71 |
*/
|
|
|
72 |
- (instancetype)initWithMaxCountBeforeReduce:(NSInteger)maxBeforeReduce
|
|
|
73 |
withSizeAfterReduce:(NSInteger)sizeAfterReduce
|
|
|
74 |
verboseMode:(BOOL)verboseMode
|
|
|
75 |
loadFromCache:(BOOL)loadFromCache;
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Inserting a new record into activity log.
|
|
|
79 |
*
|
|
|
80 |
* @param newRecord new record to be inserted
|
|
|
81 |
*/
|
|
|
82 |
- (void)addLogRecord:(FIRIAMActivityRecord *)newRecord;
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Get a immutable copy of the existing activity log records.
|
|
|
86 |
*/
|
|
|
87 |
- (NSArray<FIRIAMActivityRecord *> *)readRecords;
|
|
|
88 |
@end
|
|
|
89 |
NS_ASSUME_NONNULL_END
|