algolia / instantsearch-ios

⚡️ A library of widgets and helpers to build instant-search applications on iOS.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/ios/
Apache License 2.0
591 stars 55 forks source link

Can't disable Insights #290

Open jwells89 opened 1 year ago

jwells89 commented 1 year ago

Describe the bug 🐛 At least when instantsearch-core is added to a project with the SPM package via Xcode, there doesn't seem to be a functional way of disabling Insights. I couldn't find any documentation on the topic, and the two places I found seemingly relevant functionality (Insights.shared?.isActive and HitsSearcher.eventTracker.isEnabled) don't change anything when set to false — in the Xcode console I still see messages like, "[InstantSearchInsights] sending events package".

To Reproduce 🔍 Steps to reproduce the behavior:

  1. Disable Insights globally with Insights.shared?.isActive = false
  2. Disable Insights for a HitsSearcher with searcher.eventTracker.isEnabled = false
  3. Observe Insights continuing to be sent

Expected behavior 💭 Insights shouldn't do anything after it's been disabled.

Environment:

VladislavFitz commented 1 year ago

Hi @jwells89 , Thank you for reporting this. I'll investigate this issue and come back with a patch.

VladislavFitz commented 1 year ago

Hi @jwells89, I examined the behavior of automatic event sending when searcher.eventTracker.isEnabled is set to false, and it functions as intended by preventing the capture of new events. The events you observe in the logs might occur because of events that were already stored in memory before disabling event tracking. These events could have been captured during previous app sessions since they are stored persistently in the device's memory.