@paypay/mini-app-js-sdk 2.23.0 → 2.25.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/dist/client/index.d.ts +1 -0
- package/dist/core/clientState.d.ts +10 -0
- package/dist/core/coreFunctions/fetchCoupons.d.ts +2 -2
- package/dist/core/coreFunctions/getLoginUrl.d.ts +4 -5
- package/dist/core/coreUtils.d.ts +3 -5
- package/dist/core/coupon/couponFunctions/renderCoupons.d.ts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/sentry.d.ts +0 -2
- package/dist/mini-app-api.d.ts +3 -3
- package/dist/mini-app-js-sdk.browser.js +1 -1
- package/dist/mini-app-js-sdk.es.js +1376 -1372
- package/dist/model/bridge/getAppDetail.d.ts +1 -1
- package/dist/model/bridge/getAuthStatus.d.ts +1 -2
- package/dist/model/bridge/init.d.ts +1 -2
- package/dist/model/bridge/render.d.ts +2 -2
- package/dist/model/bridge/renderLoginButton.d.ts +2 -2
- package/dist/model/bridge/renderPayButton.d.ts +2 -2
- package/dist/types.d.ts +0 -3
- package/dist/utils/analytics.d.ts +4 -0
- package/dist/utils/fetch.d.ts +1 -1
- package/dist/utils/helper.d.ts +3 -1
- package/dist/utils/storage.d.ts +5 -11
- package/dist/views/coupon/components/CouponAction/index.d.ts +0 -8
- package/dist/views/coupon/index.d.ts +0 -8
- package/package.json +4 -3
|
@@ -283,19 +283,6 @@ function url(path) {
|
|
|
283
283
|
}
|
|
284
284
|
const img_paypayRec = url("icon-paypay-rec.svg");
|
|
285
285
|
const img_paypayRecWhite = url("icon-paypay-rec-white.svg");
|
|
286
|
-
const JS_SDK_VERSION = "2.23.0";
|
|
287
|
-
const REVISION = "c54dc8e";
|
|
288
|
-
const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
|
|
289
|
-
const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
|
|
290
|
-
const CORE_IFRAME_URL = new URL(
|
|
291
|
-
`./iframe.html?v=${JS_SDK_VERSION}&rev=${REVISION}`,
|
|
292
|
-
coreBaseUrl
|
|
293
|
-
).href;
|
|
294
|
-
const COUPON_IFRAME_URL = new URL(
|
|
295
|
-
`./coupon/iframe.html?v=${JS_SDK_VERSION}`,
|
|
296
|
-
coreBaseUrl
|
|
297
|
-
).href;
|
|
298
|
-
const SENTRY_DSN = "https://377b45f154b1fb17d8e98a6ffb67030a@o4505819519320064.ingest.sentry.io/4506579323453440";
|
|
299
286
|
var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
|
|
300
287
|
MiniAppErrorType2["success"] = "SUCCESS";
|
|
301
288
|
MiniAppErrorType2["invalidUrl"] = "INVALID_URL";
|
|
@@ -366,1344 +353,16 @@ var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
|
|
|
366
353
|
MiniAppErrorType2["merchantTimeout"] = "MERCHANT_TIMEOUT";
|
|
367
354
|
return MiniAppErrorType2;
|
|
368
355
|
})(MiniAppErrorType || {});
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
return objectToString.call(wat) === `[object ${className}]`;
|
|
372
|
-
}
|
|
373
|
-
function isPlainObject(wat) {
|
|
374
|
-
return isBuiltin(wat, "Object");
|
|
375
|
-
}
|
|
376
|
-
function isThenable(wat) {
|
|
377
|
-
return Boolean(wat && wat.then && typeof wat.then === "function");
|
|
378
|
-
}
|
|
379
|
-
function isGlobalObj(obj) {
|
|
380
|
-
return obj && obj.Math == Math ? obj : void 0;
|
|
381
|
-
}
|
|
382
|
-
const GLOBAL_OBJ = typeof globalThis == "object" && isGlobalObj(globalThis) || // eslint-disable-next-line no-restricted-globals
|
|
383
|
-
typeof window == "object" && isGlobalObj(window) || typeof self == "object" && isGlobalObj(self) || typeof global == "object" && isGlobalObj(global) || function() {
|
|
384
|
-
return this;
|
|
385
|
-
}() || {};
|
|
386
|
-
function getGlobalObject() {
|
|
387
|
-
return GLOBAL_OBJ;
|
|
388
|
-
}
|
|
389
|
-
function getGlobalSingleton(name, creator, obj) {
|
|
390
|
-
const gbl = obj || GLOBAL_OBJ;
|
|
391
|
-
const __SENTRY__ = gbl.__SENTRY__ = gbl.__SENTRY__ || {};
|
|
392
|
-
const singleton = __SENTRY__[name] || (__SENTRY__[name] = creator());
|
|
393
|
-
return singleton;
|
|
394
|
-
}
|
|
395
|
-
const PREFIX = "Sentry Logger ";
|
|
396
|
-
const CONSOLE_LEVELS = ["debug", "info", "warn", "error", "log", "assert", "trace"];
|
|
397
|
-
const originalConsoleMethods = {};
|
|
398
|
-
function consoleSandbox(callback) {
|
|
399
|
-
if (!("console" in GLOBAL_OBJ)) {
|
|
400
|
-
return callback();
|
|
401
|
-
}
|
|
402
|
-
const console2 = GLOBAL_OBJ.console;
|
|
403
|
-
const wrappedFuncs = {};
|
|
404
|
-
const wrappedLevels = Object.keys(originalConsoleMethods);
|
|
405
|
-
wrappedLevels.forEach((level) => {
|
|
406
|
-
const originalConsoleMethod = originalConsoleMethods[level];
|
|
407
|
-
wrappedFuncs[level] = console2[level];
|
|
408
|
-
console2[level] = originalConsoleMethod;
|
|
409
|
-
});
|
|
410
|
-
try {
|
|
411
|
-
return callback();
|
|
412
|
-
} finally {
|
|
413
|
-
wrappedLevels.forEach((level) => {
|
|
414
|
-
console2[level] = wrappedFuncs[level];
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
function makeLogger() {
|
|
419
|
-
let enabled = false;
|
|
420
|
-
const logger2 = {
|
|
421
|
-
enable: () => {
|
|
422
|
-
enabled = true;
|
|
423
|
-
},
|
|
424
|
-
disable: () => {
|
|
425
|
-
enabled = false;
|
|
426
|
-
},
|
|
427
|
-
isEnabled: () => enabled
|
|
428
|
-
};
|
|
429
|
-
if (typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) {
|
|
430
|
-
CONSOLE_LEVELS.forEach((name) => {
|
|
431
|
-
logger2[name] = (...args) => {
|
|
432
|
-
if (enabled) {
|
|
433
|
-
consoleSandbox(() => {
|
|
434
|
-
GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
});
|
|
439
|
-
} else {
|
|
440
|
-
CONSOLE_LEVELS.forEach((name) => {
|
|
441
|
-
logger2[name] = () => void 0;
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
return logger2;
|
|
445
|
-
}
|
|
446
|
-
const logger = makeLogger();
|
|
447
|
-
function dropUndefinedKeys(inputValue) {
|
|
448
|
-
const memoizationMap = /* @__PURE__ */ new Map();
|
|
449
|
-
return _dropUndefinedKeys(inputValue, memoizationMap);
|
|
450
|
-
}
|
|
451
|
-
function _dropUndefinedKeys(inputValue, memoizationMap) {
|
|
452
|
-
if (isPlainObject(inputValue)) {
|
|
453
|
-
const memoVal = memoizationMap.get(inputValue);
|
|
454
|
-
if (memoVal !== void 0) {
|
|
455
|
-
return memoVal;
|
|
456
|
-
}
|
|
457
|
-
const returnValue = {};
|
|
458
|
-
memoizationMap.set(inputValue, returnValue);
|
|
459
|
-
for (const key of Object.keys(inputValue)) {
|
|
460
|
-
if (typeof inputValue[key] !== "undefined") {
|
|
461
|
-
returnValue[key] = _dropUndefinedKeys(inputValue[key], memoizationMap);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return returnValue;
|
|
465
|
-
}
|
|
466
|
-
if (Array.isArray(inputValue)) {
|
|
467
|
-
const memoVal = memoizationMap.get(inputValue);
|
|
468
|
-
if (memoVal !== void 0) {
|
|
469
|
-
return memoVal;
|
|
470
|
-
}
|
|
471
|
-
const returnValue = [];
|
|
472
|
-
memoizationMap.set(inputValue, returnValue);
|
|
473
|
-
inputValue.forEach((item) => {
|
|
474
|
-
returnValue.push(_dropUndefinedKeys(item, memoizationMap));
|
|
475
|
-
});
|
|
476
|
-
return returnValue;
|
|
477
|
-
}
|
|
478
|
-
return inputValue;
|
|
479
|
-
}
|
|
480
|
-
function uuid4() {
|
|
481
|
-
const gbl = GLOBAL_OBJ;
|
|
482
|
-
const crypto = gbl.crypto || gbl.msCrypto;
|
|
483
|
-
let getRandomByte = () => Math.random() * 16;
|
|
484
|
-
try {
|
|
485
|
-
if (crypto && crypto.randomUUID) {
|
|
486
|
-
return crypto.randomUUID().replace(/-/g, "");
|
|
487
|
-
}
|
|
488
|
-
if (crypto && crypto.getRandomValues) {
|
|
489
|
-
getRandomByte = () => crypto.getRandomValues(new Uint8Array(1))[0];
|
|
490
|
-
}
|
|
491
|
-
} catch (_) {
|
|
492
|
-
}
|
|
493
|
-
return ([1e7] + 1e3 + 4e3 + 8e3 + 1e11).replace(
|
|
494
|
-
/[018]/g,
|
|
495
|
-
(c) => (
|
|
496
|
-
// eslint-disable-next-line no-bitwise
|
|
497
|
-
(c ^ (getRandomByte() & 15) >> c / 4).toString(16)
|
|
498
|
-
)
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
function arrayify(maybeArray) {
|
|
502
|
-
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
503
|
-
}
|
|
504
|
-
function isBrowserBundle() {
|
|
505
|
-
return typeof __SENTRY_BROWSER_BUNDLE__ !== "undefined" && !!__SENTRY_BROWSER_BUNDLE__;
|
|
356
|
+
function isIP(hostName) {
|
|
357
|
+
return isIPv4(hostName) || isIPv6(hostName);
|
|
506
358
|
}
|
|
507
|
-
function
|
|
508
|
-
|
|
359
|
+
function isIPv4(hostName) {
|
|
360
|
+
const expression = /(^\s*(((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]))\s*$)/;
|
|
361
|
+
return expression.test(hostName);
|
|
509
362
|
}
|
|
510
|
-
function
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
var States;
|
|
514
|
-
(function(States2) {
|
|
515
|
-
const PENDING = 0;
|
|
516
|
-
States2[States2["PENDING"] = PENDING] = "PENDING";
|
|
517
|
-
const RESOLVED = 1;
|
|
518
|
-
States2[States2["RESOLVED"] = RESOLVED] = "RESOLVED";
|
|
519
|
-
const REJECTED = 2;
|
|
520
|
-
States2[States2["REJECTED"] = REJECTED] = "REJECTED";
|
|
521
|
-
})(States || (States = {}));
|
|
522
|
-
class SyncPromise {
|
|
523
|
-
constructor(executor) {
|
|
524
|
-
SyncPromise.prototype.__init.call(this);
|
|
525
|
-
SyncPromise.prototype.__init2.call(this);
|
|
526
|
-
SyncPromise.prototype.__init3.call(this);
|
|
527
|
-
SyncPromise.prototype.__init4.call(this);
|
|
528
|
-
this._state = States.PENDING;
|
|
529
|
-
this._handlers = [];
|
|
530
|
-
try {
|
|
531
|
-
executor(this._resolve, this._reject);
|
|
532
|
-
} catch (e) {
|
|
533
|
-
this._reject(e);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
/** JSDoc */
|
|
537
|
-
then(onfulfilled, onrejected) {
|
|
538
|
-
return new SyncPromise((resolve, reject) => {
|
|
539
|
-
this._handlers.push([
|
|
540
|
-
false,
|
|
541
|
-
(result) => {
|
|
542
|
-
if (!onfulfilled) {
|
|
543
|
-
resolve(result);
|
|
544
|
-
} else {
|
|
545
|
-
try {
|
|
546
|
-
resolve(onfulfilled(result));
|
|
547
|
-
} catch (e) {
|
|
548
|
-
reject(e);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
},
|
|
552
|
-
(reason) => {
|
|
553
|
-
if (!onrejected) {
|
|
554
|
-
reject(reason);
|
|
555
|
-
} else {
|
|
556
|
-
try {
|
|
557
|
-
resolve(onrejected(reason));
|
|
558
|
-
} catch (e) {
|
|
559
|
-
reject(e);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
]);
|
|
564
|
-
this._executeHandlers();
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
/** JSDoc */
|
|
568
|
-
catch(onrejected) {
|
|
569
|
-
return this.then((val) => val, onrejected);
|
|
570
|
-
}
|
|
571
|
-
/** JSDoc */
|
|
572
|
-
finally(onfinally) {
|
|
573
|
-
return new SyncPromise((resolve, reject) => {
|
|
574
|
-
let val;
|
|
575
|
-
let isRejected;
|
|
576
|
-
return this.then(
|
|
577
|
-
(value) => {
|
|
578
|
-
isRejected = false;
|
|
579
|
-
val = value;
|
|
580
|
-
if (onfinally) {
|
|
581
|
-
onfinally();
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
(reason) => {
|
|
585
|
-
isRejected = true;
|
|
586
|
-
val = reason;
|
|
587
|
-
if (onfinally) {
|
|
588
|
-
onfinally();
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
).then(() => {
|
|
592
|
-
if (isRejected) {
|
|
593
|
-
reject(val);
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
resolve(val);
|
|
597
|
-
});
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
/** JSDoc */
|
|
601
|
-
__init() {
|
|
602
|
-
this._resolve = (value) => {
|
|
603
|
-
this._setResult(States.RESOLVED, value);
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
/** JSDoc */
|
|
607
|
-
__init2() {
|
|
608
|
-
this._reject = (reason) => {
|
|
609
|
-
this._setResult(States.REJECTED, reason);
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
/** JSDoc */
|
|
613
|
-
__init3() {
|
|
614
|
-
this._setResult = (state, value) => {
|
|
615
|
-
if (this._state !== States.PENDING) {
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
if (isThenable(value)) {
|
|
619
|
-
void value.then(this._resolve, this._reject);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
this._state = state;
|
|
623
|
-
this._value = value;
|
|
624
|
-
this._executeHandlers();
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
/** JSDoc */
|
|
628
|
-
__init4() {
|
|
629
|
-
this._executeHandlers = () => {
|
|
630
|
-
if (this._state === States.PENDING) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
const cachedHandlers = this._handlers.slice();
|
|
634
|
-
this._handlers = [];
|
|
635
|
-
cachedHandlers.forEach((handler) => {
|
|
636
|
-
if (handler[0]) {
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
if (this._state === States.RESOLVED) {
|
|
640
|
-
handler[1](this._value);
|
|
641
|
-
}
|
|
642
|
-
if (this._state === States.REJECTED) {
|
|
643
|
-
handler[2](this._value);
|
|
644
|
-
}
|
|
645
|
-
handler[0] = true;
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
const WINDOW = getGlobalObject();
|
|
651
|
-
const dateTimestampSource = {
|
|
652
|
-
nowSeconds: () => Date.now() / 1e3
|
|
653
|
-
};
|
|
654
|
-
function getBrowserPerformance() {
|
|
655
|
-
const { performance } = WINDOW;
|
|
656
|
-
if (!performance || !performance.now) {
|
|
657
|
-
return void 0;
|
|
658
|
-
}
|
|
659
|
-
const timeOrigin = Date.now() - performance.now();
|
|
660
|
-
return {
|
|
661
|
-
now: () => performance.now(),
|
|
662
|
-
timeOrigin
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
function getNodePerformance() {
|
|
666
|
-
try {
|
|
667
|
-
const perfHooks = dynamicRequire(module, "perf_hooks");
|
|
668
|
-
return perfHooks.performance;
|
|
669
|
-
} catch (_) {
|
|
670
|
-
return void 0;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
|
|
674
|
-
const timestampSource = platformPerformance === void 0 ? dateTimestampSource : {
|
|
675
|
-
nowSeconds: () => (platformPerformance.timeOrigin + platformPerformance.now()) / 1e3
|
|
676
|
-
};
|
|
677
|
-
const dateTimestampInSeconds = dateTimestampSource.nowSeconds.bind(dateTimestampSource);
|
|
678
|
-
const timestampInSeconds = timestampSource.nowSeconds.bind(timestampSource);
|
|
679
|
-
(() => {
|
|
680
|
-
const { performance } = WINDOW;
|
|
681
|
-
if (!performance || !performance.now) {
|
|
682
|
-
return void 0;
|
|
683
|
-
}
|
|
684
|
-
const threshold = 3600 * 1e3;
|
|
685
|
-
const performanceNow = performance.now();
|
|
686
|
-
const dateNow = Date.now();
|
|
687
|
-
const timeOriginDelta = performance.timeOrigin ? Math.abs(performance.timeOrigin + performanceNow - dateNow) : threshold;
|
|
688
|
-
const timeOriginIsReliable = timeOriginDelta < threshold;
|
|
689
|
-
const navigationStart = performance.timing && performance.timing.navigationStart;
|
|
690
|
-
const hasNavigationStart = typeof navigationStart === "number";
|
|
691
|
-
const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
|
|
692
|
-
const navigationStartIsReliable = navigationStartDelta < threshold;
|
|
693
|
-
if (timeOriginIsReliable || navigationStartIsReliable) {
|
|
694
|
-
if (timeOriginDelta <= navigationStartDelta) {
|
|
695
|
-
return performance.timeOrigin;
|
|
696
|
-
} else {
|
|
697
|
-
return navigationStart;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return dateNow;
|
|
701
|
-
})();
|
|
702
|
-
const DEFAULT_ENVIRONMENT = "production";
|
|
703
|
-
function getGlobalEventProcessors() {
|
|
704
|
-
return getGlobalSingleton("globalEventProcessors", () => []);
|
|
705
|
-
}
|
|
706
|
-
function notifyEventProcessors(processors, event, hint, index = 0) {
|
|
707
|
-
return new SyncPromise((resolve, reject) => {
|
|
708
|
-
const processor = processors[index];
|
|
709
|
-
if (event === null || typeof processor !== "function") {
|
|
710
|
-
resolve(event);
|
|
711
|
-
} else {
|
|
712
|
-
const result = processor(__spreadValues({}, event), hint);
|
|
713
|
-
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && processor.id && result === null && logger.log(`Event processor "${processor.id}" dropped event`);
|
|
714
|
-
if (isThenable(result)) {
|
|
715
|
-
void result.then((final) => notifyEventProcessors(processors, final, hint, index + 1).then(resolve)).then(null, reject);
|
|
716
|
-
} else {
|
|
717
|
-
void notifyEventProcessors(processors, result, hint, index + 1).then(resolve).then(null, reject);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
function makeSession(context) {
|
|
723
|
-
const startingTime = timestampInSeconds();
|
|
724
|
-
const session = {
|
|
725
|
-
sid: uuid4(),
|
|
726
|
-
init: true,
|
|
727
|
-
timestamp: startingTime,
|
|
728
|
-
started: startingTime,
|
|
729
|
-
duration: 0,
|
|
730
|
-
status: "ok",
|
|
731
|
-
errors: 0,
|
|
732
|
-
ignoreDuration: false,
|
|
733
|
-
toJSON: () => sessionToJSON(session)
|
|
734
|
-
};
|
|
735
|
-
if (context) {
|
|
736
|
-
updateSession(session, context);
|
|
737
|
-
}
|
|
738
|
-
return session;
|
|
739
|
-
}
|
|
740
|
-
function updateSession(session, context = {}) {
|
|
741
|
-
if (context.user) {
|
|
742
|
-
if (!session.ipAddress && context.user.ip_address) {
|
|
743
|
-
session.ipAddress = context.user.ip_address;
|
|
744
|
-
}
|
|
745
|
-
if (!session.did && !context.did) {
|
|
746
|
-
session.did = context.user.id || context.user.email || context.user.username;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
session.timestamp = context.timestamp || timestampInSeconds();
|
|
750
|
-
if (context.abnormal_mechanism) {
|
|
751
|
-
session.abnormal_mechanism = context.abnormal_mechanism;
|
|
752
|
-
}
|
|
753
|
-
if (context.ignoreDuration) {
|
|
754
|
-
session.ignoreDuration = context.ignoreDuration;
|
|
755
|
-
}
|
|
756
|
-
if (context.sid) {
|
|
757
|
-
session.sid = context.sid.length === 32 ? context.sid : uuid4();
|
|
758
|
-
}
|
|
759
|
-
if (context.init !== void 0) {
|
|
760
|
-
session.init = context.init;
|
|
761
|
-
}
|
|
762
|
-
if (!session.did && context.did) {
|
|
763
|
-
session.did = `${context.did}`;
|
|
764
|
-
}
|
|
765
|
-
if (typeof context.started === "number") {
|
|
766
|
-
session.started = context.started;
|
|
767
|
-
}
|
|
768
|
-
if (session.ignoreDuration) {
|
|
769
|
-
session.duration = void 0;
|
|
770
|
-
} else if (typeof context.duration === "number") {
|
|
771
|
-
session.duration = context.duration;
|
|
772
|
-
} else {
|
|
773
|
-
const duration = session.timestamp - session.started;
|
|
774
|
-
session.duration = duration >= 0 ? duration : 0;
|
|
775
|
-
}
|
|
776
|
-
if (context.release) {
|
|
777
|
-
session.release = context.release;
|
|
778
|
-
}
|
|
779
|
-
if (context.environment) {
|
|
780
|
-
session.environment = context.environment;
|
|
781
|
-
}
|
|
782
|
-
if (!session.ipAddress && context.ipAddress) {
|
|
783
|
-
session.ipAddress = context.ipAddress;
|
|
784
|
-
}
|
|
785
|
-
if (!session.userAgent && context.userAgent) {
|
|
786
|
-
session.userAgent = context.userAgent;
|
|
787
|
-
}
|
|
788
|
-
if (typeof context.errors === "number") {
|
|
789
|
-
session.errors = context.errors;
|
|
790
|
-
}
|
|
791
|
-
if (context.status) {
|
|
792
|
-
session.status = context.status;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
function closeSession(session, status) {
|
|
796
|
-
let context = {};
|
|
797
|
-
if (status) {
|
|
798
|
-
context = { status };
|
|
799
|
-
} else if (session.status === "ok") {
|
|
800
|
-
context = { status: "exited" };
|
|
801
|
-
}
|
|
802
|
-
updateSession(session, context);
|
|
803
|
-
}
|
|
804
|
-
function sessionToJSON(session) {
|
|
805
|
-
return dropUndefinedKeys({
|
|
806
|
-
sid: `${session.sid}`,
|
|
807
|
-
init: session.init,
|
|
808
|
-
// Make sure that sec is converted to ms for date constructor
|
|
809
|
-
started: new Date(session.started * 1e3).toISOString(),
|
|
810
|
-
timestamp: new Date(session.timestamp * 1e3).toISOString(),
|
|
811
|
-
status: session.status,
|
|
812
|
-
errors: session.errors,
|
|
813
|
-
did: typeof session.did === "number" || typeof session.did === "string" ? `${session.did}` : void 0,
|
|
814
|
-
duration: session.duration,
|
|
815
|
-
abnormal_mechanism: session.abnormal_mechanism,
|
|
816
|
-
attrs: {
|
|
817
|
-
release: session.release,
|
|
818
|
-
environment: session.environment,
|
|
819
|
-
ip_address: session.ipAddress,
|
|
820
|
-
user_agent: session.userAgent
|
|
821
|
-
}
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
const DEFAULT_MAX_BREADCRUMBS = 100;
|
|
825
|
-
class Scope {
|
|
826
|
-
/** Flag if notifying is happening. */
|
|
827
|
-
/** Callback for client to receive scope changes. */
|
|
828
|
-
/** Callback list that will be called after {@link applyToEvent}. */
|
|
829
|
-
/** Array of breadcrumbs. */
|
|
830
|
-
/** User */
|
|
831
|
-
/** Tags */
|
|
832
|
-
/** Extra */
|
|
833
|
-
/** Contexts */
|
|
834
|
-
/** Attachments */
|
|
835
|
-
/** Propagation Context for distributed tracing */
|
|
836
|
-
/**
|
|
837
|
-
* A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
|
|
838
|
-
* sent to Sentry
|
|
839
|
-
*/
|
|
840
|
-
/** Fingerprint */
|
|
841
|
-
/** Severity */
|
|
842
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
843
|
-
/** Transaction Name */
|
|
844
|
-
/** Span */
|
|
845
|
-
/** Session */
|
|
846
|
-
/** Request Mode Session Status */
|
|
847
|
-
// NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.
|
|
848
|
-
constructor() {
|
|
849
|
-
this._notifyingListeners = false;
|
|
850
|
-
this._scopeListeners = [];
|
|
851
|
-
this._eventProcessors = [];
|
|
852
|
-
this._breadcrumbs = [];
|
|
853
|
-
this._attachments = [];
|
|
854
|
-
this._user = {};
|
|
855
|
-
this._tags = {};
|
|
856
|
-
this._extra = {};
|
|
857
|
-
this._contexts = {};
|
|
858
|
-
this._sdkProcessingMetadata = {};
|
|
859
|
-
this._propagationContext = generatePropagationContext();
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Inherit values from the parent scope.
|
|
863
|
-
* @param scope to clone.
|
|
864
|
-
*/
|
|
865
|
-
static clone(scope) {
|
|
866
|
-
const newScope = new Scope();
|
|
867
|
-
if (scope) {
|
|
868
|
-
newScope._breadcrumbs = [...scope._breadcrumbs];
|
|
869
|
-
newScope._tags = __spreadValues({}, scope._tags);
|
|
870
|
-
newScope._extra = __spreadValues({}, scope._extra);
|
|
871
|
-
newScope._contexts = __spreadValues({}, scope._contexts);
|
|
872
|
-
newScope._user = scope._user;
|
|
873
|
-
newScope._level = scope._level;
|
|
874
|
-
newScope._span = scope._span;
|
|
875
|
-
newScope._session = scope._session;
|
|
876
|
-
newScope._transactionName = scope._transactionName;
|
|
877
|
-
newScope._fingerprint = scope._fingerprint;
|
|
878
|
-
newScope._eventProcessors = [...scope._eventProcessors];
|
|
879
|
-
newScope._requestSession = scope._requestSession;
|
|
880
|
-
newScope._attachments = [...scope._attachments];
|
|
881
|
-
newScope._sdkProcessingMetadata = __spreadValues({}, scope._sdkProcessingMetadata);
|
|
882
|
-
newScope._propagationContext = __spreadValues({}, scope._propagationContext);
|
|
883
|
-
}
|
|
884
|
-
return newScope;
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Add internal on change listener. Used for sub SDKs that need to store the scope.
|
|
888
|
-
* @hidden
|
|
889
|
-
*/
|
|
890
|
-
addScopeListener(callback) {
|
|
891
|
-
this._scopeListeners.push(callback);
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* @inheritDoc
|
|
895
|
-
*/
|
|
896
|
-
addEventProcessor(callback) {
|
|
897
|
-
this._eventProcessors.push(callback);
|
|
898
|
-
return this;
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* @inheritDoc
|
|
902
|
-
*/
|
|
903
|
-
setUser(user) {
|
|
904
|
-
this._user = user || {};
|
|
905
|
-
if (this._session) {
|
|
906
|
-
updateSession(this._session, { user });
|
|
907
|
-
}
|
|
908
|
-
this._notifyScopeListeners();
|
|
909
|
-
return this;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* @inheritDoc
|
|
913
|
-
*/
|
|
914
|
-
getUser() {
|
|
915
|
-
return this._user;
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* @inheritDoc
|
|
919
|
-
*/
|
|
920
|
-
getRequestSession() {
|
|
921
|
-
return this._requestSession;
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* @inheritDoc
|
|
925
|
-
*/
|
|
926
|
-
setRequestSession(requestSession) {
|
|
927
|
-
this._requestSession = requestSession;
|
|
928
|
-
return this;
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* @inheritDoc
|
|
932
|
-
*/
|
|
933
|
-
setTags(tags) {
|
|
934
|
-
this._tags = __spreadValues(__spreadValues({}, this._tags), tags);
|
|
935
|
-
this._notifyScopeListeners();
|
|
936
|
-
return this;
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* @inheritDoc
|
|
940
|
-
*/
|
|
941
|
-
setTag(key, value) {
|
|
942
|
-
this._tags = __spreadProps(__spreadValues({}, this._tags), { [key]: value });
|
|
943
|
-
this._notifyScopeListeners();
|
|
944
|
-
return this;
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* @inheritDoc
|
|
948
|
-
*/
|
|
949
|
-
setExtras(extras) {
|
|
950
|
-
this._extra = __spreadValues(__spreadValues({}, this._extra), extras);
|
|
951
|
-
this._notifyScopeListeners();
|
|
952
|
-
return this;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* @inheritDoc
|
|
956
|
-
*/
|
|
957
|
-
setExtra(key, extra) {
|
|
958
|
-
this._extra = __spreadProps(__spreadValues({}, this._extra), { [key]: extra });
|
|
959
|
-
this._notifyScopeListeners();
|
|
960
|
-
return this;
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* @inheritDoc
|
|
964
|
-
*/
|
|
965
|
-
setFingerprint(fingerprint) {
|
|
966
|
-
this._fingerprint = fingerprint;
|
|
967
|
-
this._notifyScopeListeners();
|
|
968
|
-
return this;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* @inheritDoc
|
|
972
|
-
*/
|
|
973
|
-
setLevel(level) {
|
|
974
|
-
this._level = level;
|
|
975
|
-
this._notifyScopeListeners();
|
|
976
|
-
return this;
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* @inheritDoc
|
|
980
|
-
*/
|
|
981
|
-
setTransactionName(name) {
|
|
982
|
-
this._transactionName = name;
|
|
983
|
-
this._notifyScopeListeners();
|
|
984
|
-
return this;
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* @inheritDoc
|
|
988
|
-
*/
|
|
989
|
-
setContext(key, context) {
|
|
990
|
-
if (context === null) {
|
|
991
|
-
delete this._contexts[key];
|
|
992
|
-
} else {
|
|
993
|
-
this._contexts[key] = context;
|
|
994
|
-
}
|
|
995
|
-
this._notifyScopeListeners();
|
|
996
|
-
return this;
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* @inheritDoc
|
|
1000
|
-
*/
|
|
1001
|
-
setSpan(span) {
|
|
1002
|
-
this._span = span;
|
|
1003
|
-
this._notifyScopeListeners();
|
|
1004
|
-
return this;
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* @inheritDoc
|
|
1008
|
-
*/
|
|
1009
|
-
getSpan() {
|
|
1010
|
-
return this._span;
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* @inheritDoc
|
|
1014
|
-
*/
|
|
1015
|
-
getTransaction() {
|
|
1016
|
-
const span = this.getSpan();
|
|
1017
|
-
return span && span.transaction;
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* @inheritDoc
|
|
1021
|
-
*/
|
|
1022
|
-
setSession(session) {
|
|
1023
|
-
if (!session) {
|
|
1024
|
-
delete this._session;
|
|
1025
|
-
} else {
|
|
1026
|
-
this._session = session;
|
|
1027
|
-
}
|
|
1028
|
-
this._notifyScopeListeners();
|
|
1029
|
-
return this;
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* @inheritDoc
|
|
1033
|
-
*/
|
|
1034
|
-
getSession() {
|
|
1035
|
-
return this._session;
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* @inheritDoc
|
|
1039
|
-
*/
|
|
1040
|
-
update(captureContext) {
|
|
1041
|
-
if (!captureContext) {
|
|
1042
|
-
return this;
|
|
1043
|
-
}
|
|
1044
|
-
if (typeof captureContext === "function") {
|
|
1045
|
-
const updatedScope = captureContext(this);
|
|
1046
|
-
return updatedScope instanceof Scope ? updatedScope : this;
|
|
1047
|
-
}
|
|
1048
|
-
if (captureContext instanceof Scope) {
|
|
1049
|
-
this._tags = __spreadValues(__spreadValues({}, this._tags), captureContext._tags);
|
|
1050
|
-
this._extra = __spreadValues(__spreadValues({}, this._extra), captureContext._extra);
|
|
1051
|
-
this._contexts = __spreadValues(__spreadValues({}, this._contexts), captureContext._contexts);
|
|
1052
|
-
if (captureContext._user && Object.keys(captureContext._user).length) {
|
|
1053
|
-
this._user = captureContext._user;
|
|
1054
|
-
}
|
|
1055
|
-
if (captureContext._level) {
|
|
1056
|
-
this._level = captureContext._level;
|
|
1057
|
-
}
|
|
1058
|
-
if (captureContext._fingerprint) {
|
|
1059
|
-
this._fingerprint = captureContext._fingerprint;
|
|
1060
|
-
}
|
|
1061
|
-
if (captureContext._requestSession) {
|
|
1062
|
-
this._requestSession = captureContext._requestSession;
|
|
1063
|
-
}
|
|
1064
|
-
if (captureContext._propagationContext) {
|
|
1065
|
-
this._propagationContext = captureContext._propagationContext;
|
|
1066
|
-
}
|
|
1067
|
-
} else if (isPlainObject(captureContext)) {
|
|
1068
|
-
captureContext = captureContext;
|
|
1069
|
-
this._tags = __spreadValues(__spreadValues({}, this._tags), captureContext.tags);
|
|
1070
|
-
this._extra = __spreadValues(__spreadValues({}, this._extra), captureContext.extra);
|
|
1071
|
-
this._contexts = __spreadValues(__spreadValues({}, this._contexts), captureContext.contexts);
|
|
1072
|
-
if (captureContext.user) {
|
|
1073
|
-
this._user = captureContext.user;
|
|
1074
|
-
}
|
|
1075
|
-
if (captureContext.level) {
|
|
1076
|
-
this._level = captureContext.level;
|
|
1077
|
-
}
|
|
1078
|
-
if (captureContext.fingerprint) {
|
|
1079
|
-
this._fingerprint = captureContext.fingerprint;
|
|
1080
|
-
}
|
|
1081
|
-
if (captureContext.requestSession) {
|
|
1082
|
-
this._requestSession = captureContext.requestSession;
|
|
1083
|
-
}
|
|
1084
|
-
if (captureContext.propagationContext) {
|
|
1085
|
-
this._propagationContext = captureContext.propagationContext;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
return this;
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* @inheritDoc
|
|
1092
|
-
*/
|
|
1093
|
-
clear() {
|
|
1094
|
-
this._breadcrumbs = [];
|
|
1095
|
-
this._tags = {};
|
|
1096
|
-
this._extra = {};
|
|
1097
|
-
this._user = {};
|
|
1098
|
-
this._contexts = {};
|
|
1099
|
-
this._level = void 0;
|
|
1100
|
-
this._transactionName = void 0;
|
|
1101
|
-
this._fingerprint = void 0;
|
|
1102
|
-
this._requestSession = void 0;
|
|
1103
|
-
this._span = void 0;
|
|
1104
|
-
this._session = void 0;
|
|
1105
|
-
this._notifyScopeListeners();
|
|
1106
|
-
this._attachments = [];
|
|
1107
|
-
this._propagationContext = generatePropagationContext();
|
|
1108
|
-
return this;
|
|
1109
|
-
}
|
|
1110
|
-
/**
|
|
1111
|
-
* @inheritDoc
|
|
1112
|
-
*/
|
|
1113
|
-
addBreadcrumb(breadcrumb, maxBreadcrumbs) {
|
|
1114
|
-
const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
|
|
1115
|
-
if (maxCrumbs <= 0) {
|
|
1116
|
-
return this;
|
|
1117
|
-
}
|
|
1118
|
-
const mergedBreadcrumb = __spreadValues({
|
|
1119
|
-
timestamp: dateTimestampInSeconds()
|
|
1120
|
-
}, breadcrumb);
|
|
1121
|
-
const breadcrumbs = this._breadcrumbs;
|
|
1122
|
-
breadcrumbs.push(mergedBreadcrumb);
|
|
1123
|
-
this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs;
|
|
1124
|
-
this._notifyScopeListeners();
|
|
1125
|
-
return this;
|
|
1126
|
-
}
|
|
1127
|
-
/**
|
|
1128
|
-
* @inheritDoc
|
|
1129
|
-
*/
|
|
1130
|
-
getLastBreadcrumb() {
|
|
1131
|
-
return this._breadcrumbs[this._breadcrumbs.length - 1];
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* @inheritDoc
|
|
1135
|
-
*/
|
|
1136
|
-
clearBreadcrumbs() {
|
|
1137
|
-
this._breadcrumbs = [];
|
|
1138
|
-
this._notifyScopeListeners();
|
|
1139
|
-
return this;
|
|
1140
|
-
}
|
|
1141
|
-
/**
|
|
1142
|
-
* @inheritDoc
|
|
1143
|
-
*/
|
|
1144
|
-
addAttachment(attachment) {
|
|
1145
|
-
this._attachments.push(attachment);
|
|
1146
|
-
return this;
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* @inheritDoc
|
|
1150
|
-
*/
|
|
1151
|
-
getAttachments() {
|
|
1152
|
-
return this._attachments;
|
|
1153
|
-
}
|
|
1154
|
-
/**
|
|
1155
|
-
* @inheritDoc
|
|
1156
|
-
*/
|
|
1157
|
-
clearAttachments() {
|
|
1158
|
-
this._attachments = [];
|
|
1159
|
-
return this;
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Applies data from the scope to the event and runs all event processors on it.
|
|
1163
|
-
*
|
|
1164
|
-
* @param event Event
|
|
1165
|
-
* @param hint Object containing additional information about the original exception, for use by the event processors.
|
|
1166
|
-
* @hidden
|
|
1167
|
-
*/
|
|
1168
|
-
applyToEvent(event, hint = {}, additionalEventProcessors) {
|
|
1169
|
-
if (this._extra && Object.keys(this._extra).length) {
|
|
1170
|
-
event.extra = __spreadValues(__spreadValues({}, this._extra), event.extra);
|
|
1171
|
-
}
|
|
1172
|
-
if (this._tags && Object.keys(this._tags).length) {
|
|
1173
|
-
event.tags = __spreadValues(__spreadValues({}, this._tags), event.tags);
|
|
1174
|
-
}
|
|
1175
|
-
if (this._user && Object.keys(this._user).length) {
|
|
1176
|
-
event.user = __spreadValues(__spreadValues({}, this._user), event.user);
|
|
1177
|
-
}
|
|
1178
|
-
if (this._contexts && Object.keys(this._contexts).length) {
|
|
1179
|
-
event.contexts = __spreadValues(__spreadValues({}, this._contexts), event.contexts);
|
|
1180
|
-
}
|
|
1181
|
-
if (this._level) {
|
|
1182
|
-
event.level = this._level;
|
|
1183
|
-
}
|
|
1184
|
-
if (this._transactionName) {
|
|
1185
|
-
event.transaction = this._transactionName;
|
|
1186
|
-
}
|
|
1187
|
-
if (this._span) {
|
|
1188
|
-
event.contexts = __spreadValues({ trace: this._span.getTraceContext() }, event.contexts);
|
|
1189
|
-
const transaction = this._span.transaction;
|
|
1190
|
-
if (transaction) {
|
|
1191
|
-
event.sdkProcessingMetadata = __spreadValues({
|
|
1192
|
-
dynamicSamplingContext: transaction.getDynamicSamplingContext()
|
|
1193
|
-
}, event.sdkProcessingMetadata);
|
|
1194
|
-
const transactionName = transaction.name;
|
|
1195
|
-
if (transactionName) {
|
|
1196
|
-
event.tags = __spreadValues({ transaction: transactionName }, event.tags);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
this._applyFingerprint(event);
|
|
1201
|
-
const scopeBreadcrumbs = this._getBreadcrumbs();
|
|
1202
|
-
const breadcrumbs = [...event.breadcrumbs || [], ...scopeBreadcrumbs];
|
|
1203
|
-
event.breadcrumbs = breadcrumbs.length > 0 ? breadcrumbs : void 0;
|
|
1204
|
-
event.sdkProcessingMetadata = __spreadProps(__spreadValues(__spreadValues({}, event.sdkProcessingMetadata), this._sdkProcessingMetadata), {
|
|
1205
|
-
propagationContext: this._propagationContext
|
|
1206
|
-
});
|
|
1207
|
-
return notifyEventProcessors(
|
|
1208
|
-
[...additionalEventProcessors || [], ...getGlobalEventProcessors(), ...this._eventProcessors],
|
|
1209
|
-
event,
|
|
1210
|
-
hint
|
|
1211
|
-
);
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* Add data which will be accessible during event processing but won't get sent to Sentry
|
|
1215
|
-
*/
|
|
1216
|
-
setSDKProcessingMetadata(newData) {
|
|
1217
|
-
this._sdkProcessingMetadata = __spreadValues(__spreadValues({}, this._sdkProcessingMetadata), newData);
|
|
1218
|
-
return this;
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* @inheritDoc
|
|
1222
|
-
*/
|
|
1223
|
-
setPropagationContext(context) {
|
|
1224
|
-
this._propagationContext = context;
|
|
1225
|
-
return this;
|
|
1226
|
-
}
|
|
1227
|
-
/**
|
|
1228
|
-
* @inheritDoc
|
|
1229
|
-
*/
|
|
1230
|
-
getPropagationContext() {
|
|
1231
|
-
return this._propagationContext;
|
|
1232
|
-
}
|
|
1233
|
-
/**
|
|
1234
|
-
* Get the breadcrumbs for this scope.
|
|
1235
|
-
*/
|
|
1236
|
-
_getBreadcrumbs() {
|
|
1237
|
-
return this._breadcrumbs;
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* This will be called on every set call.
|
|
1241
|
-
*/
|
|
1242
|
-
_notifyScopeListeners() {
|
|
1243
|
-
if (!this._notifyingListeners) {
|
|
1244
|
-
this._notifyingListeners = true;
|
|
1245
|
-
this._scopeListeners.forEach((callback) => {
|
|
1246
|
-
callback(this);
|
|
1247
|
-
});
|
|
1248
|
-
this._notifyingListeners = false;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
/**
|
|
1252
|
-
* Applies fingerprint from the scope to the event if there's one,
|
|
1253
|
-
* uses message if there's one instead or get rid of empty fingerprint
|
|
1254
|
-
*/
|
|
1255
|
-
_applyFingerprint(event) {
|
|
1256
|
-
event.fingerprint = event.fingerprint ? arrayify(event.fingerprint) : [];
|
|
1257
|
-
if (this._fingerprint) {
|
|
1258
|
-
event.fingerprint = event.fingerprint.concat(this._fingerprint);
|
|
1259
|
-
}
|
|
1260
|
-
if (event.fingerprint && !event.fingerprint.length) {
|
|
1261
|
-
delete event.fingerprint;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
function generatePropagationContext() {
|
|
1266
|
-
return {
|
|
1267
|
-
traceId: uuid4(),
|
|
1268
|
-
spanId: uuid4().substring(16)
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
const API_VERSION = 4;
|
|
1272
|
-
const DEFAULT_BREADCRUMBS = 100;
|
|
1273
|
-
class Hub {
|
|
1274
|
-
/** Is a {@link Layer}[] containing the client and scope */
|
|
1275
|
-
/** Contains the last event id of a captured event. */
|
|
1276
|
-
/**
|
|
1277
|
-
* Creates a new instance of the hub, will push one {@link Layer} into the
|
|
1278
|
-
* internal stack on creation.
|
|
1279
|
-
*
|
|
1280
|
-
* @param client bound to the hub.
|
|
1281
|
-
* @param scope bound to the hub.
|
|
1282
|
-
* @param version number, higher number means higher priority.
|
|
1283
|
-
*/
|
|
1284
|
-
constructor(client2, scope = new Scope(), _version = API_VERSION) {
|
|
1285
|
-
this._version = _version;
|
|
1286
|
-
this._stack = [{ scope }];
|
|
1287
|
-
if (client2) {
|
|
1288
|
-
this.bindClient(client2);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
/**
|
|
1292
|
-
* @inheritDoc
|
|
1293
|
-
*/
|
|
1294
|
-
isOlderThan(version) {
|
|
1295
|
-
return this._version < version;
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* @inheritDoc
|
|
1299
|
-
*/
|
|
1300
|
-
bindClient(client2) {
|
|
1301
|
-
const top = this.getStackTop();
|
|
1302
|
-
top.client = client2;
|
|
1303
|
-
if (client2 && client2.setupIntegrations) {
|
|
1304
|
-
client2.setupIntegrations();
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* @inheritDoc
|
|
1309
|
-
*/
|
|
1310
|
-
pushScope() {
|
|
1311
|
-
const scope = Scope.clone(this.getScope());
|
|
1312
|
-
this.getStack().push({
|
|
1313
|
-
client: this.getClient(),
|
|
1314
|
-
scope
|
|
1315
|
-
});
|
|
1316
|
-
return scope;
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* @inheritDoc
|
|
1320
|
-
*/
|
|
1321
|
-
popScope() {
|
|
1322
|
-
if (this.getStack().length <= 1)
|
|
1323
|
-
return false;
|
|
1324
|
-
return !!this.getStack().pop();
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* @inheritDoc
|
|
1328
|
-
*/
|
|
1329
|
-
withScope(callback) {
|
|
1330
|
-
const scope = this.pushScope();
|
|
1331
|
-
try {
|
|
1332
|
-
callback(scope);
|
|
1333
|
-
} finally {
|
|
1334
|
-
this.popScope();
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
/**
|
|
1338
|
-
* @inheritDoc
|
|
1339
|
-
*/
|
|
1340
|
-
getClient() {
|
|
1341
|
-
return this.getStackTop().client;
|
|
1342
|
-
}
|
|
1343
|
-
/** Returns the scope of the top stack. */
|
|
1344
|
-
getScope() {
|
|
1345
|
-
return this.getStackTop().scope;
|
|
1346
|
-
}
|
|
1347
|
-
/** Returns the scope stack for domains or the process. */
|
|
1348
|
-
getStack() {
|
|
1349
|
-
return this._stack;
|
|
1350
|
-
}
|
|
1351
|
-
/** Returns the topmost scope layer in the order domain > local > process. */
|
|
1352
|
-
getStackTop() {
|
|
1353
|
-
return this._stack[this._stack.length - 1];
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* @inheritDoc
|
|
1357
|
-
*/
|
|
1358
|
-
captureException(exception, hint) {
|
|
1359
|
-
const eventId = this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1360
|
-
const syntheticException = new Error("Sentry syntheticException");
|
|
1361
|
-
this._withClient((client2, scope) => {
|
|
1362
|
-
client2.captureException(
|
|
1363
|
-
exception,
|
|
1364
|
-
__spreadProps(__spreadValues({
|
|
1365
|
-
originalException: exception,
|
|
1366
|
-
syntheticException
|
|
1367
|
-
}, hint), {
|
|
1368
|
-
event_id: eventId
|
|
1369
|
-
}),
|
|
1370
|
-
scope
|
|
1371
|
-
);
|
|
1372
|
-
});
|
|
1373
|
-
return eventId;
|
|
1374
|
-
}
|
|
1375
|
-
/**
|
|
1376
|
-
* @inheritDoc
|
|
1377
|
-
*/
|
|
1378
|
-
captureMessage(message, level, hint) {
|
|
1379
|
-
const eventId = this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1380
|
-
const syntheticException = new Error(message);
|
|
1381
|
-
this._withClient((client2, scope) => {
|
|
1382
|
-
client2.captureMessage(
|
|
1383
|
-
message,
|
|
1384
|
-
level,
|
|
1385
|
-
__spreadProps(__spreadValues({
|
|
1386
|
-
originalException: message,
|
|
1387
|
-
syntheticException
|
|
1388
|
-
}, hint), {
|
|
1389
|
-
event_id: eventId
|
|
1390
|
-
}),
|
|
1391
|
-
scope
|
|
1392
|
-
);
|
|
1393
|
-
});
|
|
1394
|
-
return eventId;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* @inheritDoc
|
|
1398
|
-
*/
|
|
1399
|
-
captureEvent(event, hint) {
|
|
1400
|
-
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1401
|
-
if (!event.type) {
|
|
1402
|
-
this._lastEventId = eventId;
|
|
1403
|
-
}
|
|
1404
|
-
this._withClient((client2, scope) => {
|
|
1405
|
-
client2.captureEvent(event, __spreadProps(__spreadValues({}, hint), { event_id: eventId }), scope);
|
|
1406
|
-
});
|
|
1407
|
-
return eventId;
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* @inheritDoc
|
|
1411
|
-
*/
|
|
1412
|
-
lastEventId() {
|
|
1413
|
-
return this._lastEventId;
|
|
1414
|
-
}
|
|
1415
|
-
/**
|
|
1416
|
-
* @inheritDoc
|
|
1417
|
-
*/
|
|
1418
|
-
addBreadcrumb(breadcrumb, hint) {
|
|
1419
|
-
const { scope, client: client2 } = this.getStackTop();
|
|
1420
|
-
if (!client2)
|
|
1421
|
-
return;
|
|
1422
|
-
const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = client2.getOptions && client2.getOptions() || {};
|
|
1423
|
-
if (maxBreadcrumbs <= 0)
|
|
1424
|
-
return;
|
|
1425
|
-
const timestamp = dateTimestampInSeconds();
|
|
1426
|
-
const mergedBreadcrumb = __spreadValues({ timestamp }, breadcrumb);
|
|
1427
|
-
const finalBreadcrumb = beforeBreadcrumb ? consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint)) : mergedBreadcrumb;
|
|
1428
|
-
if (finalBreadcrumb === null)
|
|
1429
|
-
return;
|
|
1430
|
-
if (client2.emit) {
|
|
1431
|
-
client2.emit("beforeAddBreadcrumb", finalBreadcrumb, hint);
|
|
1432
|
-
}
|
|
1433
|
-
scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
|
|
1434
|
-
}
|
|
1435
|
-
/**
|
|
1436
|
-
* @inheritDoc
|
|
1437
|
-
*/
|
|
1438
|
-
setUser(user) {
|
|
1439
|
-
this.getScope().setUser(user);
|
|
1440
|
-
}
|
|
1441
|
-
/**
|
|
1442
|
-
* @inheritDoc
|
|
1443
|
-
*/
|
|
1444
|
-
setTags(tags) {
|
|
1445
|
-
this.getScope().setTags(tags);
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* @inheritDoc
|
|
1449
|
-
*/
|
|
1450
|
-
setExtras(extras) {
|
|
1451
|
-
this.getScope().setExtras(extras);
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* @inheritDoc
|
|
1455
|
-
*/
|
|
1456
|
-
setTag(key, value) {
|
|
1457
|
-
this.getScope().setTag(key, value);
|
|
1458
|
-
}
|
|
1459
|
-
/**
|
|
1460
|
-
* @inheritDoc
|
|
1461
|
-
*/
|
|
1462
|
-
setExtra(key, extra) {
|
|
1463
|
-
this.getScope().setExtra(key, extra);
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* @inheritDoc
|
|
1467
|
-
*/
|
|
1468
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1469
|
-
setContext(name, context) {
|
|
1470
|
-
this.getScope().setContext(name, context);
|
|
1471
|
-
}
|
|
1472
|
-
/**
|
|
1473
|
-
* @inheritDoc
|
|
1474
|
-
*/
|
|
1475
|
-
configureScope(callback) {
|
|
1476
|
-
const { scope, client: client2 } = this.getStackTop();
|
|
1477
|
-
if (client2) {
|
|
1478
|
-
callback(scope);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
/**
|
|
1482
|
-
* @inheritDoc
|
|
1483
|
-
*/
|
|
1484
|
-
run(callback) {
|
|
1485
|
-
const oldHub = makeMain(this);
|
|
1486
|
-
try {
|
|
1487
|
-
callback(this);
|
|
1488
|
-
} finally {
|
|
1489
|
-
makeMain(oldHub);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* @inheritDoc
|
|
1494
|
-
*/
|
|
1495
|
-
getIntegration(integration) {
|
|
1496
|
-
const client2 = this.getClient();
|
|
1497
|
-
if (!client2)
|
|
1498
|
-
return null;
|
|
1499
|
-
try {
|
|
1500
|
-
return client2.getIntegration(integration);
|
|
1501
|
-
} catch (_oO) {
|
|
1502
|
-
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && logger.warn(`Cannot retrieve integration ${integration.id} from the current Hub`);
|
|
1503
|
-
return null;
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
/**
|
|
1507
|
-
* @inheritDoc
|
|
1508
|
-
*/
|
|
1509
|
-
startTransaction(context, customSamplingContext) {
|
|
1510
|
-
const result = this._callExtensionMethod("startTransaction", context, customSamplingContext);
|
|
1511
|
-
if ((typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && !result) {
|
|
1512
|
-
const client2 = this.getClient();
|
|
1513
|
-
if (!client2) {
|
|
1514
|
-
console.warn(
|
|
1515
|
-
"Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'"
|
|
1516
|
-
);
|
|
1517
|
-
} else {
|
|
1518
|
-
console.warn(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
|
|
1519
|
-
Sentry.addTracingExtensions();
|
|
1520
|
-
Sentry.init({...});
|
|
1521
|
-
`);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
return result;
|
|
1525
|
-
}
|
|
1526
|
-
/**
|
|
1527
|
-
* @inheritDoc
|
|
1528
|
-
*/
|
|
1529
|
-
traceHeaders() {
|
|
1530
|
-
return this._callExtensionMethod("traceHeaders");
|
|
1531
|
-
}
|
|
1532
|
-
/**
|
|
1533
|
-
* @inheritDoc
|
|
1534
|
-
*/
|
|
1535
|
-
captureSession(endSession = false) {
|
|
1536
|
-
if (endSession) {
|
|
1537
|
-
return this.endSession();
|
|
1538
|
-
}
|
|
1539
|
-
this._sendSessionUpdate();
|
|
1540
|
-
}
|
|
1541
|
-
/**
|
|
1542
|
-
* @inheritDoc
|
|
1543
|
-
*/
|
|
1544
|
-
endSession() {
|
|
1545
|
-
const layer = this.getStackTop();
|
|
1546
|
-
const scope = layer.scope;
|
|
1547
|
-
const session = scope.getSession();
|
|
1548
|
-
if (session) {
|
|
1549
|
-
closeSession(session);
|
|
1550
|
-
}
|
|
1551
|
-
this._sendSessionUpdate();
|
|
1552
|
-
scope.setSession();
|
|
1553
|
-
}
|
|
1554
|
-
/**
|
|
1555
|
-
* @inheritDoc
|
|
1556
|
-
*/
|
|
1557
|
-
startSession(context) {
|
|
1558
|
-
const { scope, client: client2 } = this.getStackTop();
|
|
1559
|
-
const { release, environment = DEFAULT_ENVIRONMENT } = client2 && client2.getOptions() || {};
|
|
1560
|
-
const { userAgent } = GLOBAL_OBJ.navigator || {};
|
|
1561
|
-
const session = makeSession(__spreadValues(__spreadValues({
|
|
1562
|
-
release,
|
|
1563
|
-
environment,
|
|
1564
|
-
user: scope.getUser()
|
|
1565
|
-
}, userAgent && { userAgent }), context));
|
|
1566
|
-
const currentSession = scope.getSession && scope.getSession();
|
|
1567
|
-
if (currentSession && currentSession.status === "ok") {
|
|
1568
|
-
updateSession(currentSession, { status: "exited" });
|
|
1569
|
-
}
|
|
1570
|
-
this.endSession();
|
|
1571
|
-
scope.setSession(session);
|
|
1572
|
-
return session;
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Returns if default PII should be sent to Sentry and propagated in ourgoing requests
|
|
1576
|
-
* when Tracing is used.
|
|
1577
|
-
*/
|
|
1578
|
-
shouldSendDefaultPii() {
|
|
1579
|
-
const client2 = this.getClient();
|
|
1580
|
-
const options = client2 && client2.getOptions();
|
|
1581
|
-
return Boolean(options && options.sendDefaultPii);
|
|
1582
|
-
}
|
|
1583
|
-
/**
|
|
1584
|
-
* Sends the current Session on the scope
|
|
1585
|
-
*/
|
|
1586
|
-
_sendSessionUpdate() {
|
|
1587
|
-
const { scope, client: client2 } = this.getStackTop();
|
|
1588
|
-
const session = scope.getSession();
|
|
1589
|
-
if (session && client2 && client2.captureSession) {
|
|
1590
|
-
client2.captureSession(session);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
/**
|
|
1594
|
-
* Internal helper function to call a method on the top client if it exists.
|
|
1595
|
-
*
|
|
1596
|
-
* @param method The method to call on the client.
|
|
1597
|
-
* @param args Arguments to pass to the client function.
|
|
1598
|
-
*/
|
|
1599
|
-
_withClient(callback) {
|
|
1600
|
-
const { scope, client: client2 } = this.getStackTop();
|
|
1601
|
-
if (client2) {
|
|
1602
|
-
callback(client2, scope);
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
/**
|
|
1606
|
-
* Calls global extension method and binding current instance to the function call
|
|
1607
|
-
*/
|
|
1608
|
-
// @ts-expect-error Function lacks ending return statement and return type does not include 'undefined'. ts(2366)
|
|
1609
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1610
|
-
_callExtensionMethod(method, ...args) {
|
|
1611
|
-
const carrier = getMainCarrier();
|
|
1612
|
-
const sentry = carrier.__SENTRY__;
|
|
1613
|
-
if (sentry && sentry.extensions && typeof sentry.extensions[method] === "function") {
|
|
1614
|
-
return sentry.extensions[method].apply(this, args);
|
|
1615
|
-
}
|
|
1616
|
-
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && logger.warn(`Extension method ${method} couldn't be found, doing nothing.`);
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
function getMainCarrier() {
|
|
1620
|
-
GLOBAL_OBJ.__SENTRY__ = GLOBAL_OBJ.__SENTRY__ || {
|
|
1621
|
-
extensions: {},
|
|
1622
|
-
hub: void 0
|
|
1623
|
-
};
|
|
1624
|
-
return GLOBAL_OBJ;
|
|
1625
|
-
}
|
|
1626
|
-
function makeMain(hub) {
|
|
1627
|
-
const registry = getMainCarrier();
|
|
1628
|
-
const oldHub = getHubFromCarrier(registry);
|
|
1629
|
-
setHubOnCarrier(registry, hub);
|
|
1630
|
-
return oldHub;
|
|
1631
|
-
}
|
|
1632
|
-
function getCurrentHub() {
|
|
1633
|
-
const registry = getMainCarrier();
|
|
1634
|
-
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
|
|
1635
|
-
const hub = registry.__SENTRY__.acs.getCurrentHub();
|
|
1636
|
-
if (hub) {
|
|
1637
|
-
return hub;
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
return getGlobalHub(registry);
|
|
1641
|
-
}
|
|
1642
|
-
function getGlobalHub(registry = getMainCarrier()) {
|
|
1643
|
-
if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) {
|
|
1644
|
-
setHubOnCarrier(registry, new Hub());
|
|
1645
|
-
}
|
|
1646
|
-
return getHubFromCarrier(registry);
|
|
1647
|
-
}
|
|
1648
|
-
function hasHubOnCarrier(carrier) {
|
|
1649
|
-
return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub);
|
|
1650
|
-
}
|
|
1651
|
-
function getHubFromCarrier(carrier) {
|
|
1652
|
-
return getGlobalSingleton("hub", () => new Hub(), carrier);
|
|
1653
|
-
}
|
|
1654
|
-
function setHubOnCarrier(carrier, hub) {
|
|
1655
|
-
if (!carrier)
|
|
1656
|
-
return false;
|
|
1657
|
-
const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {};
|
|
1658
|
-
__SENTRY__.hub = hub;
|
|
1659
|
-
return true;
|
|
1660
|
-
}
|
|
1661
|
-
function captureMessage(message, captureContext) {
|
|
1662
|
-
const level = typeof captureContext === "string" ? captureContext : void 0;
|
|
1663
|
-
const context = typeof captureContext !== "string" ? { captureContext } : void 0;
|
|
1664
|
-
return getCurrentHub().captureMessage(message, level, context);
|
|
1665
|
-
}
|
|
1666
|
-
const errorsToIgnore = [
|
|
1667
|
-
MiniAppErrorType.sdkNotInitialized,
|
|
1668
|
-
MiniAppErrorType.notAuthorized,
|
|
1669
|
-
MiniAppErrorType.userCanceled,
|
|
1670
|
-
MiniAppErrorType.userCanceledSimilarTxn,
|
|
1671
|
-
MiniAppErrorType.suspectedDuplicatePayment,
|
|
1672
|
-
MiniAppErrorType.noSufficientFund
|
|
1673
|
-
];
|
|
1674
|
-
function sendWindowBridgeErrorToSentry(functionName, message, error) {
|
|
1675
|
-
if (!errorsToIgnore.includes(error) && SENTRY_DSN) {
|
|
1676
|
-
captureMessage(
|
|
1677
|
-
`windowBridge.${functionName} failed. client: ${"unknown"}, error: ${error}, message: ${message}`,
|
|
1678
|
-
"log"
|
|
1679
|
-
);
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
let clientId;
|
|
1683
|
-
if (!isEnableLocalStorage())
|
|
1684
|
-
;
|
|
1685
|
-
function getClientId() {
|
|
1686
|
-
return clientId;
|
|
1687
|
-
}
|
|
1688
|
-
function isEnableLocalStorage() {
|
|
1689
|
-
try {
|
|
1690
|
-
localStorage.getItem("ppjssdk.canWriteToLocalStorage");
|
|
1691
|
-
return true;
|
|
1692
|
-
} catch (e) {
|
|
1693
|
-
console.log(e);
|
|
1694
|
-
return false;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
function isIP(hostName) {
|
|
1698
|
-
return isIPv4(hostName) || isIPv6(hostName);
|
|
1699
|
-
}
|
|
1700
|
-
function isIPv4(hostName) {
|
|
1701
|
-
const expression = /(^\s*(((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]))\s*$)/;
|
|
1702
|
-
return expression.test(hostName);
|
|
1703
|
-
}
|
|
1704
|
-
function isIPv6(hostName) {
|
|
1705
|
-
const expression = /(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$)/;
|
|
1706
|
-
return expression.test(hostName);
|
|
363
|
+
function isIPv6(hostName) {
|
|
364
|
+
const expression = /(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$)/;
|
|
365
|
+
return expression.test(hostName);
|
|
1707
366
|
}
|
|
1708
367
|
const secondaryList = [
|
|
1709
368
|
"ab.ca",
|
|
@@ -2036,22 +695,1363 @@ function parseDomain(domain) {
|
|
|
2036
695
|
if (isIP(domain) || splitStr.length <= 2) {
|
|
2037
696
|
return domain;
|
|
2038
697
|
}
|
|
2039
|
-
const secondary = splitStr.slice(splitStr.length - 2).join(".");
|
|
2040
|
-
if (secondaryList.includes(secondary) && splitStr.length >= 3) {
|
|
2041
|
-
return splitStr.slice(splitStr.length - 3).join(".");
|
|
698
|
+
const secondary = splitStr.slice(splitStr.length - 2).join(".");
|
|
699
|
+
if (secondaryList.includes(secondary) && splitStr.length >= 3) {
|
|
700
|
+
return splitStr.slice(splitStr.length - 3).join(".");
|
|
701
|
+
}
|
|
702
|
+
return splitStr.slice(splitStr.length - 2).join(".");
|
|
703
|
+
}
|
|
704
|
+
function getDomain(subdomainCookieSharing, hostname) {
|
|
705
|
+
return subdomainCookieSharing ? parseDomain(hostname) : hostname;
|
|
706
|
+
}
|
|
707
|
+
({
|
|
708
|
+
UNAUTHORIZED: MiniAppErrorType.notAuthorized,
|
|
709
|
+
BAD_REQUEST: MiniAppErrorType.badRequest,
|
|
710
|
+
MISSING_REQUEST_PARAMS: MiniAppErrorType.badRequestInsufficientParameter,
|
|
711
|
+
OP_OUT_OF_SCOPE: MiniAppErrorType.insufficientScope,
|
|
712
|
+
MINI_APP_SCOPE_NOT_FOUND: MiniAppErrorType.insufficientScope
|
|
713
|
+
});
|
|
714
|
+
const JS_SDK_VERSION = "2.25.0";
|
|
715
|
+
const REVISION = "e26ec27";
|
|
716
|
+
const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
|
|
717
|
+
const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
|
|
718
|
+
const CORE_IFRAME_URL = new URL(
|
|
719
|
+
`./iframe.html?v=${JS_SDK_VERSION}&rev=${REVISION}`,
|
|
720
|
+
coreBaseUrl
|
|
721
|
+
).href;
|
|
722
|
+
const COUPON_IFRAME_URL = new URL(
|
|
723
|
+
`./coupon/iframe.html?v=${JS_SDK_VERSION}`,
|
|
724
|
+
coreBaseUrl
|
|
725
|
+
).href;
|
|
726
|
+
const SENTRY_DSN = "https://377b45f154b1fb17d8e98a6ffb67030a@o4505819519320064.ingest.sentry.io/4506579323453440";
|
|
727
|
+
const objectToString = Object.prototype.toString;
|
|
728
|
+
function isBuiltin(wat, className) {
|
|
729
|
+
return objectToString.call(wat) === `[object ${className}]`;
|
|
730
|
+
}
|
|
731
|
+
function isPlainObject(wat) {
|
|
732
|
+
return isBuiltin(wat, "Object");
|
|
733
|
+
}
|
|
734
|
+
function isThenable(wat) {
|
|
735
|
+
return Boolean(wat && wat.then && typeof wat.then === "function");
|
|
736
|
+
}
|
|
737
|
+
function isGlobalObj(obj) {
|
|
738
|
+
return obj && obj.Math == Math ? obj : void 0;
|
|
739
|
+
}
|
|
740
|
+
const GLOBAL_OBJ = typeof globalThis == "object" && isGlobalObj(globalThis) || // eslint-disable-next-line no-restricted-globals
|
|
741
|
+
typeof window == "object" && isGlobalObj(window) || typeof self == "object" && isGlobalObj(self) || typeof global == "object" && isGlobalObj(global) || function() {
|
|
742
|
+
return this;
|
|
743
|
+
}() || {};
|
|
744
|
+
function getGlobalObject() {
|
|
745
|
+
return GLOBAL_OBJ;
|
|
746
|
+
}
|
|
747
|
+
function getGlobalSingleton(name, creator, obj) {
|
|
748
|
+
const gbl = obj || GLOBAL_OBJ;
|
|
749
|
+
const __SENTRY__ = gbl.__SENTRY__ = gbl.__SENTRY__ || {};
|
|
750
|
+
const singleton = __SENTRY__[name] || (__SENTRY__[name] = creator());
|
|
751
|
+
return singleton;
|
|
752
|
+
}
|
|
753
|
+
const PREFIX = "Sentry Logger ";
|
|
754
|
+
const CONSOLE_LEVELS = ["debug", "info", "warn", "error", "log", "assert", "trace"];
|
|
755
|
+
const originalConsoleMethods = {};
|
|
756
|
+
function consoleSandbox(callback) {
|
|
757
|
+
if (!("console" in GLOBAL_OBJ)) {
|
|
758
|
+
return callback();
|
|
759
|
+
}
|
|
760
|
+
const console2 = GLOBAL_OBJ.console;
|
|
761
|
+
const wrappedFuncs = {};
|
|
762
|
+
const wrappedLevels = Object.keys(originalConsoleMethods);
|
|
763
|
+
wrappedLevels.forEach((level) => {
|
|
764
|
+
const originalConsoleMethod = originalConsoleMethods[level];
|
|
765
|
+
wrappedFuncs[level] = console2[level];
|
|
766
|
+
console2[level] = originalConsoleMethod;
|
|
767
|
+
});
|
|
768
|
+
try {
|
|
769
|
+
return callback();
|
|
770
|
+
} finally {
|
|
771
|
+
wrappedLevels.forEach((level) => {
|
|
772
|
+
console2[level] = wrappedFuncs[level];
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function makeLogger() {
|
|
777
|
+
let enabled = false;
|
|
778
|
+
const logger2 = {
|
|
779
|
+
enable: () => {
|
|
780
|
+
enabled = true;
|
|
781
|
+
},
|
|
782
|
+
disable: () => {
|
|
783
|
+
enabled = false;
|
|
784
|
+
},
|
|
785
|
+
isEnabled: () => enabled
|
|
786
|
+
};
|
|
787
|
+
if (typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) {
|
|
788
|
+
CONSOLE_LEVELS.forEach((name) => {
|
|
789
|
+
logger2[name] = (...args) => {
|
|
790
|
+
if (enabled) {
|
|
791
|
+
consoleSandbox(() => {
|
|
792
|
+
GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
});
|
|
797
|
+
} else {
|
|
798
|
+
CONSOLE_LEVELS.forEach((name) => {
|
|
799
|
+
logger2[name] = () => void 0;
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
return logger2;
|
|
803
|
+
}
|
|
804
|
+
const logger = makeLogger();
|
|
805
|
+
function dropUndefinedKeys(inputValue) {
|
|
806
|
+
const memoizationMap = /* @__PURE__ */ new Map();
|
|
807
|
+
return _dropUndefinedKeys(inputValue, memoizationMap);
|
|
808
|
+
}
|
|
809
|
+
function _dropUndefinedKeys(inputValue, memoizationMap) {
|
|
810
|
+
if (isPlainObject(inputValue)) {
|
|
811
|
+
const memoVal = memoizationMap.get(inputValue);
|
|
812
|
+
if (memoVal !== void 0) {
|
|
813
|
+
return memoVal;
|
|
814
|
+
}
|
|
815
|
+
const returnValue = {};
|
|
816
|
+
memoizationMap.set(inputValue, returnValue);
|
|
817
|
+
for (const key of Object.keys(inputValue)) {
|
|
818
|
+
if (typeof inputValue[key] !== "undefined") {
|
|
819
|
+
returnValue[key] = _dropUndefinedKeys(inputValue[key], memoizationMap);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return returnValue;
|
|
823
|
+
}
|
|
824
|
+
if (Array.isArray(inputValue)) {
|
|
825
|
+
const memoVal = memoizationMap.get(inputValue);
|
|
826
|
+
if (memoVal !== void 0) {
|
|
827
|
+
return memoVal;
|
|
828
|
+
}
|
|
829
|
+
const returnValue = [];
|
|
830
|
+
memoizationMap.set(inputValue, returnValue);
|
|
831
|
+
inputValue.forEach((item) => {
|
|
832
|
+
returnValue.push(_dropUndefinedKeys(item, memoizationMap));
|
|
833
|
+
});
|
|
834
|
+
return returnValue;
|
|
835
|
+
}
|
|
836
|
+
return inputValue;
|
|
837
|
+
}
|
|
838
|
+
function uuid4() {
|
|
839
|
+
const gbl = GLOBAL_OBJ;
|
|
840
|
+
const crypto = gbl.crypto || gbl.msCrypto;
|
|
841
|
+
let getRandomByte = () => Math.random() * 16;
|
|
842
|
+
try {
|
|
843
|
+
if (crypto && crypto.randomUUID) {
|
|
844
|
+
return crypto.randomUUID().replace(/-/g, "");
|
|
845
|
+
}
|
|
846
|
+
if (crypto && crypto.getRandomValues) {
|
|
847
|
+
getRandomByte = () => crypto.getRandomValues(new Uint8Array(1))[0];
|
|
848
|
+
}
|
|
849
|
+
} catch (_) {
|
|
850
|
+
}
|
|
851
|
+
return ([1e7] + 1e3 + 4e3 + 8e3 + 1e11).replace(
|
|
852
|
+
/[018]/g,
|
|
853
|
+
(c) => (
|
|
854
|
+
// eslint-disable-next-line no-bitwise
|
|
855
|
+
(c ^ (getRandomByte() & 15) >> c / 4).toString(16)
|
|
856
|
+
)
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
function arrayify(maybeArray) {
|
|
860
|
+
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
861
|
+
}
|
|
862
|
+
function isBrowserBundle() {
|
|
863
|
+
return typeof __SENTRY_BROWSER_BUNDLE__ !== "undefined" && !!__SENTRY_BROWSER_BUNDLE__;
|
|
864
|
+
}
|
|
865
|
+
function isNodeEnv() {
|
|
866
|
+
return !isBrowserBundle() && Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
867
|
+
}
|
|
868
|
+
function dynamicRequire(mod, request) {
|
|
869
|
+
return mod.require(request);
|
|
870
|
+
}
|
|
871
|
+
var States;
|
|
872
|
+
(function(States2) {
|
|
873
|
+
const PENDING = 0;
|
|
874
|
+
States2[States2["PENDING"] = PENDING] = "PENDING";
|
|
875
|
+
const RESOLVED = 1;
|
|
876
|
+
States2[States2["RESOLVED"] = RESOLVED] = "RESOLVED";
|
|
877
|
+
const REJECTED = 2;
|
|
878
|
+
States2[States2["REJECTED"] = REJECTED] = "REJECTED";
|
|
879
|
+
})(States || (States = {}));
|
|
880
|
+
class SyncPromise {
|
|
881
|
+
constructor(executor) {
|
|
882
|
+
SyncPromise.prototype.__init.call(this);
|
|
883
|
+
SyncPromise.prototype.__init2.call(this);
|
|
884
|
+
SyncPromise.prototype.__init3.call(this);
|
|
885
|
+
SyncPromise.prototype.__init4.call(this);
|
|
886
|
+
this._state = States.PENDING;
|
|
887
|
+
this._handlers = [];
|
|
888
|
+
try {
|
|
889
|
+
executor(this._resolve, this._reject);
|
|
890
|
+
} catch (e) {
|
|
891
|
+
this._reject(e);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/** JSDoc */
|
|
895
|
+
then(onfulfilled, onrejected) {
|
|
896
|
+
return new SyncPromise((resolve, reject) => {
|
|
897
|
+
this._handlers.push([
|
|
898
|
+
false,
|
|
899
|
+
(result) => {
|
|
900
|
+
if (!onfulfilled) {
|
|
901
|
+
resolve(result);
|
|
902
|
+
} else {
|
|
903
|
+
try {
|
|
904
|
+
resolve(onfulfilled(result));
|
|
905
|
+
} catch (e) {
|
|
906
|
+
reject(e);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
(reason) => {
|
|
911
|
+
if (!onrejected) {
|
|
912
|
+
reject(reason);
|
|
913
|
+
} else {
|
|
914
|
+
try {
|
|
915
|
+
resolve(onrejected(reason));
|
|
916
|
+
} catch (e) {
|
|
917
|
+
reject(e);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
]);
|
|
922
|
+
this._executeHandlers();
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
/** JSDoc */
|
|
926
|
+
catch(onrejected) {
|
|
927
|
+
return this.then((val) => val, onrejected);
|
|
928
|
+
}
|
|
929
|
+
/** JSDoc */
|
|
930
|
+
finally(onfinally) {
|
|
931
|
+
return new SyncPromise((resolve, reject) => {
|
|
932
|
+
let val;
|
|
933
|
+
let isRejected;
|
|
934
|
+
return this.then(
|
|
935
|
+
(value) => {
|
|
936
|
+
isRejected = false;
|
|
937
|
+
val = value;
|
|
938
|
+
if (onfinally) {
|
|
939
|
+
onfinally();
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
(reason) => {
|
|
943
|
+
isRejected = true;
|
|
944
|
+
val = reason;
|
|
945
|
+
if (onfinally) {
|
|
946
|
+
onfinally();
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
).then(() => {
|
|
950
|
+
if (isRejected) {
|
|
951
|
+
reject(val);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
resolve(val);
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
/** JSDoc */
|
|
959
|
+
__init() {
|
|
960
|
+
this._resolve = (value) => {
|
|
961
|
+
this._setResult(States.RESOLVED, value);
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
/** JSDoc */
|
|
965
|
+
__init2() {
|
|
966
|
+
this._reject = (reason) => {
|
|
967
|
+
this._setResult(States.REJECTED, reason);
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
/** JSDoc */
|
|
971
|
+
__init3() {
|
|
972
|
+
this._setResult = (state, value) => {
|
|
973
|
+
if (this._state !== States.PENDING) {
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
if (isThenable(value)) {
|
|
977
|
+
void value.then(this._resolve, this._reject);
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
this._state = state;
|
|
981
|
+
this._value = value;
|
|
982
|
+
this._executeHandlers();
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
/** JSDoc */
|
|
986
|
+
__init4() {
|
|
987
|
+
this._executeHandlers = () => {
|
|
988
|
+
if (this._state === States.PENDING) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const cachedHandlers = this._handlers.slice();
|
|
992
|
+
this._handlers = [];
|
|
993
|
+
cachedHandlers.forEach((handler) => {
|
|
994
|
+
if (handler[0]) {
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (this._state === States.RESOLVED) {
|
|
998
|
+
handler[1](this._value);
|
|
999
|
+
}
|
|
1000
|
+
if (this._state === States.REJECTED) {
|
|
1001
|
+
handler[2](this._value);
|
|
1002
|
+
}
|
|
1003
|
+
handler[0] = true;
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
const WINDOW = getGlobalObject();
|
|
1009
|
+
const dateTimestampSource = {
|
|
1010
|
+
nowSeconds: () => Date.now() / 1e3
|
|
1011
|
+
};
|
|
1012
|
+
function getBrowserPerformance() {
|
|
1013
|
+
const { performance } = WINDOW;
|
|
1014
|
+
if (!performance || !performance.now) {
|
|
1015
|
+
return void 0;
|
|
1016
|
+
}
|
|
1017
|
+
const timeOrigin = Date.now() - performance.now();
|
|
1018
|
+
return {
|
|
1019
|
+
now: () => performance.now(),
|
|
1020
|
+
timeOrigin
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
function getNodePerformance() {
|
|
1024
|
+
try {
|
|
1025
|
+
const perfHooks = dynamicRequire(module, "perf_hooks");
|
|
1026
|
+
return perfHooks.performance;
|
|
1027
|
+
} catch (_) {
|
|
1028
|
+
return void 0;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
const platformPerformance = isNodeEnv() ? getNodePerformance() : getBrowserPerformance();
|
|
1032
|
+
const timestampSource = platformPerformance === void 0 ? dateTimestampSource : {
|
|
1033
|
+
nowSeconds: () => (platformPerformance.timeOrigin + platformPerformance.now()) / 1e3
|
|
1034
|
+
};
|
|
1035
|
+
const dateTimestampInSeconds = dateTimestampSource.nowSeconds.bind(dateTimestampSource);
|
|
1036
|
+
const timestampInSeconds = timestampSource.nowSeconds.bind(timestampSource);
|
|
1037
|
+
(() => {
|
|
1038
|
+
const { performance } = WINDOW;
|
|
1039
|
+
if (!performance || !performance.now) {
|
|
1040
|
+
return void 0;
|
|
1041
|
+
}
|
|
1042
|
+
const threshold = 3600 * 1e3;
|
|
1043
|
+
const performanceNow = performance.now();
|
|
1044
|
+
const dateNow = Date.now();
|
|
1045
|
+
const timeOriginDelta = performance.timeOrigin ? Math.abs(performance.timeOrigin + performanceNow - dateNow) : threshold;
|
|
1046
|
+
const timeOriginIsReliable = timeOriginDelta < threshold;
|
|
1047
|
+
const navigationStart = performance.timing && performance.timing.navigationStart;
|
|
1048
|
+
const hasNavigationStart = typeof navigationStart === "number";
|
|
1049
|
+
const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
|
|
1050
|
+
const navigationStartIsReliable = navigationStartDelta < threshold;
|
|
1051
|
+
if (timeOriginIsReliable || navigationStartIsReliable) {
|
|
1052
|
+
if (timeOriginDelta <= navigationStartDelta) {
|
|
1053
|
+
return performance.timeOrigin;
|
|
1054
|
+
} else {
|
|
1055
|
+
return navigationStart;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return dateNow;
|
|
1059
|
+
})();
|
|
1060
|
+
const DEFAULT_ENVIRONMENT = "production";
|
|
1061
|
+
function getGlobalEventProcessors() {
|
|
1062
|
+
return getGlobalSingleton("globalEventProcessors", () => []);
|
|
1063
|
+
}
|
|
1064
|
+
function notifyEventProcessors(processors, event, hint, index = 0) {
|
|
1065
|
+
return new SyncPromise((resolve, reject) => {
|
|
1066
|
+
const processor = processors[index];
|
|
1067
|
+
if (event === null || typeof processor !== "function") {
|
|
1068
|
+
resolve(event);
|
|
1069
|
+
} else {
|
|
1070
|
+
const result = processor(__spreadValues({}, event), hint);
|
|
1071
|
+
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && processor.id && result === null && logger.log(`Event processor "${processor.id}" dropped event`);
|
|
1072
|
+
if (isThenable(result)) {
|
|
1073
|
+
void result.then((final) => notifyEventProcessors(processors, final, hint, index + 1).then(resolve)).then(null, reject);
|
|
1074
|
+
} else {
|
|
1075
|
+
void notifyEventProcessors(processors, result, hint, index + 1).then(resolve).then(null, reject);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
function makeSession(context) {
|
|
1081
|
+
const startingTime = timestampInSeconds();
|
|
1082
|
+
const session = {
|
|
1083
|
+
sid: uuid4(),
|
|
1084
|
+
init: true,
|
|
1085
|
+
timestamp: startingTime,
|
|
1086
|
+
started: startingTime,
|
|
1087
|
+
duration: 0,
|
|
1088
|
+
status: "ok",
|
|
1089
|
+
errors: 0,
|
|
1090
|
+
ignoreDuration: false,
|
|
1091
|
+
toJSON: () => sessionToJSON(session)
|
|
1092
|
+
};
|
|
1093
|
+
if (context) {
|
|
1094
|
+
updateSession(session, context);
|
|
1095
|
+
}
|
|
1096
|
+
return session;
|
|
1097
|
+
}
|
|
1098
|
+
function updateSession(session, context = {}) {
|
|
1099
|
+
if (context.user) {
|
|
1100
|
+
if (!session.ipAddress && context.user.ip_address) {
|
|
1101
|
+
session.ipAddress = context.user.ip_address;
|
|
1102
|
+
}
|
|
1103
|
+
if (!session.did && !context.did) {
|
|
1104
|
+
session.did = context.user.id || context.user.email || context.user.username;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
session.timestamp = context.timestamp || timestampInSeconds();
|
|
1108
|
+
if (context.abnormal_mechanism) {
|
|
1109
|
+
session.abnormal_mechanism = context.abnormal_mechanism;
|
|
1110
|
+
}
|
|
1111
|
+
if (context.ignoreDuration) {
|
|
1112
|
+
session.ignoreDuration = context.ignoreDuration;
|
|
1113
|
+
}
|
|
1114
|
+
if (context.sid) {
|
|
1115
|
+
session.sid = context.sid.length === 32 ? context.sid : uuid4();
|
|
1116
|
+
}
|
|
1117
|
+
if (context.init !== void 0) {
|
|
1118
|
+
session.init = context.init;
|
|
1119
|
+
}
|
|
1120
|
+
if (!session.did && context.did) {
|
|
1121
|
+
session.did = `${context.did}`;
|
|
1122
|
+
}
|
|
1123
|
+
if (typeof context.started === "number") {
|
|
1124
|
+
session.started = context.started;
|
|
1125
|
+
}
|
|
1126
|
+
if (session.ignoreDuration) {
|
|
1127
|
+
session.duration = void 0;
|
|
1128
|
+
} else if (typeof context.duration === "number") {
|
|
1129
|
+
session.duration = context.duration;
|
|
1130
|
+
} else {
|
|
1131
|
+
const duration = session.timestamp - session.started;
|
|
1132
|
+
session.duration = duration >= 0 ? duration : 0;
|
|
1133
|
+
}
|
|
1134
|
+
if (context.release) {
|
|
1135
|
+
session.release = context.release;
|
|
1136
|
+
}
|
|
1137
|
+
if (context.environment) {
|
|
1138
|
+
session.environment = context.environment;
|
|
1139
|
+
}
|
|
1140
|
+
if (!session.ipAddress && context.ipAddress) {
|
|
1141
|
+
session.ipAddress = context.ipAddress;
|
|
1142
|
+
}
|
|
1143
|
+
if (!session.userAgent && context.userAgent) {
|
|
1144
|
+
session.userAgent = context.userAgent;
|
|
1145
|
+
}
|
|
1146
|
+
if (typeof context.errors === "number") {
|
|
1147
|
+
session.errors = context.errors;
|
|
1148
|
+
}
|
|
1149
|
+
if (context.status) {
|
|
1150
|
+
session.status = context.status;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
function closeSession(session, status) {
|
|
1154
|
+
let context = {};
|
|
1155
|
+
if (status) {
|
|
1156
|
+
context = { status };
|
|
1157
|
+
} else if (session.status === "ok") {
|
|
1158
|
+
context = { status: "exited" };
|
|
1159
|
+
}
|
|
1160
|
+
updateSession(session, context);
|
|
1161
|
+
}
|
|
1162
|
+
function sessionToJSON(session) {
|
|
1163
|
+
return dropUndefinedKeys({
|
|
1164
|
+
sid: `${session.sid}`,
|
|
1165
|
+
init: session.init,
|
|
1166
|
+
// Make sure that sec is converted to ms for date constructor
|
|
1167
|
+
started: new Date(session.started * 1e3).toISOString(),
|
|
1168
|
+
timestamp: new Date(session.timestamp * 1e3).toISOString(),
|
|
1169
|
+
status: session.status,
|
|
1170
|
+
errors: session.errors,
|
|
1171
|
+
did: typeof session.did === "number" || typeof session.did === "string" ? `${session.did}` : void 0,
|
|
1172
|
+
duration: session.duration,
|
|
1173
|
+
abnormal_mechanism: session.abnormal_mechanism,
|
|
1174
|
+
attrs: {
|
|
1175
|
+
release: session.release,
|
|
1176
|
+
environment: session.environment,
|
|
1177
|
+
ip_address: session.ipAddress,
|
|
1178
|
+
user_agent: session.userAgent
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
const DEFAULT_MAX_BREADCRUMBS = 100;
|
|
1183
|
+
class Scope {
|
|
1184
|
+
/** Flag if notifying is happening. */
|
|
1185
|
+
/** Callback for client to receive scope changes. */
|
|
1186
|
+
/** Callback list that will be called after {@link applyToEvent}. */
|
|
1187
|
+
/** Array of breadcrumbs. */
|
|
1188
|
+
/** User */
|
|
1189
|
+
/** Tags */
|
|
1190
|
+
/** Extra */
|
|
1191
|
+
/** Contexts */
|
|
1192
|
+
/** Attachments */
|
|
1193
|
+
/** Propagation Context for distributed tracing */
|
|
1194
|
+
/**
|
|
1195
|
+
* A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
|
|
1196
|
+
* sent to Sentry
|
|
1197
|
+
*/
|
|
1198
|
+
/** Fingerprint */
|
|
1199
|
+
/** Severity */
|
|
1200
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1201
|
+
/** Transaction Name */
|
|
1202
|
+
/** Span */
|
|
1203
|
+
/** Session */
|
|
1204
|
+
/** Request Mode Session Status */
|
|
1205
|
+
// NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.
|
|
1206
|
+
constructor() {
|
|
1207
|
+
this._notifyingListeners = false;
|
|
1208
|
+
this._scopeListeners = [];
|
|
1209
|
+
this._eventProcessors = [];
|
|
1210
|
+
this._breadcrumbs = [];
|
|
1211
|
+
this._attachments = [];
|
|
1212
|
+
this._user = {};
|
|
1213
|
+
this._tags = {};
|
|
1214
|
+
this._extra = {};
|
|
1215
|
+
this._contexts = {};
|
|
1216
|
+
this._sdkProcessingMetadata = {};
|
|
1217
|
+
this._propagationContext = generatePropagationContext();
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Inherit values from the parent scope.
|
|
1221
|
+
* @param scope to clone.
|
|
1222
|
+
*/
|
|
1223
|
+
static clone(scope) {
|
|
1224
|
+
const newScope = new Scope();
|
|
1225
|
+
if (scope) {
|
|
1226
|
+
newScope._breadcrumbs = [...scope._breadcrumbs];
|
|
1227
|
+
newScope._tags = __spreadValues({}, scope._tags);
|
|
1228
|
+
newScope._extra = __spreadValues({}, scope._extra);
|
|
1229
|
+
newScope._contexts = __spreadValues({}, scope._contexts);
|
|
1230
|
+
newScope._user = scope._user;
|
|
1231
|
+
newScope._level = scope._level;
|
|
1232
|
+
newScope._span = scope._span;
|
|
1233
|
+
newScope._session = scope._session;
|
|
1234
|
+
newScope._transactionName = scope._transactionName;
|
|
1235
|
+
newScope._fingerprint = scope._fingerprint;
|
|
1236
|
+
newScope._eventProcessors = [...scope._eventProcessors];
|
|
1237
|
+
newScope._requestSession = scope._requestSession;
|
|
1238
|
+
newScope._attachments = [...scope._attachments];
|
|
1239
|
+
newScope._sdkProcessingMetadata = __spreadValues({}, scope._sdkProcessingMetadata);
|
|
1240
|
+
newScope._propagationContext = __spreadValues({}, scope._propagationContext);
|
|
1241
|
+
}
|
|
1242
|
+
return newScope;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Add internal on change listener. Used for sub SDKs that need to store the scope.
|
|
1246
|
+
* @hidden
|
|
1247
|
+
*/
|
|
1248
|
+
addScopeListener(callback) {
|
|
1249
|
+
this._scopeListeners.push(callback);
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* @inheritDoc
|
|
1253
|
+
*/
|
|
1254
|
+
addEventProcessor(callback) {
|
|
1255
|
+
this._eventProcessors.push(callback);
|
|
1256
|
+
return this;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* @inheritDoc
|
|
1260
|
+
*/
|
|
1261
|
+
setUser(user) {
|
|
1262
|
+
this._user = user || {};
|
|
1263
|
+
if (this._session) {
|
|
1264
|
+
updateSession(this._session, { user });
|
|
1265
|
+
}
|
|
1266
|
+
this._notifyScopeListeners();
|
|
1267
|
+
return this;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* @inheritDoc
|
|
1271
|
+
*/
|
|
1272
|
+
getUser() {
|
|
1273
|
+
return this._user;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* @inheritDoc
|
|
1277
|
+
*/
|
|
1278
|
+
getRequestSession() {
|
|
1279
|
+
return this._requestSession;
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* @inheritDoc
|
|
1283
|
+
*/
|
|
1284
|
+
setRequestSession(requestSession) {
|
|
1285
|
+
this._requestSession = requestSession;
|
|
1286
|
+
return this;
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* @inheritDoc
|
|
1290
|
+
*/
|
|
1291
|
+
setTags(tags) {
|
|
1292
|
+
this._tags = __spreadValues(__spreadValues({}, this._tags), tags);
|
|
1293
|
+
this._notifyScopeListeners();
|
|
1294
|
+
return this;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* @inheritDoc
|
|
1298
|
+
*/
|
|
1299
|
+
setTag(key, value) {
|
|
1300
|
+
this._tags = __spreadProps(__spreadValues({}, this._tags), { [key]: value });
|
|
1301
|
+
this._notifyScopeListeners();
|
|
1302
|
+
return this;
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* @inheritDoc
|
|
1306
|
+
*/
|
|
1307
|
+
setExtras(extras) {
|
|
1308
|
+
this._extra = __spreadValues(__spreadValues({}, this._extra), extras);
|
|
1309
|
+
this._notifyScopeListeners();
|
|
1310
|
+
return this;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* @inheritDoc
|
|
1314
|
+
*/
|
|
1315
|
+
setExtra(key, extra) {
|
|
1316
|
+
this._extra = __spreadProps(__spreadValues({}, this._extra), { [key]: extra });
|
|
1317
|
+
this._notifyScopeListeners();
|
|
1318
|
+
return this;
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* @inheritDoc
|
|
1322
|
+
*/
|
|
1323
|
+
setFingerprint(fingerprint) {
|
|
1324
|
+
this._fingerprint = fingerprint;
|
|
1325
|
+
this._notifyScopeListeners();
|
|
1326
|
+
return this;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* @inheritDoc
|
|
1330
|
+
*/
|
|
1331
|
+
setLevel(level) {
|
|
1332
|
+
this._level = level;
|
|
1333
|
+
this._notifyScopeListeners();
|
|
1334
|
+
return this;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* @inheritDoc
|
|
1338
|
+
*/
|
|
1339
|
+
setTransactionName(name) {
|
|
1340
|
+
this._transactionName = name;
|
|
1341
|
+
this._notifyScopeListeners();
|
|
1342
|
+
return this;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* @inheritDoc
|
|
1346
|
+
*/
|
|
1347
|
+
setContext(key, context) {
|
|
1348
|
+
if (context === null) {
|
|
1349
|
+
delete this._contexts[key];
|
|
1350
|
+
} else {
|
|
1351
|
+
this._contexts[key] = context;
|
|
1352
|
+
}
|
|
1353
|
+
this._notifyScopeListeners();
|
|
1354
|
+
return this;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* @inheritDoc
|
|
1358
|
+
*/
|
|
1359
|
+
setSpan(span) {
|
|
1360
|
+
this._span = span;
|
|
1361
|
+
this._notifyScopeListeners();
|
|
1362
|
+
return this;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* @inheritDoc
|
|
1366
|
+
*/
|
|
1367
|
+
getSpan() {
|
|
1368
|
+
return this._span;
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* @inheritDoc
|
|
1372
|
+
*/
|
|
1373
|
+
getTransaction() {
|
|
1374
|
+
const span = this.getSpan();
|
|
1375
|
+
return span && span.transaction;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* @inheritDoc
|
|
1379
|
+
*/
|
|
1380
|
+
setSession(session) {
|
|
1381
|
+
if (!session) {
|
|
1382
|
+
delete this._session;
|
|
1383
|
+
} else {
|
|
1384
|
+
this._session = session;
|
|
1385
|
+
}
|
|
1386
|
+
this._notifyScopeListeners();
|
|
1387
|
+
return this;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* @inheritDoc
|
|
1391
|
+
*/
|
|
1392
|
+
getSession() {
|
|
1393
|
+
return this._session;
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* @inheritDoc
|
|
1397
|
+
*/
|
|
1398
|
+
update(captureContext) {
|
|
1399
|
+
if (!captureContext) {
|
|
1400
|
+
return this;
|
|
1401
|
+
}
|
|
1402
|
+
if (typeof captureContext === "function") {
|
|
1403
|
+
const updatedScope = captureContext(this);
|
|
1404
|
+
return updatedScope instanceof Scope ? updatedScope : this;
|
|
1405
|
+
}
|
|
1406
|
+
if (captureContext instanceof Scope) {
|
|
1407
|
+
this._tags = __spreadValues(__spreadValues({}, this._tags), captureContext._tags);
|
|
1408
|
+
this._extra = __spreadValues(__spreadValues({}, this._extra), captureContext._extra);
|
|
1409
|
+
this._contexts = __spreadValues(__spreadValues({}, this._contexts), captureContext._contexts);
|
|
1410
|
+
if (captureContext._user && Object.keys(captureContext._user).length) {
|
|
1411
|
+
this._user = captureContext._user;
|
|
1412
|
+
}
|
|
1413
|
+
if (captureContext._level) {
|
|
1414
|
+
this._level = captureContext._level;
|
|
1415
|
+
}
|
|
1416
|
+
if (captureContext._fingerprint) {
|
|
1417
|
+
this._fingerprint = captureContext._fingerprint;
|
|
1418
|
+
}
|
|
1419
|
+
if (captureContext._requestSession) {
|
|
1420
|
+
this._requestSession = captureContext._requestSession;
|
|
1421
|
+
}
|
|
1422
|
+
if (captureContext._propagationContext) {
|
|
1423
|
+
this._propagationContext = captureContext._propagationContext;
|
|
1424
|
+
}
|
|
1425
|
+
} else if (isPlainObject(captureContext)) {
|
|
1426
|
+
captureContext = captureContext;
|
|
1427
|
+
this._tags = __spreadValues(__spreadValues({}, this._tags), captureContext.tags);
|
|
1428
|
+
this._extra = __spreadValues(__spreadValues({}, this._extra), captureContext.extra);
|
|
1429
|
+
this._contexts = __spreadValues(__spreadValues({}, this._contexts), captureContext.contexts);
|
|
1430
|
+
if (captureContext.user) {
|
|
1431
|
+
this._user = captureContext.user;
|
|
1432
|
+
}
|
|
1433
|
+
if (captureContext.level) {
|
|
1434
|
+
this._level = captureContext.level;
|
|
1435
|
+
}
|
|
1436
|
+
if (captureContext.fingerprint) {
|
|
1437
|
+
this._fingerprint = captureContext.fingerprint;
|
|
1438
|
+
}
|
|
1439
|
+
if (captureContext.requestSession) {
|
|
1440
|
+
this._requestSession = captureContext.requestSession;
|
|
1441
|
+
}
|
|
1442
|
+
if (captureContext.propagationContext) {
|
|
1443
|
+
this._propagationContext = captureContext.propagationContext;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return this;
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* @inheritDoc
|
|
1450
|
+
*/
|
|
1451
|
+
clear() {
|
|
1452
|
+
this._breadcrumbs = [];
|
|
1453
|
+
this._tags = {};
|
|
1454
|
+
this._extra = {};
|
|
1455
|
+
this._user = {};
|
|
1456
|
+
this._contexts = {};
|
|
1457
|
+
this._level = void 0;
|
|
1458
|
+
this._transactionName = void 0;
|
|
1459
|
+
this._fingerprint = void 0;
|
|
1460
|
+
this._requestSession = void 0;
|
|
1461
|
+
this._span = void 0;
|
|
1462
|
+
this._session = void 0;
|
|
1463
|
+
this._notifyScopeListeners();
|
|
1464
|
+
this._attachments = [];
|
|
1465
|
+
this._propagationContext = generatePropagationContext();
|
|
1466
|
+
return this;
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* @inheritDoc
|
|
1470
|
+
*/
|
|
1471
|
+
addBreadcrumb(breadcrumb, maxBreadcrumbs) {
|
|
1472
|
+
const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
|
|
1473
|
+
if (maxCrumbs <= 0) {
|
|
1474
|
+
return this;
|
|
1475
|
+
}
|
|
1476
|
+
const mergedBreadcrumb = __spreadValues({
|
|
1477
|
+
timestamp: dateTimestampInSeconds()
|
|
1478
|
+
}, breadcrumb);
|
|
1479
|
+
const breadcrumbs = this._breadcrumbs;
|
|
1480
|
+
breadcrumbs.push(mergedBreadcrumb);
|
|
1481
|
+
this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs;
|
|
1482
|
+
this._notifyScopeListeners();
|
|
1483
|
+
return this;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* @inheritDoc
|
|
1487
|
+
*/
|
|
1488
|
+
getLastBreadcrumb() {
|
|
1489
|
+
return this._breadcrumbs[this._breadcrumbs.length - 1];
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* @inheritDoc
|
|
1493
|
+
*/
|
|
1494
|
+
clearBreadcrumbs() {
|
|
1495
|
+
this._breadcrumbs = [];
|
|
1496
|
+
this._notifyScopeListeners();
|
|
1497
|
+
return this;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* @inheritDoc
|
|
1501
|
+
*/
|
|
1502
|
+
addAttachment(attachment) {
|
|
1503
|
+
this._attachments.push(attachment);
|
|
1504
|
+
return this;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* @inheritDoc
|
|
1508
|
+
*/
|
|
1509
|
+
getAttachments() {
|
|
1510
|
+
return this._attachments;
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* @inheritDoc
|
|
1514
|
+
*/
|
|
1515
|
+
clearAttachments() {
|
|
1516
|
+
this._attachments = [];
|
|
1517
|
+
return this;
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Applies data from the scope to the event and runs all event processors on it.
|
|
1521
|
+
*
|
|
1522
|
+
* @param event Event
|
|
1523
|
+
* @param hint Object containing additional information about the original exception, for use by the event processors.
|
|
1524
|
+
* @hidden
|
|
1525
|
+
*/
|
|
1526
|
+
applyToEvent(event, hint = {}, additionalEventProcessors) {
|
|
1527
|
+
if (this._extra && Object.keys(this._extra).length) {
|
|
1528
|
+
event.extra = __spreadValues(__spreadValues({}, this._extra), event.extra);
|
|
1529
|
+
}
|
|
1530
|
+
if (this._tags && Object.keys(this._tags).length) {
|
|
1531
|
+
event.tags = __spreadValues(__spreadValues({}, this._tags), event.tags);
|
|
1532
|
+
}
|
|
1533
|
+
if (this._user && Object.keys(this._user).length) {
|
|
1534
|
+
event.user = __spreadValues(__spreadValues({}, this._user), event.user);
|
|
1535
|
+
}
|
|
1536
|
+
if (this._contexts && Object.keys(this._contexts).length) {
|
|
1537
|
+
event.contexts = __spreadValues(__spreadValues({}, this._contexts), event.contexts);
|
|
1538
|
+
}
|
|
1539
|
+
if (this._level) {
|
|
1540
|
+
event.level = this._level;
|
|
1541
|
+
}
|
|
1542
|
+
if (this._transactionName) {
|
|
1543
|
+
event.transaction = this._transactionName;
|
|
1544
|
+
}
|
|
1545
|
+
if (this._span) {
|
|
1546
|
+
event.contexts = __spreadValues({ trace: this._span.getTraceContext() }, event.contexts);
|
|
1547
|
+
const transaction = this._span.transaction;
|
|
1548
|
+
if (transaction) {
|
|
1549
|
+
event.sdkProcessingMetadata = __spreadValues({
|
|
1550
|
+
dynamicSamplingContext: transaction.getDynamicSamplingContext()
|
|
1551
|
+
}, event.sdkProcessingMetadata);
|
|
1552
|
+
const transactionName = transaction.name;
|
|
1553
|
+
if (transactionName) {
|
|
1554
|
+
event.tags = __spreadValues({ transaction: transactionName }, event.tags);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
this._applyFingerprint(event);
|
|
1559
|
+
const scopeBreadcrumbs = this._getBreadcrumbs();
|
|
1560
|
+
const breadcrumbs = [...event.breadcrumbs || [], ...scopeBreadcrumbs];
|
|
1561
|
+
event.breadcrumbs = breadcrumbs.length > 0 ? breadcrumbs : void 0;
|
|
1562
|
+
event.sdkProcessingMetadata = __spreadProps(__spreadValues(__spreadValues({}, event.sdkProcessingMetadata), this._sdkProcessingMetadata), {
|
|
1563
|
+
propagationContext: this._propagationContext
|
|
1564
|
+
});
|
|
1565
|
+
return notifyEventProcessors(
|
|
1566
|
+
[...additionalEventProcessors || [], ...getGlobalEventProcessors(), ...this._eventProcessors],
|
|
1567
|
+
event,
|
|
1568
|
+
hint
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Add data which will be accessible during event processing but won't get sent to Sentry
|
|
1573
|
+
*/
|
|
1574
|
+
setSDKProcessingMetadata(newData) {
|
|
1575
|
+
this._sdkProcessingMetadata = __spreadValues(__spreadValues({}, this._sdkProcessingMetadata), newData);
|
|
1576
|
+
return this;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* @inheritDoc
|
|
1580
|
+
*/
|
|
1581
|
+
setPropagationContext(context) {
|
|
1582
|
+
this._propagationContext = context;
|
|
1583
|
+
return this;
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* @inheritDoc
|
|
1587
|
+
*/
|
|
1588
|
+
getPropagationContext() {
|
|
1589
|
+
return this._propagationContext;
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Get the breadcrumbs for this scope.
|
|
1593
|
+
*/
|
|
1594
|
+
_getBreadcrumbs() {
|
|
1595
|
+
return this._breadcrumbs;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* This will be called on every set call.
|
|
1599
|
+
*/
|
|
1600
|
+
_notifyScopeListeners() {
|
|
1601
|
+
if (!this._notifyingListeners) {
|
|
1602
|
+
this._notifyingListeners = true;
|
|
1603
|
+
this._scopeListeners.forEach((callback) => {
|
|
1604
|
+
callback(this);
|
|
1605
|
+
});
|
|
1606
|
+
this._notifyingListeners = false;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Applies fingerprint from the scope to the event if there's one,
|
|
1611
|
+
* uses message if there's one instead or get rid of empty fingerprint
|
|
1612
|
+
*/
|
|
1613
|
+
_applyFingerprint(event) {
|
|
1614
|
+
event.fingerprint = event.fingerprint ? arrayify(event.fingerprint) : [];
|
|
1615
|
+
if (this._fingerprint) {
|
|
1616
|
+
event.fingerprint = event.fingerprint.concat(this._fingerprint);
|
|
1617
|
+
}
|
|
1618
|
+
if (event.fingerprint && !event.fingerprint.length) {
|
|
1619
|
+
delete event.fingerprint;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
function generatePropagationContext() {
|
|
1624
|
+
return {
|
|
1625
|
+
traceId: uuid4(),
|
|
1626
|
+
spanId: uuid4().substring(16)
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
const API_VERSION = 4;
|
|
1630
|
+
const DEFAULT_BREADCRUMBS = 100;
|
|
1631
|
+
class Hub {
|
|
1632
|
+
/** Is a {@link Layer}[] containing the client and scope */
|
|
1633
|
+
/** Contains the last event id of a captured event. */
|
|
1634
|
+
/**
|
|
1635
|
+
* Creates a new instance of the hub, will push one {@link Layer} into the
|
|
1636
|
+
* internal stack on creation.
|
|
1637
|
+
*
|
|
1638
|
+
* @param client bound to the hub.
|
|
1639
|
+
* @param scope bound to the hub.
|
|
1640
|
+
* @param version number, higher number means higher priority.
|
|
1641
|
+
*/
|
|
1642
|
+
constructor(client2, scope = new Scope(), _version = API_VERSION) {
|
|
1643
|
+
this._version = _version;
|
|
1644
|
+
this._stack = [{ scope }];
|
|
1645
|
+
if (client2) {
|
|
1646
|
+
this.bindClient(client2);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* @inheritDoc
|
|
1651
|
+
*/
|
|
1652
|
+
isOlderThan(version) {
|
|
1653
|
+
return this._version < version;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* @inheritDoc
|
|
1657
|
+
*/
|
|
1658
|
+
bindClient(client2) {
|
|
1659
|
+
const top = this.getStackTop();
|
|
1660
|
+
top.client = client2;
|
|
1661
|
+
if (client2 && client2.setupIntegrations) {
|
|
1662
|
+
client2.setupIntegrations();
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* @inheritDoc
|
|
1667
|
+
*/
|
|
1668
|
+
pushScope() {
|
|
1669
|
+
const scope = Scope.clone(this.getScope());
|
|
1670
|
+
this.getStack().push({
|
|
1671
|
+
client: this.getClient(),
|
|
1672
|
+
scope
|
|
1673
|
+
});
|
|
1674
|
+
return scope;
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* @inheritDoc
|
|
1678
|
+
*/
|
|
1679
|
+
popScope() {
|
|
1680
|
+
if (this.getStack().length <= 1)
|
|
1681
|
+
return false;
|
|
1682
|
+
return !!this.getStack().pop();
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* @inheritDoc
|
|
1686
|
+
*/
|
|
1687
|
+
withScope(callback) {
|
|
1688
|
+
const scope = this.pushScope();
|
|
1689
|
+
try {
|
|
1690
|
+
callback(scope);
|
|
1691
|
+
} finally {
|
|
1692
|
+
this.popScope();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* @inheritDoc
|
|
1697
|
+
*/
|
|
1698
|
+
getClient() {
|
|
1699
|
+
return this.getStackTop().client;
|
|
1700
|
+
}
|
|
1701
|
+
/** Returns the scope of the top stack. */
|
|
1702
|
+
getScope() {
|
|
1703
|
+
return this.getStackTop().scope;
|
|
1704
|
+
}
|
|
1705
|
+
/** Returns the scope stack for domains or the process. */
|
|
1706
|
+
getStack() {
|
|
1707
|
+
return this._stack;
|
|
1708
|
+
}
|
|
1709
|
+
/** Returns the topmost scope layer in the order domain > local > process. */
|
|
1710
|
+
getStackTop() {
|
|
1711
|
+
return this._stack[this._stack.length - 1];
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* @inheritDoc
|
|
1715
|
+
*/
|
|
1716
|
+
captureException(exception, hint) {
|
|
1717
|
+
const eventId = this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1718
|
+
const syntheticException = new Error("Sentry syntheticException");
|
|
1719
|
+
this._withClient((client2, scope) => {
|
|
1720
|
+
client2.captureException(
|
|
1721
|
+
exception,
|
|
1722
|
+
__spreadProps(__spreadValues({
|
|
1723
|
+
originalException: exception,
|
|
1724
|
+
syntheticException
|
|
1725
|
+
}, hint), {
|
|
1726
|
+
event_id: eventId
|
|
1727
|
+
}),
|
|
1728
|
+
scope
|
|
1729
|
+
);
|
|
1730
|
+
});
|
|
1731
|
+
return eventId;
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* @inheritDoc
|
|
1735
|
+
*/
|
|
1736
|
+
captureMessage(message, level, hint) {
|
|
1737
|
+
const eventId = this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1738
|
+
const syntheticException = new Error(message);
|
|
1739
|
+
this._withClient((client2, scope) => {
|
|
1740
|
+
client2.captureMessage(
|
|
1741
|
+
message,
|
|
1742
|
+
level,
|
|
1743
|
+
__spreadProps(__spreadValues({
|
|
1744
|
+
originalException: message,
|
|
1745
|
+
syntheticException
|
|
1746
|
+
}, hint), {
|
|
1747
|
+
event_id: eventId
|
|
1748
|
+
}),
|
|
1749
|
+
scope
|
|
1750
|
+
);
|
|
1751
|
+
});
|
|
1752
|
+
return eventId;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* @inheritDoc
|
|
1756
|
+
*/
|
|
1757
|
+
captureEvent(event, hint) {
|
|
1758
|
+
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1759
|
+
if (!event.type) {
|
|
1760
|
+
this._lastEventId = eventId;
|
|
1761
|
+
}
|
|
1762
|
+
this._withClient((client2, scope) => {
|
|
1763
|
+
client2.captureEvent(event, __spreadProps(__spreadValues({}, hint), { event_id: eventId }), scope);
|
|
1764
|
+
});
|
|
1765
|
+
return eventId;
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* @inheritDoc
|
|
1769
|
+
*/
|
|
1770
|
+
lastEventId() {
|
|
1771
|
+
return this._lastEventId;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* @inheritDoc
|
|
1775
|
+
*/
|
|
1776
|
+
addBreadcrumb(breadcrumb, hint) {
|
|
1777
|
+
const { scope, client: client2 } = this.getStackTop();
|
|
1778
|
+
if (!client2)
|
|
1779
|
+
return;
|
|
1780
|
+
const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = client2.getOptions && client2.getOptions() || {};
|
|
1781
|
+
if (maxBreadcrumbs <= 0)
|
|
1782
|
+
return;
|
|
1783
|
+
const timestamp = dateTimestampInSeconds();
|
|
1784
|
+
const mergedBreadcrumb = __spreadValues({ timestamp }, breadcrumb);
|
|
1785
|
+
const finalBreadcrumb = beforeBreadcrumb ? consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint)) : mergedBreadcrumb;
|
|
1786
|
+
if (finalBreadcrumb === null)
|
|
1787
|
+
return;
|
|
1788
|
+
if (client2.emit) {
|
|
1789
|
+
client2.emit("beforeAddBreadcrumb", finalBreadcrumb, hint);
|
|
1790
|
+
}
|
|
1791
|
+
scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* @inheritDoc
|
|
1795
|
+
*/
|
|
1796
|
+
setUser(user) {
|
|
1797
|
+
this.getScope().setUser(user);
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* @inheritDoc
|
|
1801
|
+
*/
|
|
1802
|
+
setTags(tags) {
|
|
1803
|
+
this.getScope().setTags(tags);
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* @inheritDoc
|
|
1807
|
+
*/
|
|
1808
|
+
setExtras(extras) {
|
|
1809
|
+
this.getScope().setExtras(extras);
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* @inheritDoc
|
|
1813
|
+
*/
|
|
1814
|
+
setTag(key, value) {
|
|
1815
|
+
this.getScope().setTag(key, value);
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* @inheritDoc
|
|
1819
|
+
*/
|
|
1820
|
+
setExtra(key, extra) {
|
|
1821
|
+
this.getScope().setExtra(key, extra);
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* @inheritDoc
|
|
1825
|
+
*/
|
|
1826
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1827
|
+
setContext(name, context) {
|
|
1828
|
+
this.getScope().setContext(name, context);
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* @inheritDoc
|
|
1832
|
+
*/
|
|
1833
|
+
configureScope(callback) {
|
|
1834
|
+
const { scope, client: client2 } = this.getStackTop();
|
|
1835
|
+
if (client2) {
|
|
1836
|
+
callback(scope);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* @inheritDoc
|
|
1841
|
+
*/
|
|
1842
|
+
run(callback) {
|
|
1843
|
+
const oldHub = makeMain(this);
|
|
1844
|
+
try {
|
|
1845
|
+
callback(this);
|
|
1846
|
+
} finally {
|
|
1847
|
+
makeMain(oldHub);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* @inheritDoc
|
|
1852
|
+
*/
|
|
1853
|
+
getIntegration(integration) {
|
|
1854
|
+
const client2 = this.getClient();
|
|
1855
|
+
if (!client2)
|
|
1856
|
+
return null;
|
|
1857
|
+
try {
|
|
1858
|
+
return client2.getIntegration(integration);
|
|
1859
|
+
} catch (_oO) {
|
|
1860
|
+
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && logger.warn(`Cannot retrieve integration ${integration.id} from the current Hub`);
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* @inheritDoc
|
|
1866
|
+
*/
|
|
1867
|
+
startTransaction(context, customSamplingContext) {
|
|
1868
|
+
const result = this._callExtensionMethod("startTransaction", context, customSamplingContext);
|
|
1869
|
+
if ((typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && !result) {
|
|
1870
|
+
const client2 = this.getClient();
|
|
1871
|
+
if (!client2) {
|
|
1872
|
+
console.warn(
|
|
1873
|
+
"Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'"
|
|
1874
|
+
);
|
|
1875
|
+
} else {
|
|
1876
|
+
console.warn(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
|
|
1877
|
+
Sentry.addTracingExtensions();
|
|
1878
|
+
Sentry.init({...});
|
|
1879
|
+
`);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
return result;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* @inheritDoc
|
|
1886
|
+
*/
|
|
1887
|
+
traceHeaders() {
|
|
1888
|
+
return this._callExtensionMethod("traceHeaders");
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* @inheritDoc
|
|
1892
|
+
*/
|
|
1893
|
+
captureSession(endSession = false) {
|
|
1894
|
+
if (endSession) {
|
|
1895
|
+
return this.endSession();
|
|
1896
|
+
}
|
|
1897
|
+
this._sendSessionUpdate();
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* @inheritDoc
|
|
1901
|
+
*/
|
|
1902
|
+
endSession() {
|
|
1903
|
+
const layer = this.getStackTop();
|
|
1904
|
+
const scope = layer.scope;
|
|
1905
|
+
const session = scope.getSession();
|
|
1906
|
+
if (session) {
|
|
1907
|
+
closeSession(session);
|
|
1908
|
+
}
|
|
1909
|
+
this._sendSessionUpdate();
|
|
1910
|
+
scope.setSession();
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* @inheritDoc
|
|
1914
|
+
*/
|
|
1915
|
+
startSession(context) {
|
|
1916
|
+
const { scope, client: client2 } = this.getStackTop();
|
|
1917
|
+
const { release, environment = DEFAULT_ENVIRONMENT } = client2 && client2.getOptions() || {};
|
|
1918
|
+
const { userAgent } = GLOBAL_OBJ.navigator || {};
|
|
1919
|
+
const session = makeSession(__spreadValues(__spreadValues({
|
|
1920
|
+
release,
|
|
1921
|
+
environment,
|
|
1922
|
+
user: scope.getUser()
|
|
1923
|
+
}, userAgent && { userAgent }), context));
|
|
1924
|
+
const currentSession = scope.getSession && scope.getSession();
|
|
1925
|
+
if (currentSession && currentSession.status === "ok") {
|
|
1926
|
+
updateSession(currentSession, { status: "exited" });
|
|
1927
|
+
}
|
|
1928
|
+
this.endSession();
|
|
1929
|
+
scope.setSession(session);
|
|
1930
|
+
return session;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Returns if default PII should be sent to Sentry and propagated in ourgoing requests
|
|
1934
|
+
* when Tracing is used.
|
|
1935
|
+
*/
|
|
1936
|
+
shouldSendDefaultPii() {
|
|
1937
|
+
const client2 = this.getClient();
|
|
1938
|
+
const options = client2 && client2.getOptions();
|
|
1939
|
+
return Boolean(options && options.sendDefaultPii);
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Sends the current Session on the scope
|
|
1943
|
+
*/
|
|
1944
|
+
_sendSessionUpdate() {
|
|
1945
|
+
const { scope, client: client2 } = this.getStackTop();
|
|
1946
|
+
const session = scope.getSession();
|
|
1947
|
+
if (session && client2 && client2.captureSession) {
|
|
1948
|
+
client2.captureSession(session);
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Internal helper function to call a method on the top client if it exists.
|
|
1953
|
+
*
|
|
1954
|
+
* @param method The method to call on the client.
|
|
1955
|
+
* @param args Arguments to pass to the client function.
|
|
1956
|
+
*/
|
|
1957
|
+
_withClient(callback) {
|
|
1958
|
+
const { scope, client: client2 } = this.getStackTop();
|
|
1959
|
+
if (client2) {
|
|
1960
|
+
callback(client2, scope);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Calls global extension method and binding current instance to the function call
|
|
1965
|
+
*/
|
|
1966
|
+
// @ts-expect-error Function lacks ending return statement and return type does not include 'undefined'. ts(2366)
|
|
1967
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1968
|
+
_callExtensionMethod(method, ...args) {
|
|
1969
|
+
const carrier = getMainCarrier();
|
|
1970
|
+
const sentry = carrier.__SENTRY__;
|
|
1971
|
+
if (sentry && sentry.extensions && typeof sentry.extensions[method] === "function") {
|
|
1972
|
+
return sentry.extensions[method].apply(this, args);
|
|
1973
|
+
}
|
|
1974
|
+
(typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__) && logger.warn(`Extension method ${method} couldn't be found, doing nothing.`);
|
|
2042
1975
|
}
|
|
2043
|
-
return splitStr.slice(splitStr.length - 2).join(".");
|
|
2044
1976
|
}
|
|
2045
|
-
function
|
|
2046
|
-
|
|
1977
|
+
function getMainCarrier() {
|
|
1978
|
+
GLOBAL_OBJ.__SENTRY__ = GLOBAL_OBJ.__SENTRY__ || {
|
|
1979
|
+
extensions: {},
|
|
1980
|
+
hub: void 0
|
|
1981
|
+
};
|
|
1982
|
+
return GLOBAL_OBJ;
|
|
1983
|
+
}
|
|
1984
|
+
function makeMain(hub) {
|
|
1985
|
+
const registry = getMainCarrier();
|
|
1986
|
+
const oldHub = getHubFromCarrier(registry);
|
|
1987
|
+
setHubOnCarrier(registry, hub);
|
|
1988
|
+
return oldHub;
|
|
1989
|
+
}
|
|
1990
|
+
function getCurrentHub() {
|
|
1991
|
+
const registry = getMainCarrier();
|
|
1992
|
+
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
|
|
1993
|
+
const hub = registry.__SENTRY__.acs.getCurrentHub();
|
|
1994
|
+
if (hub) {
|
|
1995
|
+
return hub;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
return getGlobalHub(registry);
|
|
1999
|
+
}
|
|
2000
|
+
function getGlobalHub(registry = getMainCarrier()) {
|
|
2001
|
+
if (!hasHubOnCarrier(registry) || getHubFromCarrier(registry).isOlderThan(API_VERSION)) {
|
|
2002
|
+
setHubOnCarrier(registry, new Hub());
|
|
2003
|
+
}
|
|
2004
|
+
return getHubFromCarrier(registry);
|
|
2005
|
+
}
|
|
2006
|
+
function hasHubOnCarrier(carrier) {
|
|
2007
|
+
return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub);
|
|
2008
|
+
}
|
|
2009
|
+
function getHubFromCarrier(carrier) {
|
|
2010
|
+
return getGlobalSingleton("hub", () => new Hub(), carrier);
|
|
2011
|
+
}
|
|
2012
|
+
function setHubOnCarrier(carrier, hub) {
|
|
2013
|
+
if (!carrier)
|
|
2014
|
+
return false;
|
|
2015
|
+
const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {};
|
|
2016
|
+
__SENTRY__.hub = hub;
|
|
2017
|
+
return true;
|
|
2018
|
+
}
|
|
2019
|
+
function captureMessage(message, captureContext) {
|
|
2020
|
+
const level = typeof captureContext === "string" ? captureContext : void 0;
|
|
2021
|
+
const context = typeof captureContext !== "string" ? { captureContext } : void 0;
|
|
2022
|
+
return getCurrentHub().captureMessage(message, level, context);
|
|
2023
|
+
}
|
|
2024
|
+
const errorsToIgnore = [
|
|
2025
|
+
MiniAppErrorType.sdkNotInitialized,
|
|
2026
|
+
MiniAppErrorType.notAuthorized,
|
|
2027
|
+
MiniAppErrorType.userCanceled,
|
|
2028
|
+
MiniAppErrorType.userCanceledSimilarTxn,
|
|
2029
|
+
MiniAppErrorType.suspectedDuplicatePayment,
|
|
2030
|
+
MiniAppErrorType.noSufficientFund
|
|
2031
|
+
];
|
|
2032
|
+
function sendWindowBridgeErrorToSentry(functionName, message, error) {
|
|
2033
|
+
if (!errorsToIgnore.includes(error) && SENTRY_DSN) {
|
|
2034
|
+
captureMessage(
|
|
2035
|
+
`windowBridge.${functionName} failed. client: ${"unknown"}, error: ${error}, message: ${message}`,
|
|
2036
|
+
"log"
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
let clientId = "";
|
|
2041
|
+
function getCurrentClientId() {
|
|
2042
|
+
return clientId;
|
|
2043
|
+
}
|
|
2044
|
+
if (!isEnableLocalStorage())
|
|
2045
|
+
;
|
|
2046
|
+
function isEnableLocalStorage() {
|
|
2047
|
+
try {
|
|
2048
|
+
localStorage.getItem("ppjssdk.canWriteToLocalStorage");
|
|
2049
|
+
return true;
|
|
2050
|
+
} catch (e) {
|
|
2051
|
+
console.log(e);
|
|
2052
|
+
return false;
|
|
2053
|
+
}
|
|
2047
2054
|
}
|
|
2048
|
-
({
|
|
2049
|
-
UNAUTHORIZED: MiniAppErrorType.notAuthorized,
|
|
2050
|
-
BAD_REQUEST: MiniAppErrorType.badRequest,
|
|
2051
|
-
MISSING_REQUEST_PARAMS: MiniAppErrorType.badRequestInsufficientParameter,
|
|
2052
|
-
OP_OUT_OF_SCOPE: MiniAppErrorType.insufficientScope,
|
|
2053
|
-
MINI_APP_SCOPE_NOT_FOUND: MiniAppErrorType.insufficientScope
|
|
2054
|
-
});
|
|
2055
2055
|
function isPayPayMiniApp() {
|
|
2056
2056
|
return navigator.userAgent.includes("PayPayMiniApp/");
|
|
2057
2057
|
}
|
|
@@ -2059,8 +2059,8 @@ function getRandomString() {
|
|
|
2059
2059
|
return Math.random().toString(36).substring(7);
|
|
2060
2060
|
}
|
|
2061
2061
|
function getEventCategory(params) {
|
|
2062
|
-
var _a
|
|
2063
|
-
const clientId2 = (
|
|
2062
|
+
var _a;
|
|
2063
|
+
const clientId2 = (_a = params == null ? void 0 : params.clientId) != null ? _a : getCurrentClientId();
|
|
2064
2064
|
const featureName = (params == null ? void 0 : params.featureName) ? `_${params == null ? void 0 : params.featureName}` : "";
|
|
2065
2065
|
const sdkType = (params == null ? void 0 : params.sdkType) ? params.sdkType : isPayPayMiniApp() ? "miniapp" : "smartpayment";
|
|
2066
2066
|
return `${sdkType}_${clientId2}${featureName}`;
|
|
@@ -2224,12 +2224,9 @@ class WindowBridge {
|
|
|
2224
2224
|
);
|
|
2225
2225
|
}
|
|
2226
2226
|
try {
|
|
2227
|
-
const context = {
|
|
2228
|
-
clientOrigin: receivedMessageEvent.origin
|
|
2229
|
-
};
|
|
2230
2227
|
this.sendSuccessResponse(
|
|
2231
2228
|
receivedMessageEvent,
|
|
2232
|
-
yield functionToInvoke(...receivedMessageEvent.data.params
|
|
2229
|
+
yield functionToInvoke(...receivedMessageEvent.data.params)
|
|
2233
2230
|
);
|
|
2234
2231
|
} catch (error) {
|
|
2235
2232
|
let message = "Some error ocurred while processing the request";
|
|
@@ -2480,6 +2477,10 @@ let useAllFunctions = false;
|
|
|
2480
2477
|
let initDonePromise;
|
|
2481
2478
|
WindowBridge.init({});
|
|
2482
2479
|
void getCoreIframe();
|
|
2480
|
+
function clearInternalInitSyncState() {
|
|
2481
|
+
initDonePromise = Promise.resolve(false);
|
|
2482
|
+
}
|
|
2483
|
+
clearInternalInitSyncState();
|
|
2483
2484
|
const core = WindowBridge.getTargetWindowFunctionProxy(
|
|
2484
2485
|
getCoreIframeWindow,
|
|
2485
2486
|
CORE_IFRAME_ORIGIN
|
|
@@ -2539,7 +2540,7 @@ function init(params) {
|
|
|
2539
2540
|
const ott = url2.searchParams.get("one_time_token");
|
|
2540
2541
|
const refreshToken = getRefreshToken();
|
|
2541
2542
|
const codeVerifier = getCodeVerifier();
|
|
2542
|
-
const clientVersion = "2.
|
|
2543
|
+
const clientVersion = "2.25.0";
|
|
2543
2544
|
useAllFunctions = !!params.useAllFunctions;
|
|
2544
2545
|
if (token || ott) {
|
|
2545
2546
|
removeTokenFromUrl(url2);
|
|
@@ -2556,13 +2557,15 @@ function init(params) {
|
|
|
2556
2557
|
codeVerifier
|
|
2557
2558
|
};
|
|
2558
2559
|
let initDonePromiseResolve;
|
|
2559
|
-
|
|
2560
|
+
const nextInitDonePromise = new Promise(
|
|
2561
|
+
(resolve) => initDonePromiseResolve = resolve
|
|
2562
|
+
);
|
|
2560
2563
|
const complete = () => {
|
|
2561
2564
|
var _a;
|
|
2562
2565
|
initDonePromiseResolve(true);
|
|
2563
2566
|
(_a = params.complete) == null ? void 0 : _a.call(params);
|
|
2564
2567
|
};
|
|
2565
|
-
getCoreIframe().then(() => {
|
|
2568
|
+
initDonePromise.then(() => getCoreIframe()).then(() => {
|
|
2566
2569
|
triggerPostMessageToCore(
|
|
2567
2570
|
PPFunctionName.init,
|
|
2568
2571
|
false,
|
|
@@ -2574,6 +2577,7 @@ function init(params) {
|
|
|
2574
2577
|
(_a = params.fail) == null ? void 0 : _a.call(params, { errorCode: MiniAppErrorType.sdkNotInitialized });
|
|
2575
2578
|
complete();
|
|
2576
2579
|
});
|
|
2580
|
+
initDonePromise = nextInitDonePromise;
|
|
2577
2581
|
}
|
|
2578
2582
|
function verifyMultiFactorAuthResult(params) {
|
|
2579
2583
|
const url2 = new URL(window.location.href);
|
|
@@ -3026,7 +3030,7 @@ function executePendingFunctionCalls() {
|
|
|
3026
3030
|
}
|
|
3027
3031
|
}
|
|
3028
3032
|
executePendingFunctionCalls();
|
|
3029
|
-
proxy.revision = "
|
|
3033
|
+
proxy.revision = "e26ec27";
|
|
3030
3034
|
const client = proxy;
|
|
3031
3035
|
window._pp = client;
|
|
3032
3036
|
const miniAppSdk = client;
|