ফায়ারবেস পারফরম্যান্স মনিটরিং অক্ষম করুন


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

বিবেচনা করার মতো কয়েকটি বিকল্প নিচে দেওয়া হলো:

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

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

  • আপনি Performance Monitoring SDK সম্পূর্ণরূপে নিষ্ক্রিয় করতে পারেন, রানটাইমে এটি সক্রিয় করার কোনো বিকল্প নেই।

আপনার অ্যাপ বিল্ড প্রক্রিয়া চলাকালীন Performance Monitoring নিষ্ক্রিয় করুন।

আপনার অ্যাপ বিল্ড প্রক্রিয়ার সময় Performance Monitoring নিষ্ক্রিয় করার একটি কার্যকর উপায় হলো, অ্যাপ ডেভেলপমেন্ট এবং টেস্টিংয়ের সময় অ্যাপের প্রি-রিলিজ সংস্করণ থেকে পারফরম্যান্স ডেটা রিপোর্ট করা এড়ানো।

Performance Monitoring নিষ্ক্রিয় বা বন্ধ করতে, আপনি আপনার অ্যাপল অ্যাপের প্রপার্টি লিস্ট ফাইলে ( 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. আপনার PodfileRemote Config ব্যবহার করা হয়েছে কিনা তা নিশ্চিত করুন:

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

    সুইফট

    দ্রষ্টব্য: এই Firebase পণ্যটি macOS, Mac Catalyst, watchOS টার্গেটগুলিতে উপলব্ধ নয়।
    import FirebaseRemoteConfig
    

    উদ্দেশ্য-সি

    দ্রষ্টব্য: এই Firebase পণ্যটি macOS, Mac Catalyst, watchOS টার্গেটগুলিতে উপলব্ধ নয়।
    @import FirebaseRemoteConfig;
    
  3. আপনার 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()
    

    উদ্দেশ্য-সি

    দ্রষ্টব্য: এই 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 ভ্যালুগুলো ফেচ ও অ্যাক্টিভেট করার জন্য নিম্নলিখিত কোডটি যোগ করুন:

    সুইফট

    দ্রষ্টব্য: এই 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)")
      }
    }
    

    উদ্দেশ্য-সি

    দ্রষ্টব্য: এই 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 স্টেটমেন্টগুলিতে নিম্নলিখিত কোডটি যোগ করুন (একই ইনস্ট্যান্স মেথডের জন্য উপরে যা দেখানো হয়েছে তার পরিবর্তে):

    সুইফট

    দ্রষ্টব্য: এই 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()
    

    উদ্দেশ্য-সি

    দ্রষ্টব্য: এই 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 সেট করুন।