Mede por inbox/período: leads novos (1ª conversa do contato em qualquer inbox da rede), retorno (conversa anterior resolved há >24h) e outras (conversa anterior open ou resolved <24h). Categorias somadas batem com o conversations_count nativo do report — bucket "outras" garante o fechamento. - Novo builder V2::Reports::InboxLeadsSummaryBuilder com CTE única - Endpoint GET /api/v2/accounts/:id/reports/inbox_leads_summary - Tabs no InboxReportsShow (Visão Geral | Novas × Retorno) - Componente InboxLeadsReport com 3 metric cards + barras empilhadas - API client + Pinia (state/getters/actions/mutations) - i18n en + pt_BR - RSpec do builder cobrindo classificação e isolamento por inbox Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
126 lines
3.0 KiB
JavaScript
126 lines
3.0 KiB
JavaScript
/* global axios */
|
|
import ApiClient from './ApiClient';
|
|
|
|
const getTimeOffset = () => -new Date().getTimezoneOffset() / 60;
|
|
|
|
class ReportsAPI extends ApiClient {
|
|
constructor() {
|
|
super('reports', { accountScoped: true, apiVersion: 'v2' });
|
|
}
|
|
|
|
getReports({
|
|
metric,
|
|
from,
|
|
to,
|
|
type = 'account',
|
|
id,
|
|
groupBy,
|
|
businessHours,
|
|
}) {
|
|
return axios.get(`${this.url}`, {
|
|
params: {
|
|
metric,
|
|
since: from,
|
|
until: to,
|
|
type,
|
|
id,
|
|
group_by: groupBy,
|
|
business_hours: businessHours,
|
|
timezone_offset: getTimeOffset(),
|
|
},
|
|
});
|
|
}
|
|
|
|
// eslint-disable-next-line default-param-last
|
|
getSummary(since, until, type = 'account', id, groupBy, businessHours) {
|
|
return axios.get(`${this.url}/summary`, {
|
|
params: {
|
|
since,
|
|
until,
|
|
type,
|
|
id,
|
|
group_by: groupBy,
|
|
business_hours: businessHours,
|
|
timezone_offset: getTimeOffset(),
|
|
},
|
|
});
|
|
}
|
|
|
|
getConversationMetric(type = 'account', page = 1) {
|
|
return axios.get(`${this.url}/conversations`, {
|
|
params: {
|
|
type,
|
|
page,
|
|
},
|
|
});
|
|
}
|
|
|
|
getAgentReports({ from: since, to: until, businessHours }) {
|
|
return axios.get(`${this.url}/agents`, {
|
|
params: { since, until, business_hours: businessHours },
|
|
});
|
|
}
|
|
|
|
getConversationsSummaryReports({ from: since, to: until, businessHours }) {
|
|
return axios.get(`${this.url}/conversations_summary`, {
|
|
params: { since, until, business_hours: businessHours },
|
|
});
|
|
}
|
|
|
|
getConversationTrafficCSV({ daysBefore = 6 } = {}) {
|
|
return axios.get(`${this.url}/conversation_traffic`, {
|
|
params: { timezone_offset: getTimeOffset(), days_before: daysBefore },
|
|
});
|
|
}
|
|
|
|
getLabelReports({ from: since, to: until, businessHours }) {
|
|
return axios.get(`${this.url}/labels`, {
|
|
params: { since, until, business_hours: businessHours },
|
|
});
|
|
}
|
|
|
|
getInboxReports({ from: since, to: until, businessHours }) {
|
|
return axios.get(`${this.url}/inboxes`, {
|
|
params: { since, until, business_hours: businessHours },
|
|
});
|
|
}
|
|
|
|
getTeamReports({ from: since, to: until, businessHours }) {
|
|
return axios.get(`${this.url}/teams`, {
|
|
params: { since, until, business_hours: businessHours },
|
|
});
|
|
}
|
|
|
|
getBotMetrics({ from, to } = {}) {
|
|
return axios.get(`${this.url}/bot_metrics`, {
|
|
params: { since: from, until: to },
|
|
});
|
|
}
|
|
|
|
getBotSummary({ from, to, groupBy, businessHours } = {}) {
|
|
return axios.get(`${this.url}/bot_summary`, {
|
|
params: {
|
|
since: from,
|
|
until: to,
|
|
type: 'account',
|
|
group_by: groupBy,
|
|
business_hours: businessHours,
|
|
},
|
|
});
|
|
}
|
|
|
|
getInboxLeadsSummary({ inboxId, from, to, groupBy } = {}) {
|
|
return axios.get(`${this.url}/inbox_leads_summary`, {
|
|
params: {
|
|
inbox_id: inboxId,
|
|
since: from,
|
|
until: to,
|
|
group_by: groupBy,
|
|
timezone_offset: getTimeOffset(),
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
export default new ReportsAPI();
|