FIRDLScionLogging.m 1.7 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 "FirebaseDynamicLinks/Sources/FIRDLScionLogging.h"
  17. #import <FirebaseAnalyticsInterop/FIRInteropParameterNames.h>
  18. static NSString *const kFIRDLLogEventFirstOpenCampaign = @"dynamic_link_first_open";
  19. static NSString *const kFIRDLLogEventAppOpenCampaign = @"dynamic_link_app_open";
  20. void FIRDLLogEventToScion(FIRDLLogEvent event,
  21. NSString *_Nullable source,
  22. NSString *_Nullable medium,
  23. NSString *_Nullable campaign,
  24. id<FIRAnalyticsInterop> _Nullable analytics) {
  25. NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
  26. if (source) {
  27. parameters[kFIRIParameterSource] = source;
  28. }
  29. if (medium) {
  30. parameters[kFIRIParameterMedium] = medium;
  31. }
  32. if (campaign) {
  33. parameters[kFIRIParameterCampaign] = campaign;
  34. }
  35. NSString *name;
  36. switch (event) {
  37. case FIRDLLogEventFirstOpen:
  38. name = kFIRDLLogEventFirstOpenCampaign;
  39. break;
  40. case FIRDLLogEventAppOpen:
  41. name = kFIRDLLogEventAppOpenCampaign;
  42. break;
  43. }
  44. if (name) {
  45. [analytics logEventWithOrigin:@"fdl" name:name parameters:parameters];
  46. }
  47. }