Skip to content

chore(runway): cherry-pick fix(analytics): normalise Segment proxy URL to fix invalid-URL error in 2.23.0 cp-7.78.0#30496

Merged
vpintorico merged 1 commit into
release/7.78.0from
runway-cherry-pick-7.78.0-1779352117
May 21, 2026
Merged

chore(runway): cherry-pick fix(analytics): normalise Segment proxy URL to fix invalid-URL error in 2.23.0 cp-7.78.0#30496
vpintorico merged 1 commit into
release/7.78.0from
runway-cherry-pick-7.78.0-1779352117

Conversation

@runway-github

@runway-github runway-github Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

@segment/analytics-react-native 2.23.0 introduced a strict
validateURL regex via PR
#1157

that only allows [a-zA-Z0-9_.-] in query-param values. The MetaMask
Segment proxy URL encodes the write key as standard base64 in a query
param (?b=<base64>==), and the trailing = padding characters are
rejected by this regex.

When the URL fails validation SegmentDestination.getEndpoint()
silently falls back to https://api.segment.io/v1/b. Events reach
Segment's default endpoint but the proxy write key is only valid through
fn.segmentapis.com, so they are rejected — causing no events to
appear in Mixpanel
.

Change

Added normalizeProxyUrl in platform-adapter.ts that strips trailing
= padding from query-param values before passing the URL to the
Segment client config.

  • Stripping base64 padding is safe: decoders infer it from data length
    and the proxy server accepts both forms.
  • The = key–value separator is preserved (the regex uses a lookahead
    (?=&|$) to match only padding at the end of a param value).
  • Contains a TODO to remove once upstream fixes the regex to accept
    all RFC 3986 query characters.

Test plan

  • Run the app in dev mode and verify analytics events appear in
    Mixpanel
  • Verify no "Invalid URL has been passed" errors in the console
  • Run unit tests: yarn jest platform-adapter

Made with Cursor


Note

Medium Risk
Moderate risk because it changes how the Segment client is configured
and could affect where analytics events are sent if the proxy URL is
altered incorrectly, though the change is narrowly scoped and covered by
unit tests.

Overview
Fixes Segment proxy URL validation failures by normalizing
SEGMENT_PROXY_URL before passing it to createClient, stripping
trailing base64 = padding from query-param values (while preserving
key/value separators).

Adds focused unit coverage for normalizeProxyUrl across common URL
shapes (single/double padding, multi-param URLs) and a wiring test to
ensure createPlatformAdapter passes the normalized proxy value into
Segment client configuration.

Reviewed by Cursor Bugbot for commit
ee00a41. Bugbot is set up for automated
code reviews on this repo. Configure
here.


Co-authored-by: João Santos joaosantos15@users.noreply.github.com 66f0cb2

…L to fix invalid-URL error in 2.23.0 cp-7.78.0 (#30463)

## Summary

`@segment/analytics-react-native` 2.23.0 introduced a strict
`validateURL` regex via [PR
#1157](segmentio/analytics-react-native#1157)
that only allows `[a-zA-Z0-9_.-]` in query-param values. The MetaMask
Segment proxy URL encodes the write key as standard base64 in a query
param (`?b=<base64>==`), and the trailing `=` padding characters are
rejected by this regex.

When the URL fails validation `SegmentDestination.getEndpoint()`
silently falls back to `https://api.segment.io/v1/b`. Events reach
Segment's default endpoint but the proxy write key is only valid through
`fn.segmentapis.com`, so they are rejected — causing **no events to
appear in Mixpanel**.

## Change

Added `normalizeProxyUrl` in `platform-adapter.ts` that strips trailing
`=` padding from query-param values before passing the URL to the
Segment client config.

- Stripping base64 padding is safe: decoders infer it from data length
and the proxy server accepts both forms.
- The `=` key–value separator is preserved (the regex uses a lookahead
`(?=&|$)` to match only padding at the end of a param value).
- Contains a `TODO` to remove once upstream fixes the regex to accept
all RFC 3986 query characters.

## Test plan

- [ ] Run the app in dev mode and verify analytics events appear in
Mixpanel
- [ ] Verify no "Invalid URL has been passed" errors in the console
- [ ] Run unit tests: `yarn jest platform-adapter`


Made with [Cursor](https://cursor.com)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Moderate risk because it changes how the Segment client is configured
and could affect where analytics events are sent if the proxy URL is
altered incorrectly, though the change is narrowly scoped and covered by
unit tests.
> 
> **Overview**
> Fixes Segment proxy URL validation failures by normalizing
`SEGMENT_PROXY_URL` before passing it to `createClient`, stripping
trailing base64 `=` padding from query-param values (while preserving
key/value separators).
> 
> Adds focused unit coverage for `normalizeProxyUrl` across common URL
shapes (single/double padding, multi-param URLs) and a wiring test to
ensure `createPlatformAdapter` passes the normalized `proxy` value into
Segment client configuration.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ee00a41. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: João Santos <joaosantos15@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - PR targets a release branch (release/*)

All E2E tests pre-selected.

View GitHub Actions results

@chloeYue chloeYue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

Copy link
Copy Markdown

@vpintorico vpintorico merged commit b349be4 into release/7.78.0 May 21, 2026
202 of 206 checks passed
@vpintorico vpintorico deleted the runway-cherry-pick-7.78.0-1779352117 branch May 21, 2026 12:51
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-M team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants