@colisweb/rescript-toolkit 2.28.0 → 2.29.2

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.28.0",
3
+ "version": "2.29.2",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -1,37 +1,49 @@
1
1
  open BsSentryReactNative
2
2
 
3
- @val @scope("process.env") external nodeEnv: string = "NODE_ENV"
3
+ @val external isDev: bool = "__DEV__"
4
4
 
5
5
  let debugStyle = "background-color: #208E9C; color: white; padding: 5px; font-size: 10px;"
6
6
  let warningStyle = "background-color: #FFAD2D; color: white; padding: 5px; font-size: 10px;"
7
7
  let errorStyle = "background-color: #FF4714; color: white; padding: 5px; font-size: 10px;"
8
8
 
9
9
  let debug = str => {
10
- if nodeEnv !== "production" {
10
+ if isDev {
11
11
  Js.Console.log3("%cDEBUG", debugStyle, str)
12
12
  }
13
13
  }
14
14
 
15
15
  let debug2 = (str, str2) => {
16
- if nodeEnv !== "production" {
16
+ if isDev {
17
17
  Js.Console.log4("%cDEBUG", debugStyle, str, str2)
18
18
  }
19
19
  }
20
20
 
21
+ let debugMany = (arr: array<string>) => {
22
+ if isDev {
23
+ Js.Console.logMany(["%cDEBUG", debugStyle]->Array.concat(arr))
24
+ }
25
+ }
26
+
21
27
  let warning = str => {
22
- if nodeEnv !== "production" {
28
+ if isDev {
23
29
  Js.Console.log3("%cWARN", warningStyle, str)
24
30
  }
25
31
  }
26
32
 
27
33
  let warning2 = (str, str2) => {
28
- if nodeEnv !== "production" {
34
+ if isDev {
29
35
  Js.Console.log4("%cWARN", warningStyle, str, str2)
30
36
  }
31
37
  }
32
38
 
39
+ let warningMany = (arr: array<string>) => {
40
+ if isDev {
41
+ Js.Console.logMany(["%cWARN", warningStyle]->Array.concat(arr))
42
+ }
43
+ }
44
+
33
45
  let error = str => {
34
- if nodeEnv !== "production" {
46
+ if isDev {
35
47
  Js.Console.log3("%cERROR", errorStyle, str)
36
48
  } else {
37
49
  open Sentry
@@ -42,7 +54,7 @@ let error = str => {
42
54
  }
43
55
 
44
56
  let error2 = (str, str2) => {
45
- if nodeEnv !== "production" {
57
+ if isDev {
46
58
  Js.Console.log4("%cERROR", errorStyle, str, str2)
47
59
  } else {
48
60
  open Sentry
@@ -52,3 +64,17 @@ let error2 = (str, str2) => {
52
64
  })
53
65
  }
54
66
  }
67
+
68
+ let errorMany = (arr: array<string>) => {
69
+ let message = arr[0]
70
+ let data = arr->Array.length > 1 ? arr->Array.sliceToEnd(1) : []
71
+ if isDev {
72
+ Js.Console.logMany(["%cERROR", errorStyle]->Array.concat(arr))
73
+ } else {
74
+ open Sentry
75
+ withScope(scope => {
76
+ scope->Scope.setExtra("data", data)
77
+ captureMessage(Obj.magic(message))
78
+ })
79
+ }
80
+ }
@@ -50,3 +50,9 @@ module DomElement = {
50
50
 
51
51
  @val
52
52
  external innerWidth: int = "window.innerWidth"
53
+
54
+ @val
55
+ external screenWidth: int = "window.screen.width"
56
+
57
+ @val
58
+ external screenHeight: int = "window.screen.height"
@@ -0,0 +1,16 @@
1
+ module Browser = {
2
+ @module("@datadog/browser-rum") @scope("datadogRum")
3
+ external datadogRumInit: 'a => unit = "init"
4
+
5
+ @module("@datadog/browser-rum") @scope("datadogRum")
6
+ external startSessionReplayRecording: 'a => unit = "startSessionReplayRecording"
7
+
8
+ @module("@datadog/browser-rum") @scope("datadogRum")
9
+ external addAction: (string, 'a) => unit = "addAction"
10
+
11
+ @module("@datadog/browser-rum") @scope("datadogRum")
12
+ external addRumGlobalContext: (string, 'a) => unit = "addRumGlobalContext"
13
+
14
+ @module("@datadog/browser-rum") @scope("datadogRum")
15
+ external setUser: 'a => unit = "setUser"
16
+ }