How to use the @sentry/utils.truncate 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 / core / src / baseclient.ts View on Github external
if (prepared.dist === undefined && dist !== undefined) {
      prepared.dist = dist;
    }

    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);
github getsentry / sentry-javascript / packages / core / src / baseclient.ts View on Github external
}
    if (prepared.release === undefined && release !== undefined) {
      prepared.release = release;
    }

    if (prepared.dist === undefined && dist !== undefined) {
      prepared.dist = dist;
    }

    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);
github getsentry / sentry-javascript / packages / core / src / baseclient.ts View on Github external
const { environment, release, dist, maxValueLength = 250 } = this.getOptions();

    const prepared: Event = { ...event };
    if (prepared.environment === undefined && environment !== undefined) {
      prepared.environment = environment;
    }
    if (prepared.release === undefined && release !== undefined) {
      prepared.release = release;
    }

    if (prepared.dist === undefined && dist !== undefined) {
      prepared.dist = dist;
    }

    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();
    }