@sentry/browser 5.28.0 → 5.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 5.28.0 (705af78) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 5.30.0 (6de2dd4) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -40,6 +40,16 @@ var Sentry = (function (exports) {
40
40
  return __assign.apply(this, arguments);
41
41
  };
42
42
 
43
+ function __rest(s, e) {
44
+ var t = {};
45
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
46
+ t[p] = s[p];
47
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
48
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
49
+ t[p[i]] = s[p[i]];
50
+ return t;
51
+ }
52
+
43
53
  function __values(o) {
44
54
  var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
45
55
  if (m) return m.call(o);
@@ -191,6 +201,14 @@ var Sentry = (function (exports) {
191
201
  Status.fromHttpCode = fromHttpCode;
192
202
  })(exports.Status || (exports.Status = {}));
193
203
 
204
+ var TransactionSamplingMethod;
205
+ (function (TransactionSamplingMethod) {
206
+ TransactionSamplingMethod["Explicit"] = "explicitly_set";
207
+ TransactionSamplingMethod["Sampler"] = "client_sampler";
208
+ TransactionSamplingMethod["Rate"] = "client_rate";
209
+ TransactionSamplingMethod["Inheritance"] = "inheritance";
210
+ })(TransactionSamplingMethod || (TransactionSamplingMethod = {}));
211
+
194
212
  /* eslint-disable @typescript-eslint/no-explicit-any */
195
213
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
196
214
  /**
@@ -253,7 +271,7 @@ var Sentry = (function (exports) {
253
271
  return Object.prototype.toString.call(wat) === '[object String]';
254
272
  }
255
273
  /**
256
- * Checks whether given value's is a primitive (undefined, null, number, boolean, string)
274
+ * Checks whether given value's is a primitive (undefined, null, number, boolean, string, bigint, symbol)
257
275
  * {@link isPrimitive}.
258
276
  *
259
277
  * @param wat A value to be checked.
@@ -615,7 +633,7 @@ var Sentry = (function (exports) {
615
633
  * Truncates given string to the maximum characters count
616
634
  *
617
635
  * @param str An object that contains serializable values
618
- * @param max Maximum number of characters in truncated string
636
+ * @param max Maximum number of characters in truncated string (0 = unlimited)
619
637
  * @returns string Encoded
620
638
  */
621
639
  function truncate(str, max) {
@@ -672,15 +690,16 @@ var Sentry = (function (exports) {
672
690
  *
673
691
  * @param source An object that contains a method to be wrapped.
674
692
  * @param name A name of method to be wrapped.
675
- * @param replacement A function that should be used to wrap a given method.
693
+ * @param replacementFactory A function that should be used to wrap a given method, returning the wrapped method which
694
+ * will be substituted in for `source[name]`.
676
695
  * @returns void
677
696
  */
678
- function fill(source, name, replacement) {
697
+ function fill(source, name, replacementFactory) {
679
698
  if (!(name in source)) {
680
699
  return;
681
700
  }
682
701
  var original = source[name];
683
- var wrapped = replacement(original);
702
+ var wrapped = replacementFactory(original);
684
703
  // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work
685
704
  // otherwise it'll throw "TypeError: Object.defineProperties called on non-object"
686
705
  if (typeof wrapped === 'function') {
@@ -712,10 +731,10 @@ var Sentry = (function (exports) {
712
731
  .join('&');
713
732
  }
714
733
  /**
715
- * Transforms any object into an object literal with all it's attributes
734
+ * Transforms any object into an object literal with all its attributes
716
735
  * attached to it.
717
736
  *
718
- * @param value Initial source that we have to transform in order to be usable by the serializer
737
+ * @param value Initial source that we have to transform in order for it to be usable by the serializer
719
738
  */
720
739
  function getWalkSource(value) {
721
740
  if (isError(value)) {
@@ -788,7 +807,15 @@ var Sentry = (function (exports) {
788
807
  }
789
808
  return serialized;
790
809
  }
791
- /** Transforms any input value into a string form, either primitive value or a type of the input */
810
+ /**
811
+ * Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers,
812
+ * booleans, null, and undefined.
813
+ *
814
+ * @param value The value to stringify
815
+ * @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or
816
+ * type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value,
817
+ * unchanged.
818
+ */
792
819
  function serializeValue(value) {
793
820
  var type = Object.prototype.toString.call(value);
794
821
  // Node.js REPL notation
@@ -842,6 +869,13 @@ var Sentry = (function (exports) {
842
869
  if (typeof value === 'function') {
843
870
  return "[Function: " + getFunctionName(value) + "]";
844
871
  }
872
+ // symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable
873
+ if (typeof value === 'symbol') {
874
+ return "[" + String(value) + "]";
875
+ }
876
+ if (typeof value === 'bigint') {
877
+ return "[BigInt: " + String(value) + "]";
878
+ }
845
879
  return value;
846
880
  }
847
881
  /**
@@ -3320,8 +3354,11 @@ var Sentry = (function (exports) {
3320
3354
  }
3321
3355
  /**
3322
3356
  * Set key:value that will be sent as tags data with the event.
3357
+ *
3358
+ * Can also be used to unset a tag, by passing `undefined`.
3359
+ *
3323
3360
  * @param key String key of tag
3324
- * @param value String value of tag
3361
+ * @param value Value of tag
3325
3362
  */
3326
3363
  function setTag(key, value) {
3327
3364
  callOnHub('setTag', key, value);
@@ -3623,7 +3660,7 @@ var Sentry = (function (exports) {
3623
3660
  var _this = this;
3624
3661
  var eventId = hint && hint.event_id;
3625
3662
  var promisedEvent = isPrimitive(message)
3626
- ? this._getBackend().eventFromMessage("" + message, level, hint)
3663
+ ? this._getBackend().eventFromMessage(String(message), level, hint)
3627
3664
  : this._getBackend().eventFromException(message, hint);
3628
3665
  this._process(promisedEvent
3629
3666
  .then(function (event) { return _this._captureEvent(event, hint, scope); })
@@ -3946,7 +3983,7 @@ var Sentry = (function (exports) {
3946
3983
  // 0.0 === 0% events are sent
3947
3984
  // Sampling for transaction happens somewhere else
3948
3985
  if (!isTransaction && typeof sampleRate === 'number' && Math.random() > sampleRate) {
3949
- return SyncPromise.reject(new SentryError('This event has been sampled, will not send event.'));
3986
+ return SyncPromise.reject(new SentryError("Discarding event because it's not included in the random sample (sampling rate = " + sampleRate + ")"));
3950
3987
  }
3951
3988
  return this._prepareEvent(event, scope, hint)
3952
3989
  .then(function (prepared) {
@@ -4108,6 +4145,9 @@ var Sentry = (function (exports) {
4108
4145
  }
4109
4146
  /** Creates a SentryRequest from an event. */
4110
4147
  function eventToSentryRequest(event, api) {
4148
+ // since JS has no Object.prototype.pop()
4149
+ var _a = event.tags || {}, samplingMethod = _a.__sentry_samplingMethod, sampleRate = _a.__sentry_sampleRate, otherTags = __rest(_a, ["__sentry_samplingMethod", "__sentry_sampleRate"]);
4150
+ event.tags = otherTags;
4111
4151
  var useEnvelope = event.type === 'transaction';
4112
4152
  var req = {
4113
4153
  body: JSON.stringify(event),
@@ -4126,6 +4166,9 @@ var Sentry = (function (exports) {
4126
4166
  });
4127
4167
  var itemHeaders = JSON.stringify({
4128
4168
  type: event.type,
4169
+ // TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and
4170
+ // explicitly-set sampling decisions). Are we good with that?
4171
+ sample_rates: [{ id: samplingMethod, rate: sampleRate }],
4129
4172
  });
4130
4173
  // The trailing newline is optional. We intentionally don't send it to avoid
4131
4174
  // sending unnecessary bytes.
@@ -4799,7 +4842,7 @@ var Sentry = (function (exports) {
4799
4842
  */
4800
4843
  var limited = this._handleRateLimit(headers);
4801
4844
  if (limited)
4802
- logger.warn("Too many requests, backing off till: " + this._disabledUntil(requestType));
4845
+ logger.warn("Too many requests, backing off until: " + this._disabledUntil(requestType));
4803
4846
  if (status === exports.Status.Success) {
4804
4847
  resolve({ status: status });
4805
4848
  return;
@@ -4828,6 +4871,16 @@ var Sentry = (function (exports) {
4828
4871
  var raHeader = headers['retry-after'];
4829
4872
  if (rlHeader) {
4830
4873
  try {
4874
+ // rate limit headers are of the form
4875
+ // <header>,<header>,..
4876
+ // where each <header> is of the form
4877
+ // <retry_after>: <categories>: <scope>: <reason_code>
4878
+ // where
4879
+ // <retry_after> is a delay in ms
4880
+ // <categories> is the event type(s) (error, transaction, etc) being rate limited and is of the form
4881
+ // <category>;<category>;...
4882
+ // <scope> is what's being limited (org, project, or key) - ignored by SDK
4883
+ // <reason_code> is an arbitrary string like "org_quota" - ignored by SDK
4831
4884
  for (var _c = __values(rlHeader.trim().split(',')), _d = _c.next(); !_d.done; _d = _c.next()) {
4832
4885
  var limit = _d.value;
4833
4886
  var parameters = limit.split(':', 2);
@@ -4922,7 +4975,13 @@ var Sentry = (function (exports) {
4922
4975
  'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
4923
4976
  'retry-after': response.headers.get('Retry-After'),
4924
4977
  };
4925
- _this._handleResponse({ requestType: sentryRequest.type, response: response, headers: headers, resolve: resolve, reject: reject });
4978
+ _this._handleResponse({
4979
+ requestType: sentryRequest.type,
4980
+ response: response,
4981
+ headers: headers,
4982
+ resolve: resolve,
4983
+ reject: reject,
4984
+ });
4926
4985
  })
4927
4986
  .catch(reject);
4928
4987
  }));
@@ -5291,7 +5350,7 @@ var Sentry = (function (exports) {
5291
5350
  }
5292
5351
  var client = currentHub.getClient();
5293
5352
  var event = isPrimitive(error)
5294
- ? _this._eventFromIncompleteRejection(error)
5353
+ ? _this._eventFromRejectionWithPrimitive(error)
5295
5354
  : eventFromUnknownInput(error, undefined, {
5296
5355
  attachStacktrace: client && client.getOptions().attachStacktrace,
5297
5356
  rejection: true,
@@ -5339,16 +5398,19 @@ var Sentry = (function (exports) {
5339
5398
  return this._enhanceEventWithInitialFrame(event, url, line, column);
5340
5399
  };
5341
5400
  /**
5342
- * This function creates an Event from an TraceKitStackTrace that has part of it missing.
5401
+ * Create an event from a promise rejection where the `reason` is a primitive.
5402
+ *
5403
+ * @param reason: The `reason` property of the promise rejection
5404
+ * @returns An Event object with an appropriate `exception` value
5343
5405
  */
5344
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5345
- GlobalHandlers.prototype._eventFromIncompleteRejection = function (error) {
5406
+ GlobalHandlers.prototype._eventFromRejectionWithPrimitive = function (reason) {
5346
5407
  return {
5347
5408
  exception: {
5348
5409
  values: [
5349
5410
  {
5350
5411
  type: 'UnhandledRejection',
5351
- value: "Non-Error promise rejection captured with value: " + error,
5412
+ // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)
5413
+ value: "Non-Error promise rejection captured with value: " + String(reason),
5352
5414
  },
5353
5415
  ],
5354
5416
  },
@@ -5973,7 +6035,7 @@ var Sentry = (function (exports) {
5973
6035
  });
5974
6036
 
5975
6037
  var SDK_NAME = 'sentry.javascript.browser';
5976
- var SDK_VERSION = '5.28.0';
6038
+ var SDK_VERSION = '5.30.0';
5977
6039
 
5978
6040
  /**
5979
6041
  * The Sentry Browser SDK Client.