Skip to content

[codex] add setApiUrl builder support#5

Merged
megastep merged 4 commits into
developfrom
codex/add-set-api-url
Mar 20, 2026
Merged

[codex] add setApiUrl builder support#5
megastep merged 4 commits into
developfrom
codex/add-set-api-url

Conversation

@megastep

Copy link
Copy Markdown
Member

Summary

This change adds setApiUrl() to QonversionConfigBuilder so integrators can override the default https://api.qonversion.io base URL with a custom HTTPS endpoint.

The immediate use case is routing SDK traffic through a trusted proxy hostname when qonversion.io is blocked by restrictive firewall or network policy rules. Before this change, the SDK hard-coded the API base URL during configuration build, so consumers had no supported way to point requests at an alternate hostname without patching the package or mutating internal config state.

Root Cause

The lower networking layers were already designed to consume networkConfig.apiUrl, but the public builder API always populated that field from the API_URL constant. In practice, the SDK had an internal injection point but no public configuration surface.

That meant consumers could not safely use a reverse proxy, Cloudflare Worker hostname, or any other compliant HTTPS relay endpoint, even though the request configurator and dependency assembly already supported an injected base URL.

Fix

The builder now exposes setApiUrl(apiUrl: string): QonversionConfigBuilder.

The method validates and normalizes the provided URL before storing it in the config that is passed through the existing network stack:

  • rejects blank values
  • rejects invalid URLs
  • rejects non-HTTPS URLs
  • strips a trailing slash so request path construction remains stable

No lower-level networking behavior changed. The request configurator and assemblies continue to read networkConfig.apiUrl; this change only makes that value publicly configurable in a supported way.

User Impact

Consumers can now initialize the SDK like this:

const config = new QonversionConfigBuilder(projectKey)
  .setApiUrl('https://proxy.example.com')
  .build();

This enables the SDK to operate behind an alternate hostname, such as an HTTPS proxy or edge relay, without forking the package or relying on internal implementation details.

Validation

I verified the change with:

  • pnpm exec jest sdk/src/__tests__/QonversionConfigBuilder.test.ts --runInBand --watchman=false
  • pnpm build
  • pnpm test -- --runInBand

The builder tests now cover:

  • default API URL behavior
  • custom API URL override
  • trailing slash normalization
  • blank URL rejection
  • invalid URL rejection
  • non-HTTPS URL rejection

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the SDK's network configuration flexibility by introducing a public method to customize the API base URL. This change allows users to direct SDK traffic through alternative HTTPS endpoints, such as proxies or edge relays, which is crucial for environments with restrictive network policies. The new functionality includes robust validation to ensure URL integrity and security.

Highlights

  • API URL Customization: Introduced setApiUrl() to QonversionConfigBuilder, allowing integrators to override the default API base URL with a custom HTTPS endpoint.
  • Enhanced Network Flexibility: Enables routing SDK traffic through trusted proxy hostnames, addressing scenarios where qonversion.io might be blocked by firewalls or network policies.
  • Robust URL Validation: Implemented validation within setApiUrl() to reject blank, invalid, or non-HTTPS URLs, and to normalize by stripping trailing slashes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature allowing users to specify a custom API URL, which is particularly useful for environments with network restrictions. The implementation is clean, and the accompanying tests cover the primary validation scenarios. I have one suggestion to improve the robustness of the URL handling to prevent potential issues with malformed URLs when query parameters or fragments are present in the user-provided URL.

Comment thread sdk/src/QonversionConfigBuilder.ts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@megastep megastep marked this pull request as ready for review March 20, 2026 02:13
Copilot AI review requested due to automatic review settings March 20, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds public builder support for overriding the SDK’s base API URL, enabling integrators to route traffic through a custom HTTPS proxy endpoint while keeping the existing network stack behavior.

Changes:

  • Introduced setApiUrl(apiUrl: string) on QonversionConfigBuilder with URL validation/normalization.
  • Updated config build to use the builder-provided apiUrl instead of the API_URL constant.
  • Added unit tests covering default/custom API URL behavior and validation cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
sdk/src/QonversionConfigBuilder.ts Adds apiUrl state + setApiUrl() validation/normalization and wires it into build() network config.
sdk/src/tests/QonversionConfigBuilder.test.ts Adds tests for custom API URL override, normalization, and invalid input handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/src/QonversionConfigBuilder.ts Outdated
Comment thread sdk/src/QonversionConfigBuilder.ts Outdated
Comment thread sdk/src/__tests__/QonversionConfigBuilder.test.ts Outdated
Comment thread sdk/src/__tests__/QonversionConfigBuilder.test.ts Outdated
Comment thread sdk/src/__tests__/QonversionConfigBuilder.test.ts Outdated
Comment thread sdk/src/QonversionConfigBuilder.ts Outdated
Comment thread sdk/src/QonversionConfigBuilder.ts Outdated
@megastep

Copy link
Copy Markdown
Member Author

Addressed the latest review comments in 3018016.

Changes made:

  • preserved the original URL parse error as the QonversionError cause
  • reject API URLs that include credentials
  • documented and tested the query/hash stripping behavior for base URLs
  • renamed the setter tests to match the actual call site

Verification passed:

  • pnpm exec jest sdk/src/__tests__/QonversionConfigBuilder.test.ts --runInBand --watchman=false
  • pnpm build
  • pnpm test -- --runInBand

@megastep megastep self-assigned this Mar 20, 2026
@megastep megastep added the enhancement New feature or request label Mar 20, 2026
@megastep megastep merged commit 91edf5b into develop Mar 20, 2026
4 checks passed
@megastep megastep deleted the codex/add-set-api-url branch March 20, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants