Skip to content

Commit

Permalink
Switch to the new insights API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kshmidt-digma committed Jun 12, 2023
1 parent 7e1a80a commit a6cc42d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions backend/analyticsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class AnalyticsProvider {
}
}

async getInsights(codeObjectIds, environment) {
async getInsights(spanCodeObjectId, environment) {
try {
const response = await this.send(
"POST",
`/CodeAnalytics/codeObjects/insights`,
`/CodeAnalytics/codeObjects/insights_of_single`,
undefined,
{
codeObjectIds,
spanCodeObjectId,
environment,
}
);
Expand Down
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.post("/environments/:environmentId/assets", async function (req, res) {
app.post("/insights", async function (req, res) {
try {
const insights = await analyticsProvider.getInsights(
req.body.codeObjectIds,
req.body.spanCodeObjectId,
req.body.environment
);
res.send(insights);
Expand Down
19 changes: 7 additions & 12 deletions ui/src/components/Assets/AssetInsights/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
import {
AssetInsightsProps,
CodeObjectInsight,
GetInsightsResponse,
InsightGroup,
SpanInsight,
} from "./types";
Expand Down Expand Up @@ -214,11 +215,7 @@ export const AssetInsights = (props: AssetInsightsProps) => {

const assetTypeInfo = getAssetTypeInfo(props.assetEntry.assetType);

const codeObjectIds = [props.assetEntry.span.spanCodeObjectId];

if (props.assetEntry.span.methodCodeObjectId) {
codeObjectIds.push(`method:${props.assetEntry.span.methodCodeObjectId}`);
}
const spanCodeObjectId = props.assetEntry.span.spanCodeObjectId;

const handleAssetsLinkClick = () => {
props.onGoToAssetsPage(props.assetEntry);
Expand All @@ -229,19 +226,17 @@ export const AssetInsights = (props: AssetInsightsProps) => {
};

const fetchInsights = async () => {
const insights = (await ddClient.extension.vm?.service?.post("/insights", {
codeObjectIds,
const response = (await ddClient.extension.vm?.service?.post("/insights", {
spanCodeObjectId,
environment: props.environment,
})) as CodeObjectInsight[];
})) as GetInsightsResponse;

console.debug(
`Insights for asset with ids [${codeObjectIds
.map((x) => `"${x}"`)
.join(", ")}] have been fetched:`,
`Insights for asset with id "${spanCodeObjectId}" have been fetched:`,
insights
);

const sortedInsights = [...insights].sort(
const sortedInsights = [...response.insights].sort(
(a, b) =>
getInsightTypeOrderPriority(a.type) -
getInsightTypeOrderPriority(b.type)
Expand Down
7 changes: 7 additions & 0 deletions ui/src/components/Assets/AssetInsights/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export interface InsightWithLinksProps {
onAssetSelect: (asset: ExtendedAssetEntry) => void;
}

export interface GetInsightsResponse {
accountId: string;
environment: string;
spanCodeObjectId: string;
insights: CodeObjectInsight[];
}

export interface InsightGroup {
insights: CodeObjectInsight[];
name?: string;
Expand Down

0 comments on commit a6cc42d

Please sign in to comment.