dce-reactkit 3.2.0-beta.8 → 3.2.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/.vscode/settings.json +1 -0
- package/dist/cjs/index.js +91 -90
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/types/Log/LogMainInfo.d.ts +2 -2
- package/dist/cjs/types/types/LogBuiltInMetadata.d.ts +15 -0
- package/dist/cjs/types/types/LogFunction.d.ts +3 -5
- package/dist/esm/index.js +91 -90
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/types/Log/LogMainInfo.d.ts +2 -2
- package/dist/esm/types/types/LogBuiltInMetadata.d.ts +15 -0
- package/dist/esm/types/types/LogFunction.d.ts +3 -5
- package/dist/index.d.ts +17 -14
- package/package.json +1 -1
- package/src/helpers/genRouteHandler.ts +22 -19
- package/src/helpers/logClientEvent.tsx +14 -15
- package/src/index.ts +2 -2
- package/src/server/initLogCollection.ts +2 -2
- package/src/server/initServer.ts +10 -10
- package/src/types/Log/LogMainInfo.ts +4 -4
- package/src/types/LogBuiltInMetadata.ts +18 -0
- package/src/types/LogFunction.ts +9 -7
- package/dist/cjs/types/types/LogBuiltInCategory.d.ts +0 -10
- package/dist/esm/types/types/LogBuiltInCategory.d.ts +0 -10
- package/src/types/LogBuiltInCategory.ts +0 -11
|
@@ -23,7 +23,8 @@ import LogSource from '../types/LogSource';
|
|
|
23
23
|
import LogTypeSpecificInfo from '../types/Log/LogTypeSpecificInfo';
|
|
24
24
|
import LogMainInfo from '../types/Log/LogMainInfo';
|
|
25
25
|
import LogSourceSpecificInfo from '../types/Log/LogSourceSpecificInfo';
|
|
26
|
-
import
|
|
26
|
+
import LogBuiltInMetadata from '../types/LogBuiltInMetadata';
|
|
27
|
+
import LogAction from '../types/LogAction';
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Generate an express API route handler
|
|
@@ -507,21 +508,17 @@ const genRouteHandler = (
|
|
|
507
508
|
hour,
|
|
508
509
|
minute,
|
|
509
510
|
timestamp,
|
|
510
|
-
|
|
511
|
-
typeof opts.
|
|
512
|
-
? opts.
|
|
511
|
+
context: (
|
|
512
|
+
typeof opts.context === 'string'
|
|
513
|
+
? opts.context
|
|
513
514
|
: (
|
|
514
|
-
((opts.
|
|
515
|
-
??
|
|
515
|
+
((opts.context as any) ?? {})._
|
|
516
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
516
517
|
)
|
|
517
518
|
),
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
: (
|
|
522
|
-
((opts.subcategory as any) ?? {})._
|
|
523
|
-
?? LogBuiltInCategory.Uncategorized
|
|
524
|
-
)
|
|
519
|
+
subcontext: (
|
|
520
|
+
opts.subcontext
|
|
521
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
525
522
|
),
|
|
526
523
|
tags: opts.tags ?? [],
|
|
527
524
|
metadata: opts.metadata ?? {},
|
|
@@ -538,8 +535,14 @@ const genRouteHandler = (
|
|
|
538
535
|
}
|
|
539
536
|
: {
|
|
540
537
|
type: LogType.Action,
|
|
541
|
-
target: (
|
|
542
|
-
|
|
538
|
+
target: (
|
|
539
|
+
(opts as any).target
|
|
540
|
+
?? LogBuiltInMetadata.Target.NoSpecificTarget
|
|
541
|
+
),
|
|
542
|
+
action: (
|
|
543
|
+
(opts as any).action
|
|
544
|
+
?? LogAction.Unknown
|
|
545
|
+
),
|
|
543
546
|
}
|
|
544
547
|
);
|
|
545
548
|
|
|
@@ -611,8 +614,8 @@ const genRouteHandler = (
|
|
|
611
614
|
timestamp: Date.now(),
|
|
612
615
|
tags: [],
|
|
613
616
|
metadata: {},
|
|
614
|
-
|
|
615
|
-
|
|
617
|
+
context: LogBuiltInMetadata.Context.Uncategorized,
|
|
618
|
+
subcontext: LogBuiltInMetadata.Context.Uncategorized,
|
|
616
619
|
};
|
|
617
620
|
|
|
618
621
|
const dummyTypeSpecificInfo: LogTypeSpecificInfo = {
|
|
@@ -692,7 +695,7 @@ const genRouteHandler = (
|
|
|
692
695
|
|
|
693
696
|
// Log
|
|
694
697
|
logServerEvent({
|
|
695
|
-
|
|
698
|
+
context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
|
|
696
699
|
error: {
|
|
697
700
|
message: `${opts.title}: ${opts.description}`,
|
|
698
701
|
code: opts.code,
|
|
@@ -733,7 +736,7 @@ const genRouteHandler = (
|
|
|
733
736
|
|
|
734
737
|
// Log server-side error
|
|
735
738
|
logServerEvent({
|
|
736
|
-
|
|
739
|
+
context: LogBuiltInMetadata.Context.ServerEndpointError,
|
|
737
740
|
error: err,
|
|
738
741
|
});
|
|
739
742
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Import shared types
|
|
2
2
|
import LOG_ROUTE_PATH from '../constants/LOG_ROUTE_PATH';
|
|
3
|
-
import
|
|
3
|
+
import LogBuiltInMetadata from '../types/LogBuiltInMetadata';
|
|
4
4
|
import LogFunction from '../types/LogFunction';
|
|
5
5
|
|
|
6
6
|
// Import shared functions
|
|
@@ -15,21 +15,17 @@ const logClientEvent: LogFunction = async (opts) => {
|
|
|
15
15
|
path: LOG_ROUTE_PATH,
|
|
16
16
|
method: 'POST',
|
|
17
17
|
params: {
|
|
18
|
-
|
|
19
|
-
typeof opts.
|
|
20
|
-
? opts.
|
|
18
|
+
context: (
|
|
19
|
+
typeof opts.context === 'string'
|
|
20
|
+
? opts.context
|
|
21
21
|
: (
|
|
22
|
-
((opts.
|
|
23
|
-
??
|
|
22
|
+
((opts.context as any) ?? {})._
|
|
23
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
24
24
|
)
|
|
25
25
|
),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: (
|
|
30
|
-
((opts.subcategory as any) ?? {})._
|
|
31
|
-
?? LogBuiltInCategory.Uncategorized
|
|
32
|
-
)
|
|
26
|
+
subcontext: (
|
|
27
|
+
opts.subcontext
|
|
28
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
33
29
|
),
|
|
34
30
|
tags: JSON.stringify(opts.tags ?? []),
|
|
35
31
|
metadata: JSON.stringify(opts.metadata ?? {}),
|
|
@@ -49,8 +45,11 @@ const logClientEvent: LogFunction = async (opts) => {
|
|
|
49
45
|
: undefined
|
|
50
46
|
),
|
|
51
47
|
target: (
|
|
52
|
-
(opts as any).
|
|
53
|
-
? (
|
|
48
|
+
(opts as any).action
|
|
49
|
+
? (
|
|
50
|
+
(opts as any).target
|
|
51
|
+
?? LogBuiltInMetadata.Target.NoSpecificTarget
|
|
52
|
+
)
|
|
54
53
|
: undefined
|
|
55
54
|
),
|
|
56
55
|
action: (
|
package/src/index.ts
CHANGED
|
@@ -63,7 +63,7 @@ import Log from './types/Log';
|
|
|
63
63
|
import LogType from './types/LogType';
|
|
64
64
|
import LogSource from './types/LogSource';
|
|
65
65
|
import LogAction from './types/LogAction';
|
|
66
|
-
import
|
|
66
|
+
import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
67
67
|
|
|
68
68
|
// Component-specific-types
|
|
69
69
|
import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
@@ -136,7 +136,7 @@ export {
|
|
|
136
136
|
LogType,
|
|
137
137
|
LogSource,
|
|
138
138
|
LogAction,
|
|
139
|
-
|
|
139
|
+
LogBuiltInMetadata,
|
|
140
140
|
// Component-specific-types
|
|
141
141
|
PickableItem,
|
|
142
142
|
// Server types
|
package/src/server/initServer.ts
CHANGED
|
@@ -79,10 +79,10 @@ const initServer = (
|
|
|
79
79
|
/**
|
|
80
80
|
* Log an event
|
|
81
81
|
* @author Gabe Abrams
|
|
82
|
-
* @param {string}
|
|
83
|
-
*
|
|
84
|
-
* @param {string}
|
|
85
|
-
* how to
|
|
82
|
+
* @param {string} context Context of the event (each app determines how to
|
|
83
|
+
* organize its contexts)
|
|
84
|
+
* @param {string} subcontext Subcontext of the event (each app determines
|
|
85
|
+
* how to organize its subcontexts)
|
|
86
86
|
* @param {string} tags stringified list of tags that apply to this action
|
|
87
87
|
* (each app determines tag usage)
|
|
88
88
|
* @param {string} metadata stringified object containing optional custom metadata
|
|
@@ -98,8 +98,8 @@ const initServer = (
|
|
|
98
98
|
LOG_ROUTE_PATH,
|
|
99
99
|
genRouteHandler({
|
|
100
100
|
paramTypes: {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
context: ParamType.String,
|
|
102
|
+
subcontext: ParamType.String,
|
|
103
103
|
tags: ParamType.JSON,
|
|
104
104
|
metadata: ParamType.JSON,
|
|
105
105
|
errorMessage: ParamType.StringOptional,
|
|
@@ -113,8 +113,8 @@ const initServer = (
|
|
|
113
113
|
(params.errorMessage || params.errorCode || params.errorStack)
|
|
114
114
|
// Error
|
|
115
115
|
? {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
context: params.context,
|
|
117
|
+
subcontext: params.subcontext,
|
|
118
118
|
tags: params.tags,
|
|
119
119
|
metadata: params.metadata,
|
|
120
120
|
error: {
|
|
@@ -125,8 +125,8 @@ const initServer = (
|
|
|
125
125
|
}
|
|
126
126
|
// Action
|
|
127
127
|
: {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
context: params.context,
|
|
129
|
+
subcontext: params.subcontext,
|
|
130
130
|
tags: params.tags,
|
|
131
131
|
metadata: params.metadata,
|
|
132
132
|
target: params.target,
|
|
@@ -49,10 +49,10 @@ type LogMainInfo = {
|
|
|
49
49
|
minute: number,
|
|
50
50
|
// Timestamp of event (ms since epoch)
|
|
51
51
|
timestamp: number,
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
|
|
52
|
+
// Context of the event (each app determines how to organize contexts)
|
|
53
|
+
context: string,
|
|
54
|
+
// Subcontext of the event (each app determines how to organize subcontexts)
|
|
55
|
+
subcontext: string,
|
|
56
56
|
// List of tags that apply to this action (each app determines tag usage)
|
|
57
57
|
tags: string[],
|
|
58
58
|
// Additional optional custom metadata
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in metadata for logs
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
const LogBuiltInMetadata = {
|
|
6
|
+
// Contexts
|
|
7
|
+
Context: {
|
|
8
|
+
Uncategorized: 'n/a',
|
|
9
|
+
ServerRenderedErrorPage: '_server-rendered-error-page',
|
|
10
|
+
ServerEndpointError: '_server-endpoint-error',
|
|
11
|
+
},
|
|
12
|
+
// Targets
|
|
13
|
+
Target: {
|
|
14
|
+
NoSpecificTarget: 'n/a',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default LogBuiltInMetadata;
|
package/src/types/LogFunction.ts
CHANGED
|
@@ -10,10 +10,10 @@ type LogFunction = (
|
|
|
10
10
|
opts: (
|
|
11
11
|
// Shared info
|
|
12
12
|
{
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
13
|
+
// Context of the event (each app determines how to organize contexts)
|
|
14
|
+
context: string | { _: string },
|
|
15
|
+
// Subcontext of the event (each app determines how to organize subcontexts)
|
|
16
|
+
subcontext?: string,
|
|
17
17
|
// List of tags that apply to this action (each app determines tag usage)
|
|
18
18
|
tags?: string[],
|
|
19
19
|
// Additional optional custom metadata
|
|
@@ -28,11 +28,13 @@ type LogFunction = (
|
|
|
28
28
|
}
|
|
29
29
|
// Action
|
|
30
30
|
| {
|
|
31
|
+
// The type of action performed
|
|
32
|
+
action: LogAction,
|
|
31
33
|
// Target of the action (each app determines the list of targets)
|
|
32
34
|
// These are usually buttons, panels, elements, etc.
|
|
33
|
-
target
|
|
34
|
-
//
|
|
35
|
-
|
|
35
|
+
// If no target is included, this should indicate that this is an action
|
|
36
|
+
// being performed on the whole feature (open/close/etc)
|
|
37
|
+
target?: string,
|
|
36
38
|
}
|
|
37
39
|
)
|
|
38
40
|
),
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in categories for logs
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
declare enum LogBuiltInCategory {
|
|
6
|
-
Uncategorized = "n/a",
|
|
7
|
-
ServerRenderedErrorPage = "_server-rendered-error-page",
|
|
8
|
-
ServerEndpointError = "_server-endpoint-error"
|
|
9
|
-
}
|
|
10
|
-
export default LogBuiltInCategory;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in categories for logs
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
declare enum LogBuiltInCategory {
|
|
6
|
-
Uncategorized = "n/a",
|
|
7
|
-
ServerRenderedErrorPage = "_server-rendered-error-page",
|
|
8
|
-
ServerEndpointError = "_server-endpoint-error"
|
|
9
|
-
}
|
|
10
|
-
export default LogBuiltInCategory;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in categories for logs
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
enum LogBuiltInCategory {
|
|
6
|
-
Uncategorized = 'n/a',
|
|
7
|
-
ServerRenderedErrorPage = '_server-rendered-error-page',
|
|
8
|
-
ServerEndpointError = '_server-endpoint-error',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default LogBuiltInCategory;
|