Amplitude-TypeScript icon indicating copy to clipboard operation
Amplitude-TypeScript copied to clipboard

Question: `serverUrl` behaviour

Open gesposito opened this issue 3 years ago • 5 comments

Summary

For proxied requests I was previously using this setup

apiEndpoint: "www.custom.url"

while now it looks like I need to do something like this

serverUrl: "https://www.custom.url/2/httpapi"

is this the new intended behaviour? Is this going to change in the future?

gesposito avatar May 18 '22 11:05 gesposito

@gesposito are you referring to adding the protocol at the start? I believe we do not enforce having a path value of 2/httpapi for the url.

kevinpagtakhan avatar May 19 '22 18:05 kevinpagtakhan

I'm more concerned about the path part, and if it is ever going to change, I wasn't able to complete requests without adding it

gesposito avatar May 20 '22 07:05 gesposito

Oh i see what you mean here. So you are proxying the requests through www.custom.url, right? So for the old (amplitude-js) where apiEndpoint is used, the endpoint has a path of / hence configuring the sdk does only requires the domain. While this new SDK, consumes an entirely new endpoint that has a path of /2/httpapi, which proxied request should have too. I wouldn't be concerned about this path getting deprecated, since we still have two other (older) ingestion endpoints that we support today.

However, i believe there are areas to improve here on the developer experience side. I'll take this feedback to the team and see how we can make managing the path more seamless.

cc @qingzhuozhen

kevinpagtakhan avatar May 20 '22 15:05 kevinpagtakhan

Oh i see what you mean here. So you are proxying the requests through www.custom.url, right? So for the old (amplitude-js) where apiEndpoint is used, the endpoint has a path of / hence configuring the sdk does only requires the domain. While this new SDK, consumes an entirely new endpoint that has a path of /2/httpapi, which proxied request should have too. I wouldn't be concerned about this path getting deprecated, since we still have two other (older) ingestion endpoints that we support today.

Correct

However, i believe there are areas to improve here on the developer experience side. I'll take this feedback to the team and see how we can make managing the path more seamless.

cc @qingzhuozhen

Thanks!

gesposito avatar May 20 '22 15:05 gesposito

I'm using Cloudfront to proxy to amplitude server. It works after I added endpoint path like this:

  amplitude.init('<token>', {
    serverUrl: 'https://xxxxxxxxxxxxxxxxxxxxxxx.cloudfront.net/2/httpapi',
  })

I was doing something like:

  // This not work!
  amplitude.init('<token>', {
    serverUrl: 'https://xxxxxxxxxxxxxxxxxxxxxxx.cloudfront.net',
  })

serverUrl isn't documented, or hard to find docs for http2 api via Proxy. Hope this helps someone.

acro5piano avatar Aug 11 '23 17:08 acro5piano