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.
@@ -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 LogBuiltInCategory from '../types/LogBuiltInCategory';
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
- category: (
511
- typeof opts.category === 'string'
512
- ? opts.category
511
+ context: (
512
+ typeof opts.context === 'string'
513
+ ? opts.context
513
514
  : (
514
- ((opts.category as any) ?? {})._
515
- ?? LogBuiltInCategory.Uncategorized
515
+ ((opts.context as any) ?? {})._
516
+ ?? LogBuiltInMetadata.Context.Uncategorized
516
517
  )
517
518
  ),
518
- subcategory: (
519
- typeof opts.category === 'string'
520
- ? opts.subcategory
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: (opts as any).target ?? 'Unknown',
542
- action: (opts as any).action ?? 'Unknown'
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
- category: LogBuiltInCategory.Uncategorized,
615
- subcategory: LogBuiltInCategory.Uncategorized,
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
- category: LogBuiltInCategory.ServerRenderedErrorPage,
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
- category: LogBuiltInCategory.ServerEndpointError,
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 LogBuiltInCategory from '../types/LogBuiltInCategory';
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
- category: (
19
- typeof opts.category === 'string'
20
- ? opts.category
18
+ context: (
19
+ typeof opts.context === 'string'
20
+ ? opts.context
21
21
  : (
22
- ((opts.category as any) ?? {})._
23
- ?? LogBuiltInCategory.Uncategorized
22
+ ((opts.context as any) ?? {})._
23
+ ?? LogBuiltInMetadata.Context.Uncategorized
24
24
  )
25
25
  ),
26
- subcategory: (
27
- typeof opts.category === 'string'
28
- ? opts.subcategory
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).target
53
- ? (opts as any).target
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 LogBuiltInCategory from './types/LogBuiltInCategory';
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
- LogBuiltInCategory,
139
+ LogBuiltInMetadata,
140
140
  // Component-specific-types
141
141
  PickableItem,
142
142
  // Server types
@@ -11,8 +11,8 @@ const initLogCollection = (Collection: any) => {
11
11
  uniqueIndexKey: 'id',
12
12
  indexKeys: [
13
13
  'courseId',
14
- 'category',
15
- 'subcategory',
14
+ 'context',
15
+ 'subcontext',
16
16
  'tags',
17
17
  ],
18
18
  },
@@ -79,10 +79,10 @@ const initServer = (
79
79
  /**
80
80
  * Log an event
81
81
  * @author Gabe Abrams
82
- * @param {string} category Category of the event (each app determines how to
83
- * categorize its events)
84
- * @param {string} subcategory Subcategory of the event (each app determines
85
- * how to categorize its events)
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
- category: ParamType.String,
102
- subcategory: ParamType.String,
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
- category: params.category,
117
- subcategory: params.subcategory,
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
- category: params.category,
129
- subcategory: params.subcategory,
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
- // Category of the event (each app determines how to categorize its events)
53
- category: string,
54
- // Subcategory of the event (each app determines how to categorize its events)
55
- subcategory: string,
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;
@@ -10,10 +10,10 @@ type LogFunction = (
10
10
  opts: (
11
11
  // Shared info
12
12
  {
13
- // Category of the event (each app determines how to categorize its events)
14
- category: string | { _: string },
15
- // Subcategory of the event (each app determines how to categorize its events)
16
- subcategory?: string | { _: string },
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: string,
34
- // The type of action performed on the target
35
- action: LogAction,
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;