Firebase পারফর্ম্যান্স মনিটরিং বন্ধ করুন


আপনার ব্যবহারকারীদের Firebase Performance Monitoring ব্যবহার করা চালু বা বন্ধ করার অনুমতি দিতে, আপনি হয়ত আপনার অ্যাপ কনফিগার করতে চাইবেন যাতে আপনি Performance Monitoring চালু এবং বন্ধ করতে পারেন। অ্যাপ ডেভেলপমেন্ট ও টেস্টিংয়ের সময়ও এই ক্ষমতা আপনার কাজে লাগতে পারে।

এইসব বিকল্প বিবেচনা করে দেখুন:

  • আপনার অ্যাপ তৈরি করার সময় Performance Monitoring SDK বন্ধ করতে পারবেন এবং রানটাইমে এটি আবার চালু করার বিকল্পও পাবেন।

  • আপনি Performance Monitoring SDK চালু রেখে আপনার অ্যাপ তৈরি করতে পারেন, তবে Firebase Remote Config ব্যবহার করে রানটাইমে এটি বন্ধ করার বিকল্পও রয়েছে।

  • আপনি Performance Monitoring SDK সম্পূর্ণভাবে বন্ধ করে দিতে পারেন, রানটাইমে এটি চালু করার কোনও বিকল্প নেই।

আপনার অ্যাপ বিল্ড প্রসেস চলাকালীন Performance Monitoring বন্ধ করুন

অ্যাপ তৈরি করার প্রসেস চলাকালীন Performance Monitoring বন্ধ করে দেওয়া একটি পরিস্থিতিতে উপযোগী হতে পারে, যেমন অ্যাপ ডেভেলপমেন্ট ও টেস্টিংয়ের সময় আপনার অ্যাপের প্রি-রিলিজ ভার্সন থেকে পারফর্ম্যান্স ডেটা রিপোর্টিং এড়ানো।

Performance Monitoring বন্ধ বা ডিঅ্যাক্টিভেট করতে, আপনার Apple অ্যাপের জন্য প্রপার্টি লিস্ট ফাইলে (Info.plist) দুটি 'কী'-এর মধ্যে একটি যোগ করতে পারেন:

  • Performance Monitoring বন্ধ করতে, কিন্তু রানটাইমে আপনার অ্যাপকে এটি চালু করার অনুমতি দিতে, আপনার অ্যাপের Info.plist ফাইলে firebase_performance_collection_enabled-কে false-এ সেট করুন।

  • রানটাইমে চালু করার কোনও বিকল্প ছাড়াই Performance Monitoring সম্পূর্ণভাবে বন্ধ করতে, আপনার অ্যাপের Info.plist ফাইলে firebase_performance_collection_deactivated-কে true-এ সেট করুন।

Remote Config ব্যবহার করে রানটাইমে আপনার অ্যাপ বন্ধ করুন

Firebase Remote Config আপনাকে নিজের অ্যাপের আচরণ ও চেহারায় পরিবর্তন করতে দেয়, তাই আপনার অ্যাপের ডিপ্লয় করা ইনস্ট্যান্সে Performance Monitoring বন্ধ করার জন্য এটি একটি আদর্শ উপায় প্রদান করে।

পরের বার আপনার Apple অ্যাপ চালু হওয়ার সময় Performance Monitoring ডেটা সংগ্রহ বন্ধ করতে, নিচে দেখানো উদাহরণ কোড ব্যবহার করুন। Apple অ্যাপে Remote Config ব্যবহার করার ব্যাপারে আরও জানতে, Apple প্ল্যাটফর্মে Firebase Remote Config ব্যবহার করুন দেখুন।

  1. আপনার Podfile-এ Remote Config ব্যবহার করা হয়েছে কিনা তা নিশ্চিত করুন:

    pod 'Firebase/RemoteConfig'
    
  2. আপনার অ্যাপের AppDelegate ফাইলের উপরে নিম্নলিখিত তথ্য যোগ করুন:

    Swift

    মনে রাখবেন: এই Firebase প্রোডাক্ট macOS, Mac Catalyst, watchOS টার্গেটে উপলভ্য নয়।
    import FirebaseRemoteConfig
    

    Objective-C

    মনে রাখবেন: এই Firebase প্রোডাক্ট macOS, Mac Catalyst, watchOS টার্গেটে উপলভ্য নয়।
    @import FirebaseRemoteConfig;
    
  3. আপনার AppDelegate ফাইলে, application:didFinishLaunchingWithOptions: ইনস্ট্যান্স মেথডে launchOptions স্টেটমেন্টে নিম্নলিখিত কোড যোগ করুন:

    Swift

    মনে রাখবেন: এই প্রোডাক্ট 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()
    

    Objective-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];
    
  4. ViewController.m-এ বা আপনার অ্যাপের ব্যবহার করা অন্য কোনও ইমপ্লিমেন্টেশন ফাইলে, Remote Config ভ্যালু ফেচ ও অ্যাক্টিভেট করতে নিম্নলিখিত কোড যোগ করুন:

    Swift

    মনে রাখবেন: এই 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)")
      }
    }
    

    Objective-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);
      }
    }];
    
  5. Firebase কনসোলে Performance Monitoring বন্ধ করতে, আপনার অ্যাপের প্রোজেক্টে একটি perf_disable প্যারামিটার তৈরি করুন, তারপর এর ভ্যালু true-এ সেট করুন।

    আপনি perf_disable-এর ভ্যালু false-এ সেট করলে, Performance Monitoring চালু থাকে।

অটোমেটিক বা কাস্টম ডেটা সংগ্রহ আলাদাভাবে বন্ধ করা

আপনি উপরে দেখানো কোডে এবং Firebase কনসোলে কিছু পরিবর্তন করতে পারেন যাতে আপনি কাস্টম মনিটরিং থেকে আলাদাভাবে সমস্ত অটোমেটিক (আউট-অফ-দ্য-বক্স) মনিটরিং বন্ধ করতে পারেন।

  1. application:didFinishLaunchingWithOptions: ইনস্ট্যান্স পদ্ধতিতে (একই ইনস্ট্যান্স পদ্ধতির জন্য উপরে যা দেখানো হয়েছে তার পরিবর্তে) launchOptions স্টেটমেন্টে নিম্নলিখিত কোড যোগ করুন:

    Swift

    মনে রাখবেন: এই 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()
    

    Objective-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];
    
  2. Firebase কনসোলে নিম্নলিখিত ধাপগুলি সম্পূর্ণ করুন:

    • সব অটোমেটিক (আউট-অফ-দ্য-বক্স) মনিটরিং বন্ধ করতে, আপনার অ্যাপের প্রোজেক্টে একটি perf_disable_auto প্যারামিটার তৈরি করুন, তারপর এটির ভ্যালু true হিসেবে সেট করুন।
    • সব কাস্টম মনিটরিং বন্ধ করতে, আপনার অ্যাপের প্রোজেক্টে একটি perf_disable_manual প্যারামিটার তৈরি করুন, তারপর এর ভ্যালু true হিসেবে সেট করুন।