sweepai-dev / growthbook-3

Open Source Feature Flagging and A/B Testing Platform
https://www.growthbook.io
Other
0 stars 0 forks source link

Sweep: [Feature] Support purges for other popular CDNs besides Fastly #1

Open wwzeng1 opened 1 year ago

wwzeng1 commented 1 year ago

We use Fastly in GrowthBook Cloud to power our CDN. There is Fastly-specific code to purge the CDN when features change. If a self-hosted GrowthBook deployment also uses Fastly, they can benefit from this code, but not if they use another provider like CloudFlare. Most CDNs provide a way to purge URLs or groups of URLs.

We should add environment variables and code to support more CDNs, specifically:

We should also add some docs and tutorials for setting up various CDNs for self-hosted GrowthBook.

sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/sweepai-dev/growthbook-3/pull/3.

💎 Sweep Pro: I used GPT-4 to create this ticket. You have 11 GPT-4 tickets left.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/sweepai-dev/growthbook-3/blob/33cc2900ba93965df7ec48b803171d70ca5d14fa/docs/docs/features.mdx#L182-L229 https://github.com/sweepai-dev/growthbook-3/blob/33cc2900ba93965df7ec48b803171d70ca5d14fa/docs/docs/lib/php.mdx#L58-L154 https://github.com/sweepai-dev/growthbook-3/blob/33cc2900ba93965df7ec48b803171d70ca5d14fa/packages/back-end/src/init/config.ts#L94-L211 https://github.com/sweepai-dev/growthbook-3/blob/33cc2900ba93965df7ec48b803171d70ca5d14fa/packages/back-end/src/services/features.ts#L1-L105 https://github.com/sweepai-dev/growthbook-3/blob/33cc2900ba93965df7ec48b803171d70ca5d14fa/packages/sdk-js/README.md#L137-L236

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
packages/back-end/src/services/features.ts Add the purge logic for CloudFlare, CloudFront, and Google Cloud CDN in the queueProxyUpdate function. This function currently handles the purge for Fastly, so we need to extend it to handle the other CDN providers as well.
packages/back-end/src/init/config.ts Add new environment variables for each CDN provider's specific settings in the ConfigFile interface and in the loadConfig function. These variables will be used in the queueProxyUpdate function to handle the CDN purge.
docs/docs/features.mdx Update the documentation to include instructions on how to set up CloudFlare, CloudFront, and Google Cloud CDN for self-hosted GrowthBook. Add a new section for each CDN provider with the necessary setup steps.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

[Feature] Support purges for other popular CDNs besides Fastly sweep/feature/support-other-cdns

Description

This PR adds support for purging content from other popular CDNs besides Fastly in GrowthBook. Currently, the CDN purge functionality only supports Fastly, which limits the flexibility for users who use other CDN providers like CloudFlare, CloudFront, and Google Cloud CDN. This PR extends the purge logic to include these additional providers and adds new environment variables for each CDN provider's specific settings. Additionally, the documentation has been updated to include instructions on how to set up these CDNs for self-hosted GrowthBook.

Changes Made

  • Modified packages/back-end/src/services/features.ts to add the purge logic for CloudFlare, CloudFront, and Google Cloud CDN in the queueProxyUpdate function.
  • Modified packages/back-end/src/init/config.ts to add new environment variables for each CDN provider's specific settings in the ConfigFile interface and in the loadConfig function.
  • Updated docs/docs/features.mdx to include instructions on how to set up CloudFlare, CloudFront, and Google Cloud CDN for self-hosted GrowthBook.

Checklist

  • [x] Updated the code to support purges for CloudFlare, CloudFront, and Google Cloud CDN
  • [x] Added new environment variables for each CDN provider's specific settings
  • [x] Updated the documentation to include instructions on how to set up these CDNs for self-hosted GrowthBook

Related Issue

Link to Issue

Screenshots (if applicable)

N/A


Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord