GDTCORTransport.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/GDTCOREventTransformer.h>
  18. @class GDTCOREvent;
  19. NS_ASSUME_NONNULL_BEGIN
  20. @interface GDTCORTransport : NSObject
  21. // Please use the designated initializer.
  22. - (instancetype)init NS_UNAVAILABLE;
  23. /** Initializes a new transport that will send events to the given target backend.
  24. *
  25. * @param mappingID The mapping identifier used by the backend to map the data object transport
  26. * bytes to a proto.
  27. * @param transformers A list of transformers to be applied to events that are sent.
  28. * @param target The target backend of this transport.
  29. * @return A transport that will send events.
  30. */
  31. - (nullable instancetype)initWithMappingID:(NSString *)mappingID
  32. transformers:
  33. (nullable NSArray<id<GDTCOREventTransformer>> *)transformers
  34. target:(NSInteger)target NS_DESIGNATED_INITIALIZER;
  35. /** Copies and sends an internal telemetry event. Events sent using this API are lower in priority,
  36. * and sometimes won't be sent on their own.
  37. *
  38. * @note This will convert the event's data object to data and release the original event.
  39. *
  40. * @param event The event to send.
  41. * @param completion A block that will be called when the event has been written or dropped.
  42. */
  43. - (void)sendTelemetryEvent:(GDTCOREvent *)event
  44. onComplete:(void (^_Nullable)(BOOL wasWritten, NSError *_Nullable error))completion;
  45. /** Copies and sends an internal telemetry event. Events sent using this API are lower in priority,
  46. * and sometimes won't be sent on their own.
  47. *
  48. * @note This will convert the event's data object to data and release the original event.
  49. *
  50. * @param event The event to send.
  51. */
  52. - (void)sendTelemetryEvent:(GDTCOREvent *)event;
  53. /** Copies and sends an SDK service data event. Events send using this API are higher in priority,
  54. * and will cause a network request at some point in the relative near future.
  55. *
  56. * @note This will convert the event's data object to data and release the original event.
  57. *
  58. * @param event The event to send.
  59. * @param completion A block that will be called when the event has been written or dropped.
  60. */
  61. - (void)sendDataEvent:(GDTCOREvent *)event
  62. onComplete:(void (^_Nullable)(BOOL wasWritten, NSError *_Nullable error))completion;
  63. /** Copies and sends an SDK service data event. Events send using this API are higher in priority,
  64. * and will cause a network request at some point in the relative near future.
  65. *
  66. * @note This will convert the event's data object to data and release the original event.
  67. *
  68. * @param event The event to send.
  69. */
  70. - (void)sendDataEvent:(GDTCOREvent *)event;
  71. /** Creates an event for use by this transport.
  72. *
  73. * @return An event that is suited for use by this transport.
  74. */
  75. - (GDTCOREvent *)eventForTransport;
  76. @end
  77. NS_ASSUME_NONNULL_END