Loading workspace insights... Statistics interval
7 days30 daysLatest CI Pipeline Executions
270f73a7 feat: ENG-12261 add OAuth 2.0 support and settings UI for Phrase integration (#4699)
## Description
Adds OAuth 2.0 support and settings UI for Phrase integration
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes authentication and how Phrase API calls are authorized (OAuth
popup, session state, 401 refresh), which can break translation
workflows if server OAuth endpoints or token refresh behave differently
than password auth.
>
> **Overview**
> Adds **SSO / OAuth 2.0** as an alternative to username/password for
the Phrase connector, aimed at orgs that block password login. Settings
gain an **Authentication** dropdown, per-org **OAuth Client ID**, US
data-center flag, and a custom **Connect / Disconnect** panel that runs
the Builder API OAuth popup flow (`prepare` → `start` → `postMessage`);
tokens stay server-side and the browser only sees connection metadata.
>
> Translation actions now go through a new **`PhraseApi`** wrapper that
checks credentials (`ensureAuthenticated`), retries on **401** via
**`oauth/refresh`** in OAuth mode, and handles org switches and stale
in-memory OAuth state with **apiKey-scoped session markers**.
Username/password fields are shown only when not in OAuth mode; both
credential types can coexist when switching modes.
>
> The README documents OAuth setup (Phrase registered app, redirect URI,
admin connect steps) and a sequence diagram. Plugin version bumps to
**0.0.17**. The stub **Request an updated translation** content action
is removed; pending-job **outdated source** warnings are refactored into
`checkTranslationFreshness`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5e0c959ba6cf03cb165653deb827b7723332a959. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY --> 0295633d fix[gen2][abTests]: ENG-12786 stop injecting duplicate A/B test init scripts on pages with multiple Content components (#4694)
## Description
The Gen 2 React SDK injects the full `window.builderIoAbTest /
window.builderIoRenderContent` definition as an inline <script> once per
<Content> component, even on pages that have no A/B tests. On pages with
several Content regions (header, body, footer…) this ships multiple
identical ~4KB scripts.
JTI saw 11 copies per page.
**Fix:**
- Only emit the init script when a Content actually renders A/B variants
(gate it behind shouldRenderVariants). Pages with no A/B tests now emit
it zero times.
- Make the script idempotent `(if (!window.builderIoAbTest) { … })` so
repeated definitions never re-run and self-removing on hydration
targets, matching how the SDK's existing A/B scripts already behave.
Re-added the e2e assertion that the revert removed, counting init
scripts in the SSR response (the script self-removes from the live DOM,
so we check the response body). Asserts the realistic post-fix counts.
**Note:**
This eliminates the duplication for the reported case and reduces A/B
pages to one init per A/B-tested Content (defined once at runtime).
Collapsing to a single tag per page regardless of A/B count requires
cross-component coordination and is being tracked as a separate PR,
since that touches the same hydration-sensitive path that caused the
prior revert.
**JIRA Ticket:**
https://builder-io.atlassian.net/browse/ENG-12786
_Screenshot_
Clip of the issue:
https://clips.agent-native.com/r/9yBuG521T6eu
Clip of the fix:
https://clips.agent-native.com/r/JtAevmePWpKT
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes inline script placement and hydration-target self-removal on
the A/B SSR path, which is historically sensitive, though the fix
deliberately avoids reintroducing the prior DOM-mutation regression.
>
> **Overview**
> **Stops shipping duplicate `builderio-init-variants-fns` inline
scripts** when a page has multiple `<Content>` regions. The
`window.builderIoAbTest` / `window.builderIoRenderContent` init block is
**moved out of the always-on path** and **only rendered when
`shouldRenderVariants` is true**, so non–A/B content no longer injects
it.
>
> The init script string is now wrapped in an **idempotent IIFE**
(assign globals only if missing) and on React/React Native hydration
targets **removes itself via `document.currentScript`** after running,
avoiding repeat definitions and the client-side DOM tweaks that
previously caused hydration issues.
>
> **E2E:** SSR A/B tests count `builderio-init-variants-fns` in the
**raw navigation response** (not the live DOM) and expect **one** script
for pages with a single A/B-tested content; Gen1 React and non-SSR
frameworks skip the assertion.
>
> Patch changeset across Gen2 SDK packages documents the behavior
change.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
03df10b9db3f6a46ee812e33bd9dfa25b3769025. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->