Skip to content

Append a referrer param to the "Built with Reflex" badge link - #6951

Open
FarhanAliRaza wants to merge 1 commit into
reflex-dev:mainfrom
FarhanAliRaza:farhan/eng-11714-badge-referrer-param
Open

Append a referrer param to the "Built with Reflex" badge link#6951
FarhanAliRaza wants to merge 1 commit into
reflex-dev:mainfrom
FarhanAliRaza:farhan/eng-11714-badge-referrer-param

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Closes ENG-11714. Unblocks ENG-11623 (referral bonus).

What

The badge always links to reflex.dev β€” the destination is not freely settable. When the REFLEX_REFERRER_PARAM environment variable is set at compile time, its value is appended urlencoded:

https://reflex.dev/?ref=<urlencoded value>

Without the env var the badge link is unchanged (https://reflex.dev), so existing apps are unaffected.

Why this shape

Per discussion with @masenf: land it in the framework where the sticky badge is defined, keep the link pinned to reflex.dev, append only the param (if present), and urlencode it so special characters are not misinterpreted. The hosting service injects the per-owner referral identifier at build time via the env var β€” no user code changes.

Testing

Unit tests cover the default link, the appended param, urlencoding of special characters, and the empty-value fallback.

Review in cubic

…dge link

The badge always links to reflex.dev; when the REFLEX_REFERRER_PARAM env
var is set at compile time, its value is appended urlencoded as
https://reflex.dev/?ref=<value>. This is the mechanism the referral bonus
(ENG-11623) rides on: the hosting service injects the per-owner identifier
at build time, and the destination itself stays fixed.
@FarhanAliRaza
FarhanAliRaza requested a review from a team as a code owner August 26, 2026 19:11
@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a compile-time REFLEX_REFERRER_PARAM environment variable and appends its percent-encoded value to the Built with Reflex badge URL.

  • Adds the typed environment variable in reflex-base.
  • Computes the badge destination when StickyBadge is created.
  • Adds tests for default, populated, encoded, and empty values.
  • Leaves components-core's minimum reflex-base version unchanged despite consuming the newly introduced API.

Confidence Score: 4/5

The dependency floor must be updated before merging because supported minimum-version installations can fail during production compilation.

The URL construction itself preserves the intended referral value, but the components package unconditionally accesses an environment attribute introduced after its declared minimum reflex-base release.

Files Needing Attention: packages/reflex-components-core/src/reflex_components_core/core/sticky.py and packages/reflex-components-core/pyproject.toml

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/environment.py Adds an optional string environment variable whose existing EnvVar behavior correctly handles unset and empty values.
packages/reflex-components-core/src/reflex_components_core/core/sticky.py Correctly encodes the referral value, but consumes a reflex-base API unavailable at the package's declared minimum dependency version.
tests/units/components/core/test_sticky.py Covers URL behavior in the monorepo environment but does not exercise the supported minimum reflex-base dependency set.

Reviews (1): Last reviewed commit: "ENG-11714 feat: append a referrer param ..." | Re-trigger Greptile

Returns:
The badge destination URL.
"""
referrer = environment.REFLEX_REFERRER_PARAM.get()

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.

P1 Dependency floor lacks attribute

When production compilation uses the supported minimum dependency set, reflex-base 0.9.7 lacks REFLEX_REFERRER_PARAM, so _badge_href() raises AttributeError while creating the sticky badge and aborts compilation. Please raise the reflex-base minimum to a release containing this new attribute.

Knowledge Base Used: Component package ecosystem

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 5 files

Re-trigger cubic

@codspeed-hq

codspeed-hq Bot commented Aug 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

βœ… 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing FarhanAliRaza:farhan/eng-11714-badge-referrer-param (56e8530) with main (dfb4ef0)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@chatgpt-codex-connector chatgpt-codex-connector 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.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56e8530465

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Returns:
The badge destination URL.
"""
referrer = environment.REFLEX_REFERRER_PARAM.get()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require the reflex-base version that defines this variable

When reflex-components-core is installed with its declared minimum reflex-base >= 0.9.7, that released base package does not define REFLEX_REFERRER_PARAM, so compiling a production app with the default sticky badge raises AttributeError here. Raise the dependency floor to the base release containing this field (using the repository's development-pin flow until that release is published) so independently installed core packages remain usable.

AGENTS.md reference: AGENTS.md:L22-L23

Useful? React with πŸ‘Β / πŸ‘Ž.

@@ -0,0 +1,39 @@
"""Tests for the "Built with Reflex" sticky badge."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the test into the subpackage source mirror

This test covers packages/reflex-components-core/src/reflex_components_core/core/sticky.py, but it was added under tests/units/components/core/; move it to tests/units/reflex_components_core/core/test_sticky.py so the test layout mirrors the subpackage path as required and future module-scoped test selection finds it in the expected location.

AGENTS.md reference: AGENTS.md:L55-L58

Useful? React with πŸ‘Β / πŸ‘Ž.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant