-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Deprecate analytics & transcript methods in favor of API endpo…
…ints (#29427)
- Loading branch information
Showing
12 changed files
with
328 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
"@rocket.chat/rest-typings": patch | ||
--- | ||
|
||
Deprecate `livechat:getOverviewData` and `livechat:getAgentOverviewData` methods and create API endpoints `livechat/analytics/overview` and `livechat/analytics/agent-overview` to fetch analytics data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Users } from '@rocket.chat/models'; | ||
import { isLivechatAnalyticsAgentOverviewProps, isLivechatAnalyticsOverviewProps } from '@rocket.chat/rest-typings'; | ||
|
||
import { API } from '../../../../api/server'; | ||
import { settings } from '../../../../settings/server'; | ||
import { Livechat } from '../../lib/Livechat'; | ||
|
||
API.v1.addRoute( | ||
'livechat/analytics/agent-overview', | ||
{ | ||
authRequired: true, | ||
permissionsRequired: ['view-livechat-manager'], | ||
validateParams: isLivechatAnalyticsAgentOverviewProps, | ||
}, | ||
{ | ||
async get() { | ||
const { name, departmentId, from, to } = this.queryParams; | ||
|
||
if (!name) { | ||
throw new Error('invalid-chart-name'); | ||
} | ||
|
||
const user = await Users.findOneById(this.userId, { projection: { _id: 1, utcOffset: 1 } }); | ||
return API.v1.success( | ||
await Livechat.Analytics.getAgentOverviewData({ | ||
departmentId, | ||
utcOffset: user?.utcOffset || 0, | ||
daterange: { from, to }, | ||
chartOptions: { name }, | ||
}), | ||
); | ||
}, | ||
}, | ||
); | ||
|
||
API.v1.addRoute( | ||
'livechat/analytics/overview', | ||
{ | ||
authRequired: true, | ||
permissionsRequired: ['view-livechat-manager'], | ||
validateParams: isLivechatAnalyticsOverviewProps, | ||
}, | ||
{ | ||
async get() { | ||
const { name, departmentId, from, to } = this.queryParams; | ||
|
||
if (!name) { | ||
throw new Error('invalid-chart-name'); | ||
} | ||
|
||
const user = await Users.findOneById(this.userId, { projection: { _id: 1, utcOffset: 1 } }); | ||
const language = user?.language || settings.get('Language') || 'en'; | ||
|
||
return API.v1.success( | ||
await Livechat.Analytics.getAnalyticsOverviewData({ | ||
departmentId, | ||
utcOffset: user?.utcOffset || 0, | ||
daterange: { from, to }, | ||
analyticsOptions: { name }, | ||
language, | ||
}), | ||
); | ||
}, | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.