From 7273b1df4285911c07d35dc3633714ec0c8efd0c Mon Sep 17 00:00:00 2001 From: Kraiem Taha Yassine Date: Thu, 7 Sep 2023 10:59:20 +0100 Subject: [PATCH] Api v1.15.0 (#1466) * refactor(chalice): upgraded dependencies refactor(crons): upgraded dependencies refactor(alerts): upgraded dependencies * fix(chalice): return error when updating inexistant webhook * feat(chalice): fixed delete webhook response * feat(chalice): limit webhooks name length * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies * fix(chalice): remove urllib3 dependency * feat(chalice): remove FOSS to pydantic v2 * fix(chalice): freeze urllib3 to not have conflicts between boto3 and requests * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress feat(chalice): upgraded dependencies * feat(chalice): refactored schema * feat(DB): transfer size support * feat(chalice): support service account * feat(chalice): support service account * fix(chalice): fixed refactored PayloadSchema-name * feat(chalice): path analysis * feat(chalice): support service account 1/2 * feat(DB): timezone support * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies feat(assist): upgraded dependencies feat(sourcemaps): upgraded dependencies * feat(chalice): path analysis schema changes * feat(chalice): path analysis query change * feat(chalice): path analysis query change * feat(chalice): ios replay support * feat(chalice): ios replay support * feat(chalice): path analysis changes * feat(chalice): upgraded dependencies * feat(chalice): simple hide minor paths * feat(chalice): path analysis density * feat(chalice): session's replay ios events * feat(chalice): fixed typo * feat(chalice): support project's platform * feat(DB): support project's platform * feat(chalice): path analysis EE in progress * feat(chalice): project's platform API * feat(chalice): fixed create project * feat(chalice): EE path analysis in progress * feat(chalice): EE path analysis refactor(chalice): support specific database name for clickhouse-client * feat(chalice): upgraded dependencies feat(chalice): path analysis specific event type for startPoint feat(chalice): path analysis specific event type for endPoint feat(chalice): path analysis specific event type for exclude * refactoring(chalice): changed IOS click event type * refactoring(chalice): upgraded dependencies refactoring(alerts): upgraded dependencies refactoring(crons): upgraded dependencies refactoring(peers): upgraded dependencies refactoring(assist): upgraded dependencies refactoring(sourcemaps-reader): upgraded dependencies * refactoring(chalice): upgraded dependencies refactoring(alerts): upgraded dependencies refactoring(crons): upgraded dependencies refactoring(peers): upgraded dependencies refactoring(assist): upgraded dependencies refactoring(sourcemaps-reader): upgraded dependencies * feat(DB): rearranged queries feat(DB): ready for v1.15.0 * refactor(chalice): upgraded dependencies refactor(crons): upgraded dependencies refactor(alerts): upgraded dependencies * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies * fix(chalice): remove urllib3 dependency * feat(chalice): remove FOSS to pydantic v2 * fix(chalice): freeze urllib3 to not have conflicts between boto3 and requests * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress * feat(chalice): refactoring schema in progress feat(chalice): upgraded dependencies * feat(chalice): refactored schema * fix(chalice): pull rebase dev * feat(DB): transfer size support * feat(chalice): support service account * feat(chalice): support service account * fix(chalice): fixed refactored PayloadSchema-name * feat(chalice): path analysis * feat(DB): timezone support * feat(chalice): upgraded dependencies feat(alerts): upgraded dependencies feat(crons): upgraded dependencies feat(assist): upgraded dependencies feat(sourcemaps): upgraded dependencies * feat(chalice): path analysis schema changes * feat(chalice): path analysis query change * feat(chalice): path analysis query change * feat(chalice): path analysis changes * feat(chalice): upgraded dependencies * feat(chalice): simple hide minor paths * feat(chalice): path analysis density * feat(chalice): support project's platform * feat(chalice): upgraded dependencies feat(chalice): path analysis specific event type for startPoint feat(chalice): path analysis specific event type for endPoint feat(chalice): path analysis specific event type for exclude * refactoring(chalice): migrated the rest of schema to pydantic v2 * refactoring(chalice): upgraded dependencies refactoring(alerts): upgraded dependencies refactoring(crons): upgraded dependencies refactoring(peers): upgraded dependencies refactoring(assist): upgraded dependencies refactoring(sourcemaps-reader): upgraded dependencies * refactoring(chalice): upgraded dependencies refactoring(alerts): upgraded dependencies refactoring(crons): upgraded dependencies refactoring(peers): upgraded dependencies refactoring(assist): upgraded dependencies refactoring(sourcemaps-reader): upgraded dependencies --- api/schemas/schemas.py | 15 +---- .../db/init_dbs/postgresql/init_schema.sql | 67 ++++++++----------- 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index 7b72241b7..6dc2706db 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -1557,26 +1557,13 @@ class ClickMapSessionsSearch(SessionsSearchPayloadSchema): # return values -class IssueFilterType(str, Enum): - _selector = "CLICK_SELECTOR" - - -class IssueAdvancedFilter(BaseModel): - type: IssueFilterType = Field(default=IssueFilterType._selector) - value: List[str] = Field(default=[]) - operator: SearchEventOperator = Field(default=SearchEventOperator._is) - - class ClickMapFilterSchema(BaseModel): value: List[Literal[IssueType.click_rage, IssueType.dead_click]] = Field(default=[]) type: Literal[FilterType.issue] = Field(...) operator: Literal[SearchEventOperator._is, MathOperator._equal] = Field(...) - # source: Optional[Union[ErrorSource, str]] = Field(default=None) - filters: List[IssueAdvancedFilter] = Field(default=[]) class GetHeatmapPayloadSchema(_TimedSchema): - startTimestamp: int = Field(default=TimeUTC.now(delta_days=-30)) url: str = Field(...) # issues: List[Literal[IssueType.click_rage, IssueType.dead_click]] = Field(default=[]) filters: List[ClickMapFilterSchema] = Field(default=[]) @@ -1635,5 +1622,5 @@ class FeatureFlagSchema(BaseModel): flag_type: FeatureFlagType = Field(default=FeatureFlagType.single_variant) is_persist: Optional[bool] = Field(default=False) is_active: Optional[bool] = Field(default=True) - conditions: List[FeatureFlagCondition] = Field(default=[]) + conditions: List[FeatureFlagCondition] = Field(default=[], min_length=1) variants: List[FeatureFlagVariant] = Field(default=[]) diff --git a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql index 1d3c3567a..f8eb1ef43 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -1,5 +1,4 @@ BEGIN; --- Schemas and functions definitions: CREATE SCHEMA IF NOT EXISTS events_common; CREATE SCHEMA IF NOT EXISTS events; CREATE EXTENSION IF NOT EXISTS pg_trgm; @@ -8,7 +7,7 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto; CREATE OR REPLACE FUNCTION openreplay_version() RETURNS text AS $$ -SELECT 'v1.15.0-ee' +SELECT 'v1.14.0-ee' $$ LANGUAGE sql IMMUTABLE; @@ -31,6 +30,7 @@ end; $$ LANGUAGE plpgsql; + CREATE OR REPLACE FUNCTION events.funnel(steps integer[], m integer) RETURNS boolean AS $$ DECLARE @@ -55,6 +55,7 @@ END; $$ LANGUAGE plpgsql IMMUTABLE; + CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS $$ BEGIN @@ -70,6 +71,7 @@ END; $$ LANGUAGE plpgsql; + CREATE OR REPLACE FUNCTION notify_alert() RETURNS trigger AS $$ DECLARE @@ -94,7 +96,7 @@ BEGIN END; $$ LANGUAGE plpgsql; --- All tables and types: + DO $$ @@ -107,7 +109,6 @@ $$ ('dashboards'), ('dashboard_widgets'), ('errors'), - ('errors_tags'), ('integrations'), ('issues'), ('jira_cloud'), @@ -497,21 +498,6 @@ $$ CREATE INDEX IF NOT EXISTS user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id); CREATE INDEX IF NOT EXISTS user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id); - CREATE TABLE IF NOT EXISTS errors_tags - ( - key text NOT NULL, - value text NOT NULL, - created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), - error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, - session_id bigint NOT NULL, - message_id bigint NOT NULL, - FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE - ); - - CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id); - CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id); - CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id); - IF NOT EXISTS(SELECT * FROM pg_type typ WHERE typ.typname = 'platform') THEN @@ -577,11 +563,11 @@ $$ watchdogs_score bigint NOT NULL DEFAULT 0, issue_score bigint NOT NULL DEFAULT 0, issue_types issue_type[] NOT NULL DEFAULT '{}'::issue_type[], - utm_source text NULL DEFAULT NULL, - utm_medium text NULL DEFAULT NULL, - utm_campaign text NULL DEFAULT NULL, - referrer text NULL DEFAULT NULL, - base_referrer text NULL DEFAULT NULL, + utm_source text DEFAULT NULL, + utm_medium text DEFAULT NULL, + utm_campaign text DEFAULT NULL, + referrer text DEFAULT NULL, + base_referrer text DEFAULT NULL, file_key bytea DEFAULT NULL, metadata_1 text DEFAULT NULL, metadata_2 text DEFAULT NULL, @@ -842,7 +828,6 @@ $$ config jsonb NOT NULL DEFAULT '{}'::jsonb ); - CREATE TABLE IF NOT EXISTS searches ( search_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, @@ -941,9 +926,9 @@ $$ ( feature_flag_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE, + name text NOT NULL, flag_key text NOT NULL, - description text DEFAULT NULL, - payload jsonb DEFAULT NULL, + description text NOT NULL, flag_type text NOT NULL, is_persist boolean NOT NULL DEFAULT FALSE, is_active boolean NOT NULL DEFAULT FALSE, @@ -956,9 +941,6 @@ $$ CREATE INDEX IF NOT EXISTS idx_feature_flags_project_id ON public.feature_flags (project_id); - ALTER TABLE feature_flags - ADD CONSTRAINT unique_project_flag_deleted UNIQUE (project_id, flag_key, deleted_at); - CREATE TABLE IF NOT EXISTS public.feature_flags_conditions ( condition_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, @@ -968,16 +950,6 @@ $$ filters jsonb NOT NULL DEFAULT '[]'::jsonb ); - CREATE TABLE IF NOT EXISTS public.feature_flags_variants - ( - variant_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY, - feature_flag_id integer NOT NULL REFERENCES feature_flags (feature_flag_id) ON DELETE CASCADE, - value text NOT NULL, - description text DEFAULT NULL, - payload jsonb DEFAULT NULL, - rollout_percentage integer DEFAULT 0 - ); - CREATE TABLE IF NOT EXISTS public.sessions_feature_flags ( session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE, @@ -1126,6 +1098,21 @@ $$ CREATE INDEX IF NOT EXISTS errors_error_id_timestamp_session_id_idx ON events.errors (error_id, timestamp, session_id); CREATE INDEX IF NOT EXISTS errors_error_id_idx ON events.errors (error_id); + CREATE TABLE IF NOT EXISTS errors_tags + ( + key text NOT NULL, + value text NOT NULL, + created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), + error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, + session_id bigint NOT NULL, + message_id bigint NOT NULL, + FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id); + CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id); + CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id); + IF NOT EXISTS(SELECT * FROM pg_type typ WHERE typ.typname = 'http_method') THEN