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

Provide a way to turn off Insights logging #310

Open mariuscristescuascend opened 3 months ago

mariuscristescuascend commented 3 months ago

Is your feature request related to a problem? Please describe 🙏

I recently integrated the InstantSearch SDK v7.26.1 and AlgoliaSearchClient SDK v8.19.0 in our iOS app in order to trigger several InstantSearch Insights events.

After I finished my integration debugging I was left with a verbose logging in my console that I cannot turn off. Every 30 seconds I get a log like this:

2024-03-06T14:37:01+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing 2024-03-06T14:37:31+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing 2024-03-06T14:38:01+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing 2024-03-06T14:38:31+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing 2024-03-06T14:39:01+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing 2024-03-06T14:39:31+0200 info Insights (B5UR3QDMCF) : [InstantSearchInsights] no pending event packages, skip flushing

I instantiate Insights with:

    Insights.register(appId: ApplicationID(rawValue: algoliaAppId),
                     apiKey: APIKey(rawValue: algoliaApiKey),
                     userToken: UserToken(rawValue: String(user.id)))

I tried this, but it had no effect:

   Insights.shared(appId: ApplicationID(rawValue: algoliaAppId))?.isLoggingEnabled = false

This logging past the integration phase is unnecessary and pollutes the console, making it hard to see important logging.

*Describe the solution you'd like 🤔**

Provide a way to turn of the logging, or better yet, make logging default to silent and only activate it when needed.