GDTCOREvent.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/GDTCOREventDataObject.h>
  18. @class GDTCORClock;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** The different possible quality of service specifiers. High values indicate high priority. */
  21. typedef NS_ENUM(NSInteger, GDTCOREventQoS) {
  22. /** The QoS tier wasn't set, and won't ever be sent. */
  23. GDTCOREventQoSUnknown = 0,
  24. /** This event is internal telemetry data that should not be sent on its own if possible. */
  25. GDTCOREventQoSTelemetry = 1,
  26. /** This event should be sent, but in a batch only roughly once per day. */
  27. GDTCOREventQoSDaily = 2,
  28. /** This event should be sent when requested by the uploader. */
  29. GDTCOREventQosDefault = 3,
  30. /** This event should be sent immediately along with any other data that can be batched. */
  31. GDTCOREventQoSFast = 4,
  32. /** This event should only be uploaded on wifi. */
  33. GDTCOREventQoSWifiOnly = 5,
  34. };
  35. @interface GDTCOREvent : NSObject <NSSecureCoding>
  36. /** The mapping identifier, to allow backends to map the transport bytes to a proto. */
  37. @property(readonly, nonatomic) NSString *mappingID;
  38. /** The identifier for the backend this event will eventually be sent to. */
  39. @property(readonly, nonatomic) NSInteger target;
  40. /** The data object encapsulated in the transport of your choice, as long as it implements
  41. * the GDTCOREventDataObject protocol. */
  42. @property(nullable, nonatomic) id<GDTCOREventDataObject> dataObject;
  43. /** The quality of service tier this event belongs to. */
  44. @property(nonatomic) GDTCOREventQoS qosTier;
  45. /** The clock snapshot at the time of the event. */
  46. @property(nonatomic) GDTCORClock *clockSnapshot;
  47. /** The resulting file URL when [dataObject -transportBytes] has been saved to disk.*/
  48. @property(nullable, readonly, nonatomic) NSURL *fileURL;
  49. /** A dictionary provided to aid prioritizers by allowing the passing of arbitrary data. It will be
  50. * retained by a copy in -copy, but not used for -hash.
  51. *
  52. * @note Ensure that classes contained therein implement NSSecureCoding to prevent loss of data.
  53. */
  54. @property(nullable, nonatomic) NSDictionary *customPrioritizationParams;
  55. // Please use the designated initializer.
  56. - (instancetype)init NS_UNAVAILABLE;
  57. /** Initializes an instance using the given mappingID.
  58. *
  59. * @param mappingID The mapping identifier.
  60. * @param target The event's target identifier.
  61. * @return An instance of this class.
  62. */
  63. - (nullable instancetype)initWithMappingID:(NSString *)mappingID
  64. target:(NSInteger)target NS_DESIGNATED_INITIALIZER;
  65. @end
  66. NS_ASSUME_NONNULL_END