Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(insights): expose internal client through eventTracker #150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dhayab
Copy link
Member

@dhayab dhayab commented Aug 30, 2024

Q A
Bug fix? no
New feature? yes
BC breaks? no
Related Issue Slack
Need Doc update yes

Describe your change

This exposes the Insights client created within the algolia_insights helper so it can be used to push events that are unsupported by the helper at this time.

Example usage

searcher.eventTracker?.client.pushEvents(
  insightsEvents: InsightsEvents(events: [
    AddedToCartObjectIDs(
      eventName: 'eventName',
      eventType: ConversionEvent.conversion,
      eventSubtype: AddToCartEvent.addToCart,
      index: 'instant_search',
      objectIDs: ['objectID1', 'objectID2'],
      userToken: 'userToken')
]));

@dhayab dhayab force-pushed the feat/expose-internal-insights-client branch from bf6bb80 to 35edc75 Compare August 30, 2024 14:33
@dhayab dhayab marked this pull request as ready for review August 30, 2024 14:33
@dhayab dhayab requested review from aallam, a team, sarahdayan and aymeric-giraudet and removed request for a team August 30, 2024 14:33
@aallam
Copy link
Member

aallam commented Sep 2, 2024

The issue with exposing (and using) the client directly is that it doesn't handle the offline case. That's why the insights flutter package exists.

@dhayab
Copy link
Member Author

dhayab commented Sep 2, 2024

Thanks @aallam for the feedback!

From what I understand, the better way to handle the gap we're facing it to update all of the insights helper types and methods to handle the missing event types and subtypes.

Until we have the resources to comprehensively address it, do you think this PR work as a stop-gap measure if we ensure users understand that by directly accessing the insights client they don't benefit from the offline capability?

@aallam
Copy link
Member

aallam commented Sep 2, 2024

Until we have the resources to comprehensively address it, do you think this PR work as a stop-gap measure if we ensure users understand that by directly accessing the insights client they don't benefit from the offline capability?

Yeah, sure it could be. It is also possible for users to instantiate their own instance of the client if they wish.
In all cases, it must be clear that events sent directly through the client are executed immediately. If a call fails, there will be no further retries. That's the main reason for using the helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants