Changes:
- fixed sentry-issue-reporter - fixed telemetry reporter - fixed DB schema
This commit is contained in:
parent
dc455f807a
commit
3fb4f6e05c
3 changed files with 143 additions and 138 deletions
13
api/app.py
13
api/app.py
|
|
@ -70,19 +70,24 @@ def asayer_middleware(event, get_response):
|
|||
import time
|
||||
now = int(time.time() * 1000)
|
||||
response = get_response(event)
|
||||
if response.status_code == 500 and helper.allow_sentry() and ASAYER_SESSION_ID is not None and not helper.is_local():
|
||||
with configure_scope() as scope:
|
||||
scope.set_tag('stage', environ["stage"])
|
||||
scope.set_tag('asayer_session_id', ASAYER_SESSION_ID)
|
||||
scope.set_extra("context", event.context)
|
||||
sentry_sdk.capture_exception(Exception(response.body))
|
||||
if helper.TRACK_TIME:
|
||||
print(f"Execution time: {int(time.time() * 1000) - now} ms")
|
||||
except Exception as e:
|
||||
print("middleware exception handling")
|
||||
print(e)
|
||||
pg_client.close()
|
||||
if helper.allow_sentry() and ASAYER_SESSION_ID is not None and not helper.is_local():
|
||||
with configure_scope() as scope:
|
||||
scope.set_tag('stage', environ["stage"])
|
||||
scope.set_tag('openReplaySessionToken', ASAYER_SESSION_ID)
|
||||
scope.set_extra("context", event.context)
|
||||
sentry_sdk.capture_exception(e)
|
||||
raise e
|
||||
response = Response(body={"Code": "InternalServerError",
|
||||
"Message": "An internal server error occurred [level=Fatal]."},
|
||||
status_code=500)
|
||||
pg_client.close()
|
||||
return response
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def compute():
|
|||
RETURNING *,(SELECT email FROM public.users WHERE role='owner' LIMIT 1);"""
|
||||
)
|
||||
data = cur.fetchone()
|
||||
requests.post('https://parrot.asayer.io/os/telemetry', json=process_data(data))
|
||||
requests.post('https://parrot.asayer.io/os/telemetry', json={"stats": [process_data(data)]})
|
||||
|
||||
|
||||
def new_client():
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|||
CREATE OR REPLACE FUNCTION generate_api_key(length integer) RETURNS text AS
|
||||
$$
|
||||
declare
|
||||
chars text[] := ''{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}'';
|
||||
result text := '''';
|
||||
chars text[] := '{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}';
|
||||
result text := '';
|
||||
i integer := 0;
|
||||
begin
|
||||
if length < 0 then
|
||||
raise exception ''Given length cannot be less than 0'';
|
||||
raise exception 'Given length cannot be less than 0';
|
||||
end if;
|
||||
for i in 1..length
|
||||
loop
|
||||
|
|
@ -31,7 +31,7 @@ CREATE TABLE public.tenants
|
|||
user_id text NOT NULL DEFAULT generate_api_key(20),
|
||||
name text NOT NULL,
|
||||
api_key text NOT NULL DEFAULT generate_api_key(20),
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone ''utc''),
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
edition varchar(3) NOT NULL,
|
||||
version_number text NOT NULL,
|
||||
license text NULL,
|
||||
|
|
@ -43,80 +43,80 @@ CREATE TABLE public.tenants
|
|||
CONSTRAINT onerow_uni CHECK (tenant_id = 1)
|
||||
);
|
||||
|
||||
CREATE TYPE user_role AS ENUM (''owner'', ''admin'', ''member'');
|
||||
CREATE TYPE user_role AS ENUM ('owner', 'admin', 'member');
|
||||
|
||||
CREATE TABLE users
|
||||
(
|
||||
user_id integer generated BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
email text NOT NULL UNIQUE,
|
||||
role user_role NOT NULL DEFAULT ''member'',
|
||||
role user_role NOT NULL DEFAULT 'member',
|
||||
name text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone ''utc''),
|
||||
created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
appearance jsonb NOT NULL default ''{
|
||||
"role": "dev",
|
||||
"dashboard": {
|
||||
"cpu": false,
|
||||
"fps": false,
|
||||
"avgCpu": false,
|
||||
"avgFps": false,
|
||||
"errors": true,
|
||||
"crashes": false,
|
||||
"overview": true,
|
||||
"sessions": true,
|
||||
"topMetrics": true,
|
||||
"callsErrors": false,
|
||||
"pageMetrics": true,
|
||||
"performance": true,
|
||||
"timeToRender": false,
|
||||
"userActivity": false,
|
||||
"avgFirstPaint": false,
|
||||
"countSessions": false,
|
||||
"errorsPerType": false,
|
||||
"slowestImages": true,
|
||||
"speedLocation": false,
|
||||
"slowestDomains": false,
|
||||
"avgPageLoadTime": false,
|
||||
"avgTillFirstBit": false,
|
||||
"avgTimeToRender": false,
|
||||
"avgVisitedPages": false,
|
||||
"avgImageLoadTime": false,
|
||||
"busiestTimeOfDay": true,
|
||||
"errorsPerDomains": false,
|
||||
"missingResources": false,
|
||||
"resourcesByParty": false,
|
||||
"sessionsFeedback": false,
|
||||
"slowestResources": false,
|
||||
"avgUsedJsHeapSize": false,
|
||||
"domainsErrors_4xx": false,
|
||||
"domainsErrors_5xx": false,
|
||||
"memoryConsumption": false,
|
||||
"pagesDomBuildtime": false,
|
||||
"pagesResponseTime": false,
|
||||
"avgRequestLoadTime": false,
|
||||
"avgSessionDuration": false,
|
||||
"sessionsPerBrowser": false,
|
||||
"applicationActivity": true,
|
||||
"sessionsFrustration": false,
|
||||
"avgPagesDomBuildtime": false,
|
||||
"avgPagesResponseTime": false,
|
||||
"avgTimeToInteractive": false,
|
||||
"resourcesCountByType": false,
|
||||
"resourcesLoadingTime": false,
|
||||
"avgDomContentLoadStart": false,
|
||||
"avgFirstContentfulPixel": false,
|
||||
"resourceTypeVsResponseEnd": false,
|
||||
"impactedSessionsByJsErrors": false,
|
||||
"impactedSessionsBySlowPages": false,
|
||||
"resourcesVsVisuallyComplete": false,
|
||||
"pagesResponseTimeDistribution": false
|
||||
},
|
||||
"sessionsLive": false,
|
||||
"sessionsDevtools": true
|
||||
}''::jsonb,
|
||||
appearance jsonb NOT NULL default '{
|
||||
"role": "dev",
|
||||
"dashboard": {
|
||||
"cpu": false,
|
||||
"fps": false,
|
||||
"avgCpu": false,
|
||||
"avgFps": false,
|
||||
"errors": true,
|
||||
"crashes": false,
|
||||
"overview": true,
|
||||
"sessions": true,
|
||||
"topMetrics": true,
|
||||
"callsErrors": false,
|
||||
"pageMetrics": true,
|
||||
"performance": true,
|
||||
"timeToRender": false,
|
||||
"userActivity": false,
|
||||
"avgFirstPaint": false,
|
||||
"countSessions": false,
|
||||
"errorsPerType": false,
|
||||
"slowestImages": true,
|
||||
"speedLocation": false,
|
||||
"slowestDomains": false,
|
||||
"avgPageLoadTime": false,
|
||||
"avgTillFirstBit": false,
|
||||
"avgTimeToRender": false,
|
||||
"avgVisitedPages": false,
|
||||
"avgImageLoadTime": false,
|
||||
"busiestTimeOfDay": true,
|
||||
"errorsPerDomains": false,
|
||||
"missingResources": false,
|
||||
"resourcesByParty": false,
|
||||
"sessionsFeedback": false,
|
||||
"slowestResources": false,
|
||||
"avgUsedJsHeapSize": false,
|
||||
"domainsErrors_4xx": false,
|
||||
"domainsErrors_5xx": false,
|
||||
"memoryConsumption": false,
|
||||
"pagesDomBuildtime": false,
|
||||
"pagesResponseTime": false,
|
||||
"avgRequestLoadTime": false,
|
||||
"avgSessionDuration": false,
|
||||
"sessionsPerBrowser": false,
|
||||
"applicationActivity": true,
|
||||
"sessionsFrustration": false,
|
||||
"avgPagesDomBuildtime": false,
|
||||
"avgPagesResponseTime": false,
|
||||
"avgTimeToInteractive": false,
|
||||
"resourcesCountByType": false,
|
||||
"resourcesLoadingTime": false,
|
||||
"avgDomContentLoadStart": false,
|
||||
"avgFirstContentfulPixel": false,
|
||||
"resourceTypeVsResponseEnd": false,
|
||||
"impactedSessionsByJsErrors": false,
|
||||
"impactedSessionsBySlowPages": false,
|
||||
"resourcesVsVisuallyComplete": false,
|
||||
"pagesResponseTimeDistribution": false
|
||||
},
|
||||
"sessionsLive": false,
|
||||
"sessionsDevtools": true
|
||||
}'::jsonb,
|
||||
api_key text UNIQUE default generate_api_key(20) not null,
|
||||
jwt_iat timestamp without time zone NULL DEFAULT NULL,
|
||||
data jsonb NOT NULL DEFAULT ''{}''::jsonb,
|
||||
data jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
weekly_report boolean NOT NULL DEFAULT TRUE
|
||||
);
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ CREATE TABLE basic_authentication
|
|||
UNIQUE (user_id)
|
||||
);
|
||||
|
||||
CREATE TYPE oauth_provider AS ENUM (''jira'', ''github'');
|
||||
CREATE TYPE oauth_provider AS ENUM ('jira', 'github');
|
||||
CREATE TABLE oauth_authentication
|
||||
(
|
||||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
|
|
@ -150,7 +150,7 @@ CREATE TABLE projects
|
|||
name text NOT NULL,
|
||||
active boolean NOT NULL,
|
||||
sample_rate smallint NOT NULL DEFAULT 100 CHECK (sample_rate >= 0 AND sample_rate <= 100),
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone ''utc''),
|
||||
created_at timestamp without time zone NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
deleted_at timestamp without time zone NULL DEFAULT NULL,
|
||||
max_session_duration integer NOT NULL DEFAULT 7200000,
|
||||
metadata_1 text DEFAULT NULL,
|
||||
|
|
@ -163,18 +163,18 @@ CREATE TABLE projects
|
|||
metadata_8 text DEFAULT NULL,
|
||||
metadata_9 text DEFAULT NULL,
|
||||
metadata_10 text DEFAULT NULL,
|
||||
gdpr jsonb NOT NULL DEFAULT ''{
|
||||
gdpr jsonb NOT NULL DEFAULT '{
|
||||
"maskEmails": true,
|
||||
"sampleRate": 33,
|
||||
"maskNumbers": false,
|
||||
"defaultInputMode": "plain"
|
||||
}''::jsonb -- ??????
|
||||
}'::jsonb -- ??????
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION notify_project() RETURNS trigger AS
|
||||
$$
|
||||
BEGIN
|
||||
PERFORM pg_notify(''project'', row_to_json(NEW)::text);
|
||||
PERFORM pg_notify('project', row_to_json(NEW)::text);
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
|
@ -187,7 +187,7 @@ EXECUTE PROCEDURE notify_project();
|
|||
|
||||
-- --- alerts.sql ---
|
||||
|
||||
CREATE TYPE alert_detection_method AS ENUM (''threshold'', ''change'');
|
||||
CREATE TYPE alert_detection_method AS ENUM ('threshold', 'change');
|
||||
|
||||
CREATE TABLE alerts
|
||||
(
|
||||
|
|
@ -199,10 +199,10 @@ CREATE TABLE alerts
|
|||
detection_method alert_detection_method NOT NULL,
|
||||
query jsonb NOT NULL,
|
||||
deleted_at timestamp NULL DEFAULT NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone(''utc''::text, now()),
|
||||
options jsonb NOT NULL DEFAULT ''{
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
options jsonb NOT NULL DEFAULT '{
|
||||
"renotifyInterval": 1440
|
||||
}''::jsonb
|
||||
}'::jsonb
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -212,11 +212,11 @@ DECLARE
|
|||
clone jsonb;
|
||||
BEGIN
|
||||
clone = to_jsonb(NEW);
|
||||
clone = jsonb_set(clone, ''{created_at}'', to_jsonb(CAST(EXTRACT(epoch FROM NEW.created_at) * 1000 AS BIGINT)));
|
||||
clone = jsonb_set(clone, '{created_at}', to_jsonb(CAST(EXTRACT(epoch FROM NEW.created_at) * 1000 AS BIGINT)));
|
||||
IF NEW.deleted_at NOTNULL THEN
|
||||
clone = jsonb_set(clone, ''{deleted_at}'', to_jsonb(CAST(EXTRACT(epoch FROM NEW.deleted_at) * 1000 AS BIGINT)));
|
||||
clone = jsonb_set(clone, '{deleted_at}', to_jsonb(CAST(EXTRACT(epoch FROM NEW.deleted_at) * 1000 AS BIGINT)));
|
||||
END IF;
|
||||
PERFORM pg_notify(''alert'', clone::text);
|
||||
PERFORM pg_notify('alert', clone::text);
|
||||
RETURN NEW;
|
||||
END ;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
|
@ -230,7 +230,7 @@ EXECUTE PROCEDURE notify_alert();
|
|||
|
||||
-- --- webhooks.sql ---
|
||||
|
||||
create type webhook_type as enum (''webhook'', ''slack'', ''email'');
|
||||
create type webhook_type as enum ('webhook', 'slack', 'email');
|
||||
|
||||
create table webhooks
|
||||
(
|
||||
|
|
@ -238,7 +238,7 @@ create table webhooks
|
|||
constraint webhooks_pkey
|
||||
primary key,
|
||||
endpoint text not null,
|
||||
created_at timestamp default timezone(''utc''::text, now()) not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp,
|
||||
auth_header text,
|
||||
type webhook_type not null,
|
||||
|
|
@ -258,8 +258,8 @@ CREATE TABLE notifications
|
|||
button_text varchar(80) NULL,
|
||||
button_url text NULL,
|
||||
image_url text NULL,
|
||||
created_at timestamp NOT NULL DEFAULT timezone(''utc''::text, now()),
|
||||
options jsonb NOT NULL DEFAULT ''{}''::jsonb
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc'::text, now()),
|
||||
options jsonb NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX notifications_user_id_index ON notifications (user_id);
|
||||
|
|
@ -282,7 +282,7 @@ CREATE TABLE funnels
|
|||
user_id integer NOT NULL REFERENCES users (user_id) ON DELETE CASCADE,
|
||||
name text not null,
|
||||
filter jsonb not null,
|
||||
created_at timestamp default timezone(''utc''::text, now()) not null,
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
deleted_at timestamp,
|
||||
is_public boolean NOT NULL DEFAULT False
|
||||
);
|
||||
|
|
@ -291,7 +291,7 @@ CREATE INDEX ON public.funnels (user_id, is_public);
|
|||
|
||||
-- --- announcements.sql ---
|
||||
|
||||
create type announcement_type as enum (''notification'', ''alert'');
|
||||
create type announcement_type as enum ('notification', 'alert');
|
||||
|
||||
create table announcements
|
||||
(
|
||||
|
|
@ -303,19 +303,19 @@ create table announcements
|
|||
button_text varchar(30),
|
||||
button_url text,
|
||||
image_url text,
|
||||
created_at timestamp default timezone(''utc''::text, now()) not null,
|
||||
type announcement_type default ''notification''::announcement_type not null
|
||||
created_at timestamp default timezone('utc'::text, now()) not null,
|
||||
type announcement_type default 'notification'::announcement_type not null
|
||||
);
|
||||
|
||||
-- --- integrations.sql ---
|
||||
|
||||
CREATE TYPE integration_provider AS ENUM (''bugsnag'', ''cloudwatch'', ''datadog'', ''newrelic'', ''rollbar'', ''sentry'', ''stackdriver'', ''sumologic'', ''elasticsearch''); --, ''jira'', ''github'');
|
||||
CREATE TYPE integration_provider AS ENUM ('bugsnag', 'cloudwatch', 'datadog', 'newrelic', 'rollbar', 'sentry', 'stackdriver', 'sumologic', 'elasticsearch'); --, 'jira', 'github');
|
||||
CREATE TABLE integrations
|
||||
(
|
||||
project_id integer NOT NULL REFERENCES projects (project_id) ON DELETE CASCADE,
|
||||
provider integration_provider NOT NULL,
|
||||
options jsonb NOT NULL,
|
||||
request_data jsonb NOT NULL DEFAULT ''{}''::jsonb,
|
||||
request_data jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
PRIMARY KEY (project_id, provider)
|
||||
);
|
||||
|
||||
|
|
@ -323,9 +323,9 @@ CREATE OR REPLACE FUNCTION notify_integration() RETURNS trigger AS
|
|||
$$
|
||||
BEGIN
|
||||
IF NEW IS NULL THEN
|
||||
PERFORM pg_notify(''integration'', (row_to_json(OLD)::text || ''{"options": null, "request_data": null}''::text));
|
||||
PERFORM pg_notify('integration', (row_to_json(OLD)::text || '{"options": null, "request_data": null}'::text));
|
||||
ELSIF (OLD IS NULL) OR (OLD.options <> NEW.options) THEN
|
||||
PERFORM pg_notify(''integration'', row_to_json(NEW)::text);
|
||||
PERFORM pg_notify('integration', row_to_json(NEW)::text);
|
||||
END IF;
|
||||
RETURN NULL;
|
||||
END;
|
||||
|
|
@ -354,25 +354,25 @@ create table jira_cloud
|
|||
-- --- issues.sql ---
|
||||
|
||||
CREATE TYPE issue_type AS ENUM (
|
||||
''click_rage'',
|
||||
''dead_click'',
|
||||
''excessive_scrolling'',
|
||||
''bad_request'',
|
||||
''missing_resource'',
|
||||
''memory'',
|
||||
''cpu'',
|
||||
''slow_resource'',
|
||||
''slow_page_load'',
|
||||
''crash'',
|
||||
''ml_cpu'',
|
||||
''ml_memory'',
|
||||
''ml_dead_click'',
|
||||
''ml_click_rage'',
|
||||
''ml_mouse_thrashing'',
|
||||
''ml_excessive_scrolling'',
|
||||
''ml_slow_resources'',
|
||||
''custom'',
|
||||
''js_exception''
|
||||
'click_rage',
|
||||
'dead_click',
|
||||
'excessive_scrolling',
|
||||
'bad_request',
|
||||
'missing_resource',
|
||||
'memory',
|
||||
'cpu',
|
||||
'slow_resource',
|
||||
'slow_page_load',
|
||||
'crash',
|
||||
'ml_cpu',
|
||||
'ml_memory',
|
||||
'ml_dead_click',
|
||||
'ml_click_rage',
|
||||
'ml_mouse_thrashing',
|
||||
'ml_excessive_scrolling',
|
||||
'ml_slow_resources',
|
||||
'custom',
|
||||
'js_exception'
|
||||
);
|
||||
|
||||
CREATE TABLE issues
|
||||
|
|
@ -388,8 +388,8 @@ CREATE INDEX issues_context_string_gin_idx ON public.issues USING GIN (context_s
|
|||
|
||||
-- --- errors.sql ---
|
||||
|
||||
CREATE TYPE error_source AS ENUM (''js_exception'', ''bugsnag'', ''cloudwatch'', ''datadog'', ''newrelic'', ''rollbar'', ''sentry'', ''stackdriver'', ''sumologic'');
|
||||
CREATE TYPE error_status AS ENUM (''unresolved'', ''resolved'', ''ignored'');
|
||||
CREATE TYPE error_source AS ENUM ('js_exception', 'bugsnag', 'cloudwatch', 'datadog', 'newrelic', 'rollbar', 'sentry', 'stackdriver', 'sumologic');
|
||||
CREATE TYPE error_status AS ENUM ('unresolved', 'resolved', 'ignored');
|
||||
CREATE TABLE errors
|
||||
(
|
||||
error_id text NOT NULL PRIMARY KEY,
|
||||
|
|
@ -398,7 +398,7 @@ CREATE TABLE errors
|
|||
name text DEFAULT NULL,
|
||||
message text NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
status error_status NOT NULL DEFAULT ''unresolved'',
|
||||
status error_status NOT NULL DEFAULT 'unresolved',
|
||||
parent_error_id text DEFAULT NULL REFERENCES errors (error_id) ON DELETE SET NULL,
|
||||
stacktrace jsonb, --to save the stacktrace and not query S3 another time
|
||||
stacktrace_parsed_at timestamp
|
||||
|
|
@ -428,9 +428,9 @@ CREATE INDEX user_viewed_errors_error_id_idx ON public.user_viewed_errors (error
|
|||
|
||||
-- --- sessions.sql ---
|
||||
|
||||
CREATE TYPE device_type AS ENUM (''desktop'', ''tablet'', ''mobile'', ''other'');
|
||||
CREATE TYPE country AS ENUM (''UN'', ''RW'', ''SO'', ''YE'', ''IQ'', ''SA'', ''IR'', ''CY'', ''TZ'', ''SY'', ''AM'', ''KE'', ''CD'', ''DJ'', ''UG'', ''CF'', ''SC'', ''JO'', ''LB'', ''KW'', ''OM'', ''QA'', ''BH'', ''AE'', ''IL'', ''TR'', ''ET'', ''ER'', ''EG'', ''SD'', ''GR'', ''BI'', ''EE'', ''LV'', ''AZ'', ''LT'', ''SJ'', ''GE'', ''MD'', ''BY'', ''FI'', ''AX'', ''UA'', ''MK'', ''HU'', ''BG'', ''AL'', ''PL'', ''RO'', ''XK'', ''ZW'', ''ZM'', ''KM'', ''MW'', ''LS'', ''BW'', ''MU'', ''SZ'', ''RE'', ''ZA'', ''YT'', ''MZ'', ''MG'', ''AF'', ''PK'', ''BD'', ''TM'', ''TJ'', ''LK'', ''BT'', ''IN'', ''MV'', ''IO'', ''NP'', ''MM'', ''UZ'', ''KZ'', ''KG'', ''TF'', ''HM'', ''CC'', ''PW'', ''VN'', ''TH'', ''ID'', ''LA'', ''TW'', ''PH'', ''MY'', ''CN'', ''HK'', ''BN'', ''MO'', ''KH'', ''KR'', ''JP'', ''KP'', ''SG'', ''CK'', ''TL'', ''RU'', ''MN'', ''AU'', ''CX'', ''MH'', ''FM'', ''PG'', ''SB'', ''TV'', ''NR'', ''VU'', ''NC'', ''NF'', ''NZ'', ''FJ'', ''LY'', ''CM'', ''SN'', ''CG'', ''PT'', ''LR'', ''CI'', ''GH'', ''GQ'', ''NG'', ''BF'', ''TG'', ''GW'', ''MR'', ''BJ'', ''GA'', ''SL'', ''ST'', ''GI'', ''GM'', ''GN'', ''TD'', ''NE'', ''ML'', ''EH'', ''TN'', ''ES'', ''MA'', ''MT'', ''DZ'', ''FO'', ''DK'', ''IS'', ''GB'', ''CH'', ''SE'', ''NL'', ''AT'', ''BE'', ''DE'', ''LU'', ''IE'', ''MC'', ''FR'', ''AD'', ''LI'', ''JE'', ''IM'', ''GG'', ''SK'', ''CZ'', ''NO'', ''VA'', ''SM'', ''IT'', ''SI'', ''ME'', ''HR'', ''BA'', ''AO'', ''NA'', ''SH'', ''BV'', ''BB'', ''CV'', ''GY'', ''GF'', ''SR'', ''PM'', ''GL'', ''PY'', ''UY'', ''BR'', ''FK'', ''GS'', ''JM'', ''DO'', ''CU'', ''MQ'', ''BS'', ''BM'', ''AI'', ''TT'', ''KN'', ''DM'', ''AG'', ''LC'', ''TC'', ''AW'', ''VG'', ''VC'', ''MS'', ''MF'', ''BL'', ''GP'', ''GD'', ''KY'', ''BZ'', ''SV'', ''GT'', ''HN'', ''NI'', ''CR'', ''VE'', ''EC'', ''CO'', ''PA'', ''HT'', ''AR'', ''CL'', ''BO'', ''PE'', ''MX'', ''PF'', ''PN'', ''KI'', ''TK'', ''TO'', ''WF'', ''WS'', ''NU'', ''MP'', ''GU'', ''PR'', ''VI'', ''UM'', ''AS'', ''CA'', ''US'', ''PS'', ''RS'', ''AQ'', ''SX'', ''CW'', ''BQ'', ''SS'');
|
||||
CREATE TYPE platform AS ENUM (''web'',''ios'',''android'');
|
||||
CREATE TYPE device_type AS ENUM ('desktop', 'tablet', 'mobile', 'other');
|
||||
CREATE TYPE country AS ENUM ('UN', 'RW', 'SO', 'YE', 'IQ', 'SA', 'IR', 'CY', 'TZ', 'SY', 'AM', 'KE', 'CD', 'DJ', 'UG', 'CF', 'SC', 'JO', 'LB', 'KW', 'OM', 'QA', 'BH', 'AE', 'IL', 'TR', 'ET', 'ER', 'EG', 'SD', 'GR', 'BI', 'EE', 'LV', 'AZ', 'LT', 'SJ', 'GE', 'MD', 'BY', 'FI', 'AX', 'UA', 'MK', 'HU', 'BG', 'AL', 'PL', 'RO', 'XK', 'ZW', 'ZM', 'KM', 'MW', 'LS', 'BW', 'MU', 'SZ', 'RE', 'ZA', 'YT', 'MZ', 'MG', 'AF', 'PK', 'BD', 'TM', 'TJ', 'LK', 'BT', 'IN', 'MV', 'IO', 'NP', 'MM', 'UZ', 'KZ', 'KG', 'TF', 'HM', 'CC', 'PW', 'VN', 'TH', 'ID', 'LA', 'TW', 'PH', 'MY', 'CN', 'HK', 'BN', 'MO', 'KH', 'KR', 'JP', 'KP', 'SG', 'CK', 'TL', 'RU', 'MN', 'AU', 'CX', 'MH', 'FM', 'PG', 'SB', 'TV', 'NR', 'VU', 'NC', 'NF', 'NZ', 'FJ', 'LY', 'CM', 'SN', 'CG', 'PT', 'LR', 'CI', 'GH', 'GQ', 'NG', 'BF', 'TG', 'GW', 'MR', 'BJ', 'GA', 'SL', 'ST', 'GI', 'GM', 'GN', 'TD', 'NE', 'ML', 'EH', 'TN', 'ES', 'MA', 'MT', 'DZ', 'FO', 'DK', 'IS', 'GB', 'CH', 'SE', 'NL', 'AT', 'BE', 'DE', 'LU', 'IE', 'MC', 'FR', 'AD', 'LI', 'JE', 'IM', 'GG', 'SK', 'CZ', 'NO', 'VA', 'SM', 'IT', 'SI', 'ME', 'HR', 'BA', 'AO', 'NA', 'SH', 'BV', 'BB', 'CV', 'GY', 'GF', 'SR', 'PM', 'GL', 'PY', 'UY', 'BR', 'FK', 'GS', 'JM', 'DO', 'CU', 'MQ', 'BS', 'BM', 'AI', 'TT', 'KN', 'DM', 'AG', 'LC', 'TC', 'AW', 'VG', 'VC', 'MS', 'MF', 'BL', 'GP', 'GD', 'KY', 'BZ', 'SV', 'GT', 'HN', 'NI', 'CR', 'VE', 'EC', 'CO', 'PA', 'HT', 'AR', 'CL', 'BO', 'PE', 'MX', 'PF', 'PN', 'KI', 'TK', 'TO', 'WF', 'WS', 'NU', 'MP', 'GU', 'PR', 'VI', 'UM', 'AS', 'CA', 'US', 'PS', 'RS', 'AQ', 'SX', 'CW', 'BQ', 'SS');
|
||||
CREATE TYPE platform AS ENUM ('web','ios','android');
|
||||
|
||||
CREATE TABLE sessions
|
||||
(
|
||||
|
|
@ -440,7 +440,7 @@ CREATE TABLE sessions
|
|||
start_ts bigint NOT NULL,
|
||||
duration integer NOT NULL,
|
||||
rev_id text DEFAULT NULL,
|
||||
platform platform NOT NULL DEFAULT ''web'',
|
||||
platform platform NOT NULL DEFAULT 'web',
|
||||
is_snippet boolean NOT NULL DEFAULT FALSE,
|
||||
user_id text DEFAULT NULL,
|
||||
user_anonymous_id text DEFAULT NULL,
|
||||
|
|
@ -460,7 +460,7 @@ CREATE TABLE sessions
|
|||
errors_count integer NOT NULL DEFAULT 0,
|
||||
watchdogs_score bigint NOT NULL DEFAULT 0,
|
||||
issue_score bigint NOT NULL DEFAULT 0,
|
||||
issue_types issue_type[] NOT NULL DEFAULT ''{}''::issue_type[],
|
||||
issue_types issue_type[] NOT NULL DEFAULT '{}'::issue_type[],
|
||||
metadata_1 text DEFAULT NULL,
|
||||
metadata_2 text DEFAULT NULL,
|
||||
metadata_3 text DEFAULT NULL,
|
||||
|
|
@ -513,15 +513,15 @@ CREATE INDEX sessions_start_ts_idx ON public.sessions (start_ts) WHERE duration
|
|||
CREATE INDEX sessions_project_id_idx ON public.sessions (project_id) WHERE duration > 0;
|
||||
|
||||
ALTER TABLE public.sessions
|
||||
ADD CONSTRAINT web_browser_constraint CHECK ( (sessions.platform = ''web'' AND sessions.user_browser NOTNULL) OR
|
||||
(sessions.platform != ''web'' AND sessions.user_browser ISNULL));
|
||||
ADD CONSTRAINT web_browser_constraint CHECK ( (sessions.platform = 'web' AND sessions.user_browser NOTNULL) OR
|
||||
(sessions.platform != 'web' AND sessions.user_browser ISNULL));
|
||||
|
||||
ALTER TABLE public.sessions
|
||||
ADD CONSTRAINT web_user_browser_version_constraint CHECK ( sessions.platform = ''web'' OR sessions.user_browser_version ISNULL);
|
||||
ADD CONSTRAINT web_user_browser_version_constraint CHECK ( sessions.platform = 'web' OR sessions.user_browser_version ISNULL);
|
||||
|
||||
ALTER TABLE public.sessions
|
||||
ADD CONSTRAINT web_user_agent_constraint CHECK ( (sessions.platform = ''web'' AND sessions.user_agent NOTNULL) OR
|
||||
(sessions.platform != ''web'' AND sessions.user_agent ISNULL));
|
||||
ADD CONSTRAINT web_user_agent_constraint CHECK ( (sessions.platform = 'web' AND sessions.user_agent NOTNULL) OR
|
||||
(sessions.platform != 'web' AND sessions.user_agent ISNULL));
|
||||
|
||||
|
||||
|
||||
|
|
@ -547,15 +547,15 @@ create table assigned_sessions
|
|||
issue_id text NOT NULL,
|
||||
provider oauth_provider NOT NULL,
|
||||
created_by integer NOT NULL,
|
||||
created_at timestamp default timezone(''utc''::text, now()) NOT NULL,
|
||||
provider_data jsonb default ''{}''::jsonb NOT NULL
|
||||
created_at timestamp default timezone('utc'::text, now()) NOT NULL,
|
||||
provider_data jsonb default '{}'::jsonb NOT NULL
|
||||
);
|
||||
|
||||
-- --- events_common.sql ---
|
||||
|
||||
CREATE SCHEMA events_common;
|
||||
|
||||
CREATE TYPE events_common.custom_level AS ENUM (''info'',''error'');
|
||||
CREATE TYPE events_common.custom_level AS ENUM ('info','error');
|
||||
|
||||
CREATE TABLE events_common.customs
|
||||
(
|
||||
|
|
@ -564,7 +564,7 @@ CREATE TABLE events_common.customs
|
|||
seq_index integer NOT NULL,
|
||||
name text NOT NULL,
|
||||
payload jsonb NOT NULL,
|
||||
level events_common.custom_level NOT NULL DEFAULT ''info'',
|
||||
level events_common.custom_level NOT NULL DEFAULT 'info',
|
||||
PRIMARY KEY (session_id, timestamp, seq_index)
|
||||
);
|
||||
CREATE INDEX ON events_common.customs (name);
|
||||
|
|
@ -598,9 +598,9 @@ CREATE INDEX ON events_common.requests (duration);
|
|||
CREATE INDEX requests_url_gin_idx ON events_common.requests USING GIN (url gin_trgm_ops);
|
||||
CREATE INDEX ON events_common.requests (timestamp);
|
||||
CREATE INDEX requests_url_gin_idx2 ON events_common.requests USING GIN (RIGHT(url, length(url) - (CASE
|
||||
WHEN url LIKE ''http://%''
|
||||
WHEN url LIKE 'http://%'
|
||||
THEN 7
|
||||
WHEN url LIKE ''https://%''
|
||||
WHEN url LIKE 'https://%'
|
||||
THEN 8
|
||||
ELSE 0 END))
|
||||
gin_trgm_ops);
|
||||
|
|
@ -640,9 +640,9 @@ CREATE INDEX pages_base_path_idx ON events.pages (base_path);
|
|||
CREATE INDEX pages_base_path_idx2 ON events.pages (RIGHT(base_path, length(base_path) - 1));
|
||||
CREATE INDEX pages_base_referrer_idx ON events.pages (base_referrer);
|
||||
CREATE INDEX pages_base_referrer_gin_idx2 ON events.pages USING GIN (RIGHT(base_referrer, length(base_referrer) - (CASE
|
||||
WHEN base_referrer LIKE ''http://%''
|
||||
WHEN base_referrer LIKE 'http://%'
|
||||
THEN 7
|
||||
WHEN base_referrer LIKE ''https://%''
|
||||
WHEN base_referrer LIKE 'https://%'
|
||||
THEN 8
|
||||
ELSE 0 END))
|
||||
gin_trgm_ops);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue