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

Add keepalive flag for standard transport (not only batching) #768

Closed
arm1n opened this issue Jan 12, 2023 · 4 comments
Closed

Add keepalive flag for standard transport (not only batching) #768

arm1n opened this issue Jan 12, 2023 · 4 comments

Comments

@arm1n
Copy link

arm1n commented Jan 12, 2023

Hi there,

I'm facing an issue when using the standard transport (fetch-dispatcher), where there is no keepalive: true setting applied on the fetch request, whereas it's put on the request when using the batch dispatcher. Is there any reason why this mechanism is not attached in the standard transport?

In my case I've to call identify() + group() right after users has entered a group, but there's a hard redirect happening right after that process, thus leading to cancelling these requests. If they would be configured with keepalive the problem could be circumvented.

Thanks for any feedback!

@chrisradek
Copy link
Contributor

@arm1n Thanks for opening this issue! It sounds reasonable to me to support setting keepalive: true for all requests - we'll try to dig into why that wasn't done to begin with when batched dispatcher was introduced.

We did make a recent update (that's rolling out to the CDN soon) that will store events in localstorage if thefetch call hasn't completed and you leave the page - then get sent from the new page so long as the domain is the same. But the keepalive option should be even more reliable for browsers that support it.

@arm1n
Copy link
Author

arm1n commented Jan 20, 2023

Thanks for the heads up @chrisradek - yes I agree, the keepalive option should be the safer approach and it shouldn't have a negative impact when just setting it in the standard transport as well 👍

@silesky
Copy link
Contributor

silesky commented Feb 14, 2023

@arm1n

I've added a keepalive configuration option in 1.51.0

   const analytics = AnalyticsBrowser.load(
      { writeKey: '<WRITEKEY>' },
      {
        integrations: {
          'Segment.io': {
            deliveryStrategy: {
              config: {
                keepalive: true,
              },
            },
          },
        },
      }
    )

@arm1n
Copy link
Author

arm1n commented Feb 14, 2023

Awesome, thanks for the update and implementation!

@arm1n arm1n closed this as completed Feb 14, 2023
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

No branches or pull requests

3 participants