algolia / algoliasearch-helper-flutter

⚡️ Building block to create instant-search applications with Flutter
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/flutter/
Other
21 stars 14 forks source link

Getting QueryID for events #128

Closed agustinlacuara closed 4 months ago

agustinlacuara commented 4 months ago

I'm having trouble getting the queryId from HitsSearch in my Flutter App (Im using Flutter Helper and Algolia Insights as docs recommend).

In my pubspec.yaml:

algolia_helper_flutter: ^1.0.0-pre
algolia_insights: ^1.0.0-pre

This is how I set my HitsSearcher

final _productsSearcher = HitsSearcher(
        applicationID: Environment.algoliaApplicationId,
        apiKey: Environment.algoliaSearchOnlyKey,
        indexName: Environment.algoliaProductsHitsIndex,
        insights: true, ← Here activating insights to get queryId in every query.
);

Also added this in the paginationController to see if it works:

_pagingController.addPageRequestListener(
        (pageKey) => _productsSearcher.applyState(
               (state) => state.copyWith(
                     clickAnalytics: true, ← Here activating click analytics
                     analytics: true, ← Here activating analytics
                     page: pageKey,
                     ruleContexts: [widget.algoliaContext],
               ),
        ),
);

Now, the problem is that, as defined in the SearchResponse model from the Flutter Helper package, it should have (if the setup is ok) a response.queryID.

This parameter is optional in the model, but can't get it to be returned.

Also, I found out that _productSearcher has a field called queryId (which is also optional) and again, cant get it to be else than null.

So, after tryng to find queryId I found out that there are more than one place where it can be reached from. But from any of those I always get a null as queryId.

This is a mandatory input for the click and conversion events after search. Which are really important for the personalization. So i beleive there ir something missing from my configs. But docs for this functionality is still in progress i assume.

Expected behavior 💭

Environment:

SdxCoder commented 4 months ago

Experiencing the same issue, as you can see below there is no queryID key in raw object.

Screenshot 2024-03-04 at 12 22 26 PM

cc @aallam

agustinlacuara commented 4 months ago

Seems to be merged for next release! https://github.com/algolia/api-clients-automation/pull/2801

aallam commented 4 months ago

Version 1.5.1 is released with the fix :)

agustinlacuara commented 4 months ago

To access this new parameter, there is no need to update algolia_flutter_helper package. SearchResponse.queryId is now working correctly!