FIRIAMAnalyticsEventLogger.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "FirebaseInAppMessaging/Sources/Private/Analytics/FIRIAMClientInfoFetcher.h"
  18. #import "FirebaseInAppMessaging/Sources/Private/Util/FIRIAMTimeFetcher.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. /// Values for different fiam activity types.
  21. typedef NS_ENUM(NSInteger, FIRIAMAnalyticsLogEventType) {
  22. FIRIAMAnalyticsLogEventUnknown = -1,
  23. FIRIAMAnalyticsEventMessageImpression = 0,
  24. FIRIAMAnalyticsEventActionURLFollow = 1,
  25. FIRIAMAnalyticsEventMessageDismissAuto = 2,
  26. FIRIAMAnalyticsEventMessageDismissClick = 3,
  27. FIRIAMAnalyticsEventMessageDismissSwipe = 4,
  28. // category: errors happened
  29. FIRIAMAnalyticsEventImageFetchError = 11,
  30. FIRIAMAnalyticsEventImageFormatUnsupported = 12,
  31. FIRIAMAnalyticsEventFetchAPINetworkError = 13,
  32. FIRIAMAnalyticsEventFetchAPIClientError = 14, // server returns 4xx status code
  33. FIRIAMAnalyticsEventFetchAPIServerError = 15, // server returns 5xx status code
  34. // Events for test messages
  35. FIRIAMAnalyticsEventTestMessageImpression = 16,
  36. FIRIAMAnalyticsEventTestMessageClick = 17,
  37. };
  38. // a protocol for collecting Analytics log records. It's implementation will decide
  39. // what to do with that analytics log record
  40. @protocol FIRIAMAnalyticsEventLogger
  41. /**
  42. * Adds an analytics log record.
  43. * @param eventTimeInMs the timestamp in ms for when the event happened.
  44. * if it's nil, the implementation will use the current system for this info.
  45. */
  46. - (void)logAnalyticsEventForType:(FIRIAMAnalyticsLogEventType)eventType
  47. forCampaignID:(NSString *)campaignID
  48. withCampaignName:(NSString *)campaignName
  49. eventTimeInMs:(nullable NSNumber *)eventTimeInMs
  50. completion:(void (^)(BOOL success))completion;
  51. @optional
  52. /**
  53. * Adds an analytics log indicating that a campaign has been interacted with, and is therefore
  54. * considered responsible for future conversion events as defined by the app developer during
  55. * campaign creation. Only necessary if the implementing class talks to Firebase Analytics.
  56. */
  57. - (void)logConversionTrackingEventForCampaignID:(NSString *)campaignID;
  58. @end
  59. NS_ASSUME_NONNULL_END