Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
3ad80f20
Commit
3ad80f20
authored
5 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Add a wrapper for Sentry.showReportDialog()
parent
8e03da0d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/common/errorreport.js
+33
-0
33 additions, 0 deletions
packages/common/errorreport.js
with
33 additions
and
0 deletions
packages/common/errorreport.js
+
33
−
0
View file @
3ad80f20
...
@@ -2,6 +2,9 @@ import * as Sentry from '@sentry/browser';
...
@@ -2,6 +2,9 @@ import * as Sentry from '@sentry/browser';
import
env
from
'
./env.js
'
;
import
env
from
'
./env.js
'
;
import
environment
from
'
consts:environment
'
;
import
environment
from
'
consts:environment
'
;
let
_isInitialized
=
false
let
_canReportEvent
=
false
;
/**
/**
* Initializes error reporting.
* Initializes error reporting.
*
*
...
@@ -16,6 +19,9 @@ export function init(options) {
...
@@ -16,6 +19,9 @@ export function init(options) {
};
};
let
actual
=
Object
.
assign
({},
defaults
,
options
);
let
actual
=
Object
.
assign
({},
defaults
,
options
);
if
(
_isInitialized
)
throw
new
Error
(
"
Already initialized
"
);
let
sentryOptions
=
{
debug
:
actual
.
debug
,
environment
:
environment
};
let
sentryOptions
=
{
debug
:
actual
.
debug
,
environment
:
environment
};
if
(
actual
.
release
)
{
if
(
actual
.
release
)
{
...
@@ -36,9 +42,32 @@ export function init(options) {
...
@@ -36,9 +42,32 @@ export function init(options) {
};
};
}
else
{
}
else
{
sentryOptions
[
'
dsn
'
]
=
env
.
sentryDSN
;
sentryOptions
[
'
dsn
'
]
=
env
.
sentryDSN
;
_canReportEvent
=
true
;
}
}
Sentry
.
init
(
sentryOptions
);
Sentry
.
init
(
sentryOptions
);
_isInitialized
=
true
;
}
/**
* Whether showReportDialog() will work.
*/
export
function
canReportEvent
()
{
if
(
!
_isInitialized
)
throw
new
Error
(
"
Not initialized
"
);
return
_canReportEvent
;
}
/**
* Show a report dialog for user error feedback.
*
* Call canReportEvent() first to see if this will do anything.
*/
export
function
showReportDialog
()
{
if
(
!
canReportEvent
())
return
;
Sentry
.
showReportDialog
();
}
}
/**
/**
...
@@ -47,6 +76,8 @@ export function init(options) {
...
@@ -47,6 +76,8 @@ export function init(options) {
* @param {*} exception
* @param {*} exception
*/
*/
export
function
captureException
(
exception
)
{
export
function
captureException
(
exception
)
{
if
(
!
_isInitialized
)
throw
new
Error
(
"
Not initialized
"
);
Sentry
.
captureException
(
exception
);
Sentry
.
captureException
(
exception
);
}
}
...
@@ -57,6 +88,8 @@ export function captureException(exception) {
...
@@ -57,6 +88,8 @@ export function captureException(exception) {
* @param {String} [level=error] The loglevel (error, warning, info, debug)
* @param {String} [level=error] The loglevel (error, warning, info, debug)
*/
*/
export
function
captureMessage
(
message
,
level
)
{
export
function
captureMessage
(
message
,
level
)
{
if
(
!
_isInitialized
)
throw
new
Error
(
"
Not initialized
"
);
if
(
!
level
)
if
(
!
level
)
level
=
'
error
'
;
level
=
'
error
'
;
if
(
!
[
'
error
'
,
'
warning
'
,
'
info
'
,
'
debug
'
].
includes
(
level
))
if
(
!
[
'
error
'
,
'
warning
'
,
'
info
'
,
'
debug
'
].
includes
(
level
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment