Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(django): allow elements chain as string for certain teams #18701

Merged
merged 13 commits into from
Nov 20, 2023

Conversation

davemurphysf
Copy link
Contributor

@davemurphysf davemurphysf commented Nov 17, 2023

Problem

As part of killing elements parsing in plugin-server (#18418), we need to send elements chain as a string from the client (PostHog/posthog-js#823).

Changes

This will add a flag (elementsChainAsString) in decide response to allow returning elements chain as a string rather than JSON object if ELEMENT_CHAIN_AS_STRING_TEAMS is set and includes the current team id

Related PR: https://github.com/PostHog/posthog-cloud-infra/pull/2314

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

How did you test this code?

Added a unit test for when ELEMENT_CHAIN_AS_STRING_TEAMS is set and not set

Copy link
Contributor

github-actions bot commented Nov 17, 2023

Size Change: 0 B

Total Size: 1.99 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.99 MB

compressed-size-action

@davemurphysf davemurphysf requested a review from a team November 20, 2023 03:39
@@ -37,3 +37,5 @@
NEW_ANALYTICS_CAPTURE_ENDPOINT = os.getenv("NEW_CAPTURE_ENDPOINT", "/i/v0/e/")
NEW_ANALYTICS_CAPTURE_TEAM_IDS = get_set(os.getenv("NEW_ANALYTICS_CAPTURE_TEAM_IDS", ""))
NEW_ANALYTICS_CAPTURE_SAMPLING_RATE = get_from_env("NEW_ANALYTICS_CAPTURE_SAMPLING_RATE", type_cast=float, default=1.0)

ELEMENT_CHAIN_AS_STRING_TEAMS = get_set(os.getenv("ELEMENT_CHAIN_AS_STRING_TEAMS", ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware we had a get_set, could have used that... Nice!

@@ -2991,6 +2991,20 @@ def test_decide_new_capture_activation(self, *args):
self.assertEqual(response.status_code, 200)
self.assertFalse("analytics" in response.json())

@patch("posthog.models.feature_flag.flag_analytics.CACHE_BUCKET_SIZE", 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think we need this mock for this test.

Copy link
Contributor

@tomasfarias tomasfarias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! :shipit:

# Conflicts:
#	posthog/api/test/test_decide.py
@davemurphysf davemurphysf merged commit 73efda3 into master Nov 20, 2023
67 checks passed
@davemurphysf davemurphysf deleted the dave/add-elements-chain-flag-in-decide branch November 20, 2023 18:26
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.

3 participants