client.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as os from 'os';
  2. import { TextEncoder } from 'util';
  3. import { ServerRuntimeClient, applySdkMetadata } from '@sentry/core';
  4. /**
  5. * The Sentry Node SDK Client.
  6. *
  7. * @see NodeClientOptions for documentation on configuration options.
  8. * @see SentryClient for usage documentation.
  9. */
  10. class NodeClient extends ServerRuntimeClient {
  11. /**
  12. * Creates a new Node SDK instance.
  13. * @param options Configuration options for this SDK.
  14. */
  15. constructor(options) {
  16. applySdkMetadata(options, 'node');
  17. // Until node supports global TextEncoder in all versions we support, we are forced to pass it from util
  18. options.transportOptions = {
  19. textEncoder: new TextEncoder(),
  20. ...options.transportOptions,
  21. };
  22. const clientOptions = {
  23. ...options,
  24. platform: 'node',
  25. runtime: { name: 'node', version: global.process.version },
  26. serverName: options.serverName || global.process.env.SENTRY_NAME || os.hostname(),
  27. };
  28. super(clientOptions);
  29. }
  30. }
  31. export { NodeClient };
  32. //# sourceMappingURL=client.js.map