- changed requirements
- changed slack add integration
- added slack edit integration
- removed sourcemaps_reader extra payload
This commit is contained in:
KRAIEM Taha Yassine 2021-05-20 16:12:56 +02:00
parent e4689e213a
commit dc455f807a
9 changed files with 28 additions and 22 deletions

View file

@ -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": "",

View file

@ -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)

View file

@ -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)

View file

@ -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 {

View file

@ -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={

View file

@ -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

View file

@ -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:

View file

@ -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})

View file

@ -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