amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
133 stars 38 forks source link

Question: `serverUrl` behaviour #105

Open gesposito opened 2 years ago

gesposito commented 2 years ago

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?

kevinpagtakhan commented 2 years ago

@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.

gesposito commented 2 years ago

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

kevinpagtakhan commented 2 years ago

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

gesposito commented 2 years ago

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!

acro5piano commented 1 year ago

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.