@colisweb/rescript-toolkit 2.38.2 → 2.40.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/package.json
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open BsSentry
|
|
2
|
-
|
|
3
1
|
type t
|
|
4
2
|
@val external windowInstance: option<t> = "window"
|
|
5
3
|
@val external window: t = "window"
|
|
@@ -7,6 +5,8 @@ type t
|
|
|
7
5
|
let get = () => Js.typeof(windowInstance) !== "undefined" ? window : process
|
|
8
6
|
let instance = get()
|
|
9
7
|
|
|
8
|
+
@new
|
|
9
|
+
external makeError: string => Js.Exn.t = "Error"
|
|
10
10
|
@get external _nodeEnv: t => string = "NODE_ENV"
|
|
11
11
|
|
|
12
12
|
let nodeEnv = instance->_nodeEnv
|
|
@@ -50,14 +50,11 @@ let warning3 = (str, str2, str3) => {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
let error = str => {
|
|
53
|
+
let error = (str: string) => {
|
|
54
54
|
if nodeEnv !== "production" {
|
|
55
55
|
Js.Console.log3("%cERROR", errorStyle, str)
|
|
56
56
|
} else {
|
|
57
|
-
|
|
58
|
-
withScope(_scope => {
|
|
59
|
-
captureMessage(Obj.magic(str))
|
|
60
|
-
})
|
|
57
|
+
DatadogRum.Browser.addError(makeError(str))
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
|
|
@@ -65,10 +62,11 @@ let error2 = (str, str2) => {
|
|
|
65
62
|
if nodeEnv !== "production" {
|
|
66
63
|
Js.Console.log4("%cERROR", errorStyle, str, str2)
|
|
67
64
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
DatadogRum.Browser.addErrorWithContext(
|
|
66
|
+
makeError(str),
|
|
67
|
+
{
|
|
68
|
+
"cause": str2,
|
|
69
|
+
},
|
|
70
|
+
)
|
|
73
71
|
}
|
|
74
72
|
}
|
package/src/vendors/Axios.res
CHANGED
|
@@ -111,15 +111,15 @@ module Interceptors = {
|
|
|
111
111
|
module WithResult = {
|
|
112
112
|
type customError<'apiError, 'response> = [
|
|
113
113
|
| #default(error<'response>)
|
|
114
|
-
| #decodeError(Decco.decodeError)
|
|
114
|
+
| #decodeError(config, Decco.decodeError)
|
|
115
115
|
| #custom('apiError)
|
|
116
116
|
]
|
|
117
117
|
|
|
118
|
-
type decodeData<'newData
|
|
118
|
+
type decodeData<'newData> = Js.Json.t => result<'newData, Decco.decodeError>
|
|
119
119
|
|
|
120
120
|
type mapError<'a, 'response, 'headers, 'request> = error<'response> => customError<'a, 'response>
|
|
121
121
|
|
|
122
|
-
let toResult = (promise, ~mapError, ~decodeData) =>
|
|
122
|
+
let toResult = (promise, ~mapError, ~decodeData: decodeData<'a>) =>
|
|
123
123
|
promise
|
|
124
124
|
->Promise.Js.toResult
|
|
125
125
|
->Promise.mapError(err => mapError->Option.mapWithDefault(#default(err), fn => fn(err)))
|
|
@@ -127,14 +127,14 @@ module WithResult = {
|
|
|
127
127
|
Promise.resolved(
|
|
128
128
|
switch decodeData(response.data) {
|
|
129
129
|
| Ok(_) as ok => ok
|
|
130
|
-
| Error(decodeError) => Error(#decodeError(decodeError))
|
|
130
|
+
| Error(decodeError) => Error(#decodeError(response.config, decodeError))
|
|
131
131
|
},
|
|
132
132
|
)
|
|
133
133
|
})
|
|
134
134
|
|
|
135
135
|
let get = (
|
|
136
136
|
~config=?,
|
|
137
|
-
~decodeData: decodeData<'newData
|
|
137
|
+
~decodeData: decodeData<'newData>,
|
|
138
138
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
139
139
|
string,
|
|
140
140
|
) => get(string, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
@@ -142,7 +142,7 @@ module WithResult = {
|
|
|
142
142
|
let post = (
|
|
143
143
|
~data,
|
|
144
144
|
~config=?,
|
|
145
|
-
~decodeData: decodeData<'newData
|
|
145
|
+
~decodeData: decodeData<'newData>,
|
|
146
146
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
147
147
|
string,
|
|
148
148
|
) => post(string, ~data, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
@@ -150,7 +150,7 @@ module WithResult = {
|
|
|
150
150
|
let put = (
|
|
151
151
|
~data,
|
|
152
152
|
~config=?,
|
|
153
|
-
~decodeData: decodeData<'newData
|
|
153
|
+
~decodeData: decodeData<'newData>,
|
|
154
154
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
155
155
|
string,
|
|
156
156
|
) => put(string, ~data, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
@@ -158,21 +158,21 @@ module WithResult = {
|
|
|
158
158
|
let patch = (
|
|
159
159
|
~data,
|
|
160
160
|
~config=?,
|
|
161
|
-
~decodeData: decodeData<'newData
|
|
161
|
+
~decodeData: decodeData<'newData>,
|
|
162
162
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
163
163
|
string,
|
|
164
164
|
) => patch(string, ~data, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
165
165
|
|
|
166
166
|
let delete = (
|
|
167
167
|
~config=?,
|
|
168
|
-
~decodeData: decodeData<'newData
|
|
168
|
+
~decodeData: decodeData<'newData>,
|
|
169
169
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
170
170
|
string,
|
|
171
171
|
) => delete(string, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
172
172
|
|
|
173
173
|
let options = (
|
|
174
174
|
~config=?,
|
|
175
|
-
~decodeData: decodeData<'newData
|
|
175
|
+
~decodeData: decodeData<'newData>,
|
|
176
176
|
~mapError: option<mapError<'a, 'response, 'headers, 'request>>=?,
|
|
177
177
|
string,
|
|
178
178
|
) => options(string, ~config?, ())->toResult(~decodeData, ~mapError)
|
|
@@ -13,4 +13,13 @@ module Browser = {
|
|
|
13
13
|
|
|
14
14
|
@module("@datadog/browser-rum") @scope("datadogRum")
|
|
15
15
|
external setUser: 'a => unit = "setUser"
|
|
16
|
+
|
|
17
|
+
@module("@datadog/browser-rum") @scope("datadogRum")
|
|
18
|
+
external addAction: (string, 'a) => unit = "addAction"
|
|
19
|
+
|
|
20
|
+
@module("@datadog/browser-rum") @scope("datadogRum")
|
|
21
|
+
external addError: Js.Exn.t => unit = "addError"
|
|
22
|
+
|
|
23
|
+
@module("@datadog/browser-rum") @scope("datadogRum")
|
|
24
|
+
external addErrorWithContext: (Js.Exn.t, 'context) => unit = "addError"
|
|
16
25
|
}
|