GDTCORTransformer.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #import <Foundation/Foundation.h>
  17. #import <GoogleDataTransport/GDTCORLifecycle.h>
  18. @class GDTCOREvent;
  19. @protocol GDTCOREventTransformer;
  20. NS_ASSUME_NONNULL_BEGIN
  21. /** Manages the transforming of events. It's desirable for this to be its own class
  22. * because running all events through a single instance ensures that transformers are thread-safe.
  23. * Having a per-transport queue to run on isn't sufficient because transformer objects could
  24. * maintain state (or at least, there's nothing to stop them from doing that) and the same instances
  25. * may be used across multiple instances.
  26. */
  27. @interface GDTCORTransformer : NSObject <GDTCORLifecycleProtocol>
  28. /** Instantiates or returns the event transformer singleton.
  29. *
  30. * @return The singleton instance of the event transformer.
  31. */
  32. + (instancetype)sharedInstance;
  33. /** Writes the result of applying the given transformers' -transform method on the given event.
  34. *
  35. * @note If the app is suspended, a background task will be created to complete work in-progress,
  36. * but this method will not send any further events until the app is resumed.
  37. *
  38. * @param event The event to apply transformers on.
  39. * @param transformers The list of transformers to apply.
  40. */
  41. - (void)transformEvent:(GDTCOREvent *)event
  42. withTransformers:(nullable NSArray<id<GDTCOREventTransformer>> *)transformers;
  43. @end
  44. NS_ASSUME_NONNULL_END