From ce6a5e34493dbaee398e16f63ad362c388706f70 Mon Sep 17 00:00:00 2001 From: KRAIEM Taha Yassine Date: Tue, 11 May 2021 18:42:02 +0200 Subject: [PATCH] Changes: - cleaned env-vars - changed chalice.yaml env-vars --- api/.chalice/config.json | 8 ---- api/chalicelib/blueprints/bp_core.py | 8 +++- api/chalicelib/core/issues.py | 55 ++++++++++++++++++++++++- api/chalicelib/utils/helper.py | 6 +-- ee/api/.chalice/config.json | 10 ----- ee/api/chalicelib/blueprints/bp_core.py | 8 +++- ee/api/chalicelib/core/issues.py | 55 ++++++++++++++++++++++++- ee/api/chalicelib/utils/helper.py | 6 +-- scripts/helm/app/chalice.yaml | 36 ++++++++++++++++ 9 files changed, 160 insertions(+), 32 deletions(-) diff --git a/api/.chalice/config.json b/api/.chalice/config.json index 8048eae73..0e47dc608 100644 --- a/api/.chalice/config.json +++ b/api/.chalice/config.json @@ -15,8 +15,6 @@ "isEE": "false", "stage": "default-fos", "jwt_issuer": "openreplay-default-fos", - "allowCron": "true", - "sentry": "false", "sentryURL": "", "pg_host": "postgresql.db.svc.cluster.local", "pg_port": "5432", @@ -28,16 +26,10 @@ "email_funnel": "http://127.0.0.1:8000/async/funnel/%s", "email_basic": "http://127.0.0.1:8000/async/basic/%s", "assign_link": "http://127.0.0.1:8000/async/email_assignment", - "verification_link": "http://127.0.0.1:8000/email/validate/", - "verification_success_redirect": "", - "verification_fail_redirect": "", "captcha_server": "", "captcha_key": "", - "jira_api": "http://127.0.0.1:3000/dev", - "github_api": "http://127.0.0.1:4000/dev", "sessions_bucket": "", "sessions_region": "", - "stack_reader": "", "put_S3_TTL": "20", "sourcemaps_bucket": "", "sourcemaps_bucket_key": "", diff --git a/api/chalicelib/blueprints/bp_core.py b/api/chalicelib/blueprints/bp_core.py index f2ca10746..3b2910606 100644 --- a/api/chalicelib/blueprints/bp_core.py +++ b/api/chalicelib/blueprints/bp_core.py @@ -870,7 +870,13 @@ def get_weekly_report_config(context): @app.route('/{projectId}/issue_types', methods=['GET']) def issue_types(projectId, context): - return {"data": issues.get_types(project_id=projectId)} + # return {"data": issues.get_types_by_project(project_id=projectId)} + return {"data": issues.get_all_types()} + + +@app.route('/issue_types', methods=['GET']) +def all_issue_types(context): + return {"data": issues.get_all_types()} @app.route('/flows', methods=['GET', 'PUT', 'POST', 'DELETE']) diff --git a/api/chalicelib/core/issues.py b/api/chalicelib/core/issues.py index 61a6946da..e1aa54712 100644 --- a/api/chalicelib/core/issues.py +++ b/api/chalicelib/core/issues.py @@ -58,7 +58,7 @@ def get_by_session_id(session_id, issue_type=None): return helper.list_to_camel_case(cur.fetchall()) -def get_types(project_id): +def get_types_by_project(project_id): with pg_client.PostgresClient() as cur: cur.execute( cur.mogrify(f"""SELECT type, @@ -70,3 +70,56 @@ def get_types(project_id): WHERE project_id = %(project_id)s) AS types ORDER BY "order";""", {"project_id": project_id})) return helper.list_to_camel_case(cur.fetchall()) + + +def get_all_types(): + return [ + { + "type": "js_exception", + "visible": True, + "order": 0, + "name": "Errors" + }, + { + "type": "bad_request", + "visible": True, + "order": 1, + "name": "Bad Requests" + }, + { + "type": "missing_resource", + "visible": True, + "order": 2, + "name": "Missing Images" + }, + { + "type": "click_rage", + "visible": True, + "order": 3, + "name": "Click Rage" + }, + { + "type": "dead_click", + "visible": True, + "order": 4, + "name": "Dead Clicks" + }, + { + "type": "memory", + "visible": True, + "order": 5, + "name": "High Memory" + }, + { + "type": "cpu", + "visible": True, + "order": 6, + "name": "High CPU" + }, + { + "type": "crash", + "visible": True, + "order": 7, + "name": "Crashes" + } + ] diff --git a/api/chalicelib/utils/helper.py b/api/chalicelib/utils/helper.py index a75e13bd8..58b071061 100644 --- a/api/chalicelib/utils/helper.py +++ b/api/chalicelib/utils/helper.py @@ -134,17 +134,13 @@ def __sbool_to_bool(value): return value.lower() in ["true", "yes", "1"] -def allow_cron(): - return "allowCron" not in environ or __sbool_to_bool(environ["allowCron"]) - - def allow_captcha(): return environ.get("captcha_server") is not None and environ.get("captcha_key") is not None \ and len(environ["captcha_server"]) > 0 and len(environ["captcha_key"]) > 0 def allow_sentry(): - return "sentry" not in environ or __sbool_to_bool(environ["sentry"]) + return environ.get("sentryURL") is not None and len(environ["sentryURL"]) > 0 def async_post(endpoint, data): diff --git a/ee/api/.chalice/config.json b/ee/api/.chalice/config.json index 155657b67..4136e6ee0 100644 --- a/ee/api/.chalice/config.json +++ b/ee/api/.chalice/config.json @@ -15,8 +15,6 @@ "isEE": "true", "stage": "default-ee", "jwt_issuer": "openreplay-default-ee", - "allowCron": "true", - "sentry": "false", "sentryURL": "", "pg_host": "127.0.0.1", "pg_port": "9202", @@ -31,24 +29,16 @@ "email_plans": "http://127.0.0.1:8000/async/plans/%s", "email_basic": "http://127.0.0.1:8000/async/basic/%s", "assign_link": "http://127.0.0.1:8000/async/email_assignment", - "verification_link": "http://127.0.0.1:8000/email/validate/", - "verification_success_redirect": "", - "verification_fail_redirect": "", "captcha_server": "", "captcha_key": "", - "jira_api": "http://127.0.0.1:3000/dev", - "github_api": "http://127.0.0.1:4000/dev", "sessions_bucket": "asayer-mobs-staging", "sessions_region": "eu-central-1", - "stack_reader": "", "put_S3_TTL": "20", "sourcemaps_bucket": "", "sourcemaps_bucket_key": "", "sourcemaps_bucket_secret": "", "sourcemaps_bucket_region": "", "js_cache_bucket": "", - "SIGN_ID": "", - "SIGN_KEY": "", "async_Token": "", "EMAIL_HOST": "", "EMAIL_PORT": "587", diff --git a/ee/api/chalicelib/blueprints/bp_core.py b/ee/api/chalicelib/blueprints/bp_core.py index f2ca10746..3b2910606 100644 --- a/ee/api/chalicelib/blueprints/bp_core.py +++ b/ee/api/chalicelib/blueprints/bp_core.py @@ -870,7 +870,13 @@ def get_weekly_report_config(context): @app.route('/{projectId}/issue_types', methods=['GET']) def issue_types(projectId, context): - return {"data": issues.get_types(project_id=projectId)} + # return {"data": issues.get_types_by_project(project_id=projectId)} + return {"data": issues.get_all_types()} + + +@app.route('/issue_types', methods=['GET']) +def all_issue_types(context): + return {"data": issues.get_all_types()} @app.route('/flows', methods=['GET', 'PUT', 'POST', 'DELETE']) diff --git a/ee/api/chalicelib/core/issues.py b/ee/api/chalicelib/core/issues.py index 61a6946da..e1aa54712 100644 --- a/ee/api/chalicelib/core/issues.py +++ b/ee/api/chalicelib/core/issues.py @@ -58,7 +58,7 @@ def get_by_session_id(session_id, issue_type=None): return helper.list_to_camel_case(cur.fetchall()) -def get_types(project_id): +def get_types_by_project(project_id): with pg_client.PostgresClient() as cur: cur.execute( cur.mogrify(f"""SELECT type, @@ -70,3 +70,56 @@ def get_types(project_id): WHERE project_id = %(project_id)s) AS types ORDER BY "order";""", {"project_id": project_id})) return helper.list_to_camel_case(cur.fetchall()) + + +def get_all_types(): + return [ + { + "type": "js_exception", + "visible": True, + "order": 0, + "name": "Errors" + }, + { + "type": "bad_request", + "visible": True, + "order": 1, + "name": "Bad Requests" + }, + { + "type": "missing_resource", + "visible": True, + "order": 2, + "name": "Missing Images" + }, + { + "type": "click_rage", + "visible": True, + "order": 3, + "name": "Click Rage" + }, + { + "type": "dead_click", + "visible": True, + "order": 4, + "name": "Dead Clicks" + }, + { + "type": "memory", + "visible": True, + "order": 5, + "name": "High Memory" + }, + { + "type": "cpu", + "visible": True, + "order": 6, + "name": "High CPU" + }, + { + "type": "crash", + "visible": True, + "order": 7, + "name": "Crashes" + } + ] diff --git a/ee/api/chalicelib/utils/helper.py b/ee/api/chalicelib/utils/helper.py index a75e13bd8..58b071061 100644 --- a/ee/api/chalicelib/utils/helper.py +++ b/ee/api/chalicelib/utils/helper.py @@ -134,17 +134,13 @@ def __sbool_to_bool(value): return value.lower() in ["true", "yes", "1"] -def allow_cron(): - return "allowCron" not in environ or __sbool_to_bool(environ["allowCron"]) - - def allow_captcha(): return environ.get("captcha_server") is not None and environ.get("captcha_key") is not None \ and len(environ["captcha_server"]) > 0 and len(environ["captcha_key"]) > 0 def allow_sentry(): - return "sentry" not in environ or __sbool_to_bool(environ["sentry"]) + return environ.get("sentryURL") is not None and len(environ["sentryURL"]) > 0 def async_post(endpoint, data): diff --git a/scripts/helm/app/chalice.yaml b/scripts/helm/app/chalice.yaml index 56cef6e80..22d856453 100644 --- a/scripts/helm/app/chalice.yaml +++ b/scripts/helm/app/chalice.yaml @@ -26,3 +26,39 @@ env: pg_dbname: postgres pg_user: postgres pg_password: asayerPostgres + ch_host: '' + ch_port: '' + alert_ntf: http://127.0.0.1:8000/async/alerts/notifications/%s + email_signup: http://127.0.0.1:8000/async/email_signup/%s + email_funnel: http://127.0.0.1:8000/async/funnel/%s + email_plans: http://127.0.0.1:8000/async/plans/%s + email_basic: http://127.0.0.1:8000/async/basic/%s + assign_link: http://127.0.0.1:8000/async/email_assignment + captcha_server: '' + captcha_key: '' + sessions_bucket: asayer-mobs-staging + sessions_region: eu-central-1 + put_S3_TTL: '20' + sourcemaps_bucket: '' + sourcemaps_bucket_key: '' + sourcemaps_bucket_secret: '' + sourcemaps_bucket_region: '' + js_cache_bucket: '' + async_Token: '' + EMAIL_HOST: '' + EMAIL_PORT: '587' + EMAIL_USER: '' + EMAIL_PASSWORD: '' + EMAIL_USE_TLS: 'true' + EMAIL_USE_SSL: 'false' + EMAIL_SSL_KEY: '' + EMAIL_SSL_CERT: '' + EMAIL_FROM: OpenReplay + SITE_URL: '' + announcement_url: '' + jwt_secret: '' + jwt_algorithm: '' + jwt_exp_delta_seconds: '' + S3_HOST: '' + S3_KEY: '' + S3_SECRET: '' \ No newline at end of file