अपने उपयोगकर्ताओं को फायरबेस प्रदर्शन मॉनिटरिंग का उपयोग करने के लिए ऑप्ट-इन या ऑप्ट-आउट करने देने के लिए, आप अपने ऐप को कॉन्फ़िगर करना चाह सकते हैं ताकि आप प्रदर्शन मॉनिटरिंग को सक्षम और अक्षम कर सकें। ऐप के विकास और परीक्षण के दौरान आपको यह क्षमता उपयोगी भी लग सकती है।
विचार करने के लिए निम्नलिखित कुछ विकल्प हैं:
आप अपने ऐप का निर्माण करते समय प्रदर्शन निगरानी एसडीके को रनटाइम पर पुनः सक्षम करने के विकल्प के साथ अक्षम कर सकते हैं।
आप अपने ऐप को प्रदर्शन मॉनिटरिंग एसडीके सक्षम के साथ बना सकते हैं लेकिन फायरबेस रिमोट कॉन्फिग का उपयोग करके इसे रनटाइम पर अक्षम करने का विकल्प है।
आप प्रदर्शन मॉनिटरिंग एसडीके को पूरी तरह से निष्क्रिय कर सकते हैं, इसे रनटाइम पर सक्षम करने का कोई विकल्प नहीं है।
अपने ऐप निर्माण प्रक्रिया के दौरान प्रदर्शन निगरानी अक्षम करें
एक स्थिति जहां आपके ऐप निर्माण प्रक्रिया के दौरान प्रदर्शन निगरानी को अक्षम करना उपयोगी हो सकता है, ऐप के विकास और परीक्षण के दौरान आपके ऐप के रिलीज़-पूर्व संस्करण से प्रदर्शन डेटा की रिपोर्टिंग से बचना है।
प्रदर्शन मॉनिटरिंग को अक्षम या निष्क्रिय करने के लिए, आप अपने Apple ऐप के लिए संपत्ति सूची फ़ाइल ( Info.plist
) में दो कुंजियों में से एक जोड़ सकते हैं:
प्रदर्शन निगरानी को अक्षम करने के लिए, लेकिन अपने ऐप को इसे रनटाइम पर सक्षम करने की अनुमति दें, अपने ऐप की
Info.plist
फ़ाइल मेंfirebase_performance_collection_enabled
कोfalse
पर सेट करें।प्रदर्शन निगरानी को पूरी तरह से निष्क्रिय करने के लिए, इसे रनटाइम पर सक्षम करने के विकल्प के बिना, अपने ऐप की
Info.plist
फ़ाइल मेंfirebase_performance_collection_deactivated
कोtrue
पर सेट करें।
Remote Config का उपयोग करके अपने ऐप को रनटाइम पर अक्षम करें
फायरबेस रिमोट कॉन्फ़िगरेशन आपको अपने ऐप के व्यवहार और उपस्थिति में परिवर्तन करने देता है, इसलिए यह आपको अपने ऐप के परिनियोजित उदाहरणों में प्रदर्शन मॉनिटरिंग को अक्षम करने का एक आदर्श तरीका प्रदान करता है।
अगली बार जब आपका Apple ऐप शुरू हो तो प्रदर्शन निगरानी डेटा संग्रह को अक्षम करने के लिए, नीचे दिखाए गए उदाहरण कोड का उपयोग करें। किसी Apple ऐप में Remote Config का उपयोग करने के बारे में अधिक जानकारी के लिए, Apple प्लेटफॉर्म पर Firebase Remote Config का उपयोग करें देखें।
सुनिश्चित करें कि आपके
Podfile
में रिमोट कॉन्फिग का उपयोग किया जाता है:pod 'Firebase/RemoteConfig'
अपने ऐप की
AppDelegate
फ़ाइल के शीर्ष पर निम्न जोड़ें:तीव्र
नोट: यह फायरबेस उत्पाद macOS, Mac Catalyst, watchOS लक्ष्यों पर उपलब्ध नहीं है।import FirebaseRemoteConfig
उद्देश्य सी
नोट: यह फायरबेस उत्पाद 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()
उद्देश्य सी
नोट: यह फायरबेस उत्पाद 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
में, या आपके ऐप द्वारा उपयोग की जाने वाली अन्य कार्यान्वयन फ़ाइल में, रिमोट कॉन्फ़िग मानों को लाने और सक्रिय करने के लिए निम्न कोड जोड़ें:तीव्र
नोट: यह फायरबेस उत्पाद 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)") } }
उद्देश्य सी
नोट: यह फायरबेस उत्पाद 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); } }];
फायरबेस कंसोल में प्रदर्शन निगरानी को अक्षम करने के लिए, अपने ऐप के प्रोजेक्ट में एक perf_disable पैरामीटर बनाएं, फिर उसके मान को
true
पर सेट करें।यदि आप perf_disable का मान
false
पर सेट करते हैं, तो प्रदर्शन निगरानी सक्षम रहती है।
स्वचालित या कस्टम डेटा संग्रह को अलग से अक्षम करें
आप कस्टम मॉनिटरिंग से अलग से सभी स्वचालित (आउट-ऑफ-द-बॉक्स) मॉनिटरिंग को अक्षम करने के लिए ऊपर और फायरबेस कंसोल में दिखाए गए कोड में कुछ बदलाव कर सकते हैं।
application:didFinishLaunchingWithOptions:
उदाहरण विधि में निम्नलिखित कोड कोlaunchOptions
स्टेटमेंट में जोड़ें (उसी उदाहरण विधि के लिए ऊपर दिखाए गए के बजाय):तीव्र
नोट: यह फायरबेस उत्पाद 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()
उद्देश्य सी
नोट: यह फायरबेस उत्पाद 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];
फायरबेस कंसोल में निम्नलिखित को पूरा करें:
- सभी स्वचालित (आउट-ऑफ-द-बॉक्स) मॉनिटरिंग को अक्षम करने के लिए, अपने ऐप के प्रोजेक्ट में एक perf_disable_auto पैरामीटर बनाएं, फिर उसके मान को
true
पर सेट करें। - सभी कस्टम मॉनिटरिंग को अक्षम करने के लिए, अपने ऐप के प्रोजेक्ट में एक perf_disable_manual पैरामीटर बनाएं, फिर उसके मान को
true
पर सेट करें।
- सभी स्वचालित (आउट-ऑफ-द-बॉक्स) मॉनिटरिंग को अक्षम करने के लिए, अपने ऐप के प्रोजेक्ट में एक perf_disable_auto पैरामीटर बनाएं, फिर उसके मान को