* feat(DB): rearranged queries feat(DB): ready for v1.15.0 * 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 * 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(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
137 lines
5.5 KiB
Python
137 lines
5.5 KiB
Python
from chalicelib.core import roles, traces, assist_records, sessions
|
|
from chalicelib.core import unlock, signals
|
|
from chalicelib.core import sessions_insights
|
|
from chalicelib.utils import assist_helper
|
|
|
|
unlock.check()
|
|
|
|
from or_dependencies import OR_context
|
|
from routers.base import get_routers
|
|
import schemas
|
|
from fastapi import Depends, Body
|
|
|
|
public_app, app, app_apikey = get_routers()
|
|
|
|
|
|
@app.get('/client/roles', tags=["client", "roles"])
|
|
def get_roles(context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {
|
|
'data': roles.get_roles(tenant_id=context.tenant_id)
|
|
}
|
|
|
|
|
|
@app.post('/client/roles', tags=["client", "roles"])
|
|
@app.put('/client/roles', tags=["client", "roles"])
|
|
def add_role(data: schemas.RolePayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
data = roles.create(tenant_id=context.tenant_id, user_id=context.user_id, data=data)
|
|
if "errors" in data:
|
|
return data
|
|
|
|
return {
|
|
'data': data
|
|
}
|
|
|
|
|
|
@app.post('/client/roles/{roleId}', tags=["client", "roles"])
|
|
@app.put('/client/roles/{roleId}', tags=["client", "roles"])
|
|
def edit_role(roleId: int, data: schemas.RolePayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
data = roles.update(tenant_id=context.tenant_id, user_id=context.user_id, role_id=roleId, data=data)
|
|
if "errors" in data:
|
|
return data
|
|
|
|
return {
|
|
'data': data
|
|
}
|
|
|
|
|
|
@app.delete('/client/roles/{roleId}', tags=["client", "roles"])
|
|
def delete_role(roleId: int, _=Body(None), context: schemas.CurrentContext = Depends(OR_context)):
|
|
data = roles.delete(tenant_id=context.tenant_id, user_id=context.user_id, role_id=roleId)
|
|
if "errors" in data:
|
|
return data
|
|
return {
|
|
'data': data
|
|
}
|
|
|
|
|
|
@app.get('/config/assist/credentials', tags=["assist"])
|
|
@app.get('/assist/credentials', tags=["assist"])
|
|
def get_assist_credentials():
|
|
return {"data": assist_helper.get_full_config()}
|
|
|
|
|
|
@app.post('/trails', tags=["traces", "trails"])
|
|
def get_trails(data: schemas.TrailSearchPayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {
|
|
'data': traces.get_all(tenant_id=context.tenant_id, data=data)
|
|
}
|
|
|
|
|
|
@app.post('/trails/actions', tags=["traces", "trails"])
|
|
def get_available_trail_actions(context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {'data': traces.get_available_actions(tenant_id=context.tenant_id)}
|
|
|
|
|
|
@app.put('/{projectId}/assist/save', tags=["assist"])
|
|
def sign_record_for_upload(projectId: int, data: schemas.AssistRecordPayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
if not sessions.session_exists(project_id=projectId, session_id=data.session_id):
|
|
return {"errors": ["Session not found"]}
|
|
return {"data": assist_records.presign_record(project_id=projectId, data=data, context=context)}
|
|
|
|
|
|
@app.put('/{projectId}/assist/save/done', tags=["assist"])
|
|
def save_record_after_upload(projectId: int, data: schemas.AssistRecordSavePayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
if not sessions.session_exists(project_id=projectId, session_id=data.session_id):
|
|
return {"errors": ["Session not found"]}
|
|
return {"data": {"URL": assist_records.save_record(project_id=projectId, data=data, context=context)}}
|
|
|
|
|
|
@app.post('/{projectId}/assist/records', tags=["assist"])
|
|
def search_records(projectId: int, data: schemas.AssistRecordSearchPayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {"data": assist_records.search_records(project_id=projectId, data=data, context=context)}
|
|
|
|
|
|
@app.get('/{projectId}/assist/records/{recordId}', tags=["assist"])
|
|
def get_record(projectId: int, recordId: int, context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {"data": assist_records.get_record(project_id=projectId, record_id=recordId, context=context)}
|
|
|
|
|
|
@app.post('/{projectId}/assist/records/{recordId}', tags=["assist"])
|
|
def update_record(projectId: int, recordId: int, data: schemas.AssistRecordUpdatePayloadSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
result = assist_records.update_record(project_id=projectId, record_id=recordId, data=data, context=context)
|
|
if "errors" in result:
|
|
return result
|
|
return {"data": result}
|
|
|
|
|
|
@app.delete('/{projectId}/assist/records/{recordId}', tags=["assist"])
|
|
def delete_record(projectId: int, recordId: int, _=Body(None),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
result = assist_records.delete_record(project_id=projectId, record_id=recordId, context=context)
|
|
if "errors" in result:
|
|
return result
|
|
return {"data": result}
|
|
|
|
|
|
@app.post('/{projectId}/signals', tags=['signals'])
|
|
def send_interactions(projectId: int, data: schemas.SignalsSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
data = signals.handle_frontend_signals_queued(project_id=projectId, user_id=context.user_id, data=data)
|
|
|
|
if "errors" in data:
|
|
return data
|
|
return {'data': data}
|
|
|
|
|
|
@app.post('/{projectId}/dashboard/insights', tags=["insights"])
|
|
@app.post('/{projectId}/dashboard/insights', tags=["insights"])
|
|
def sessions_search(projectId: int, data: schemas.GetInsightsSchema = Body(...),
|
|
context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {'data': sessions_insights.fetch_selected(data=data, project_id=projectId)}
|