diff --git a/api/.chalice/config.json b/api/.chalice/config.json index 3b2960416..8385a17e7 100644 --- a/api/.chalice/config.json +++ b/api/.chalice/config.json @@ -33,9 +33,6 @@ "put_S3_TTL": "20", "sourcemaps_reader": "http://127.0.0.1:3000/", "sourcemaps_bucket": "sourcemaps", - "sourcemaps_bucket_key": "", - "sourcemaps_bucket_secret": "", - "sourcemaps_bucket_region": "us-east-1", "js_cache_bucket": "sessions-assets", "async_Token": "", "EMAIL_HOST": "", diff --git a/api/app.py b/api/app.py index 469d8a42f..52208c02b 100644 --- a/api/app.py +++ b/api/app.py @@ -39,7 +39,6 @@ class F: def tb_print_exception(etype, value, tb, limit=None, file=None, chain=True): if ASAYER_SESSION_ID is not None and not helper.is_local(): - # bugsnag.notify(Exception(str(value)), meta_data={"special_info": {"asayerSessionId": ASAYER_SESSION_ID}}) value = type(value)(f"[asayer_session_id={ASAYER_SESSION_ID}] " + str(value)) old_tb(etype, value, tb, limit, file, chain) diff --git a/api/chalicelib/blueprints/bp_core.py b/api/chalicelib/blueprints/bp_core.py index 3b2910606..bd42b2254 100644 --- a/api/chalicelib/blueprints/bp_core.py +++ b/api/chalicelib/blueprints/bp_core.py @@ -881,5 +881,5 @@ def all_issue_types(context): @app.route('/flows', methods=['GET', 'PUT', 'POST', 'DELETE']) @app.route('/{projectId}/flows', methods=['GET', 'PUT', 'POST', 'DELETE']) -def removed_endpoints(context): +def removed_endpoints(projectId=None, context=None): return Response(body={"errors": ["Endpoint no longer available"]}, status_code=410) diff --git a/api/chalicelib/blueprints/bp_core_dynamic.py b/api/chalicelib/blueprints/bp_core_dynamic.py index 989da2852..462954cb4 100644 --- a/api/chalicelib/blueprints/bp_core_dynamic.py +++ b/api/chalicelib/blueprints/bp_core_dynamic.py @@ -35,7 +35,7 @@ def login(): if helper.allow_captcha() and not captcha.is_valid(data["g-recaptcha-response"]): return {"errors": ["Invalid captcha."]} r = users.authenticate(data['email'], data['password'], - for_plugin= False + for_plugin=False ) if r is None: return { @@ -78,6 +78,7 @@ def get_account(context): } } + @app.route('/projects', methods=['GET']) def get_projects(context): return {"data": projects.get_projects(tenant_id=context["tenantId"], recording_state=True, gdpr=True, recorded=True, @@ -157,13 +158,29 @@ def add_slack_client(context): data = app.current_request.json_body if "url" not in data or "name" not in data: return {"errors": ["please provide a url and a name"]} - if Slack.add_integration(tenant_id=context["tenantId"], url=data["url"], name=data["name"]): + if Slack.add_channel(tenant_id=context["tenantId"], url=data["url"], name=data["name"]): return {"data": {"status": "success"}} else: return { - "errors": ["We couldn't send you a test message on your Slack channel. Please verify your webhook url."] + "errors": ["We couldn't send you a test message on your Slack channel. Please verify your webhook url."] } + +@app.route('/integrations/slack/{integrationId}', methods=['POST', 'PUT']) +def edit_slack_integration(integrationId, context): + data = app.current_request.json_body + if data.get("url") and len(data["url"]) > 0: + old = webhook.get(tenant_id=context["tenantId"], webhook_id=integrationId) + if old["endpoint"] != data["url"]: + if not Slack.say_hello(data["url"]): + return { + "errors": [ + "We couldn't send you a test message on your Slack channel. Please verify your webhook url."] + } + return {"data": webhook.update(tenant_id=context["tenantId"], webhook_id=integrationId, + changes={"name": data.get("name", ""), "endpoint": data["url"]})} + + @app.route('/{projectId}/errors/search', methods=['POST']) def errors_search(projectId, context): data = app.current_request.json_body @@ -387,6 +404,7 @@ def search_sessions_by_metadata(context): m_key=key, project_id=project_id)} + @app.route('/plans', methods=['GET']) def get_current_plan(context): return { diff --git a/api/chalicelib/core/collaboration_slack.py b/api/chalicelib/core/collaboration_slack.py index 5fc80511c..c7df5c5a6 100644 --- a/api/chalicelib/core/collaboration_slack.py +++ b/api/chalicelib/core/collaboration_slack.py @@ -6,10 +6,10 @@ from chalicelib.core import webhook class Slack: @classmethod - def add_integration(cls, tenant_id, **args): + def add_channel(cls, tenant_id, **args): url = args["url"] name = args["name"] - if cls.__say_hello(url): + if cls.say_hello(url): webhook.add(tenant_id=tenant_id, endpoint=url, webhook_type="slack", @@ -18,7 +18,7 @@ class Slack: return False @classmethod - def __say_hello(cls, url): + def say_hello(cls, url): r = requests.post( url=url, json={ diff --git a/api/chalicelib/core/events.py b/api/chalicelib/core/events.py index 65ade49ed..69213a079 100644 --- a/api/chalicelib/core/events.py +++ b/api/chalicelib/core/events.py @@ -365,7 +365,7 @@ def __get_merged_queries(queries, value, project_id): def __get_autocomplete_table(value, project_id): with pg_client.PostgresClient() as cur: cur.execute(cur.mogrify("""SELECT DISTINCT ON(value,type) project_id, value, type - FROM (SELECT * + FROM (SELECT project_id, type, value FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY type ORDER BY value) AS Row_ID FROM public.autocomplete diff --git a/api/chalicelib/core/sourcemaps_parser.py b/api/chalicelib/core/sourcemaps_parser.py index 81a1bd283..b7c17f3d3 100644 --- a/api/chalicelib/core/sourcemaps_parser.py +++ b/api/chalicelib/core/sourcemaps_parser.py @@ -8,12 +8,7 @@ def get_original_trace(key, positions): "key": key, "positions": positions, "padding": 5, - "bucket": environ['sourcemaps_bucket'], - "bucket_config": { - "aws_access_key_id": environ["sourcemaps_bucket_key"], - "aws_secret_access_key": environ["sourcemaps_bucket_secret"], - "aws_region": environ["sourcemaps_bucket_region"] - } + "bucket": environ['sourcemaps_bucket'] } r = requests.post(environ["sourcemaps_reader"], json=payload) if r.status_code != 200: diff --git a/api/chalicelib/core/webhook.py b/api/chalicelib/core/webhook.py index 99a3b0569..e622c2231 100644 --- a/api/chalicelib/core/webhook.py +++ b/api/chalicelib/core/webhook.py @@ -40,7 +40,7 @@ def get_by_type(tenant_id, webhook_type): cur.execute( cur.mogrify("""\ SELECT - w.webhook_id AS id,w.webhook_id,w.endpoint,w.auth_header,w.type,w.index,w.name,w.created_at + w.webhook_id AS integration_id, w.webhook_id AS id,w.webhook_id,w.endpoint,w.auth_header,w.type,w.index,w.name,w.created_at FROM public.webhooks AS w WHERE w.type =%(type)s AND deleted_at ISNULL;""", {"type": webhook_type}) diff --git a/api/requirements.txt b/api/requirements.txt index 094d32758..671aa5da5 100644 --- a/api/requirements.txt +++ b/api/requirements.txt @@ -5,9 +5,6 @@ pyjwt==1.7.1 psycopg2-binary==2.8.6 pytz==2020.1 sentry-sdk==0.19.1 -rollbar==0.15.1 -bugsnag==4.0.1 -kubernetes==12.0.0 elasticsearch==7.9.1 jira==2.0.0 schedule==1.1.0