How to use the @sentry/utils.uuid4 function in @sentry/utils

To help you get started, we’ve selected a few @sentry/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
public captureException(exception: any, hint?: EventHint): string {
    const eventId = (this._lastEventId = uuid4());
    let finalHint = hint;

    // If there's no explicit hint provided, mimick the same thing that would happen
    // in the minimal itself to create a consistent behavior.
    // We don't do this in the client, as it's the lowest level API, and doing this,
    // would prevent user from having full control over direct calls.
    if (!hint) {
      let syntheticException: Error;
      try {
        throw new Error('Sentry syntheticException');
      } catch (exception) {
        syntheticException = exception as Error;
      }
      finalHint = {
        originalException: exception,
        syntheticException,
github getsentry / sentry-javascript / packages / opentracing / src / spancontext.ts View on Github external
public constructor(
    public readonly traceId?: string,
    public readonly spanId: string = uuid4().substring(16), // private readonly parentId: string,
  ) {}
github getsentry / sentry-javascript / packages / core / src / baseclient.ts View on Github external
if (prepared.message) {
      prepared.message = truncate(prepared.message, maxValueLength);
    }

    const exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
    if (exception && exception.value) {
      exception.value = truncate(exception.value, maxValueLength);
    }

    const request = prepared.request;
    if (request && request.url) {
      request.url = truncate(request.url, maxValueLength);
    }

    if (prepared.event_id === undefined) {
      prepared.event_id = uuid4();
    }

    this._addIntegrations(prepared.sdk);

    // We prepare the result here with a resolved Event.
    let result = SyncPromise.resolve(prepared);

    // This should be the last thing called, since we want that
    // {@link Hub.addEventProcessor} gets the finished prepared event.
    if (scope) {
      // In case we have a hub we reassign it.
      result = scope.applyToEvent(prepared, hint);
    }

    return result;
  }
github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
public captureMessage(message: string, level?: Severity, hint?: EventHint): string {
    const eventId = (this._lastEventId = uuid4());
    let finalHint = hint;

    // If there's no explicit hint provided, mimick the same thing that would happen
    // in the minimal itself to create a consistent behavior.
    // We don't do this in the client, as it's the lowest level API, and doing this,
    // would prevent user from having full control over direct calls.
    if (!hint) {
      let syntheticException: Error;
      try {
        throw new Error(message);
      } catch (exception) {
        syntheticException = exception as Error;
      }
      finalHint = {
        originalException: message,
        syntheticException,
github getsentry / sentry-javascript / packages / apm / src / span.ts View on Github external
*/
export class Span implements SpanInterface, SpanContext {
  /**
   * The reference to the current hub.
   */
  private readonly _hub: Hub = (getCurrentHub() as unknown) as Hub;

  /**
   * @inheritDoc
   */
  private readonly _traceId: string = uuid4();

  /**
   * @inheritDoc
   */
  private readonly _spanId: string = uuid4().substring(16);

  /**
   * @inheritDoc
   */
  private readonly _parentSpanId?: string;

  /**
   * @inheritDoc
   */
  public sampled?: boolean;

  /**
   * Timestamp when the span was created.
   */
  public readonly startTimestamp: number = timestampWithMs();
github getsentry / sentry-javascript / packages / hub / src / span.ts View on Github external
public constructor(
    private readonly _traceId: string = uuid4(),
    private readonly _spanId: string = uuid4().substring(16),
    private _sampled?: boolean,
    private _parent?: Span,
  ) {}
github getsentry / sentry-javascript / packages / hub / src / hub.ts View on Github external
public captureEvent(event: Event, hint?: EventHint): string {
    const eventId = (this._lastEventId = uuid4());
    this._invokeClient('captureEvent', event, {
      ...hint,
      event_id: eventId,
    });
    return eventId;
  }
github getsentry / sentry-javascript / packages / hub / src / span.ts View on Github external
public constructor(
    private readonly _traceId: string = uuid4(),
    private readonly _spanId: string = uuid4().substring(16),
    private _sampled?: boolean,
    private _parent?: Span,
  ) {}