當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。