Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Batch export logs frontend #17605

Merged
merged 19 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import posthog from 'posthog-js'
import {
ActionType,
BatchExportLogEntry,
CohortType,
DashboardCollaboratorType,
DashboardTemplateEditorType,
Expand Down Expand Up @@ -541,6 +542,10 @@ class ApiRequest {
return this.batchExports(teamId).addPathComponent(id)
}

public batchExportLogs(id: BatchExportConfiguration['id'], teamId?: TeamType['id']): ApiRequest {
return this.batchExport(id, teamId).addPathComponent('logs')
}

public batchExportRuns(id: BatchExportConfiguration['id'], teamId?: TeamType['id']): ApiRequest {
return this.batchExports(teamId).addPathComponent(id).addPathComponent('runs')
}
Expand All @@ -553,6 +558,14 @@ class ApiRequest {
return this.batchExportRuns(id, teamId).addPathComponent(runId)
}

public batchExportRunLogs(
id: BatchExportConfiguration['id'],
runId: BatchExportRun['id'],
teamId?: TeamType['id']
): ApiRequest {
return this.batchExportRun(id, runId, teamId).addPathComponent('logs')
}

// Request finalization
public async get(options?: ApiMethodOptions): Promise<any> {
return await api.get(this.assembleFullUrl(), options)
Expand Down Expand Up @@ -1191,6 +1204,65 @@ const api = {
},
},

batchExportLogs: {
async search(
batchExportId: string,
currentTeamId: number | null,
searchTerm: string | null = null,
typeFilters: CheckboxValueType[] = [],
trailingEntry: BatchExportLogEntry | null = null,
leadingEntry: BatchExportLogEntry | null = null
): Promise<BatchExportLogEntry[]> {
const params = toParams(
{
limit: LOGS_PORTION_LIMIT,
type_filter: typeFilters,
search: searchTerm || undefined,
before: trailingEntry?.timestamp,
after: leadingEntry?.timestamp,
},
true
)

const response = await new ApiRequest()
.batchExportLogs(batchExportId, currentTeamId || undefined)
.withQueryString(params)
.get()

return response.results
},
},

batchExportRunLogs: {
async search(
batchExportId: string,
batchExportRunId: string,
currentTeamId: number | null,
searchTerm: string | null = null,
typeFilters: CheckboxValueType[] = [],
trailingEntry: BatchExportLogEntry | null = null,
leadingEntry: BatchExportLogEntry | null = null
): Promise<BatchExportLogEntry[]> {
const params = toParams(
{
limit: LOGS_PORTION_LIMIT,
type_filter: typeFilters,
search: searchTerm || undefined,
before: trailingEntry?.timestamp,
after: leadingEntry?.timestamp,
},
true
)

const response = await new ApiRequest()
.batchExportRunLogs(batchExportId, batchExportRunId, currentTeamId || undefined)
.withQueryString(params)
.get()

return response.results
},
},

annotations: {
async get(annotationId: RawAnnotationType['id']): Promise<RawAnnotationType> {
return await new ApiRequest().annotation(annotationId).get()
Expand Down
Loading
Loading