@colisweb/rescript-toolkit 2.11.2 → 2.12.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/.gitlab-ci.yml +1 -2
- package/bsconfig.json +1 -2
- package/package.json +2 -2
- package/src/Toolkit.res +2 -0
- package/src/logger/Toolkit__BrowserLogger.res +54 -0
- package/src/logger/Toolkit__BrowserLogger.resi +8 -0
- package/src/logger/Toolkit__NativeLogger.res +54 -0
- package/src/logger/Toolkit__NativeLogger.resi +8 -0
- package/src/logger/index.md +16 -0
- package/src/request/Toolkit__Request.res +3 -8
- package/src/sentry/SentryLogger.res +0 -114
- package/src/sentry/SentryReactNativeLogger.res +0 -114
- package/src/sentry/index.md +0 -3
package/.gitlab-ci.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
include:
|
|
2
|
-
- "https://colisweb-open-source.gitlab.io/ci-common/v13.
|
|
2
|
+
- "https://colisweb-open-source.gitlab.io/ci-common/v13.11.1/templates/colisweb.yml"
|
|
3
3
|
|
|
4
4
|
# -----------------------------------------------
|
|
5
5
|
# Test
|
|
@@ -16,7 +16,6 @@ rescript compilation:
|
|
|
16
16
|
- .yarn/
|
|
17
17
|
script:
|
|
18
18
|
- export NPM_TOKEN=${NPM_TOKEN:-undefined}
|
|
19
|
-
- echo $NPM_TOKEN
|
|
20
19
|
- yarn install --cache-folder .yarn --pure-lockfile
|
|
21
20
|
- yarn test
|
|
22
21
|
|
package/bsconfig.json
CHANGED
|
@@ -31,12 +31,11 @@
|
|
|
31
31
|
"reason-react",
|
|
32
32
|
"decco",
|
|
33
33
|
"rescript-classnames",
|
|
34
|
-
"rescript-logger",
|
|
35
34
|
"reschema",
|
|
36
35
|
"rescript-react-update",
|
|
37
36
|
"restorative"
|
|
38
37
|
],
|
|
39
|
-
"ppx-flags": ["decco/ppx", "lenses-ppx/ppx"
|
|
38
|
+
"ppx-flags": ["decco/ppx", "lenses-ppx/ppx"],
|
|
40
39
|
"refmt": 3,
|
|
41
40
|
"warnings": {
|
|
42
41
|
"number": "-44-30-32",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rescript clean",
|
|
6
6
|
"build": "rescript build",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"reschema": "1.3.1",
|
|
66
66
|
"rescript": "9.1.4",
|
|
67
67
|
"rescript-classnames": "6.0.0",
|
|
68
|
-
"rescript-logger": "2.0.2",
|
|
69
68
|
"rescript-react-update": "5.0.0",
|
|
70
69
|
"restorative": "0.4.0-beta.1",
|
|
71
70
|
"sanitize-html": "2.6.1",
|
|
@@ -74,6 +73,7 @@
|
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
75
|
"@babel/core": "7.16.5",
|
|
76
|
+
"@sentry/browser": "6.17.6",
|
|
77
77
|
"@storybook/addon-actions": "6.1.21",
|
|
78
78
|
"@storybook/addon-essentials": "6.1.21",
|
|
79
79
|
"@storybook/addon-knobs": "6.1.21",
|
package/src/Toolkit.res
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
open BsSentry
|
|
2
|
+
|
|
3
|
+
@val @scope("process.env") external nodeEnv: string = "NODE_ENV"
|
|
4
|
+
|
|
5
|
+
let debugStyle = "background-color: #208E9C; color: white; padding: 5px; font-size: 10px;"
|
|
6
|
+
let warningStyle = "background-color: #FFAD2D; color: white; padding: 5px; font-size: 10px;"
|
|
7
|
+
let errorStyle = "background-color: #FF4714; color: white; padding: 5px; font-size: 10px;"
|
|
8
|
+
|
|
9
|
+
let debug = str => {
|
|
10
|
+
if nodeEnv !== "production" {
|
|
11
|
+
Js.Console.log3("%cDEBUG", debugStyle, str)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let debug2 = (str, str2) => {
|
|
16
|
+
if nodeEnv !== "production" {
|
|
17
|
+
Js.Console.log4("%cDEBUG", debugStyle, str, str2)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let warning = str => {
|
|
22
|
+
if nodeEnv !== "production" {
|
|
23
|
+
Js.Console.log3("%cWARN", warningStyle, str)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let warning2 = (str, str2) => {
|
|
28
|
+
if nodeEnv !== "production" {
|
|
29
|
+
Js.Console.log4("%cWARN", warningStyle, str, str2)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let error = str => {
|
|
34
|
+
if nodeEnv !== "production" {
|
|
35
|
+
Js.Console.log3("%cERROR", errorStyle, str)
|
|
36
|
+
} else {
|
|
37
|
+
open Sentry
|
|
38
|
+
withScope(_scope => {
|
|
39
|
+
captureMessage(Obj.magic(str))
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let error2 = (str, str2) => {
|
|
45
|
+
if nodeEnv !== "production" {
|
|
46
|
+
Js.Console.log4("%cERROR", errorStyle, str, str2)
|
|
47
|
+
} else {
|
|
48
|
+
open Sentry
|
|
49
|
+
withScope(scope => {
|
|
50
|
+
scope->Scope.setExtra("data", str2)
|
|
51
|
+
captureMessage(Obj.magic(str))
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
open BsSentryReactNative
|
|
2
|
+
|
|
3
|
+
@val @scope("process.env") external nodeEnv: string = "NODE_ENV"
|
|
4
|
+
|
|
5
|
+
let debugStyle = "background-color: #208E9C; color: white; padding: 5px; font-size: 10px;"
|
|
6
|
+
let warningStyle = "background-color: #FFAD2D; color: white; padding: 5px; font-size: 10px;"
|
|
7
|
+
let errorStyle = "background-color: #FF4714; color: white; padding: 5px; font-size: 10px;"
|
|
8
|
+
|
|
9
|
+
let debug = str => {
|
|
10
|
+
if nodeEnv !== "production" {
|
|
11
|
+
Js.Console.log3("%cDEBUG", debugStyle, str)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let debug2 = (str, str2) => {
|
|
16
|
+
if nodeEnv !== "production" {
|
|
17
|
+
Js.Console.log4("%cDEBUG", debugStyle, str, str2)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let warning = str => {
|
|
22
|
+
if nodeEnv !== "production" {
|
|
23
|
+
Js.Console.log3("%cWARN", warningStyle, str)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let warning2 = (str, str2) => {
|
|
28
|
+
if nodeEnv !== "production" {
|
|
29
|
+
Js.Console.log4("%cWARN", warningStyle, str, str2)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let error = str => {
|
|
34
|
+
if nodeEnv !== "production" {
|
|
35
|
+
Js.Console.log3("%cERROR", errorStyle, str)
|
|
36
|
+
} else {
|
|
37
|
+
open Sentry
|
|
38
|
+
withScope(_scope => {
|
|
39
|
+
captureMessage(Obj.magic(str))
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let error2 = (str, str2) => {
|
|
45
|
+
if nodeEnv !== "production" {
|
|
46
|
+
Js.Console.log4("%cERROR", errorStyle, str, str2)
|
|
47
|
+
} else {
|
|
48
|
+
open Sentry
|
|
49
|
+
withScope(scope => {
|
|
50
|
+
scope->Scope.setExtra("data", str2)
|
|
51
|
+
captureMessage(Obj.magic(str))
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Logger
|
|
2
|
+
|
|
3
|
+
Display log only at development and trigger Sentry on error on production.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```reason
|
|
8
|
+
let obj = {
|
|
9
|
+
"test": 1,
|
|
10
|
+
"z": "ee"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
Toolkit.BrowserLogger.debug("test")
|
|
14
|
+
|
|
15
|
+
Toolkit.BrowserLogger.error2("Error", obj)
|
|
16
|
+
```
|
|
@@ -55,10 +55,7 @@ let toResult = (
|
|
|
55
55
|
switch response["data"]->mapData {
|
|
56
56
|
| Ok(_) as ok => ok
|
|
57
57
|
| Error(error) => {
|
|
58
|
-
|
|
59
|
-
"Decoder failure"
|
|
60
|
-
("err", error)
|
|
61
|
-
)
|
|
58
|
+
Toolkit__BrowserLogger.error2("Decoder failure", error)
|
|
62
59
|
Error(
|
|
63
60
|
#invalidResponseData(
|
|
64
61
|
response->castToUndecodedResponse,
|
|
@@ -76,10 +73,8 @@ let toResult = (
|
|
|
76
73
|
switch error {
|
|
77
74
|
| Ok(err) => Error(#custom(err))
|
|
78
75
|
| Error(_err) =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
("err", _err)
|
|
82
|
-
)
|
|
76
|
+
Toolkit__BrowserLogger.error2("errorDecoder", _err)
|
|
77
|
+
|
|
83
78
|
Error(#invalidErrorData)
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
open BsSentry
|
|
2
|
-
|
|
3
|
-
let error = (loc: ReScriptLogger.Location.t, event) => {
|
|
4
|
-
open Sentry
|
|
5
|
-
withScope(scope => {
|
|
6
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
7
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
8
|
-
scope->Scope.setExtra("function", loc.value)
|
|
9
|
-
captureMessage(event)
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let error1 = (loc: ReScriptLogger.Location.t, event, (label, data)) => {
|
|
14
|
-
open Sentry
|
|
15
|
-
withScope(scope => {
|
|
16
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
17
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
18
|
-
scope->Scope.setExtra("function", loc.value)
|
|
19
|
-
scope->Scope.setExtra(label, data)
|
|
20
|
-
captureMessage(event)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let error2 = (loc: ReScriptLogger.Location.t, event, (label1, data1), (label2, data2)) => {
|
|
25
|
-
open Sentry
|
|
26
|
-
withScope(scope => {
|
|
27
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
28
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
29
|
-
scope->Scope.setExtra("function", loc.value)
|
|
30
|
-
scope->Scope.setExtra(label1, data1)
|
|
31
|
-
scope->Scope.setExtra(label2, data2)
|
|
32
|
-
captureMessage(event)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let error3 = (
|
|
37
|
-
loc: ReScriptLogger.Location.t,
|
|
38
|
-
event,
|
|
39
|
-
(label1, data1),
|
|
40
|
-
(label2, data2),
|
|
41
|
-
(label3, data3),
|
|
42
|
-
) => {
|
|
43
|
-
open Sentry
|
|
44
|
-
withScope(scope => {
|
|
45
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
46
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
47
|
-
scope->Scope.setExtra("function", loc.value)
|
|
48
|
-
scope->Scope.setExtra(label1, data1)
|
|
49
|
-
scope->Scope.setExtra(label2, data2)
|
|
50
|
-
scope->Scope.setExtra(label3, data3)
|
|
51
|
-
captureMessage(event)
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
let error4 = (
|
|
55
|
-
loc: ReScriptLogger.Location.t,
|
|
56
|
-
event,
|
|
57
|
-
(label1, data1),
|
|
58
|
-
(label2, data2),
|
|
59
|
-
(label3, data3),
|
|
60
|
-
(label4, data4),
|
|
61
|
-
) => {
|
|
62
|
-
open Sentry
|
|
63
|
-
withScope(scope => {
|
|
64
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
65
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
66
|
-
scope->Scope.setExtra("function", loc.value)
|
|
67
|
-
scope->Scope.setExtra(label1, data1)
|
|
68
|
-
scope->Scope.setExtra(label2, data2)
|
|
69
|
-
scope->Scope.setExtra(label3, data3)
|
|
70
|
-
scope->Scope.setExtra(label4, data4)
|
|
71
|
-
captureMessage(event)
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
let error5 = (
|
|
75
|
-
loc: ReScriptLogger.Location.t,
|
|
76
|
-
event,
|
|
77
|
-
(label1, data1),
|
|
78
|
-
(label2, data2),
|
|
79
|
-
(label3, data3),
|
|
80
|
-
(label4, data4),
|
|
81
|
-
(label5, data5),
|
|
82
|
-
) => {
|
|
83
|
-
open Sentry
|
|
84
|
-
withScope(scope => {
|
|
85
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
86
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
87
|
-
scope->Scope.setExtra("function", loc.value)
|
|
88
|
-
scope->Scope.setExtra(label1, data1)
|
|
89
|
-
scope->Scope.setExtra(label2, data2)
|
|
90
|
-
scope->Scope.setExtra(label3, data3)
|
|
91
|
-
scope->Scope.setExtra(label4, data4)
|
|
92
|
-
scope->Scope.setExtra(label5, data5)
|
|
93
|
-
captureMessage(event)
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let errorWithData = (loc: ReScriptLogger.Location.t, event, (label, data)) => {
|
|
98
|
-
open Sentry
|
|
99
|
-
withScope(scope => {
|
|
100
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
101
|
-
scope->Scope.setExtra(label, data)
|
|
102
|
-
captureMessage(event)
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let errorWithData2 = (loc: ReScriptLogger.Location.t, event, (label1, data1), (label2, data2)) => {
|
|
107
|
-
open Sentry
|
|
108
|
-
withScope(scope => {
|
|
109
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
110
|
-
scope->Scope.setExtra(label1, data1)
|
|
111
|
-
scope->Scope.setExtra(label2, data2)
|
|
112
|
-
captureMessage(event)
|
|
113
|
-
})
|
|
114
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
open BsSentryReactNative
|
|
2
|
-
|
|
3
|
-
let error = (loc: ReScriptLogger.Location.t, event) => {
|
|
4
|
-
open Sentry
|
|
5
|
-
withScope(scope => {
|
|
6
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
7
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
8
|
-
scope->Scope.setExtra("function", loc.value)
|
|
9
|
-
captureMessage(event)
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let error1 = (loc: ReScriptLogger.Location.t, event, (label, data)) => {
|
|
14
|
-
open Sentry
|
|
15
|
-
withScope(scope => {
|
|
16
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
17
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
18
|
-
scope->Scope.setExtra("function", loc.value)
|
|
19
|
-
scope->Scope.setExtra(label, data)
|
|
20
|
-
captureMessage(event)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let error2 = (loc: ReScriptLogger.Location.t, event, (label1, data1), (label2, data2)) => {
|
|
25
|
-
open Sentry
|
|
26
|
-
withScope(scope => {
|
|
27
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
28
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
29
|
-
scope->Scope.setExtra("function", loc.value)
|
|
30
|
-
scope->Scope.setExtra(label1, data1)
|
|
31
|
-
scope->Scope.setExtra(label2, data2)
|
|
32
|
-
captureMessage(event)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let error3 = (
|
|
37
|
-
loc: ReScriptLogger.Location.t,
|
|
38
|
-
event,
|
|
39
|
-
(label1, data1),
|
|
40
|
-
(label2, data2),
|
|
41
|
-
(label3, data3),
|
|
42
|
-
) => {
|
|
43
|
-
open Sentry
|
|
44
|
-
withScope(scope => {
|
|
45
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
46
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
47
|
-
scope->Scope.setExtra("function", loc.value)
|
|
48
|
-
scope->Scope.setExtra(label1, data1)
|
|
49
|
-
scope->Scope.setExtra(label2, data2)
|
|
50
|
-
scope->Scope.setExtra(label3, data3)
|
|
51
|
-
captureMessage(event)
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
let error4 = (
|
|
55
|
-
loc: ReScriptLogger.Location.t,
|
|
56
|
-
event,
|
|
57
|
-
(label1, data1),
|
|
58
|
-
(label2, data2),
|
|
59
|
-
(label3, data3),
|
|
60
|
-
(label4, data4),
|
|
61
|
-
) => {
|
|
62
|
-
open Sentry
|
|
63
|
-
withScope(scope => {
|
|
64
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
65
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
66
|
-
scope->Scope.setExtra("function", loc.value)
|
|
67
|
-
scope->Scope.setExtra(label1, data1)
|
|
68
|
-
scope->Scope.setExtra(label2, data2)
|
|
69
|
-
scope->Scope.setExtra(label3, data3)
|
|
70
|
-
scope->Scope.setExtra(label4, data4)
|
|
71
|
-
captureMessage(event)
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
let error5 = (
|
|
75
|
-
loc: ReScriptLogger.Location.t,
|
|
76
|
-
event,
|
|
77
|
-
(label1, data1),
|
|
78
|
-
(label2, data2),
|
|
79
|
-
(label3, data3),
|
|
80
|
-
(label4, data4),
|
|
81
|
-
(label5, data5),
|
|
82
|
-
) => {
|
|
83
|
-
open Sentry
|
|
84
|
-
withScope(scope => {
|
|
85
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
86
|
-
scope->Scope.setExtra("fullPath", loc.fullPath)
|
|
87
|
-
scope->Scope.setExtra("function", loc.value)
|
|
88
|
-
scope->Scope.setExtra(label1, data1)
|
|
89
|
-
scope->Scope.setExtra(label2, data2)
|
|
90
|
-
scope->Scope.setExtra(label3, data3)
|
|
91
|
-
scope->Scope.setExtra(label4, data4)
|
|
92
|
-
scope->Scope.setExtra(label5, data5)
|
|
93
|
-
captureMessage(event)
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let errorWithData = (loc: ReScriptLogger.Location.t, event, (label, data)) => {
|
|
98
|
-
open Sentry
|
|
99
|
-
withScope(scope => {
|
|
100
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
101
|
-
scope->Scope.setExtra(label, data)
|
|
102
|
-
captureMessage(event)
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let errorWithData2 = (loc: ReScriptLogger.Location.t, event, (label1, data1), (label2, data2)) => {
|
|
107
|
-
open Sentry
|
|
108
|
-
withScope(scope => {
|
|
109
|
-
scope->Scope.setExtra("module", loc.subModulePath->List.toArray)
|
|
110
|
-
scope->Scope.setExtra(label1, data1)
|
|
111
|
-
scope->Scope.setExtra(label2, data2)
|
|
112
|
-
captureMessage(event)
|
|
113
|
-
})
|
|
114
|
-
}
|
package/src/sentry/index.md
DELETED