PostHog / posthog

🦔 PostHog provides open-source web & product analytics, session recording, feature flagging and A/B testing that you can self-host. Get started - free.
https://posthog.com
Other
22.05k stars 1.33k forks source link

feat: RemoteConfig logic (decide replacement) #26348

Open benjackwhite opened 16 hours ago

benjackwhite commented 16 hours ago

Problem

WIP - Playing with the idea to see how it works and feels.

See https://github.com/PostHog/product-internal/pull/680 for more info.

Generally the idea is that the new flags service will replace the "decide" django endpoint with a much more scalable solution. The thing it won't do necessarily is handle the "remote config" side of things which is currently the other main use for decide.

My idea is to generate the "config" parts into a dedicated helper model which takes care of creating this config derived from the various settings allowing us to do a few cool things:

  1. Serve the config as a static file via a CDN - no hot servers needed
  2. Back support /decide filling in from the same highly cached concept
  3. Build an additional file which is a token-scoped file containing all of the config and all of the posthog-js (one load to rule them all)
  4. Allow us to GTM style things for the destinations to inject extra JS loading in a hyper optimal way

Changes

This PR is just part 1 - generate the RemoteConfigs as and when they should be, with new endpoints to serve them (endpoints that will eventually be served by the CDN instead).

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?