FIRDLScionLogging.m 1.8 KB

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