@sentry/browser 6.17.4 → 6.17.8-beta.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.
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 6.17.4 (20d1bfb) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.17.8-beta.0 (07f9257) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
3
  /**
4
4
  * TODO(v7): Remove this enum and replace with SeverityLevel
@@ -18,8 +18,7 @@ var Sentry = (function (exports) {
18
18
  Severity["Debug"] = "debug";
19
19
  /** JSDoc */
20
20
  Severity["Critical"] = "critical";
21
- })(exports.Severity || (exports.Severity = {}));
22
- const SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
21
+ })(exports.Severity || (exports.Severity = {}));
23
22
 
24
23
  /**
25
24
  * Consumes the promise and logs the error when it rejects.
@@ -478,6 +477,8 @@ var Sentry = (function (exports) {
478
477
  return components;
479
478
  }
480
479
 
480
+ const SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
481
+
481
482
  // TODO: Implement different loggers for different environments
482
483
  const global$1 = getGlobalObject();
483
484
  /** Prefix for logging strings */
@@ -706,16 +707,18 @@ var Sentry = (function (exports) {
706
707
  source[name] = wrapped;
707
708
  }
708
709
  /**
709
- * Defines a non enumerable property. This creates a non enumerable property on an object.
710
+ * Defines a non-enumerable property on the given object.
710
711
  *
711
- * @param func The function to set a property to
712
- * @param name the name of the special sentry property
713
- * @param value the property to define
712
+ * @param obj The object on which to set the property
713
+ * @param name The name of the property to be set
714
+ * @param value The value to which to set the property
714
715
  */
715
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
716
- function addNonEnumerableProperty(func, name, value) {
717
- Object.defineProperty(func, name, {
716
+ function addNonEnumerableProperty(obj, name, value) {
717
+ Object.defineProperty(obj, name, {
718
+ // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
718
719
  value: value,
720
+ writable: true,
721
+ configurable: true,
719
722
  });
720
723
  }
721
724
  /**
@@ -1211,12 +1214,12 @@ var Sentry = (function (exports) {
1211
1214
  if (!(level in global$2.console)) {
1212
1215
  return;
1213
1216
  }
1214
- fill(global$2.console, level, function (originalConsoleLevel) {
1217
+ fill(global$2.console, level, function (originalConsoleMethod) {
1215
1218
  return function (...args) {
1216
1219
  triggerHandlers('console', { args, level });
1217
1220
  // this fails for some browsers. :(
1218
- if (originalConsoleLevel) {
1219
- Function.prototype.apply.call(originalConsoleLevel, global$2.console, args);
1221
+ if (originalConsoleMethod) {
1222
+ originalConsoleMethod.call(global$2.console, args);
1220
1223
  }
1221
1224
  };
1222
1225
  });
@@ -4260,7 +4263,7 @@ var Sentry = (function (exports) {
4260
4263
  hub.bindClient(client);
4261
4264
  }
4262
4265
 
4263
- const SDK_VERSION = '6.17.4';
4266
+ const SDK_VERSION = '6.17.8-beta.0';
4264
4267
 
4265
4268
  let originalFunctionToString;
4266
4269
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4491,14 +4494,10 @@ var Sentry = (function (exports) {
4491
4494
  InboundFilters: InboundFilters
4492
4495
  });
4493
4496
 
4494
- /**
4495
- * This was originally forked from https://github.com/occ/TraceKit, but has since been
4496
- * largely modified and is now maintained as part of Sentry JS SDK.
4497
- */
4498
4497
  // global reference to slice
4499
4498
  const UNKNOWN_FUNCTION = '?';
4500
4499
  // Chromium based browsers: Chrome, Brave, new Opera, new Edge
4501
- const chrome = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4500
+ const chrome = /^\s*at (?:(.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
4502
4501
  // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
4503
4502
  // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
4504
4503
  // We need this specific case for now because we want no other regex to match.
@@ -4508,10 +4507,11 @@ var Sentry = (function (exports) {
4508
4507
  const chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/;
4509
4508
  // Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
4510
4509
  const reactMinifiedRegexp = /Minified React error #\d+;/i;
4510
+ const opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4511
+ const opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
4511
4512
  /** JSDoc */
4512
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
4513
4513
  function computeStackTrace(ex) {
4514
- let stack = null;
4514
+ let frames = [];
4515
4515
  let popSize = 0;
4516
4516
  if (ex) {
4517
4517
  if (typeof ex.framesToPop === 'number') {
@@ -4522,48 +4522,50 @@ var Sentry = (function (exports) {
4522
4522
  }
4523
4523
  }
4524
4524
  try {
4525
- // This must be tried first because Opera 10 *destroys*
4526
- // its stacktrace property if you try to access the stack
4527
- // property first!!
4528
- stack = computeStackTraceFromStacktraceProp(ex);
4529
- if (stack) {
4530
- return popFrames(stack, popSize);
4531
- }
4525
+ // Access and store the stacktrace property before doing ANYTHING
4526
+ // else to it because Opera is not very good at providing it
4527
+ // reliably in other circumstances.
4528
+ const stacktrace = ex.stacktrace || ex.stack || '';
4529
+ frames = parseFrames(stacktrace);
4532
4530
  }
4533
4531
  catch (e) {
4534
4532
  // no-empty
4535
4533
  }
4536
- try {
4537
- stack = computeStackTraceFromStackProp(ex);
4538
- if (stack) {
4539
- return popFrames(stack, popSize);
4540
- }
4541
- }
4542
- catch (e) {
4543
- // no-empty
4534
+ if (frames.length && popSize > 0) {
4535
+ frames = frames.slice(popSize);
4544
4536
  }
4545
4537
  return {
4546
4538
  message: extractMessage(ex),
4547
4539
  name: ex && ex.name,
4548
- stack: [],
4549
- failed: true,
4540
+ stack: frames,
4550
4541
  };
4551
4542
  }
4552
4543
  /** JSDoc */
4553
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, complexity
4554
- function computeStackTraceFromStackProp(ex) {
4555
- if (!ex || !ex.stack) {
4556
- return null;
4557
- }
4558
- const stack = [];
4559
- const lines = ex.stack.split('\n');
4544
+ // eslint-disable-next-line complexity
4545
+ function parseFrames(stackString) {
4546
+ const frames = [];
4547
+ const lines = stackString.split('\n');
4560
4548
  let isEval;
4561
4549
  let submatch;
4562
4550
  let parts;
4563
4551
  let element;
4564
- for (let i = 0; i < lines.length; ++i) {
4565
- if ((parts = chrome.exec(lines[i]))) {
4566
- const isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line
4552
+ for (const line of lines) {
4553
+ if ((parts = opera10Regex.exec(line))) {
4554
+ element = {
4555
+ filename: parts[2],
4556
+ function: parts[3] || UNKNOWN_FUNCTION,
4557
+ lineno: +parts[1],
4558
+ };
4559
+ }
4560
+ else if ((parts = opera11Regex.exec(line))) {
4561
+ element = {
4562
+ filename: parts[5],
4563
+ function: parts[3] || parts[4] || UNKNOWN_FUNCTION,
4564
+ lineno: +parts[1],
4565
+ colno: +parts[2],
4566
+ };
4567
+ }
4568
+ else if ((parts = chrome.exec(line))) {
4567
4569
  isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
4568
4570
  if (isEval && (submatch = chromeEval.exec(parts[2]))) {
4569
4571
  // throw out eval line/column and use top-most line/column number
@@ -4571,31 +4573,25 @@ var Sentry = (function (exports) {
4571
4573
  parts[3] = submatch[2]; // line
4572
4574
  parts[4] = submatch[3]; // column
4573
4575
  }
4574
- // Arpad: Working with the regexp above is super painful. it is quite a hack, but just stripping the `address at `
4575
- // prefix here seems like the quickest solution for now.
4576
- let url = parts[2] && parts[2].indexOf('address at ') === 0 ? parts[2].substr('address at '.length) : parts[2];
4577
4576
  // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
4578
4577
  // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
4579
- let func = parts[1] || UNKNOWN_FUNCTION;
4580
- [func, url] = extractSafariExtensionDetails(func, url);
4578
+ const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);
4581
4579
  element = {
4582
- url,
4583
- func,
4584
- args: isNative ? [parts[2]] : [],
4585
- line: parts[3] ? +parts[3] : null,
4586
- column: parts[4] ? +parts[4] : null,
4580
+ filename,
4581
+ function: func,
4582
+ lineno: parts[3] ? +parts[3] : undefined,
4583
+ colno: parts[4] ? +parts[4] : undefined,
4587
4584
  };
4588
4585
  }
4589
- else if ((parts = winjs.exec(lines[i]))) {
4586
+ else if ((parts = winjs.exec(line))) {
4590
4587
  element = {
4591
- url: parts[2],
4592
- func: parts[1] || UNKNOWN_FUNCTION,
4593
- args: [],
4594
- line: +parts[3],
4595
- column: parts[4] ? +parts[4] : null,
4588
+ filename: parts[2],
4589
+ function: parts[1] || UNKNOWN_FUNCTION,
4590
+ lineno: +parts[3],
4591
+ colno: parts[4] ? +parts[4] : undefined,
4596
4592
  };
4597
4593
  }
4598
- else if ((parts = gecko.exec(lines[i]))) {
4594
+ else if ((parts = gecko.exec(line))) {
4599
4595
  isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
4600
4596
  if (isEval && (submatch = geckoEval.exec(parts[3]))) {
4601
4597
  // throw out eval line/column and use top-most line number
@@ -4604,91 +4600,22 @@ var Sentry = (function (exports) {
4604
4600
  parts[4] = submatch[2];
4605
4601
  parts[5] = ''; // no column when eval
4606
4602
  }
4607
- else if (i === 0 && !parts[5] && ex.columnNumber !== void 0) {
4608
- // FireFox uses this awesome columnNumber property for its top frame
4609
- // Also note, Firefox's column number is 0-based and everything else expects 1-based,
4610
- // so adding 1
4611
- // NOTE: this hack doesn't work if top-most frame is eval
4612
- stack[0].column = ex.columnNumber + 1;
4613
- }
4614
- let url = parts[3];
4603
+ let filename = parts[3];
4615
4604
  let func = parts[1] || UNKNOWN_FUNCTION;
4616
- [func, url] = extractSafariExtensionDetails(func, url);
4605
+ [func, filename] = extractSafariExtensionDetails(func, filename);
4617
4606
  element = {
4618
- url,
4619
- func,
4620
- args: parts[2] ? parts[2].split(',') : [],
4621
- line: parts[4] ? +parts[4] : null,
4622
- column: parts[5] ? +parts[5] : null,
4607
+ filename,
4608
+ function: func,
4609
+ lineno: parts[4] ? +parts[4] : undefined,
4610
+ colno: parts[5] ? +parts[5] : undefined,
4623
4611
  };
4624
4612
  }
4625
4613
  else {
4626
4614
  continue;
4627
4615
  }
4628
- if (!element.func && element.line) {
4629
- element.func = UNKNOWN_FUNCTION;
4630
- }
4631
- stack.push(element);
4616
+ frames.push(element);
4632
4617
  }
4633
- if (!stack.length) {
4634
- return null;
4635
- }
4636
- return {
4637
- message: extractMessage(ex),
4638
- name: ex.name,
4639
- stack,
4640
- };
4641
- }
4642
- /** JSDoc */
4643
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4644
- function computeStackTraceFromStacktraceProp(ex) {
4645
- if (!ex || !ex.stacktrace) {
4646
- return null;
4647
- }
4648
- // Access and store the stacktrace property before doing ANYTHING
4649
- // else to it because Opera is not very good at providing it
4650
- // reliably in other circumstances.
4651
- const stacktrace = ex.stacktrace;
4652
- const opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
4653
- const opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i;
4654
- const lines = stacktrace.split('\n');
4655
- const stack = [];
4656
- let parts;
4657
- for (let line = 0; line < lines.length; line += 2) {
4658
- let element = null;
4659
- if ((parts = opera10Regex.exec(lines[line]))) {
4660
- element = {
4661
- url: parts[2],
4662
- func: parts[3],
4663
- args: [],
4664
- line: +parts[1],
4665
- column: null,
4666
- };
4667
- }
4668
- else if ((parts = opera11Regex.exec(lines[line]))) {
4669
- element = {
4670
- url: parts[6],
4671
- func: parts[3] || parts[4],
4672
- args: parts[5] ? parts[5].split(',') : [],
4673
- line: +parts[1],
4674
- column: +parts[2],
4675
- };
4676
- }
4677
- if (element) {
4678
- if (!element.func && element.line) {
4679
- element.func = UNKNOWN_FUNCTION;
4680
- }
4681
- stack.push(element);
4682
- }
4683
- }
4684
- if (!stack.length) {
4685
- return null;
4686
- }
4687
- return {
4688
- message: extractMessage(ex),
4689
- name: ex.name,
4690
- stack,
4691
- };
4618
+ return frames;
4692
4619
  }
4693
4620
  /**
4694
4621
  * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
@@ -4710,25 +4637,16 @@ var Sentry = (function (exports) {
4710
4637
  * Unfortunatelly "just" changing RegExp is too complicated now and making it pass all tests
4711
4638
  * and fix this case seems like an impossible, or at least way too time-consuming task.
4712
4639
  */
4713
- const extractSafariExtensionDetails = (func, url) => {
4640
+ const extractSafariExtensionDetails = (func, filename) => {
4714
4641
  const isSafariExtension = func.indexOf('safari-extension') !== -1;
4715
4642
  const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
4716
4643
  return isSafariExtension || isSafariWebExtension
4717
4644
  ? [
4718
4645
  func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,
4719
- isSafariExtension ? `safari-extension:${url}` : `safari-web-extension:${url}`,
4646
+ isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,
4720
4647
  ]
4721
- : [func, url];
4648
+ : [func, filename];
4722
4649
  };
4723
- /** Remove N number of frames from the stack */
4724
- function popFrames(stacktrace, popSize) {
4725
- try {
4726
- return Object.assign(Object.assign({}, stacktrace), { stack: stacktrace.stack.slice(popSize) });
4727
- }
4728
- catch (e) {
4729
- return stacktrace;
4730
- }
4731
- }
4732
4650
  /**
4733
4651
  * There are cases where stacktrace.message is an Event object
4734
4652
  * https://github.com/getsentry/sentry-javascript/issues/1949
@@ -4807,12 +4725,12 @@ var Sentry = (function (exports) {
4807
4725
  * @hidden
4808
4726
  */
4809
4727
  function prepareFramesForEvent(stack) {
4810
- if (!stack || !stack.length) {
4728
+ if (!stack.length) {
4811
4729
  return [];
4812
4730
  }
4813
4731
  let localStack = stack;
4814
- const firstFrameFunction = localStack[0].func || '';
4815
- const lastFrameFunction = localStack[localStack.length - 1].func || '';
4732
+ const firstFrameFunction = localStack[0].function || '';
4733
+ const lastFrameFunction = localStack[localStack.length - 1].function || '';
4816
4734
  // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
4817
4735
  if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
4818
4736
  localStack = localStack.slice(1);
@@ -4824,12 +4742,12 @@ var Sentry = (function (exports) {
4824
4742
  // The frame where the crash happened, should be the last entry in the array
4825
4743
  return localStack
4826
4744
  .slice(0, STACKTRACE_LIMIT)
4827
- .map((frame) => ({
4828
- colno: frame.column === null ? undefined : frame.column,
4829
- filename: frame.url || localStack[0].url,
4830
- function: frame.func || '?',
4745
+ .map(frame => ({
4746
+ filename: frame.filename || localStack[0].filename,
4747
+ function: frame.function || '?',
4748
+ lineno: frame.lineno,
4749
+ colno: frame.colno,
4831
4750
  in_app: true,
4832
- lineno: frame.line === null ? undefined : frame.line,
4833
4751
  }))
4834
4752
  .reverse();
4835
4753
  }
@@ -6724,6 +6642,7 @@ var Sentry = (function (exports) {
6724
6642
  exports.SDK_NAME = SDK_NAME;
6725
6643
  exports.SDK_VERSION = SDK_VERSION;
6726
6644
  exports.Scope = Scope;
6645
+ exports.Session = Session;
6727
6646
  exports.Transports = index;
6728
6647
  exports.addBreadcrumb = addBreadcrumb;
6729
6648
  exports.addGlobalEventProcessor = addGlobalEventProcessor;