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

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

wmelton opened this issue · comments

commented

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.

  • Severity: High - blocking builds.

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:

  • Version 1.0.0
  • Node: 16.14.2
  • Npm: 8.10

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.

commented

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.

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

commented

@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))