Skip to content

feat: hackathon client configurator - #1930

Merged
daniel-graham-amplitude merged 2 commits into
mainfrom
hackathon-client-configurator
Sep 22, 2026
Merged

daniel-graham-amplitude merged 2 commits into
mainfrom
hackathon-client-configurator

Conversation

@daniel-graham-amplitude

@daniel-graham-amplitude daniel-graham-amplitude commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Note

Low Risk
Changes are limited to local test-server tooling and a dev dependency; production SDK packages and runtime behavior are unaffected.

Overview
Adds a hackathon-style Browser Client Configurator under test-server/ for building and trying amplitude.init() setups without hand-editing code.

The main page is a React form mapped to analytics, autocapture (including network capture rules), Session Replay, and Guides & Surveys options, with tooltips aligned to SDK JSDoc. It emits ESM, browser snippet, or Unified initAll code (only non-default fields), highlights output via Prism (prismjs devDependency), and supports Copy Link / Run using a compressed ?config= query param. The run page loads workspace SDK packages through Vite aliases, initializes plugins in doc order, and logs events from a small sandbox.

Vite is updated to register the new HTML entries and scope @vitejs/plugin-react to configurator/ so other test pages stay unchanged. The iframe sandbox Playwright spec only has formatting tweaks.

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

@daniel-graham-amplitude
daniel-graham-amplitude requested a review from a team as a code owner August 12, 2026 02:06
@daniel-graham-amplitude
daniel-graham-amplitude marked this pull request as draft August 12, 2026 02:06

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Panels collapse on every re-render
    • Panel now omits the open prop unless defaultOpen is true, so details stays uncontrolled across form re-renders.
  • ✅ Fixed: Capture rule IDs collide after restore
    • decodeStateFromUrl now advances the rule id counter past restored ids via rememberCaptureRuleIds before new rules are created.

Create PR

Or push these changes by commenting:

@cursor push 8d2d26826e
Preview (8d2d26826e)
diff --git a/test-server/configurator/autocapture-options.js b/test-server/configurator/autocapture-options.js
--- a/test-server/configurator/autocapture-options.js
+++ b/test-server/configurator/autocapture-options.js
@@ -104,6 +104,17 @@
   };
 }
 
+// Shared links restore rules with their original ids, so bump the counter past anything already in
+// use before the next createCaptureRule() call.
+export function rememberCaptureRuleIds(rules = []) {
+  for (const rule of rules) {
+    const match = /^rule-(\d+)$/.exec(rule?.id);
+    if (match) {
+      nextRuleId = Math.max(nextRuleId, Number(match[1]));
+    }
+  }
+}
+
 const pageUrlAllowlist = {
   key: 'pageUrlAllowlist',
   label: 'Page URL allowlist',

diff --git a/test-server/configurator/components.jsx b/test-server/configurator/components.jsx
--- a/test-server/configurator/components.jsx
+++ b/test-server/configurator/components.jsx
@@ -193,10 +193,11 @@
 }
 
 // Left uncontrolled so the browser owns the open/closed state; the panel re-renders on every
-// keystroke elsewhere on the page and a controlled `open` would fight that.
+// keystroke elsewhere on the page and a controlled `open` would fight that. Only pass `open` when
+// the panel should start open — `open={false}` is still controlled and would slam shut on re-render.
 export function Panel({ title, description, badge, defaultOpen = false, children }) {
   return (
-    <details style={styles.panel} open={defaultOpen}>
+    <details style={styles.panel} {...(defaultOpen ? { open: true } : {})}>
       <summary style={styles.panelSummary}>
         {title}
         {badge ? <span style={styles.panelBadge}>{badge}</span> : null}

diff --git a/test-server/configurator/share-link.js b/test-server/configurator/share-link.js
--- a/test-server/configurator/share-link.js
+++ b/test-server/configurator/share-link.js
@@ -1,3 +1,5 @@
+import { rememberCaptureRuleIds } from './autocapture-options.js';
+
 // The form state round-trips through a single query parameter, so a bookmarked URL reopens the same
 // configuration.
 //
@@ -90,7 +92,9 @@
     return defaults;
   }
   try {
-    return mergeOverDefaults(defaults, JSON.parse(await inflate(fromBase64Url(saved))));
+    const state = mergeOverDefaults(defaults, JSON.parse(await inflate(fromBase64Url(saved))));
+    rememberCaptureRuleIds(state.autocaptureSubOptions?.networkTracking?.captureRules);
+    return state;
   } catch (error) {
     // A truncated or hand-edited link shouldn't leave the page blank.
     console.warn(`Ignoring unreadable ?${STATE_PARAM} parameter`, error);

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 98106e9. Configure here.

Comment thread test-server/configurator/components.jsx
Comment thread test-server/configurator/autocapture-options.js
@github-actions

github-actions Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 64.81 KB (0%)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 135.72 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 219.27 KB (0%)
@amplitude/element-selector (gzipped esm) 3.4 KB (0%)

@daniel-graham-amplitude
daniel-graham-amplitude marked this pull request as ready for review September 22, 2026 16:58
@daniel-graham-amplitude
daniel-graham-amplitude merged commit d9de021 into main Sep 22, 2026
18 checks passed
@daniel-graham-amplitude
daniel-graham-amplitude deleted the hackathon-client-configurator branch September 22, 2026 17:17
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.

2 participants