newrelic / nr1-community

An open-source library of useful components for building on New Relic One's programmability platform.
https://developer.newrelic.com
Apache License 2.0
11 stars 12 forks source link

Problem with "timeRangeToNrql" #98

Open rangakore opened 9 months ago

rangakore commented 9 months ago

Description

The Problem is "If I timeRangeToNrql functionality in my nerdlet, the UI is not getting rendering.

The below is showing in Visual Studio Code at import statement

Could not find a declaration file for module '@newrelic/nr1-community'. 'c:/SRE/test/testing/node_modules/@newrelic/nr1-community/dist/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/newrelic__nr1-community if it exists or add a new declaration (.d.ts) file containing declare module '@newrelic/nr1-community';

We are tyring to make use of "timeRangeToNrql" from "@newrelic/nr1-community" package in order to access default Datetimepicker provided by nerdpack. It was working until around 10/30/2023 10 AM EST. From chrome console we observed below error

Uncaught (in promise) ReferenceError: regeneratorRuntime is not defined
    at index.es.js:24:2303
    at index.es.js:24:3275
    at Module.<anonymous> (index.es.js:32:985)
    at ./node_modules/@newrelic/nr1-community/dist/index.es.js (vendors~feee8365-58d5-4e00-8de9-32ea9721a57f--home~latest.js:52549:30)
    at __webpack_require__ (bootstrap:82:1)
    at ./nerdlets/home/index.js (bootstrap:261:1)
    at __webpack_require__ (bootstrap:82:1)
    at Object.__factory (bootstrap:257:1)
    at z (3rd-app-fdec6153.js:1:3122530)
    at 3rd-app-fdec6153.js:1:2073654

If I comment below import

import { timeRangeToNrql } from '@newrelic/nr1-community'

then UI is getting rendered.

below is the sample code

import React from 'react';

import {
  LineChart,
  PlatformStateContext,
} from 'nr1'

import { timeRangeToNrql } from '@newrelic/nr1-community'

export default class HomeNerdlet extends React.Component {
  render() {
    let query = `from NrAiIncident SELECT count(*) where event = 'close' and tags.label.appname is not null facet dayOfMonthOf(timestamp), tags.label.appname`

    return (
      <>
        <PlatformStateContext.Consumer>
          {
            (PlatformState) =>  {
              const since = timeRangeToNrql(PlatformState)
              return (
                <LineChart
                  accountIds={[2327062]}
                  query={
                    query +
                    ' ' +
                    since +
                    'TIMESERIES AUTO'
                  }
                  fullWidth
                />
              )
            }
          }
        </PlatformStateContext.Consumer>
      </>
    )
  }
}

Steps to Reproduce

Expected Behaviour

Relevant Logs / Console output

Your Environment

Additional context

rangakore commented 9 months ago

For now, resolved the issue by changing to import to below

import { timeRangeToNrql } from '@newrelic/nr-labs-components'