-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathfetch-org-analytics.mts
More file actions
35 lines (30 loc) · 1.01 KB
/
Copy pathfetch-org-analytics.mts
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { handleApiCall } from '../../util/socket/api.mjs'
import { setupSdk } from '../../util/socket/sdk.mjs'
import type { CResult } from '../../types.mts'
import type { SetupSdkOptions } from '../../util/socket/sdk.mjs'
import type { SocketSdkSuccessResult } from '@socketsecurity/sdk-stable'
export type FetchOrgAnalyticsDataOptions = {
commandPath?: string | undefined
sdkOpts?: SetupSdkOptions | undefined
}
export async function fetchOrgAnalyticsData(
time: number,
options?: FetchOrgAnalyticsDataOptions | undefined,
): Promise<CResult<SocketSdkSuccessResult<'getOrgAnalytics'>['data']>> {
const { commandPath, sdkOpts } = {
__proto__: null,
...options,
} as FetchOrgAnalyticsDataOptions
const sockSdkCResult = await setupSdk(sdkOpts)
if (!sockSdkCResult.ok) {
return sockSdkCResult
}
const sockSdk = sockSdkCResult.data
return await handleApiCall<'getOrgAnalytics'>(
sockSdk.getOrgAnalytics(time.toString()),
{
commandPath,
description: 'analytics data',
},
)
}