DataDog / datadog-api-client-typescript

Typescript client for the Datadog API
https://www.npmjs.com/package/@datadog/datadog-api-client
Apache License 2.0
82 stars 15 forks source link

Module '@datadog/datadog-api-client' has no exported member 'client' #725

Closed wmelton closed 2 years ago

wmelton commented 2 years ago

Describe the bug After the recent update to the ts datadog-api-client library, typescript build fails with Module '@datadog/datadog-api-client' has no exported member 'client'

This library has been running in production for some time with no issues. After update now build fails.

To Reproduce I placed this code in the header of my file:

import { client, v1 } from '@datadog/datadog-api-client'

And build fails with Module '@datadog/datadog-api-client' has no exported member 'client'

After attempting to get authentication working again first, I get this error:

image

Expected behavior It is expected that the library will import and instantiate correctly as it did before.

Screenshots

image

Environment and Versions (please complete the following information): A clear and precise description of your setup:

therve commented 2 years ago

Hi,

We released 1.0.0 with a new client namespace. I'm not sure what's happening but I don't see how you can have the 2 errors you get concurrently. Either you use the previous version and you get the 2nd, or you use the new one and you get the first. Are those happening on the same environment? Can you share your package.json? Thanks.

wmelton commented 2 years ago

Hey @therve,

The two screenshots were an attempt to use it either way to attempt to get build to pass.

I just removed the package altogether, ran npm ci and then installed it again. That still failed.

I removed the @/ path resolver in the tsconfig file and then it started working. That shouldn't be the case given the number of packages that use the @.. naming conventions these days, so who knows - maybe its just a ghost in the machine this morning.

We can probably just close this since it's working now and assume it was an issue on my instances and not in your sdk for now.

Thanks for the fast response.

larebsyed commented 1 year ago

@wmelton I am running into same issue, can you elaborate what you did to resolve this?

wmelton commented 1 year ago

@larebsyed Working code for me:

import { client, v2 } from '@datadog/datadog-api-client'
const configuration = client.createConfiguration()
const apiInstance = new v2.MetricsApi(configuration)

const params: v2.MetricsApiSubmitMetricsRequest = {
    body: {
      series: [
        {
          metric: {{some_metric}},
          type: 1,
          points: [
            {
              timestamp: Math.floor(new Date().getTime() / 1000),
              value: metric_value,
            },
          ],
          tags,
        },
      ],
    },
  }

apiInstance
    .submitMetrics(params)
    .then((data: v2.IntakePayloadAccepted) => {
     // perhaps you want to do something here
    })
    .catch((error: any) => logger.error(error))