1 |
efrain |
1 |
/*
|
|
|
2 |
* Copyright 2018 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 |
#import "GoogleDataTransport/GDTCORLibrary/Internal/GDTCORLifecycle.h"
|
|
|
20 |
|
|
|
21 |
@class GDTCOREvent;
|
|
|
22 |
|
|
|
23 |
@protocol GDTCOREventTransformer;
|
|
|
24 |
|
|
|
25 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
26 |
|
|
|
27 |
/** Manages the transforming of events. It's desirable for this to be its own class
|
|
|
28 |
* because running all events through a single instance ensures that transformers are thread-safe.
|
|
|
29 |
* Having a per-transport queue to run on isn't sufficient because transformer objects could
|
|
|
30 |
* maintain state (or at least, there's nothing to stop them from doing that) and the same instances
|
|
|
31 |
* may be used across multiple instances.
|
|
|
32 |
*/
|
|
|
33 |
@interface GDTCORTransformer : NSObject <GDTCORLifecycleProtocol>
|
|
|
34 |
|
|
|
35 |
/** Instantiates or returns the event transformer singleton.
|
|
|
36 |
*
|
|
|
37 |
* @return The singleton instance of the event transformer.
|
|
|
38 |
*/
|
|
|
39 |
+ (instancetype)sharedInstance;
|
|
|
40 |
|
|
|
41 |
/** Writes the result of applying the given transformers' `transformGDTEvent:` method on the given
|
|
|
42 |
* event.
|
|
|
43 |
*
|
|
|
44 |
* @note If the app is suspended, a background task will be created to complete work in-progress,
|
|
|
45 |
* but this method will not send any further events until the app is resumed.
|
|
|
46 |
*
|
|
|
47 |
* @param event The event to apply transformers on.
|
|
|
48 |
* @param transformers The list of transformers to apply.
|
|
|
49 |
* @param completion A block to run when an event was written to disk or dropped.
|
|
|
50 |
*/
|
|
|
51 |
- (void)transformEvent:(GDTCOREvent *)event
|
|
|
52 |
withTransformers:(nullable NSArray<id<GDTCOREventTransformer>> *)transformers
|
|
|
53 |
onComplete:(void (^_Nullable)(BOOL wasWritten, NSError *_Nullable error))completion;
|
|
|
54 |
|
|
|
55 |
@end
|
|
|
56 |
|
|
|
57 |
NS_ASSUME_NONNULL_END
|