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

chore: update project tree scroll to current ID context menu, top bar #29423

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
18103b6
fix: lemon tree/project tree drag and drop
adamleithp Feb 27, 2025
e98bf56
fix: remove comments
adamleithp Feb 27, 2025
8198f60
Update UI snapshots for `chromium` (3)
github-actions[bot] Feb 27, 2025
3a81328
Update UI snapshots for `chromium` (2)
github-actions[bot] Feb 27, 2025
5abfc00
Update UI snapshots for `chromium` (1)
github-actions[bot] Feb 27, 2025
cc79757
Update UI snapshots for `chromium` (2)
github-actions[bot] Feb 27, 2025
8d1e2e0
fixed delete folder, using new util functions for paths
adamleithp Feb 27, 2025
9340d45
fixed lemon tree arrow functionality
adamleithp Feb 27, 2025
cbf1dee
implementing new layout design for tree and others
adamleithp Feb 28, 2025
2e97be3
fixed lemon tree arrow functionality again, lemon tree default node/f…
adamleithp Feb 28, 2025
5c74fb1
reverted affected snapshots from previous commits
adamleithp Feb 28, 2025
64b9474
removed 'lemon' from context menu-moved to ui folder, removed unused …
adamleithp Feb 28, 2025
a2981fc
Merge branch 'master' into devex/project-tree-updates-7
adamleithp Feb 28, 2025
b0c1aef
added lemon tree notice about side click
adamleithp Feb 28, 2025
927aba1
fixed indentation
adamleithp Feb 28, 2025
002a107
Update UI snapshots for `chromium` (2)
github-actions[bot] Feb 28, 2025
6c5c9d0
Update UI snapshots for `chromium` (1)
github-actions[bot] Feb 28, 2025
0fdd29e
Update UI snapshots for `chromium` (3)
github-actions[bot] Feb 28, 2025
8952e19
fix: rust docker image build workflow fix (#29366)
oliverb123 Feb 28, 2025
dace418
feat(retention): graph UX updates (#29270)
anirudhpillai Feb 28, 2025
33d8f87
fix: Error in staff arg in `generate_demo_data` (#29368)
rossgray Feb 28, 2025
de0dba1
chore: add Discord notification template (#29311)
daibhin Feb 28, 2025
005228b
feat: discussions support (#29355)
daibhin Feb 28, 2025
bac971d
chore: better queue (#29353)
pauldambra Feb 28, 2025
6c3b927
fix: improved survey search (#29372)
lucasheriques Feb 28, 2025
794e744
fix(retention): fix showing mean (#29374)
anirudhpillai Feb 28, 2025
ad944ae
feat: add link from live events view to explore view (#29349)
frankh Mar 1, 2025
2ccee35
feat(prop-defs): add hidden option to property definitions (#29085)
raquelmsmith Mar 1, 2025
b43ef5f
chore(deps): Update posthog-js to 1.225.0 (#29385)
posthog-bot Mar 2, 2025
5d6dbf5
fix: ux improvements for CSS selector field in surveys (#29373)
lucasheriques Mar 2, 2025
0ff6166
feat(data-warehouse): Log merge stats from delta (#29357)
Gilbert09 Mar 2, 2025
b6c35c4
feat(experiments): handle multiple variant exposure (#29336)
andehen Mar 3, 2025
ddbeff7
chore: disable plugin server posthog capture if not set (#29275)
daibhin Mar 3, 2025
a49c128
fix: add events to survey display summary (#29384)
lucasheriques Mar 3, 2025
50a63d2
feat: Add IP-range blocking to bot blocking transformation (#29369)
robbie-c Mar 3, 2025
597b0d9
fix: open ssl path for cmake (#29383)
pauldambra Mar 3, 2025
9fc4f6b
feat: add a slack interactivity callback endpoint (#29361)
pl Mar 3, 2025
c75f927
fix: event hosts undefined in onboarding (#29342)
joshsny Mar 3, 2025
532ee7d
feat: activity log detail (#29391)
pauldambra Mar 3, 2025
1750e4d
added top bar with edit/cancel save button, removed --- seperator, up…
adamleithp Mar 3, 2025
5a33e1b
added new folder in top bar button, fixed new folder logic
adamleithp Mar 3, 2025
1500053
feat: discussions support (#29355)
daibhin Feb 28, 2025
6ba261f
feat(cdp): allow substring without length param (#28746)
MarconLP Mar 3, 2025
ee0a11f
chore: remove a legacy leftover s/posthog.client/posthog.clickhouse.c…
orian Mar 3, 2025
286dd4c
feat: Added some geoip counters info (#29405)
benjackwhite Mar 3, 2025
6ed32f5
feat: move waterfall view (#29390)
pauldambra Mar 3, 2025
858260d
chore: add 1% sampling option (#29400)
veryayskiy Mar 3, 2025
b5f04ba
chore(cdp): Removed job and schedules (#29352)
benjackwhite Mar 3, 2025
e7b7e0d
feat(cdp): slack integration fixes (#29356)
MarconLP Mar 3, 2025
a6c73d8
feat(cdp): allow replaying events (#28850)
MarconLP Mar 3, 2025
e14e4c7
chore(deps): Update posthog-js to 1.225.1 (#29410)
posthog-bot Mar 3, 2025
803ff79
feat: improve playlist counts (#29381)
pauldambra Mar 3, 2025
6858459
chore(data-warehouse): Pyarrow optimisations (#29401)
Gilbert09 Mar 3, 2025
0fdf8e6
fix: Installing pymssql in flox (#29409)
rossgray Mar 3, 2025
e5ef48b
fix(err): capture merge metric + ui changes (#29370)
oliverb123 Mar 3, 2025
710b742
chore(data-warehouse): Better error raised for missing env vars for d…
Gilbert09 Mar 3, 2025
be66600
Attempt to display non-zero value on Web Vitals (#29358)
rafaeelaudibert Mar 3, 2025
3c9bbad
fix(experiments): Ensure web experiments use stats v2 (#29406)
danielbachhuber Mar 3, 2025
5cffe67
feat(cdp): Mini purge of old ingesters (#29341)
benjackwhite Mar 3, 2025
3574c64
fix: Migration script for hog functions (#29416)
benjackwhite Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
6 changes: 5 additions & 1 deletion .flox/env/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ nodemon = { pkg-path = "nodemon" }
xmlsec = { pkg-path = "xmlsec", version = "1.3.6" }
openssl = { pkg-path = "openssl", version = "3.4.1", pkg-group = "openssl" }
cmake = { pkg-path = "cmake", version = "3.31.5", pkg-group = "cmake" }
freetds = { pkg-path = "freetds" }

# Set environment variables in the `[vars]` section. These variables may not
# reference one another, and are added to the environment without first
Expand All @@ -54,6 +55,9 @@ cmake = { pkg-path = "cmake", version = "3.31.5", pkg-group = "cmake" }
DEBUG = "1"
POSTHOG_SKIP_MIGRATION_CHECKS = "1"
DIRENV_LOG_FORMAT = "" # Disable direnv activation logging (in case direnv is present)
OPENSSL_ROOT_DIR = "$FLOX_ENV"
OPENSSL_LIB_DIR = "$FLOX_ENV/lib"
OPENSSL_INCLUDE_DIR = "$FLOX_ENV/include"
LDFLAGS="-L$FLOX_ENV/lib"
CPPFLAGS="-I$FLOX_ENV/include"

Expand Down Expand Up @@ -90,7 +94,7 @@ echo -e "Python interpreter path, for your code editor: \033[33m.flox/cache/venv
source "$PYTHON_DIR/bin/activate"

# Install Python dependencies (this is practically instant thanks to uv)
uv pip install -q -r requirements.txt -r requirements-dev.txt
uv pip install -q --no-binary=pymssql -r requirements.txt -r requirements-dev.txt

# Install top-level Node dependencies (only if not present all yet, because this takes almost a second even with pnpm)
# This also sets up pre-commit hooks via Husky
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/rust-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v2

- name: Retrieve sccache configuration
id: sccache
run: |
echo "endpoint=$SCCACHE_WEBDAV_ENDPOINT" >> "$GITHUB_OUTPUT"
echo "::add-mask::$SCCACHE_WEBDAV_TOKEN"
echo "token=$SCCACHE_WEBDAV_TOKEN" >> "$GITHUB_OUTPUT"

- name: Build and push image
id: docker_build
uses: depot/build-push-action@v1
Expand All @@ -114,8 +121,8 @@ jobs:
platforms: linux/arm64,linux/amd64
build-args: BIN=${{ matrix.image }}
secrets: |
SCCACHE_WEBDAV_ENDPOINT=${{ env.SCCACHE_WEBDAV_ENDPOINT }}
SCCACHE_WEBDAV_TOKEN=${{ env.SCCACHE_WEBDAV_TOKEN }}
SCCACHE_WEBDAV_ENDPOINT=${{ steps.sccache.outputs.endpoint }}
SCCACHE_WEBDAV_TOKEN=${{ steps.sccache.outputs.token }}

- name: Container image digest
id: digest
Expand Down
39 changes: 20 additions & 19 deletions common/hogvm/__tests__/__snapshots__/stl.hoge
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,23 @@
"print", 1, 35, 32, "-- string/array --", 2, "print", 1, 35, 32, "a", 32, "a", 32, "b", 32, "c", 2, "tuple", 3, 2, "in",
2, 32, "z", 32, "a", 32, "b", 32, "c", 2, "tuple", 3, 2, "in", 2, 2, "print", 2, 35, 32, "a", 32, "a", 32, "b", 32, "c",
43, 3, 2, "in", 2, 32, "z", 32, "a", 32, "b", 32, "c", 43, 3, 2, "in", 2, 2, "print", 2, 35, 32, "hello", 32, "he", 2,
"startsWith", 2, 32, "abcdef", 33, 2, 33, 3, 2, "substring", 3, 2, "print", 2, 35, 31, 31, 32, "firstNonNull", 2,
"coalesce", 3, 32, "notNull", 2, "assumeNotNull", 1, 2, "print", 2, 35, 32, "", 2, "print", 1, 35, 32, "-- date --", 2,
"print", 1, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toYear", 1, 32, "2024-12-18T00:00:00Z", 2,
"toDateTime", 1, 2, "toMonth", 1, 2, "print", 2, 35, 2, "now", 0, 2, "typeof", 1, 2, "print", 1, 35, 32,
"2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2, "toStartOfDay", 1, 32, "2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2,
"toStartOfWeek", 1, 2, "print", 2, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toYYYYMM", 1, 2, "print", 1,
35, 32, "day", 33, 1, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 32, "day", 32, "2024-12-18", 2, "toDate", 1,
32, "day", 33, 5, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 2, "dateDiff", 3, 2, "print", 2, 35, 32, "day", 32,
"2024-12-18T12:34:56Z", 2, "toDateTime", 1, 2, "dateTrunc", 2, 2, "print", 1, 35, 32, "2024-12-18", 2, "toDate", 1, 33,
3, 2, "addDays", 2, 2, "print", 1, 35, 33, 5, 2, "toIntervalDay", 1, 33, 2, 2, "toIntervalMonth", 1, 2, "print", 2, 35,
2, "today", 0, 2, "typeof", 1, 2, "print", 1, 35, 32, "", 2, "print", 1, 35, 32, "-- json --", 2, "print", 1, 35, 32,
"{\"a\":123.1}", 32, "a", 2, "JSONExtractInt", 2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2,
"JSONExtractInt", 2, 2, "jsonStringify", 1, 2, "print", 2, 35, 32, "{\"a\":123.1}", 32, "a", 2, "JSONExtractFloat", 2,
2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2, "JSONExtractFloat", 2, 2, "jsonStringify", 1, 2, "print", 2,
35, 32, "{\"a\":123.1}", 32, "a", 2, "JSONExtractString", 2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2,
"JSONExtractString", 2, 2, "jsonStringify", 1, 2, "print", 2, 35, 32, "{\"a\":123}", 32, "a", 2, "JSONExtractArrayRaw",
2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2, "JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 2,
"print", 2, 35, 32, "{\"a\":[]}", 32, "a", 2, "JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 32,
"{\"a\":[\"hello\"]}", 32, "a", 2, "JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 2, "print", 2, 35]
"startsWith", 2, 32, "abcdef", 33, 2, 33, 3, 2, "substring", 3, 2, "print", 2, 35, 32, "abcdef", 33, 2, 2, "substring",
2, 2, "print", 1, 35, 31, 31, 32, "firstNonNull", 2, "coalesce", 3, 32, "notNull", 2, "assumeNotNull", 1, 2, "print", 2,
35, 32, "", 2, "print", 1, 35, 32, "-- date --", 2, "print", 1, 35, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2,
"toYear", 1, 32, "2024-12-18T00:00:00Z", 2, "toDateTime", 1, 2, "toMonth", 1, 2, "print", 2, 35, 2, "now", 0, 2,
"typeof", 1, 2, "print", 1, 35, 32, "2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2, "toStartOfDay", 1, 32,
"2024-12-18T11:11:11Z", 2, "toDateTime", 1, 2, "toStartOfWeek", 1, 2, "print", 2, 35, 32, "2024-12-18T00:00:00Z", 2,
"toDateTime", 1, 2, "toYYYYMM", 1, 2, "print", 1, 35, 32, "day", 33, 1, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd",
3, 32, "day", 32, "2024-12-18", 2, "toDate", 1, 32, "day", 33, 5, 32, "2024-12-18", 2, "toDate", 1, 2, "dateAdd", 3, 2,
"dateDiff", 3, 2, "print", 2, 35, 32, "day", 32, "2024-12-18T12:34:56Z", 2, "toDateTime", 1, 2, "dateTrunc", 2, 2,
"print", 1, 35, 32, "2024-12-18", 2, "toDate", 1, 33, 3, 2, "addDays", 2, 2, "print", 1, 35, 33, 5, 2, "toIntervalDay",
1, 33, 2, 2, "toIntervalMonth", 1, 2, "print", 2, 35, 2, "today", 0, 2, "typeof", 1, 2, "print", 1, 35, 32, "", 2,
"print", 1, 35, 32, "-- json --", 2, "print", 1, 35, 32, "{\"a\":123.1}", 32, "a", 2, "JSONExtractInt", 2, 2,
"jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2, "JSONExtractInt", 2, 2, "jsonStringify", 1, 2, "print", 2, 35,
32, "{\"a\":123.1}", 32, "a", 2, "JSONExtractFloat", 2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2,
"JSONExtractFloat", 2, 2, "jsonStringify", 1, 2, "print", 2, 35, 32, "{\"a\":123.1}", 32, "a", 2, "JSONExtractString",
2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}", 32, "a", 2, "JSONExtractString", 2, 2, "jsonStringify", 1, 2,
"print", 2, 35, 32, "{\"a\":123}", 32, "a", 2, "JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 32, "{\"a\":\"hello\"}",
32, "a", 2, "JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 2, "print", 2, 35, 32, "{\"a\":[]}", 32, "a", 2,
"JSONExtractArrayRaw", 2, 2, "jsonStringify", 1, 32, "{\"a\":[\"hello\"]}", 32, "a", 2, "JSONExtractArrayRaw", 2, 2,
"jsonStringify", 1, 2, "print", 2, 35]
4 changes: 3 additions & 1 deletion common/hogvm/__tests__/__snapshots__/stl.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ function toIntervalMonth(val) { return __toHogInterval(val, 'month') }
function toIntervalDay(val) { return __toHogInterval(val, 'day') }
function toDateTime (input, zone) { return __toDateTime(input, zone) }
function toDate (input) { return __toDate(input) }
function substring(s, start, length) {
function substring(s, start, optionalLength) {
if (typeof s !== 'string') return '';
const startIdx = start - 1;
const length = typeof optionalLength === 'number' ? optionalLength : s.length - startIdx;
if (startIdx < 0 || length < 0) return '';
const endIdx = startIdx + length;
return startIdx < s.length ? s.slice(startIdx, endIdx) : '';
Expand Down Expand Up @@ -531,6 +532,7 @@ print("-- string/array --");
print(__x_in("a", tuple("a", "b", "c")), __x_in("z", tuple("a", "b", "c")));
print(__x_in("a", ["a", "b", "c"]), __x_in("z", ["a", "b", "c"]));
print(startsWith("hello", "he"), substring("abcdef", 2, 3));
print(substring("abcdef", 2));
print(coalesce(null, null, "firstNonNull"), assumeNotNull("notNull"));
print("");
print("-- date --");
Expand Down
1 change: 1 addition & 0 deletions common/hogvm/__tests__/__snapshots__/stl.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ one
true false
true false
true bcd
bcdef
firstNonNull notNull

-- date --
Expand Down
1 change: 1 addition & 0 deletions common/hogvm/__tests__/stl.hog
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ print('-- string/array --')
print(in('a', tuple('a','b','c')), in('z', tuple('a','b','c')))
print(in('a', ['a','b','c']), in('z', ['a','b','c']))
print(startsWith('hello','he'), substring('abcdef',2,3))
print(substring('abcdef',2))
print(coalesce(null, null, 'firstNonNull'), assumeNotNull('notNull'))
print('')
print('-- date --')
Expand Down
4 changes: 2 additions & 2 deletions common/hogvm/python/stl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,10 @@ def substring(args: list[Any], team: Optional["Team"], stdout: Optional[list[str
# start is 1-based.
s = args[0]
start = args[1]
length = args[2]
if not isinstance(s, str):
return ""
start_idx = start - 1
length = args[2] if len(args) > 2 else len(s) - start_idx
if start_idx < 0 or length < 0:
return ""
end_idx = start_idx + length
Expand Down Expand Up @@ -1060,7 +1060,7 @@ def JSONExtractString(args: list[Any], team: Optional["Team"], stdout: Optional[
"range": STLFunction(fn=range_fn, minArgs=1, maxArgs=2),
"round": STLFunction(fn=round_fn, minArgs=1, maxArgs=1),
"startsWith": STLFunction(fn=startsWith, minArgs=2, maxArgs=2),
"substring": STLFunction(fn=substring, minArgs=3, maxArgs=3),
"substring": STLFunction(fn=substring, minArgs=2, maxArgs=3),
"toIntervalDay": STLFunction(fn=toIntervalDay, minArgs=1, maxArgs=1),
"toIntervalHour": STLFunction(fn=toIntervalHour, minArgs=1, maxArgs=1),
"toIntervalMinute": STLFunction(fn=toIntervalMinute, minArgs=1, maxArgs=1),
Expand Down
5 changes: 3 additions & 2 deletions common/hogvm/typescript/src/stl/stl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,12 @@ function startsWithFn([str, prefix]: any[]): boolean {
return typeof str === 'string' && typeof prefix === 'string' && str.startsWith(prefix)
}

function substringFn([s, start, length]: any[]): string {
function substringFn([s, start, optionalLength]: any[]): string {
if (typeof s !== 'string') {
return ''
}
const startIdx = start - 1
const length = typeof optionalLength === 'number' ? optionalLength : s.length - startIdx
if (startIdx < 0 || length < 0) {
return ''
}
Expand Down Expand Up @@ -1259,7 +1260,7 @@ export const STL: Record<string, STLFunction> = {
range: { fn: rangeFn, minArgs: 1, maxArgs: 2 },
round: { fn: roundFn, minArgs: 1, maxArgs: 1 },
startsWith: { fn: startsWithFn, minArgs: 2, maxArgs: 2 },
substring: { fn: substringFn, minArgs: 3, maxArgs: 3 },
substring: { fn: substringFn, minArgs: 2, maxArgs: 3 },
toIntervalDay: { fn: toIntervalDayFn, minArgs: 1, maxArgs: 1 },
toIntervalHour: { fn: toIntervalHourFn, minArgs: 1, maxArgs: 1 },
toIntervalMinute: { fn: toIntervalMinuteFn, minArgs: 1, maxArgs: 1 },
Expand Down
33 changes: 26 additions & 7 deletions ee/api/ee_event_definition.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
from typing import cast

import posthoganalytics
from django.utils import timezone
from loginas.utils import is_impersonated_session
from rest_framework import serializers

from ee.models.event_definition import EnterpriseEventDefinition
from posthog.api.shared import UserBasicSerializer
from posthog.api.tagged_item import TaggedItemSerializerMixin
from posthog.event_usage import groups
from posthog.models import User
from posthog.models.activity_logging.activity_log import (
Detail,
dict_changes_between,
log_activity,
Detail,
)

from loginas.utils import is_impersonated_session
from typing import cast
import posthoganalytics
from posthog.event_usage import groups
from posthog.models import User


class EnterpriseEventDefinitionSerializer(TaggedItemSerializerMixin, serializers.ModelSerializer):
updated_by = UserBasicSerializer(read_only=True)
Expand Down Expand Up @@ -44,6 +44,7 @@ class Meta:
"verified",
"verified_at",
"verified_by",
"hidden",
# Action fields
"is_action",
"action_id",
Expand All @@ -69,9 +70,27 @@ class Meta:
"created_by",
]

def validate(self, data):
validated_data = super().validate(data)

if "hidden" in validated_data and "verified" in validated_data:
if validated_data["hidden"] and validated_data["verified"]:
raise serializers.ValidationError("An event cannot be both hidden and verified")

return validated_data

def update(self, event_definition: EnterpriseEventDefinition, validated_data):
validated_data["updated_by"] = self.context["request"].user

# If setting hidden=True, ensure verified becomes false
if validated_data.get("hidden", False):
validated_data["verified"] = False
validated_data["verified_by"] = None
validated_data["verified_at"] = None
# If setting verified=True, ensure hidden becomes false
elif validated_data.get("verified", False):
validated_data["hidden"] = False

if "verified" in validated_data:
if validated_data["verified"] and not event_definition.verified:
# Verify event only if previously unverified
Expand Down
35 changes: 31 additions & 4 deletions ee/api/ee_property_definition.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from rest_framework import serializers
from django.utils import timezone
from loginas.utils import is_impersonated_session
from rest_framework import serializers

from ee.models.property_definition import EnterprisePropertyDefinition
from posthog.api.shared import UserBasicSerializer
from posthog.api.tagged_item import TaggedItemSerializerMixin
from posthog.models import PropertyDefinition
from posthog.models.activity_logging.activity_log import (
Detail,
dict_changes_between,
log_activity,
Detail,
)
from loginas.utils import is_impersonated_session


class EnterprisePropertyDefinitionSerializer(TaggedItemSerializerMixin, serializers.ModelSerializer):
Expand All @@ -31,6 +32,7 @@ class Meta:
"verified",
"verified_at",
"verified_by",
"hidden",
)
read_only_fields = [
"id",
Expand All @@ -41,7 +43,32 @@ class Meta:
"verified_by",
]

def update(self, property_definition: EnterprisePropertyDefinition, validated_data):
def validate(self, data):
validated_data = super().validate(data)

if "hidden" in validated_data and "verified" in validated_data:
if validated_data["hidden"] and validated_data["verified"]:
raise serializers.ValidationError("A property cannot be both hidden and verified")

# If setting hidden=True, ensure verified becomes false
if validated_data.get("hidden", False):
validated_data["verified"] = False
# If setting verified=True, ensure hidden becomes false
elif validated_data.get("verified", False):
validated_data["hidden"] = False

return validated_data

Comment on lines +46 to +60
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The validation logic here is duplicated in the update method. Consider extracting this logic to a helper method to avoid inconsistencies if one part is updated but not the other.

def update(self, property_definition: EnterprisePropertyDefinition, validated_data: dict):
# If setting hidden=True, ensure verified becomes false
if validated_data.get("hidden", False):
validated_data["verified"] = False
validated_data["verified_by"] = None
validated_data["verified_at"] = None
# If setting verified=True, ensure hidden becomes false
elif validated_data.get("verified", False):
validated_data["hidden"] = False

Comment on lines +63 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This logic duplicates what's already done in the validate method. Since validate is called before update, this code may be redundant and could be removed.

validated_data["updated_by"] = self.context["request"].user
if "property_type" in validated_data:
if validated_data["property_type"] == "Numeric":
Expand Down
8 changes: 8 additions & 0 deletions ee/api/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ class PublicIntegrationViewSet(viewsets.GenericViewSet):
authentication_classes = []
permission_classes = []

@action(methods=["POST"], detail=False, url_path="slack/interactivity-callback")
def slack_interactivity_callback(self, request: Request, *args: Any, **kwargs: Any) -> Response:
# This is an empty endpoint for the Slack interactivity callback.
# We don't verify the request, as we don't do anything with the submitted data.
# We only use it to supress the warnings when users press buttons in Slack messages.
# In case we decide to do something with it, please add the verification process here.
Comment on lines +27 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding request validation for security, even if you're not using the data. Without validation, this endpoint could potentially be abused.

return Response({"status": "ok"})

@action(methods=["POST"], detail=False, url_path="slack/events")
def slack_events(self, request: Request, *args: Any, **kwargs: Any) -> Response:
try:
Expand Down
Loading
Loading