Skip to content

Commit

Permalink
Merge branch 'master' into fix-funnel-trends-sessions-persons-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Jul 18, 2024
2 parents 3489b58 + 56d1174 commit d77b67d
Show file tree
Hide file tree
Showing 331 changed files with 7,026 additions and 4,135 deletions.
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
"group": "main"
}
},
{
"name": "Frontend (https)",
"command": "pnpm start",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}",
"presentation": {
"group": "main"
},
"env": {
"LOCAL_HTTPS": "1",
"JS_URL": "https://secure.posthog.dev"
}
},
{
"name": "Backend",
"consoleName": "Backend",
Expand Down Expand Up @@ -197,6 +211,21 @@
"order": 2,
"group": "compound"
}
},
{
"name": "PostHog (https)",
"configurations": [
"Backend",
"Celery Threaded Pool",
"Frontend (https)",
"Plugin Server",
"Temporal Worker"
],
"stopAll": true,
"presentation": {
"order": 2,
"group": "compound"
}
}
]
}
2 changes: 1 addition & 1 deletion bin/celery-queues.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Important: Add new queues to make Celery consume tasks from them.

# NOTE: Keep in sync with posthog/tasks/utils.py
CELERY_WORKER_QUEUES=celery,stats,email,analytics_queries,long_running,exports,subscription_delivery,usage_reports,session_replay_embeddings,session_replay_general,session_replay_persistence
CELERY_WORKER_QUEUES=celery,stats,email,analytics_queries,analytics_limited,long_running,exports,subscription_delivery,usage_reports,session_replay_embeddings,session_replay_general,session_replay_persistence
4 changes: 2 additions & 2 deletions cypress/e2e/experiments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ describe('Experiments', () => {
cy.get('[data-attr="create-annotation-submit"]').click()
cy.contains(secondaryMetricName).should('exist')

// Edit minimum acceptable improvement
cy.get('input[data-attr="min-acceptable-improvement"]').type('{selectall}20').should('have.value', '20')
// Edit minimum detectable effect
cy.get('input[data-attr="min-detectable-effect"]').type('{selectall}20').should('have.value', '20')

// Save experiment
cy.get('[data-attr="save-experiment"]').first().click()
Expand Down
53 changes: 44 additions & 9 deletions ee/clickhouse/views/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,56 @@ def update(self, instance: Experiment, validated_data: dict, *args: Any, **kwarg
if extra_keys:
raise ValidationError(f"Can't update keys: {', '.join(sorted(extra_keys))} on Experiment")

if "feature_flag_variants" in validated_data.get("parameters", {}):
if len(validated_data["parameters"]["feature_flag_variants"]) != len(feature_flag.variants):
raise ValidationError("Can't update feature_flag_variants on Experiment")

for variant in validated_data["parameters"]["feature_flag_variants"]:
if (
len([ff_variant for ff_variant in feature_flag.variants if ff_variant["key"] == variant["key"]])
!= 1
):
# if an experiment has launched, we cannot edit its variants anymore.
if not instance.is_draft:
if "feature_flag_variants" in validated_data.get("parameters", {}):
if len(validated_data["parameters"]["feature_flag_variants"]) != len(feature_flag.variants):
raise ValidationError("Can't update feature_flag_variants on Experiment")

for variant in validated_data["parameters"]["feature_flag_variants"]:
if (
len([ff_variant for ff_variant in feature_flag.variants if ff_variant["key"] == variant["key"]])
!= 1
):
raise ValidationError("Can't update feature_flag_variants on Experiment")

properties = validated_data.get("filters", {}).get("properties")
if properties:
raise ValidationError("Experiments do not support global filter properties")

if instance.is_draft:
# if feature flag variants have changed, update the feature flag.
if validated_data.get("parameters"):
variants = validated_data["parameters"].get("feature_flag_variants", [])
aggregation_group_type_index = validated_data["parameters"].get("aggregation_group_type_index")

global_filters = validated_data.get("filters")
properties = []
if global_filters:
properties = global_filters.get("properties", [])
if properties:
raise ValidationError("Experiments do not support global filter properties")

default_variants = [
{"key": "control", "name": "Control Group", "rollout_percentage": 50},
{"key": "test", "name": "Test Variant", "rollout_percentage": 50},
]

filters = {
"groups": [{"properties": properties, "rollout_percentage": 100}],
"multivariate": {"variants": variants or default_variants},
"aggregation_group_type_index": aggregation_group_type_index,
}

existing_flag_serializer = FeatureFlagSerializer(
feature_flag,
data={"filters": filters},
partial=True,
context=self.context,
)
existing_flag_serializer.is_valid(raise_exception=True)
existing_flag_serializer.save()

if instance.is_draft and has_start_date:
feature_flag.active = True
feature_flag.save()
Expand Down
Loading

0 comments on commit d77b67d

Please sign in to comment.