DataDog / datadog-api-client-typescript

Typescript client for the Datadog API

Home Page:http://datadoghq.dev/datadog-api-client-typescript/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught Exceptions When Initializing Client

danwize opened this issue · comments

Uncaught exceptions in DatadogLibrary when trying to initialize api clients.

Label the issue properly.

  • Add severity/ label.
  • Add documentation label if this issue is related to documentation changes.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new react app: npx create-react-app system-status-display --template typescript
  2. Install the data dog client: npm install @datadog/datadog-api-client
  3. Create a Datadog.ts file like this:
    import { v1 } from "@datadog/datadog-api-client"; import { ConfigurationParameters } from "@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/configuration"; const configurationOptions:ConfigurationParameters = { //@ts-ignore debug: true, httpConfig:{ compress: false } } const configurtion = v1.createConfiguration(configurationOptions); const apiInstance = new v1.SyntheticsApi(configurtion); export const getSyntheticTests = async ()=>{ let tests = await apiInstance.listTests(); return tests.tests; }
  4. Call the getSyntheticTestsMethod from App.tsx. Add this code inside the App component
    const getStuffFromDataDog = useEffect(()=>{ let serviceGroups:ServiceGroup[] = []; let apiServiceGroup: ServiceGroup = { name: "Apis", services: [] }; let datadogSynthetics = getSyntheticTests(); //set up x api stuff let belleXApiService: Service = { name: "X API", status:ServiceStatus.Good }; });
  5. When the Datadog client is initalized, I see this exception in the javascript console:

Uncaught ReferenceError: process is not defined
at Object../node_modules/@datadog/datadog-api-client/dist/userAgent.js (userAgent.ts:4)
at Object.options.factory (react refresh:6)
at webpack_require (bootstrap:24)
at fn (hot module replacement:61)
at Object../node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/http/http.js (http.ts:1)
at Object.options.factory (react refresh:6)
at webpack_require (bootstrap:24)
at fn (hot module replacement:61)
at Object../node_modules/@datadog/datadog-api-client/dist/packages/datadog-api-client-v1/index.js (index.ts:1)
at Object.options.factory (react refresh:6)

Expected behavior
DataDog api client should initialize and return the list of synthetic tests.

Environment and Versions (please complete the following information):
node js project in visual studio code on windows 10. Chrome Browser:

  • react
  • typescript
  • @datadog/datadog-api-client": "^1.0.0-beta.6

system-status-display.zip

Does Datadog expose their open api json file so I can try generating a client?

Hi, for now this is a node only project, so it won't work in the browser as you noticed. The spec files are in https://github.com/DataDog/datadog-api-client-typescript/tree/master/.generator/schemas.

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

Should be fixed by #899