Skip to content

Commit

Permalink
pricing A/B test worker
Browse files Browse the repository at this point in the history
  • Loading branch information
aorcsik committed Jun 27, 2024
1 parent 09b9b94 commit 55006e4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ dist/*.js
changelog.json
changelog_latest.json
.DS_Store
wrangler.toml
.env
/wrangler.toml
22 changes: 22 additions & 0 deletions src/js/pricing/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
async fetch(request) {
const urlObject = new URL(request.url);

urlObject.hostname = 'webflow.bitrise.io';

if (urlObject.search.match(/us=1/) || request.headers.get('cf-ipcountry') === 'US') {
urlObject.pathname = '/plans-pricing-us';
const response = await fetch(urlObject);
const data = (await response.text()).replace('plans-pricing-us', 'plans-pricing');
return new Response(data, {
status: response.status,
statusText: response.statusText,
headers: Object.fromEntries(response.headers.entries()),
});
}

urlObject.pathname = urlObject.pathname.replace('plans-pricing-test', 'plans-pricing');

return fetch(urlObject);
},
};
5 changes: 5 additions & 0 deletions src/js/pricing/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = "pricing-proxy"
main = "./src/js/pricing/worker.js"
compatibility_date = "2023-08-23"
route = "bitrise.io/plans-pricing-test*"
no_bundle = true

0 comments on commit 55006e4

Please sign in to comment.