本文整理汇总了TypeScript中ui/chrome.getInjected函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getInjected函数的具体用法?TypeScript getInjected怎么用?TypeScript getInjected使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getInjected函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: memoize
export const getAPMIndexPattern = memoize(async () => {
const apmIndexPatternTitle: string = chrome.getInjected(
'apmIndexPatternTitle'
);
const res = await callApi<ISavedObjectAPIResponse>({
pathname: `/api/saved_objects/_find`,
query: {
type: 'index-pattern',
search: `"${apmIndexPatternTitle}"`,
search_fields: 'title',
per_page: 200
}
});
return res.saved_objects.find(
savedObject => savedObject.attributes.title === apmIndexPatternTitle
);
});
示例2: createErrorGroupWatch
export async function createErrorGroupWatch({
emails = [],
schedule,
serviceName,
slackUrl,
threshold,
timeRange
}: Arguments) {
const id = `apm-${uuid.v4()}`;
const apmIndexPatternTitle = chrome.getInjected('apmIndexPatternTitle');
const slackUrlPath = getSlackPathUrl(slackUrl);
const emailTemplate = i18n.translate(
'xpack.apm.serviceDetails.enableErrorReportsPanel.emailTemplateText',
{
defaultMessage:
'Your service {serviceName} has error groups which exceeds {threshold} occurrences within {timeRange}{br}' +
'{br}' +
'{errorGroupsBuckets}{br}' +
'{errorLogMessage}{br}' +
'{errorCulprit}N/A{slashErrorCulprit}{br}' +
'{docCountParam} occurrences{br}' +
'{slashErrorGroupsBucket}',
values: {
serviceName: '"{{ctx.metadata.serviceName}}"',
threshold: '{{ctx.metadata.threshold}}',
timeRange:
'"{{ctx.metadata.timeRangeValue}}{{ctx.metadata.timeRangeUnit}}"',
errorGroupsBuckets:
'{{#ctx.payload.aggregations.error_groups.buckets}}',
errorLogMessage:
'<strong>{{sample.hits.hits.0._source.error.log.message}}{{^sample.hits.hits.0._source.error.log.message}}{{sample.hits.hits.0._source.error.exception.0.message}}{{/sample.hits.hits.0._source.error.log.message}}</strong>',
errorCulprit:
'{{sample.hits.hits.0._source.error.culprit}}{{^sample.hits.hits.0._source.error.culprit}}',
slashErrorCulprit: '{{/sample.hits.hits.0._source.error.culprit}}',
docCountParam: '{{doc_count}}',
slashErrorGroupsBucket:
'{{/ctx.payload.aggregations.error_groups.buckets}}',
br: '<br/>'
}
}
);
const slackTemplate = i18n.translate(
'xpack.apm.serviceDetails.enableErrorReportsPanel.slackTemplateText',
{
defaultMessage: `Your service {serviceName} has error groups which exceeds {threshold} occurrences within {timeRange}
{errorGroupsBuckets}
{errorLogMessage}
{errorCulprit}N/A{slashErrorCulprit}
{docCountParam} occurrences
{slashErrorGroupsBucket}`,
values: {
serviceName: '"{{ctx.metadata.serviceName}}"',
threshold: '{{ctx.metadata.threshold}}',
timeRange:
'"{{ctx.metadata.timeRangeValue}}{{ctx.metadata.timeRangeUnit}}"',
errorGroupsBuckets:
'{{#ctx.payload.aggregations.error_groups.buckets}}',
errorLogMessage:
'>*{{sample.hits.hits.0._source.error.log.message}}{{^sample.hits.hits.0._source.error.log.message}}{{sample.hits.hits.0._source.error.exception.0.message}}{{/sample.hits.hits.0._source.error.log.message}}*',
errorCulprit:
'>{{#sample.hits.hits.0._source.error.culprit}}`{{sample.hits.hits.0._source.error.culprit}}`{{/sample.hits.hits.0._source.error.culprit}}{{^sample.hits.hits.0._source.error.culprit}}',
slashErrorCulprit: '{{/sample.hits.hits.0._source.error.culprit}}',
docCountParam: '>{{doc_count}}',
slashErrorGroupsBucket:
'{{/ctx.payload.aggregations.error_groups.buckets}}'
}
}
);
const actions: Actions = {
log_error: { logging: { text: emailTemplate } }
};
const body = {
metadata: {
emails,
trigger: i18n.translate(
'xpack.apm.serviceDetails.enableErrorReportsPanel.triggerText',
{
defaultMessage: 'This value must be changed in trigger section'
}
),
serviceName,
threshold,
timeRangeValue: timeRange.value,
timeRangeUnit: timeRange.unit,
slackUrlPath
},
trigger: {
schedule
},
input: {
search: {
request: {
indices: [apmIndexPatternTitle],
body: {
size: 0,
query: {
//.........这里部分代码省略.........