-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send List of Metric-Context to SearchMetrics endpoint (#46)
Replace metrics and context query with a list of metric (key, partial context) tuples sent to the SearchMetrics endpoint.
- Loading branch information
1 parent
0638dea
commit 134eab9
Showing
4 changed files
with
103 additions
and
46 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
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,39 @@ | ||
import { ISyntaxErrorDetails } from 'types/components/NotificationContainer/NotificationContainer'; | ||
import { ISelectConfig } from 'types/services/models/explorer/createAppModel'; | ||
|
||
import { jsValidVariableRegex } from 'utils/getObjectPaths'; | ||
|
||
import { formatValue } from '../formatValue'; | ||
|
||
export default function getMetricsListFromSelect( | ||
selectData: ISelectConfig, | ||
error?: ISyntaxErrorDetails, | ||
): Array<[string, string]> { | ||
const metricsList: Array<[string, string]> = []; | ||
|
||
if (selectData === undefined) { | ||
return metricsList; | ||
} | ||
|
||
selectData.options?.forEach((option) => { | ||
const metricName = option.value?.option_name ?? ''; | ||
const context: string = | ||
option.value?.context && Object.keys(option.value?.context).length > 0 | ||
? Object.keys(option.value?.context) | ||
.map((item) => { | ||
const contextKey = !jsValidVariableRegex.test(item) | ||
? `['${item}']` | ||
: `${item}`; | ||
const contextValue = (option.value?.context as any)[item]; | ||
return `{${formatValue(contextKey)}: ${formatValue( | ||
contextValue, | ||
)}}`; | ||
}) | ||
.join(', ') | ||
: '{}'; | ||
|
||
metricsList.push([metricName, context]); | ||
}); | ||
|
||
return metricsList; | ||
} |
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