当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chrome.getInjected函数代码示例

本文整理汇总了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
  );
});
开发者ID:elastic,项目名称:kibana,代码行数:18,代码来源:savedObjects.ts

示例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: {
//.........这里部分代码省略.........
开发者ID:lucabelluccini,项目名称:kibana,代码行数:101,代码来源:createErrorGroupWatch.ts


注:本文中的ui/chrome.getInjected函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。