FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Exceptionless.JavaScript/packages/angularjs/src/index.ts at main · exceptionless/Exceptionless.JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
exceptionless
/
Exceptionless.JavaScript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
22
Star
60
Code
Issues
0
Pull requests
11
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Exceptionless.JavaScript
/
packages
/
angularjs
/
src
/
index.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
149 lines (137 loc) · 5.43 KB
Breadcrumbs
Exceptionless.JavaScript
/
packages
/
angularjs
/
src
/
index.ts
Copy path
File metadata and controls
149 lines (137 loc) · 5.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import
{
BrowserExceptionlessClient
,
Exceptionless
,
toError
}
from
"@exceptionless/browser"
;
declare
let
angular
;
angular
.
module
(
"exceptionless"
,
[
]
)
.
constant
(
"$ExceptionlessClient"
,
Exceptionless
)
.
factory
(
"exceptionlessHttpInterceptor"
,
[
"$location"
,
"$q"
,
"$ExceptionlessClient"
,
(
$location
:
ng
.
ILocationService
,
$q
:
ng
.
IQService
,
$ExceptionlessClient
:
BrowserExceptionlessClient
)
=>
{
return
{
responseError
:
function
responseError
(
response
:
ng
.
IHttpResponse
<
{
Message
?:
string
}
>
)
{
if
(
response
.
status
===
404
)
{
void
$ExceptionlessClient
.
submitNotFound
(
response
.
config
.
url
)
;
}
else
if
(
response
.
status
!==
401
)
{
const
message
=
`[
${
response
.
status
}
]
${
response
.
data
?.
Message
??
response
.
config
.
url
}
`
;
void
$ExceptionlessClient
.
createUnhandledException
(
new
Error
(
message
)
,
"errorHttpInterceptor"
)
.
setSource
(
response
.
config
.
url
)
.
setProperty
(
"response"
,
response
)
.
setProperty
(
"referrer"
,
$location
.
absUrl
(
)
)
.
submit
(
)
;
}
return
$q
.
reject
(
response
)
;
}
}
;
}
]
)
.
config
(
[
"$httpProvider"
,
"$provide"
,
"$ExceptionlessClient"
,
(
$httpProvider
:
ng
.
IHttpProvider
,
$provide
:
ng
.
IModule
,
$ExceptionlessClient
:
BrowserExceptionlessClient
)
=>
{
$httpProvider
.
interceptors
.
push
(
"exceptionlessHttpInterceptor"
)
;
$provide
.
decorator
(
"$exceptionHandler"
,
[
"$delegate"
,
(
$delegate
:
(
ex
:
Error
,
cause
:
string
)
=>
void
)
=>
{
return
(
exception
:
Error
,
cause
:
string
)
=>
{
$delegate
(
exception
,
cause
)
;
void
$ExceptionlessClient
.
createUnhandledException
(
exception
,
"$exceptionHandler"
)
.
setMessage
(
cause
)
.
submit
(
)
;
}
;
}
]
)
;
$provide
.
decorator
(
"$log"
,
[
"$delegate"
,
(
$delegate
)
=>
{
function
decorateRegularCall
(
property
:
string
,
logLevel
:
string
)
{
const
previousFn
=
$delegate
[
property
]
;
return
(
$delegate
[
property
]
=
(
...
args
:
string
[
]
)
=>
{
if
(
(
angular
as
{
mock
?:
unknown
}
)
.
mock
)
{
$delegate
[
property
]
.
logs
=
[
]
;
}
// eslint-disable-next-line prefer-spread
previousFn
.
apply
(
null
,
args
)
;
if
(
args
[
0
]
&&
args
[
0
]
.
length
>
0
)
{
void
$ExceptionlessClient
.
submitLog
(
undefined
,
args
[
0
]
,
logLevel
)
;
}
}
)
;
}
$delegate
.
log
=
decorateRegularCall
(
"log"
,
"Trace"
)
;
$delegate
.
info
=
decorateRegularCall
(
"info"
,
"Info"
)
;
$delegate
.
warn
=
decorateRegularCall
(
"warn"
,
"Warn"
)
;
$delegate
.
debug
=
decorateRegularCall
(
"debug"
,
"Debug"
)
;
$delegate
.
error
=
decorateRegularCall
(
"error"
,
"Error"
)
;
return
$delegate
;
}
]
)
;
}
]
)
.
run
(
[
"$rootScope"
,
"$ExceptionlessClient"
,
(
$rootScope
:
ng
.
IRootScopeService
,
$ExceptionlessClient
:
BrowserExceptionlessClient
)
=>
{
$rootScope
.
$on
(
"$routeChangeSuccess"
,
(
_event
,
next
,
current
)
=>
{
if
(
!
current
)
{
return
;
}
void
$ExceptionlessClient
.
createFeatureUsage
(
current
.
name
as
string
)
.
setProperty
(
"next"
,
next
)
.
setProperty
(
"current"
,
current
)
.
submit
(
)
;
}
)
;
$rootScope
.
$on
(
"$routeChangeError"
,
(
_event
,
current
,
previous
,
rejection
)
=>
{
const
error
:
Error
=
toError
(
rejection
,
"Route Change Error"
)
;
void
$ExceptionlessClient
.
createUnhandledException
(
error
,
"$routeChangeError"
)
.
setProperty
(
"current"
,
current
)
.
setProperty
(
"previous"
,
previous
)
.
submit
(
)
;
}
)
;
$rootScope
.
$on
(
"$stateChangeSuccess"
,
(
_event
,
toState
,
toParams
,
fromState
,
fromParams
)
=>
{
if
(
!
toState
||
toState
.
name
===
"otherwise"
)
{
return
;
}
void
$ExceptionlessClient
.
createFeatureUsage
(
(
toState
.
controller
||
toState
.
name
)
as
string
)
.
setProperty
(
"toState"
,
toState
)
.
setProperty
(
"toParams"
,
toParams
)
.
setProperty
(
"fromState"
,
fromState
)
.
setProperty
(
"fromParams"
,
fromParams
)
.
submit
(
)
;
}
)
;
$rootScope
.
$on
(
"$stateNotFound"
,
(
_event
,
unfoundState
,
fromState
,
fromParams
)
=>
{
if
(
!
unfoundState
)
{
return
;
}
void
$ExceptionlessClient
.
createNotFound
(
unfoundState
.
to
as
string
)
.
setProperty
(
"unfoundState"
,
unfoundState
)
.
setProperty
(
"fromState"
,
fromState
)
.
setProperty
(
"fromParams"
,
fromParams
)
.
submit
(
)
;
}
)
;
const
stateChangeError
=
"$stateChangeError"
;
$rootScope
.
$on
(
stateChangeError
,
(
_event
,
toState
,
toParams
,
fromState
,
fromParams
,
error
)
=>
{
if
(
!
error
)
{
return
;
}
const
builder
=
error
&&
error
.
status
===
404
?
$ExceptionlessClient
.
createNotFound
(
error
.
config
.
url
as
string
)
:
$ExceptionlessClient
.
createUnhandledException
(
error
as
Error
,
stateChangeError
)
;
void
builder
.
setSource
(
stateChangeError
)
.
setMessage
(
error
?.
statusText
as
string
)
.
setProperty
(
"toState"
,
toState
)
.
setProperty
(
"toParams"
,
toParams
)
.
setProperty
(
"fromState"
,
fromState
)
.
setProperty
(
"fromParams"
,
fromParams
)
.
submit
(
)
;
}
)
;
$rootScope
.
$on
(
"$destroy"
,
(
)
=>
{
void
$ExceptionlessClient
.
config
.
services
.
queue
.
process
(
)
;
}
)
;
}
]
)
;
Back
|
FazBrowse Home
|
New Git URL