-
Notifications
You must be signed in to change notification settings - Fork 96
Setting the apiHost in the configuration has no effect #156
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
Comments
This currently works as intended. The idea was before you've received results from Segment's /settings endpoint, you may have a preference for EU vs US endpoints. Segment settings has the final say, but we acknowledge this is problematic when intending to use a proxy (which I assume you're wanting to do). We'll look at this soon and try and figure out a good path forward. In the meantime feel free to fork and comment out the following line in SegmentDestination.swift
That'll make it such that whatever you supply will be used at all times. |
If this is "working as intended", can you please documented it clearly in the Analytics Swift documentation - https://segment.com/docs/connections/sources/catalog/libraries/mobile/swift-ios/ I just spent several hours last night trying to understand why our events aren't going through our proxy with the apiHost configuration set. In fact, from my troubleshooting, it is unclear to me if what you are saying is accurate (that Anyway, I've opened this ticket https://segment.zendesk.com/hc/requests/488619 |
Just to confirm, this is the workaround you are proposing, correct? If so, it is not working for me. As I pointed out in my last comment, Thank you. |
Appreciate your assurance, but the Swift debugger disagrees with you.
But if you can point me to the actual line of code where the apiHost from the configuration object is being passed to HttpClient, that will facilitate our troubleshooting.
Alternatively, please give us a timeline on when your proposed fix will be merged.
I want to mention that as a paying customer, we do not appreciate your arrogant tone.
Thank you.
Regards,
Jack
… On Oct 28, 2022, at 10:34 AM, Brandon Sneed ***@***.***> wrote:
@jackgene It is being read, I assure you. See HTTPClient.swift. That workaround is no longer necessary once this PR is merged: #165. Documentation will be updated before a point release is made.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
@jackgene There was no "tone". I'm just sharing facts. As an employee here trying to help you, I don't appreciate yours so lets take it down a notch. See the line below as to where it's being read. analytics-swift/Sources/Segment/Utilities/HTTPClient.swift Lines 30 to 52 in 93314b0
The fix has already been merged since we first spoke. A point release has yet to happen, pending documentation. |
The lines you highlighted is the initializer for HTTPClient (called "constructor" in other languages). It shows that the initializer accepts an (Note that in Swift (and in most programming languages really), the fact that there's a constructor parameter named For let configuration = Configuration("some write key").apiHost("myhost.com/v1")
let analytics = Analytics(configuration: configuration)
HTTPClient(
analytics: analytics,
apiHost: configuration.values.apiHost // THIS LINE
) If you look through the analytics-swift source, you'll find that the
You'll note that in none of these locations is Another point worth noting, you "assured me" that
You'll quickly see it's not referenced anywhere. Try the same thing with say |
Thanks for all those super useful links. Here, I'll paste the code for you since it seems difficult for you to see it on GitHub.
Low and behold, apiKey gets set from the configuration value that was specified if null was passed into the constructor. HTTPClient is a somewhat generic class that lost its way a little over time. But wait, there's more! Just a few lines down ....
Enjoy. |
You may want to re-read this issue. It is about |
Ya got me. My apologies, apiKey has been front and center for me all week. I'll make a PR for the default setting of apiHost in the coming days, however that doesn't seem like what you needed in the first place. The linked PR has more along the lines of what you and the original poster of this bug were looking for. See Configuration.requestFactory which gives you full control over all the details of a given request (headers/url/path/etc). |
Actually, I'll reopen this as another issue that omits the confusion. |
I think you are right, that the And apologies if my frustration was coming through, but my point was that I knew I was writing the Going through the code manually, and having Xcode try and find all references to Thanks for opening the new issue, and have a nice weekend! |
No worries at all! Glad requestFactory does the trick for you and you're back in business. Hope you have a good weekend as well. Ttys! |
Describe the bug
Setting the apiHost in the configuration has no effect, events are still sent to api.segment.io/v1 regardless of the configuration values for apiHost.
Steps for repro:
I have created an example app with repro in a fork: https://github.com/kraftful/analytics-swift/tree/jgable/api-host-repro (specific commit is ce5331d)
Examples/APIHostConfigurationRepro
folder)Expected:
Actual:
Expected behavior
Event batches should be sent to the configured apiHost.
Screenshots
Platform (please complete the following information):
The text was updated successfully, but these errors were encountered: