Skip to content

Setting a custom api host defaults in api.segment.io/v1 url #821

@talhapeloton

Description

@talhapeloton

Looking to set a custom url as a default host for analytics, in the source there appears to be two ways to do this: by overriding the connection factory or by setting a defaultApiHost in the builder.

While setting the defaultApiHost will correctly update to the custom url, this code found in the analytics constructor that sets the apiHostSet will always yield true. It appears that the value for projectSettings/integrations/Segment.io returns api.segment.io/v1 despite the defaultApiHost override.

Below is a sample of the analytics constructor in the project written in Kotlin.

// uses defaultApiHost
Analytics.Builder(application, WRITE_KEY)
.use(AmplitudeIntegration.FACTORY)
.trackApplicationLifecycleEvents()
.defaultApiHost(HOST_URL)
.build()

// override connection factory
Analytics.Builder(application, WRITE_KEY)
.use(AmplitudeIntegration.FACTORY)
.trackApplicationLifecycleEvents()
.connectionFactory(object : ConnectionFactory() {
@throws(IOException::class)
override fun openConnection(url: String): HttpURLConnection {
return super.openConnection(HOST_URL)
}
})
.build()

The Android Studio debugger for projectSettings:
Screen Shot 2023-01-06 at 12 28 22 PM

Are there any additional requirements needed to properly set the correct apiHost ? Looking for more context based on the source code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions