* wip
* display known unix timestamps as date strings in property filter select box
* show selected unix timestamp property as a datetime string in the property filter
* remove console.log
* update test to construct property definition correctly
* correct another test
* dates have different operators
* format property filter values for display in Select boxes and the PropertyValue component
* fix typescript error
* it _is_ a type, I don't need to say it is
* don't have before and after for unmatched types of operators
* separate the current applicable operators and the operator to display mapping, and add cypress tests for before and after operator visibility
* correct cypress test
* remove unused method
* remove dangling comment
* why does test fail in CI but not locally
* why does test fail in CI but not locally
* why does test fail in CI but not locally
* log values of operator options, why does this fail in CI but not locally
* why does test fail in CI but not locally
* intercept more decide calls to try and set feature flags from cypress test
* why does test fail in CI but not locally
* Remove cypress install
* add a readme for how to test feature flags so it isn't lost if there are no tests currently testing feature flags
* Resolve weird SQL formatting issue
* Use a discriminated union for ActorType
* Use standard response types for related groups
* Update typing
* Always filter related actors by group type index
* Update snapshots & typing
* Migration to add name_singular and name_plural to groups
* Allow modifying group type names
* Use name_plural and name_singular through the app
* Update tab names
* fixup
* Update snapshots
* Don't delete events from Postgres since we don't do it on CH
* Update frontend for accuracy
* Update test_person.py
* Don't display "ID-less user" as a link
* Remove flipsort related logic
* Only load events from the last 6 months in events table
* Disable customization in actions tab
* Rename prop
* Dont poll events in actions page
* Show a different header above events table in actions page
* Update tests with frozen time
* Decouple months of actions tab with other months
* Calculate action count over 3 months
* Update tests
* Remove `minute` interval support from frontend
* Remove minute support from backend, default to hour instead
Also adds tests for interval logic
* Remove now-dead minute support from backend
* revert interval_candidate logic
* Move IntervalMixin to separate file
* Run queries against person_distinct_id2 when async migration is done
* Only write to clickhouse_person_unique_id topic if async migration is incomplete
* Update query snapshots
* Update plugin-server
* Adjust caching logic
* Keep person_distinct_id2 in sync on split_person
Follow-up to https://github.com/PostHog/posthog/pull/7671, covering a
new corner case.
* Deprecate some methods
* Handle versioning in split_person
* Select for update
* query events by date for properties known to be dates
* can't currently import journeys_for helper outside of ee folder
* actually remove the EE import
* even though no values of the specified property were not parseable account for unparseable values
* move tests into EE folder cos they're clickhouse only
* remove new line to take this file out of the PR diff
* use more forgiving ClickHouse datetime function
* wip
* add more tests and rename filters
* Adds a broken date picker behind a feature flag
* Revert "wip"
This reverts commit 6ec1da8744.
* add working basic UI for date selection in taxonomic property filter
* add a failing test by writing a unix timestamp the way the SDK does
* obey mypy
* add awareness of type and format so we can query our $time property as a DateTime in the events api
* hard code property definition in the eventsTableLogic
* Revert "obey mypy"
This reverts commit f09ae4369a.
* hold taxonomic property filter open - but with possible kludge in cohortsModel
* remove my edits to settings
* put back materialization of columns that test snapshots are expecting
* let the datepicker hold the taxonomic pop up open
* update snapshot
* simpler datepicker visibility in filter row
* simplify property type format for unix timestamps
* remove the datepicker now button
* Actually delete all of the drop down held open tests
* Remove leftover `console.log`s
Co-authored-by: Michael Matloka <dev@twixes.com>
* fix(retention): add regression test for not_icontains filter
Previously if using the not_icontains filter, we were trying to double
substitute a query when fetching persons for retention. This adds a
test (and in the next commit a fix) such that we instead apply the
clickhouse substitute only once to each part of the query.
Resolves https://github.com/PostHog/posthog/issues/7747
* avoid double substitution
* Rework solution to not change ActorBaseQuery interface
* Remove unued import
* fix typing
* it works...
* clean up server side
* move logic from query to helpers/api
* typing fixes
* add tests to helpers
* test for metadata queries
* api tests
* util tests
* improve some types and move logic to utils
* Get PlayerMeta working
* tests for sessionRecordingPlayerLogic
* fix some more tests
* analytics fix
* name flip
* player util tests
* Add comments + remove logs
* Clean up some comments
* make is_active a bit cleaner
* remove some log statements
* add comment to metadata function
* some cleanup
* typescript fix
* timestamp plays follows scrubbing
* fix bug with hitting 60 seconds
* fix end position bug
* fix bugs with skip ahead
* fix some bugs
* fix white screen on buffer end
* fix buffer scrubbing bugs
* fix skip bug
* fix circular import
* rename start_window_id to last_active_window_id
* fix tests
* bug fix for no window_id case
* fix bug when scrubbing to the end of the player
* rename setBuffer + setScrub to startBuffer + startScrub
* fix(retention): fix breakdown people urls
This change returns people_url for each breakdown cohort in the
response. We also merge the initial and returning queries together,
as this makes it easier to align the people query also.
Note that I'm talking about person_id as opposed to actor_type etc.
but perhaps that can be a followup.
* clean up clickhouse params
* tidy up a little
* remove import
* remove non-breakdown specific code
* make cohort by initial event date a special breakdown case
* keep date for backwards compat
* Remove unused sql
* make test stable
* wip
* Get most of the tests working
* test(retention): remove graph retention test
We no longer need this, we have all the information we need from the
table response for retention, and can construct this on the frontend.
* revert any changes to posthog/queries/retention.py
* revert any changes to ee/clickhouse/models/person.py
* Revert posthog/queries/retention.py to merge-base
* Ensure actor id is a str
* Add type for actor serialiser for type narrowing
* run black
* sort imports
* Remove retention_actors.py
* fix typings
* format
* reverse str type
* sort imports
* rename
* split out functions
* remove deuplicate logic
* working
* fix type
* don't stringify
* fix test
* ordering doesn't matter
* trigger ci
Co-authored-by: eric <eeoneric@gmail.com>
* Make person hooks only happen in tests
* Remove a data script
* Update split_person code to handle hookless life
* Delete clickhouse data async in the background
* Resolve another insights N+1 issue
Using `prefetch_related` to avoid loading the same dashboard/user
multiple times if referred to by different insights. More queries _can_
be better! :)
* Improve the test
* Get test stable, add created_by user
* Order by created_at over id in groups list, similar to persons
* Change table column name to be consistent with persons
* Default to `.name` property if one is passed for groups
This improves a usability issue with groups temporarily
* convert to actor form
* change var name
* remove unused imports
* typing issue
* use subquery
* bad import
* groups for general retention query
* actor in period
* update imports
* update test
* remove comment
* Create a new way to get distinct id queries thats gated by team_id
* Update most cases to use the new query
* Convert EVENT_JOIN_PERSON_SQL to new query
* Mostly convert GET_DISTINCT_IDS_BY_PERSON_ID_FILTER
* Mostly convert GET_DISTINCT_IDS_BY_PROPERTY_SQL
* Convert GET_PERSON_IDS_BY_FILTER
* Flag benchmarks
* Resolve circular imports
* Update a snapshot test
* Add a test for the new query logic
* test(retention): add http api tests for retention breakdowns
This just adds tests for person and event property breakdowns
* Add helper function for substituting clickhouse sql params
* feat(retention): add support for multiple breakdown props
This just reuses the work done for funnel multiple breakdown values. I
haven't tested this with anything other than person or event properties.
Rather than try to get it working for all the other property types.
The change adds a new `breakdowns` parameter to the retention endpoint,
that is the same as for funnels, e.g. it looks like:
```
{
...
"breakdowns": [{"type": "person", "property": "os"}, ...]
...
}
```
The return structure is the same as the non-breakdown version, except we
also include a `breakdown_values` property that is e.g. `["Chrome",
"95"]`, and the `label` attribute for this case would be "Chrome::95".
* fix typing
* update query snapshots
* remove unused imports
* use `self.assertEqual` instead of `assert`
* Remove explicit should_join_persons
* Revert limit by changes, use breakdown_type
* update snapshots
* fix typing
* use json_encode_request_params in retention test requests
* update json_encode_request_params to encode_get_request_params to better reflect purpose
* perf(retention): add benchmark query for retention with breakdown
* no materialize
* Use GroupTypeIndex type in BE
* Consistent ordering for group types
* Better BE type for group type index
* Handle non-url safe keys in groups
Previously this would crash due to never decoding the url and not
handling it in the backend
* Allow fetching related groups from the API
* Solve minor type errors
* Add a tooltip
* data-attr for tracking links
* Add related groups onto person page
* Fix an import
* Kill useEffect
* refactor(stickiness): refactor one stickiness test to use api
This change demonstrates how to migrate a `Query` object level test to
an api based test. It purely focuses on the method of action invocation
and not on any of the e.g. setup or assertions. The StickinessQuery
object is only used by the REST API (and benchmarking), where as the
REST stickiness API is used by external users including our own frontend
developers, so makes sense to test at this level.
* Migrate stickiness query tests to api
This doesn't touch the stickiness people API however
* Migrate clickhouse specific stickiness tests
* Migrate stickiness people query tests to http api level
NOTE! This isn't just a straight migration, but also makes one important
change to application code that would otherwise result in a test
failure. Specifically, when trying to find an action based on the
`entity_id` query param, we need to consider that the entity_id is a
string. This is fine for when trying to find events, as we are comparing
event ids which are strings, but for actions the id is an int, so we
need to ensure we cast the action id to a string before comparison.
* Move stickiness query tests to api tests location
* make stickiness tests stable across postgres/clickhouse
* Add comment regarding casting action ids to strings
* Update wording
* Update view to use postgres tables
We keep these in sync now
* Add retrieve endpoint
* Link to a (blank) groups page
* Show events table and properties under group
* Update pagination for groups
* update testing utils
* Update tests
* Patch tests relying on returned models
* Remove duplicated line
* wip
* normalise to breakdown and breakdowns on the way out of the API
* read from breakdowns or breakdown property of filters
* wip
* wip
* delete a console.log
* remove console.log and speculative multi breakdown changes
* remove empty test
* remove console log
* more tidying
* more tidying
* more tidying
* simplify funnel logic slightly
* a test for the data transformations with no breakdown
* can test data transformation with a single property breakdown
* keep expanding the test to see why multi prop doesn't display
* don't throw key error if there is no breakdown property to pop from the multi property API response
* funnel step table can detect breakdown without relying on filter
* try to highlight the differences in the paths through TaxonomicBreakdownFilter
* better behaviour when adding and removing multi property breakdowns
* displays multi property breakdown in old style steps funnel views
* it is safe to always show breakdown in new vertical layout
* resolve multi property breakdown typehinting
* updates comment
* updates comment
* don't print breakdown value twice
* tooltip for long values and prettier pill
* convert tests to journeys_for
* fix multi breakdown helper
* better behaviour when navigating between trends and funnels
* Refactor the multi property breakdown helper to calm the mypy type checker down
* safer access to dict in multi property helper
* makes clean filters feature flags aware and keeps breakdown values when switching between trends and funnels
* test fix
* remove overly verbose data tests
* add some more specific tests to multi prop breakdown
* obey mypy
* remove the breakdown type from the backend which was causing serialization issues
* working for unique_groups math
* fix types
* add null check
* update snapshots
* update payload
* update snapshots
* use constructor
* adjust queries
* introduce base class
* consolidate querying
* shared serializer and typed
* sort imports
* snapshots
* typing
* change name
* Add group model
```sql
BEGIN;
--
-- Create model Group
--
CREATE TABLE "posthog_group" ("id" serial NOT NULL PRIMARY KEY, "group_key" varchar(400) NOT NULL, "group_type_index" integer NOT NULL, "group_properties" jsonb NOT NULL, "created_at" timestamp with time zone NOT NULL, "properties_last_updated_at" jsonb NOT NULL, "properties_last_operation" jsonb NOT NULL, "version" bigint NOT NULL, "team_id" integer NOT NULL);
--
-- Create constraint unique team_id/group_key/group_type_index combo on model group
--
ALTER TABLE "posthog_group" ADD CONSTRAINT "unique team_id/group_key/group_type_index combo" UNIQUE ("team_id", "group_key", "group_type_index");
ALTER TABLE "posthog_group" ADD CONSTRAINT "posthog_group_team_id_b3aed896_fk_posthog_team_id" FOREIGN KEY ("team_id") REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "posthog_group_team_id_b3aed896" ON "posthog_group" ("team_id");
COMMIT;
```
* Remove a dead import
* Improve typing for groups
* Make groups updating more generic, avoid mutation
This simplifies using the same logic for groups
Note there's a behavioral change: We don't produce a new kafka message
if nothing has been updated anymore.
* Rename a function
* WIP: Handle group property updates
... by storing them in postgres
Uses identical pattern to person property updates, except we handle
first-seen case within updates as well.
* Get rid of boolean option
* WIP continued
* fetchGroup() and upsertGroup()
* Test more edge cases
* Add tests for upsertGroup() in properties-updater
* Rename to PropertyUpdateOperation
* Followup
* Solve typing issues
* changed implementation to use pg
* unusd
* update type
* update snapshots
* rename and remove inlining
* restore bad merge code
* adjust types
* add flag
* remove var
* misnamed
* change to uuid
* make sure to use string when passing result
* remove from columnoptimizer logic and have group join logic implemented by event query classes per insight
* add flag to funnel event query
* remove unnecessary logic
* typing
* working actors func
* fix typos
* remove unused func
* use serialized result
* wrong var
* use actors
* remove dead imports
* remove verbosity
* update snapshots
* typos
* remove signals
* remove plugin excess
* update typing
* clean up
* use actor func for all funnel persons
* types
* make sure limits are set
* remove functions
* fix limits
* funnel trends
* types
* indexing
* moved basic funnel tests
* unordered test
* remove duplicate test
* check ids
* more test adjustments
* sort
* change class names
* sort
* reformat
* change string to int
* remove duplicate
* update comment
* use actor result to paginate not serialized
* adjust tests after merging
* simplify typing
* don't import removed func
Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
* don't add leading slash to absolute url with no protocol
* don't add a base uri in only one funnel instantiation - will probably break tests
* remove console logs
* every API verb normalises URLs
* implement multi property breakdown as an array from the spike
* correct type hint on method
* really resolve the conflict
* don't break groups
* refactor test assertions for breakdown cases
* adds a test to prove that funnels can receive a string and not an array
* protect saved dashboards from multi property changeover
* WIP
* multi breakdown working with funnel step breakdown
* prove funnel step person breakdown works with multi property breakdown
* don't need to protect cached dashboards from multi property breakdowns when they can't be set from the UI
* capitalise keywords in SQL
* convert a single test to journey helper
* wip
* account for funnel step breakdown sometimes being an array sent as a string
* safer handling of funnel step breakdown
* convert a test
* revert commits that made things worse
* simpler handling of funnel step breakdown
* no need to change funnel step breakdown type hint
* update imports
* guard against integer properties
* compare funnel step breakdown differently now there are arrays involved
* look for strict intersection for funnel step breakdown
* update test snapshots
* need to set breakdown_values earlier in processing
* remove tests that cover speculative functionality
* update snapshot
* move setup of breakdown values back out of update_filters
* update snapshots
* remove a sql parameter that was never assigned to
* Update ee/clickhouse/models/test/test_property.py
Co-authored-by: Harry Waye <harry@posthog.com>
* Update ee/clickhouse/queries/funnels/base.py
Co-authored-by: Harry Waye <harry@posthog.com>
* address review comment to simplify reading json expressions for breakdown
* clarify why some uses of get_property_string_expr escape params before passing
* add keyword arguments for calls to getting property string expressions in funnels
* switch to keyword arguments in test helper method
* fix parameterised test
* add multi property materialized column tests
* introduce the shim to allow new API for breakdown properties
* can't remove the naive funnel step breakdown list detection
* move funnel step breakdown list handling
* better handling of numeric funnel step breakdown values
* update snapshots
Co-authored-by: Harry Waye <harry@posthog.com>
* Addtest for people_urls in retention trend response
* Add people_urls to retention trend response
* Run black formater
* sort imports
* Add default value for base_uri
* Let type be missing in EventPattern in tests
TypedDict is so rubbish in not allowing missing attributes 🤷
* fix typing
* refactor creation helper functions
* revert docker compose change