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
package/.vscode/settings.json
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -2203,10 +2203,10 @@ const initServer = (opts) => {
|
|
|
2203
2203
|
/**
|
|
2204
2204
|
* Log an event
|
|
2205
2205
|
* @author Gabe Abrams
|
|
2206
|
-
* @param {string}
|
|
2207
|
-
*
|
|
2208
|
-
* @param {string}
|
|
2209
|
-
* how to
|
|
2206
|
+
* @param {string} context Context of the event (each app determines how to
|
|
2207
|
+
* organize its contexts)
|
|
2208
|
+
* @param {string} subcontext Subcontext of the event (each app determines
|
|
2209
|
+
* how to organize its subcontexts)
|
|
2210
2210
|
* @param {string} tags stringified list of tags that apply to this action
|
|
2211
2211
|
* (each app determines tag usage)
|
|
2212
2212
|
* @param {string} metadata stringified object containing optional custom metadata
|
|
@@ -2220,8 +2220,8 @@ const initServer = (opts) => {
|
|
|
2220
2220
|
*/
|
|
2221
2221
|
opts.app.post(LOG_ROUTE_PATH, genRouteHandler({
|
|
2222
2222
|
paramTypes: {
|
|
2223
|
-
|
|
2224
|
-
|
|
2223
|
+
context: ParamType$1.String,
|
|
2224
|
+
subcontext: ParamType$1.String,
|
|
2225
2225
|
tags: ParamType$1.JSON,
|
|
2226
2226
|
metadata: ParamType$1.JSON,
|
|
2227
2227
|
errorMessage: ParamType$1.StringOptional,
|
|
@@ -2234,8 +2234,8 @@ const initServer = (opts) => {
|
|
|
2234
2234
|
const log = logServerEvent((params.errorMessage || params.errorCode || params.errorStack)
|
|
2235
2235
|
// Error
|
|
2236
2236
|
? {
|
|
2237
|
-
|
|
2238
|
-
|
|
2237
|
+
context: params.context,
|
|
2238
|
+
subcontext: params.subcontext,
|
|
2239
2239
|
tags: params.tags,
|
|
2240
2240
|
metadata: params.metadata,
|
|
2241
2241
|
error: {
|
|
@@ -2246,8 +2246,8 @@ const initServer = (opts) => {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
// Action
|
|
2248
2248
|
: {
|
|
2249
|
-
|
|
2250
|
-
|
|
2249
|
+
context: params.context,
|
|
2250
|
+
subcontext: params.subcontext,
|
|
2251
2251
|
tags: params.tags,
|
|
2252
2252
|
metadata: params.metadata,
|
|
2253
2253
|
target: params.target,
|
|
@@ -2582,16 +2582,62 @@ var LogSource;
|
|
|
2582
2582
|
var LogSource$1 = LogSource;
|
|
2583
2583
|
|
|
2584
2584
|
/**
|
|
2585
|
-
* Built-in
|
|
2585
|
+
* Built-in metadata for logs
|
|
2586
2586
|
* @author Gabe Abrams
|
|
2587
2587
|
*/
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2588
|
+
const LogBuiltInMetadata = {
|
|
2589
|
+
// Contexts
|
|
2590
|
+
Context: {
|
|
2591
|
+
Uncategorized: 'n/a',
|
|
2592
|
+
ServerRenderedErrorPage: '_server-rendered-error-page',
|
|
2593
|
+
ServerEndpointError: '_server-endpoint-error',
|
|
2594
|
+
},
|
|
2595
|
+
// Targets
|
|
2596
|
+
Target: {
|
|
2597
|
+
NoSpecificTarget: 'n/a',
|
|
2598
|
+
},
|
|
2599
|
+
};
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* Types of actions
|
|
2603
|
+
* @author Gabe Abrams
|
|
2604
|
+
*/
|
|
2605
|
+
var LogAction;
|
|
2606
|
+
(function (LogAction) {
|
|
2607
|
+
// Target was opened by the user (it was not on screen, but now it is)
|
|
2608
|
+
LogAction["Open"] = "open";
|
|
2609
|
+
// Target was closed by the user (it was on screen, but now it is not)
|
|
2610
|
+
LogAction["Close"] = "close";
|
|
2611
|
+
// Target was cancelled by the user (it was on closed without saving)
|
|
2612
|
+
LogAction["Cancel"] = "cancel";
|
|
2613
|
+
// Target was expanded by the user (it always remains on screen, but size was changed)
|
|
2614
|
+
LogAction["Expand"] = "expand";
|
|
2615
|
+
// Target was collapsed by the user (it always remains on screen, but size was changed)
|
|
2616
|
+
LogAction["Collapse"] = "collapse";
|
|
2617
|
+
// Target was viewed by the user (only for items that are not opened or closed, those must use Open/Close actions)
|
|
2618
|
+
LogAction["View"] = "view";
|
|
2619
|
+
// Target interrupted the user (popup, dialog, validation message, etc. appeared without user prompting)
|
|
2620
|
+
LogAction["Interrupt"] = "interrupt";
|
|
2621
|
+
// Target was created by the user (it did not exist before)
|
|
2622
|
+
LogAction["Create"] = "create";
|
|
2623
|
+
// Target was edited by the user (it existed and was changed)
|
|
2624
|
+
LogAction["Edit"] = "edit";
|
|
2625
|
+
// Target was deleted by the user (it existed and now it doesn't)
|
|
2626
|
+
LogAction["Delete"] = "delete";
|
|
2627
|
+
// Target was added by the user (it already existed and was added to another place)
|
|
2628
|
+
LogAction["Add"] = "add";
|
|
2629
|
+
// Target was removed by the user (it was removed from something but still exists)
|
|
2630
|
+
LogAction["Remove"] = "remove";
|
|
2631
|
+
// Target was activated by the user (click, check, tap, keypress, etc.)
|
|
2632
|
+
LogAction["Activate"] = "activate";
|
|
2633
|
+
// Target was deactivated by the user (click away, uncheck, tap outside of, tab away, etc.)
|
|
2634
|
+
LogAction["Deactivate"] = "deactivate";
|
|
2635
|
+
// User showed interest in a target (hover, peek, etc.)
|
|
2636
|
+
LogAction["Peek"] = "peek";
|
|
2637
|
+
// Unknown action
|
|
2638
|
+
LogAction["Unknown"] = "unknown";
|
|
2639
|
+
})(LogAction || (LogAction = {}));
|
|
2640
|
+
var LogAction$1 = LogAction;
|
|
2595
2641
|
|
|
2596
2642
|
/**
|
|
2597
2643
|
* Generate an express API route handler
|
|
@@ -2917,7 +2963,7 @@ const genRouteHandler = (opts) => {
|
|
|
2917
2963
|
* @author Gabe Abrams
|
|
2918
2964
|
*/
|
|
2919
2965
|
const logServerEvent = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2920
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
2966
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2921
2967
|
// NOTE: internally, we slip through an opts.overrideAsClientEvent boolean
|
|
2922
2968
|
// that indicates that this is actually a client event, but we don't
|
|
2923
2969
|
// include that in the LogFunction type because this is internal and
|
|
@@ -2947,27 +2993,25 @@ const genRouteHandler = (opts) => {
|
|
|
2947
2993
|
hour,
|
|
2948
2994
|
minute,
|
|
2949
2995
|
timestamp,
|
|
2950
|
-
|
|
2951
|
-
? opts.
|
|
2952
|
-
: ((_d = ((_c = opts.
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
tags: (_g = opts.tags) !== null && _g !== void 0 ? _g : [],
|
|
2957
|
-
metadata: (_h = opts.metadata) !== null && _h !== void 0 ? _h : {},
|
|
2996
|
+
context: (typeof opts.context === 'string'
|
|
2997
|
+
? opts.context
|
|
2998
|
+
: ((_d = ((_c = opts.context) !== null && _c !== void 0 ? _c : {})._) !== null && _d !== void 0 ? _d : LogBuiltInMetadata.Context.Uncategorized)),
|
|
2999
|
+
subcontext: ((_e = opts.subcontext) !== null && _e !== void 0 ? _e : LogBuiltInMetadata.Context.Uncategorized),
|
|
3000
|
+
tags: (_f = opts.tags) !== null && _f !== void 0 ? _f : [],
|
|
3001
|
+
metadata: (_g = opts.metadata) !== null && _g !== void 0 ? _g : {},
|
|
2958
3002
|
};
|
|
2959
3003
|
// Type-specific info
|
|
2960
3004
|
const typeSpecificInfo = (('error' in opts && opts.error)
|
|
2961
3005
|
? {
|
|
2962
3006
|
type: LogType$1.Error,
|
|
2963
|
-
errorMessage: (
|
|
2964
|
-
errorCode: (
|
|
2965
|
-
errorStack: (
|
|
3007
|
+
errorMessage: (_h = opts.error.message) !== null && _h !== void 0 ? _h : 'Unknown message',
|
|
3008
|
+
errorCode: (_j = opts.error.code) !== null && _j !== void 0 ? _j : ReactKitErrorCode$1.NoCode,
|
|
3009
|
+
errorStack: (_k = opts.error.stack) !== null && _k !== void 0 ? _k : 'No stack',
|
|
2966
3010
|
}
|
|
2967
3011
|
: {
|
|
2968
3012
|
type: LogType$1.Action,
|
|
2969
|
-
target: (
|
|
2970
|
-
action: (
|
|
3013
|
+
target: ((_l = opts.target) !== null && _l !== void 0 ? _l : LogBuiltInMetadata.Target.NoSpecificTarget),
|
|
3014
|
+
action: ((_m = opts.action) !== null && _m !== void 0 ? _m : LogAction$1.Unknown),
|
|
2971
3015
|
});
|
|
2972
3016
|
// Source-specific info
|
|
2973
3017
|
const sourceSpecificInfo = (opts.overrideAsClientEvent
|
|
@@ -3030,8 +3074,8 @@ const genRouteHandler = (opts) => {
|
|
|
3030
3074
|
timestamp: Date.now(),
|
|
3031
3075
|
tags: [],
|
|
3032
3076
|
metadata: {},
|
|
3033
|
-
|
|
3034
|
-
|
|
3077
|
+
context: LogBuiltInMetadata.Context.Uncategorized,
|
|
3078
|
+
subcontext: LogBuiltInMetadata.Context.Uncategorized,
|
|
3035
3079
|
};
|
|
3036
3080
|
const dummyTypeSpecificInfo = {
|
|
3037
3081
|
type: LogType$1.Error,
|
|
@@ -3090,7 +3134,7 @@ const genRouteHandler = (opts) => {
|
|
|
3090
3134
|
send(html, (_a = opts.status) !== null && _a !== void 0 ? _a : 500);
|
|
3091
3135
|
// Log
|
|
3092
3136
|
logServerEvent({
|
|
3093
|
-
|
|
3137
|
+
context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
|
|
3094
3138
|
error: {
|
|
3095
3139
|
message: `${opts.title}: ${opts.description}`,
|
|
3096
3140
|
code: opts.code,
|
|
@@ -3129,7 +3173,7 @@ const genRouteHandler = (opts) => {
|
|
|
3129
3173
|
handleError(res, err);
|
|
3130
3174
|
// Log server-side error
|
|
3131
3175
|
logServerEvent({
|
|
3132
|
-
|
|
3176
|
+
context: LogBuiltInMetadata.Context.ServerEndpointError,
|
|
3133
3177
|
error: err,
|
|
3134
3178
|
});
|
|
3135
3179
|
return;
|
|
@@ -3336,14 +3380,12 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3336
3380
|
path: LOG_ROUTE_PATH,
|
|
3337
3381
|
method: 'POST',
|
|
3338
3382
|
params: {
|
|
3339
|
-
|
|
3340
|
-
? opts.
|
|
3341
|
-
: ((_b = ((_a = opts.
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
tags: JSON.stringify((_e = opts.tags) !== null && _e !== void 0 ? _e : []),
|
|
3346
|
-
metadata: JSON.stringify((_f = opts.metadata) !== null && _f !== void 0 ? _f : {}),
|
|
3383
|
+
context: (typeof opts.context === 'string'
|
|
3384
|
+
? opts.context
|
|
3385
|
+
: ((_b = ((_a = opts.context) !== null && _a !== void 0 ? _a : {})._) !== null && _b !== void 0 ? _b : LogBuiltInMetadata.Context.Uncategorized)),
|
|
3386
|
+
subcontext: ((_c = opts.subcontext) !== null && _c !== void 0 ? _c : LogBuiltInMetadata.Context.Uncategorized),
|
|
3387
|
+
tags: JSON.stringify((_d = opts.tags) !== null && _d !== void 0 ? _d : []),
|
|
3388
|
+
metadata: JSON.stringify((_e = opts.metadata) !== null && _e !== void 0 ? _e : {}),
|
|
3347
3389
|
errorMessage: (opts.error
|
|
3348
3390
|
? opts.error.message
|
|
3349
3391
|
: undefined),
|
|
@@ -3353,8 +3395,8 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3353
3395
|
errorStack: (opts.error
|
|
3354
3396
|
? opts.error.stack
|
|
3355
3397
|
: undefined),
|
|
3356
|
-
target: (opts.
|
|
3357
|
-
? opts.target
|
|
3398
|
+
target: (opts.action
|
|
3399
|
+
? ((_f = opts.target) !== null && _f !== void 0 ? _f : LogBuiltInMetadata.Target.NoSpecificTarget)
|
|
3358
3400
|
: undefined),
|
|
3359
3401
|
action: (opts.action
|
|
3360
3402
|
? opts.action
|
|
@@ -3374,8 +3416,8 @@ const initLogCollection = (Collection) => {
|
|
|
3374
3416
|
uniqueIndexKey: 'id',
|
|
3375
3417
|
indexKeys: [
|
|
3376
3418
|
'courseId',
|
|
3377
|
-
'
|
|
3378
|
-
'
|
|
3419
|
+
'context',
|
|
3420
|
+
'subcontext',
|
|
3379
3421
|
'tags',
|
|
3380
3422
|
],
|
|
3381
3423
|
});
|
|
@@ -3397,47 +3439,6 @@ var DayOfWeek;
|
|
|
3397
3439
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
3398
3440
|
var DayOfWeek$1 = DayOfWeek;
|
|
3399
3441
|
|
|
3400
|
-
/**
|
|
3401
|
-
* Types of actions
|
|
3402
|
-
* @author Gabe Abrams
|
|
3403
|
-
*/
|
|
3404
|
-
var LogAction;
|
|
3405
|
-
(function (LogAction) {
|
|
3406
|
-
// Target was opened by the user (it was not on screen, but now it is)
|
|
3407
|
-
LogAction["Open"] = "open";
|
|
3408
|
-
// Target was closed by the user (it was on screen, but now it is not)
|
|
3409
|
-
LogAction["Close"] = "close";
|
|
3410
|
-
// Target was cancelled by the user (it was on closed without saving)
|
|
3411
|
-
LogAction["Cancel"] = "cancel";
|
|
3412
|
-
// Target was expanded by the user (it always remains on screen, but size was changed)
|
|
3413
|
-
LogAction["Expand"] = "expand";
|
|
3414
|
-
// Target was collapsed by the user (it always remains on screen, but size was changed)
|
|
3415
|
-
LogAction["Collapse"] = "collapse";
|
|
3416
|
-
// Target was viewed by the user (only for items that are not opened or closed, those must use Open/Close actions)
|
|
3417
|
-
LogAction["View"] = "view";
|
|
3418
|
-
// Target interrupted the user (popup, dialog, validation message, etc. appeared without user prompting)
|
|
3419
|
-
LogAction["Interrupt"] = "interrupt";
|
|
3420
|
-
// Target was created by the user (it did not exist before)
|
|
3421
|
-
LogAction["Create"] = "create";
|
|
3422
|
-
// Target was edited by the user (it existed and was changed)
|
|
3423
|
-
LogAction["Edit"] = "edit";
|
|
3424
|
-
// Target was deleted by the user (it existed and now it doesn't)
|
|
3425
|
-
LogAction["Delete"] = "delete";
|
|
3426
|
-
// Target was added by the user (it already existed and was added to another place)
|
|
3427
|
-
LogAction["Add"] = "add";
|
|
3428
|
-
// Target was removed by the user (it was removed from something but still exists)
|
|
3429
|
-
LogAction["Remove"] = "remove";
|
|
3430
|
-
// Target was activated by the user (click, check, tap, keypress, etc.)
|
|
3431
|
-
LogAction["Activate"] = "activate";
|
|
3432
|
-
// Target was deactivated by the user (click away, uncheck, tap outside of, tab away, etc.)
|
|
3433
|
-
LogAction["Deactivate"] = "deactivate";
|
|
3434
|
-
// User showed interest in a target (hover, peek, etc.)
|
|
3435
|
-
LogAction["Peek"] = "peek";
|
|
3436
|
-
// Unknown action
|
|
3437
|
-
LogAction["Unknown"] = "unknown";
|
|
3438
|
-
})(LogAction || (LogAction = {}));
|
|
3439
|
-
var LogAction$1 = LogAction;
|
|
3440
|
-
|
|
3441
3442
|
exports.AppWrapper = AppWrapper;
|
|
3442
3443
|
exports.ButtonInputGroup = ButtonInputGroup;
|
|
3443
3444
|
exports.CheckboxButton = CheckboxButton;
|
|
@@ -3451,7 +3452,7 @@ exports.HOUR_IN_MS = HOUR_IN_MS;
|
|
|
3451
3452
|
exports.ItemPicker = ItemPicker;
|
|
3452
3453
|
exports.LoadingSpinner = LoadingSpinner;
|
|
3453
3454
|
exports.LogAction = LogAction$1;
|
|
3454
|
-
exports.
|
|
3455
|
+
exports.LogBuiltInMetadata = LogBuiltInMetadata;
|
|
3455
3456
|
exports.LogSource = LogSource$1;
|
|
3456
3457
|
exports.LogType = LogType$1;
|
|
3457
3458
|
exports.MINUTE_IN_MS = MINUTE_IN_MS;
|