Skip to content

Main convert - #372

Merged
JosephSamirL merged 11 commits into
mainfrom
main-convert
Apr 6, 2026
Merged

Main convert#372
JosephSamirL merged 11 commits into
mainfrom
main-convert

Conversation

@abbaseya

@abbaseya abbaseya commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

JosephSamirL and others added 11 commits November 26, 2025 22:51
Add @convertcom/js-sdk-cloudflare with edge-specific helpers for running
Convert experiments inside Cloudflare Workers: KV-backed DataStore adapter,
edge config cache, cookie helpers, and variation-aware cache utilities.

Includes a demo Worker (demo/cloudflare-workers/) demonstrating page-level
A/B testing with HTMLRewriter, asset swaps, split URL redirects, and SPA
injection patterns.

Updates release-please config, publish workflows, and root build scripts
to support the new package.
Fix SDK singleton race condition by caching the initialization promise
so concurrent cold-start requests share one init. Guard JSON.parse calls
in KVDataStore and EdgeConfigCache against corrupted KV data. Type the
applyVariation parameter as BucketedVariation instead of any.
…tional persistence

Address code review on Cloudflare Workers integration:

- Replace KV-based EdgeConfigCache with Cloudflare built-in fetch cache
  (cf: { cacheTtl, cacheEverything }) — simpler, free on all plans, no KV
  dependency needed for basic setup
- Mark KVDataStore as optional — deterministic MurmurHash bucketing means
  the same visitor ID always gets the same variation without persistence
- Document that releaseQueues() must be called in waitUntil() before the
  Worker finishes, since the SDK setTimeout-based event timer will not fire
  in stateless Workers
- Update demo, README, and wrangler.toml to reflect KV-free default setup
- Replace Karma + BrowserStack browser tests with Playwright
- Port all UMD bundle browser tests (19 tests)
- Add full-chain integration tests matching PHP SDK pattern (17 tests per mode)
- Support 3 auth modes: static, live (public key), live-secret (key+secret)
- Upgrade CI to Node 22, corepack, actions v4
- Remove Karma, BrowserStack, and Puppeteer dependencies
- Add TESTING.md documentation
Regenerate yarn.lock after merging latest main-convert changes.
Remove KV namespace as a required setup step since the implementation
now uses Cloudflare's native cf.cacheTtl for config caching and
deterministic MurmurHash bucketing for visitor assignment.
- Add built-in origin server (origin/) with HTML pages for all routes
- Map URL paths to location properties matching the staging project
  (/events → "events", /statistics → "statistics", /pricing → "pricing")
- Pass visitor properties for audience matching ({mobile: true})
- Use fetchOrigin() helper to avoid infinite loop on fetch(request)
- Accept */* in addition to text/html for curl compatibility
- Add ORIGIN_URL env var to wrangler.toml for configurable origin
- Pre-configure staging SDK key (10035569/10034190)
- Merge verification steps and troubleshooting into README
- Replace 4 static HTML files with a shared template in server.js
- Merge ROUTE_LOCATION_MAP and feature key constants into a single
  ROUTES config object
- Deduplicate statistics/pricing experiment logic in decideForRoute()
  by branching on experienceKey vs runExperiences

Addresses SonarCloud duplicated lines threshold (target ≤ 3%).
@abbaseya
abbaseya requested review from a team and JosephSamirL April 6, 2026 18:51
@abbaseya abbaseya self-assigned this Apr 6, 2026
@abbaseya
abbaseya removed the request for review from JosephSamirL April 6, 2026 18:51
@sonarqubecloud

sonarqubecloud Bot commented Apr 6, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@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 the @convertcom/js-sdk-cloudflare package and a Cloudflare Workers demo for edge experimentation. It also migrates the js-sdk testing framework from Karma to Playwright, adding comprehensive integration tests. Feedback identifies a TypeScript destructuring error in the demo worker, recommends restoring the build step in the browser test script to ensure accuracy, and suggests replacing any types with specific SDK types for better type safety.

Comment thread demo/cloudflare-workers/src/index.ts
Comment thread packages/js-sdk/package.json
Comment thread demo/cloudflare-workers/src/index.ts
@JosephSamirL
JosephSamirL merged commit 8baef32 into main Apr 6, 2026
8 checks passed
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