From d46b2e2bb2ea23e1f20f14c994f247d83ad587f9 Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Mon, 22 Nov 2021 15:52:19 -0500 Subject: [PATCH] Debounce the image size tracking to prevent tracking continuously --- .../App Settings/AppSettingsViewController.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift b/WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift index 9c06246cceb1..4a5df4179fe2 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/AppSettingsViewController.swift @@ -148,13 +148,20 @@ class AppSettingsViewController: UITableViewController { MediaSettings().maxImageSizeSetting = value ShareExtensionService.configureShareExtensionMaximumMediaDimension(value) - var properties = [String: AnyObject]() - properties["enabled"] = (value != Int.max) as AnyObject - properties["value"] = value as Int as AnyObject - WPAnalytics.track(.appSettingsImageOptimizationChanged, withProperties: properties) + self.debounce(#selector(self.trackImageSizeChanged), afterDelay: 0.5) } } + @objc func trackImageSizeChanged() { + let value = MediaSettings().maxImageSizeSetting + + var properties = [String: AnyObject]() + properties["enabled"] = (value != Int.max) as AnyObject + properties["value"] = value as Int as AnyObject + + WPAnalytics.track(.appSettingsImageOptimizationChanged, withProperties: properties) + } + func pushVideoResolutionSettings() -> ImmuTableAction { return { [weak self] row in let values = [MediaSettings.VideoResolution.size640x480,