FPRConsoleURLGenerator.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "FirebasePerformance/Sources/Common/FPRConsoleURLGenerator.h"
  15. NSString *const URL_BASE_PATH = @"https://console.firebase.google.com";
  16. NSString *const UTM_MEDIUM = @"ios-ide";
  17. NSString *const UTM_SOURCE = @"perf-ios-sdk";
  18. @implementation FPRConsoleURLGenerator
  19. /** This is a class method to generate the console URL for the project's dashboard page.*/
  20. + (NSString *)generateDashboardURLWithProjectID:(NSString *)projectID
  21. bundleID:(NSString *)bundleID {
  22. NSString *rootUrl = [FPRConsoleURLGenerator getRootURLWithProjectID:projectID bundleID:bundleID];
  23. return [NSString
  24. stringWithFormat:@"%@/trends?utm_source=%@&utm_medium=%@", rootUrl, UTM_SOURCE, UTM_MEDIUM];
  25. }
  26. /** This is a class method to generate the console URL for the custom trace.*/
  27. + (NSString *)generateCustomTraceURLWithProjectID:(NSString *)projectID
  28. bundleID:(NSString *)bundleID
  29. traceName:(NSString *)traceName {
  30. NSString *rootUrl = [FPRConsoleURLGenerator getRootURLWithProjectID:projectID bundleID:bundleID];
  31. return [NSString stringWithFormat:@"%@/metrics/trace/"
  32. @"DURATION_TRACE/%@?utm_source=%@&utm_medium=%@",
  33. rootUrl, traceName, UTM_SOURCE, UTM_MEDIUM];
  34. }
  35. /** This is a class method to generate the console URL for the screen trace.*/
  36. + (NSString *)generateScreenTraceURLWithProjectID:(NSString *)projectID
  37. bundleID:(NSString *)bundleID
  38. traceName:(NSString *)traceName {
  39. NSString *rootUrl = [FPRConsoleURLGenerator getRootURLWithProjectID:projectID bundleID:bundleID];
  40. return [NSString stringWithFormat:@"%@/metrics/trace/"
  41. @"SCREEN_TRACE/%@?utm_source=%@&utm_medium=%@",
  42. rootUrl, traceName, UTM_SOURCE, UTM_MEDIUM];
  43. }
  44. /** This is a class method to get the root URL for the console .*/
  45. + (NSString *)getRootURLWithProjectID:(NSString *)projectID bundleID:(NSString *)bundleID {
  46. return [NSString
  47. stringWithFormat:@"%@/project/%@/performance/app/ios:%@", URL_BASE_PATH, projectID, bundleID];
  48. }
  49. @end