Open
Description
SDK
JavaScript SDK
Description
The example snippet is for JavaScript which isn't entirely accurate for TypeScript. Using TypeScript shows these problems
- The type of
nextCall
is BaseServerInterceptingCall which has aprivate Metadata
property. If you typenextCall
as that, you cannot accessmetadata
due to that classifier. While its not real private (which exists in JS now but isnt being used here) you can still access it at runtime no problem, but if you use TypeScript to type that properly, you will fail the compiler check. - The
methodDescriptor
shape is the following which does not contain theservice
property that this snippet attempts to use for thegrpc.service
property.
{
path: string,
requestStream: boolean,
responseStream: boolean,
requestDeserialize: Function,
responseSerialize: Function
}
- The
span.setStatus({ code: "error" })
line fails the typecheck because Sentry's SDK types are actually looking for one of these and not a string.
declare const SPAN_STATUS_UNSET = 0;
declare const SPAN_STATUS_OK = 1;
declare const SPAN_STATUS_ERROR = 2;
/** The status code of a span. */
export type SpanStatusCode = typeof SPAN_STATUS_UNSET | typeof SPAN_STATUS_OK | typeof SPAN_STATUS_ERROR;
Suggested Solution
Provide an example snippet for TypeScript.