사용자가 Firebase Performance Monitoring 사용을 선택하거나 선택 해제할 수 있도록 하려면 Performance Monitoring을 사용 설정 및 중지할 수 있도록 앱을 구성해야 할 수 있습니다. 이 기능은 앱 개발 및 테스트 중에 유용할 수도 있습니다.
다음은 고려해야 할 몇 가지 옵션입니다.
런타임에 다시 활성화하는 옵션을 사용하여 앱을 빌드할 때 Performance Monitoring SDK를 비활성화할 수 있습니다.
Performance Monitoring SDK를 사용하도록 설정한 상태에서 앱을 빌드할 수 있지만 Firebase 원격 구성을 사용하여 런타임 시 비활성화할 수 있는 옵션이 있습니다.
런타임에 활성화하는 옵션 없이 Performance Monitoring SDK를 완전히 비활성화할 수 있습니다.
앱 빌드 프로세스 중 성능 모니터링 비활성화
앱 빌드 프로세스 중에 성능 모니터링을 비활성화하는 것이 유용할 수 있는 한 가지 상황은 앱 개발 및 테스트 중에 앱의 시험판 버전에서 성능 데이터를 보고하지 않는 것입니다.
성능 모니터링을 비활성화하거나 비활성화하려면 Apple 앱의 속성 목록 파일( Info.plist
)에 다음 두 키 중 하나를 추가하면 됩니다.
성능 모니터링을 비활성화하지만 앱이 런타임에 활성화하도록 허용하려면 앱의
Info.plist
파일에서firebase_performance_collection_enabled
를false
로 설정합니다.런타임에 활성화하는 옵션 없이 성능 모니터링을 완전히 비활성화하려면 앱의
Info.plist
파일에서firebase_performance_collection_deactivated
를true
로 설정하세요.
원격 구성을 사용하여 런타임 시 앱 비활성화
Firebase 원격 구성을 사용하면 앱의 동작과 모양을 변경할 수 있으므로 앱의 배포된 인스턴스에서 성능 모니터링을 비활성화할 수 있는 이상적인 방법을 제공합니다.
다음에 Apple 앱을 시작할 때 성능 모니터링 데이터 수집을 비활성화하려면 아래 표시된 예제 코드를 사용하십시오. Apple 앱에서 원격 구성을 사용하는 방법에 대한 자세한 내용은 Apple 플랫폼에서 Firebase 원격 구성 사용 을 참조하세요.
Podfile
에서 원격 구성이 사용되는지 확인하십시오.pod 'Firebase/RemoteConfig'
앱의
AppDelegate
파일 상단에 다음을 추가합니다.빠른
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.import FirebaseRemoteConfig
목표-C
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.@import FirebaseRemoteConfig;
AppDelegate
파일에서application:didFinishLaunchingWithOptions:
인스턴스 메서드의launchOptions
문에 다음 코드를 추가합니다.빠른
참고: 이 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.remoteConfig = RemoteConfig.remoteConfig() // You can change the "false" below to "true" to permit more fetches when validating // your app, but you should change it back to "false" or remove this statement before // distributing your app in production. let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: false) remoteConfig.configSettings = remoteConfigSettings! // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. remoteConfig.setDefaultsFromPlistFileName("RemoteConfigDefaults") // Important! This needs to be applied before FirebaseApp.configure() if !remoteConfig["perf_disable"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
목표-C
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.self.remoteConfig = [FIRRemoteConfig remoteConfig]; // You can change the NO below to YES to permit more fetches when validating // your app, but you should change it back to NO or remove this statement before // distributing your app in production. FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:NO]; self.remoteConfig.configSettings = remoteConfigSettings; // Load in-app defaults from a plist file that sets perf_disable to false until // you update values in the Firebase console. [self.remoteConfig setDefaultsFromPlistFileName:@"RemoteConfigDefaults"]; // Important! This needs to be applied before [FIRApp configure] if (!self.remoteConfig[@"perf_disable"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FIRApp configure];
ViewController.m
또는 앱에서 사용하는 다른 구현 파일에서 다음 코드를 추가하여 원격 구성 값을 가져오고 활성화합니다.빠른
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.//RemoteConfig fetch and activation in your app, shortly after startup remoteConfig.fetch(withExpirationDuration: TimeInterval(30.0)) { (status, error) -> Void in if status == .success { print("Config fetched!") self.remoteConfig.activateFetched() } else { print("Config not fetched") print("Error \(error!.localizedDescription)") } }
목표-C
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.//RemoteConfig fetch and activation in your app, shortly after startup [self.remoteConfig fetchWithExpirationDuration:30.0 completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) { if (status == FIRRemoteConfigFetchStatusSuccess) { NSLog(@"Config fetched!"); [self.remoteConfig activateFetched]; } else { NSLog(@"Config not fetched"); NSLog(@"Error %@", error.localizedDescription); } }];
Firebase 콘솔에서 Performance Monitoring을 비활성화하려면 앱 프로젝트에서 perf_disable 매개변수를 만든 다음 해당 값을
true
로 설정합니다.perf_disable 값을
false
로 설정하면 성능 모니터링이 활성화된 상태로 유지됩니다.
자동 또는 사용자 지정 데이터 수집을 개별적으로 비활성화
맞춤 모니터링과 별도로 모든 자동(즉시 사용 가능한) 모니터링을 비활성화할 수 있도록 위에 표시된 코드와 Firebase 콘솔을 일부 변경할 수 있습니다.
application:didFinishLaunchingWithOptions:
인스턴스 메서드의launchOptions
문에 다음 코드를 추가합니다(동일한 인스턴스 메서드에 대해 위에 표시된 것 대신).빠른
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.remoteConfig = FIRRemoteConfig.remoteConfig() let remoteConfigSettings = FIRRemoteConfigSettings(developerModeEnabled: true) remoteConfig.configSettings = remoteConfigSettings! // Important! This needs to be applied before FirebaseApp.configure() if remoteConfig["perf_disable_auto"].boolValue { // The following line disables all automatic (out-of-the-box) monitoring Performance.sharedInstance().isInstrumentationEnabled = false } else { Performance.sharedInstance().isInstrumentationEnabled = true } if remoteConfig["perf_disable_manual"].boolValue { // The following line disables all custom monitoring Performance.sharedInstance().isDataCollectionEnabled = false } else { Performance.sharedInstance().isDataCollectionEnabled = true } // Use Firebase library to configure APIs FirebaseApp.configure()
목표-C
참고: 이 Firebase 제품은 macOS, Mac Catalyst, watchOS 대상에서 사용할 수 없습니다.self.remoteConfig = [FIRRemoteConfig remoteConfig]; FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES]; self.remoteConfig.configSettings = remoteConfigSettings; // Important! This needs to be applied before [FirebaseApp configure] if (self.remoteConfig[@"perf_disable_auto"].numberValue.boolValue) { // The following line disables all automatic (out-of-the-box) monitoring [FIRPerformance sharedInstance].instrumentationEnabled = NO; } else { [FIRPerformance sharedInstance].instrumentationEnabled = YES; } if (self.remoteConfig[@"perf_disable_manual"].numberValue.boolValue) { // The following line disables all custom monitoring [FIRPerformance sharedInstance].dataCollectionEnabled = NO; } else { [FIRPerformance sharedInstance].dataCollectionEnabled = YES; } // Use Firebase library to configure APIs [FirebaseApp configure];
Firebase 콘솔에서 다음을 완료합니다.
- 모든 자동(기본 제공) 모니터링을 비활성화하려면 앱의 프로젝트에서 perf_disable_auto 매개변수를 생성한 다음 해당 값을
true
로 설정합니다. - 모든 사용자 지정 모니터링을 비활성화하려면 앱의 프로젝트에서 perf_disable_manual 매개변수를 만든 다음 해당 값을
true
로 설정합니다.
- 모든 자동(기본 제공) 모니터링을 비활성화하려면 앱의 프로젝트에서 perf_disable_auto 매개변수를 생성한 다음 해당 값을