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/dist/esm/index.js
CHANGED
|
@@ -2195,10 +2195,10 @@ const initServer = (opts) => {
|
|
|
2195
2195
|
/**
|
|
2196
2196
|
* Log an event
|
|
2197
2197
|
* @author Gabe Abrams
|
|
2198
|
-
* @param {string}
|
|
2199
|
-
*
|
|
2200
|
-
* @param {string}
|
|
2201
|
-
* how to
|
|
2198
|
+
* @param {string} context Context of the event (each app determines how to
|
|
2199
|
+
* organize its contexts)
|
|
2200
|
+
* @param {string} subcontext Subcontext of the event (each app determines
|
|
2201
|
+
* how to organize its subcontexts)
|
|
2202
2202
|
* @param {string} tags stringified list of tags that apply to this action
|
|
2203
2203
|
* (each app determines tag usage)
|
|
2204
2204
|
* @param {string} metadata stringified object containing optional custom metadata
|
|
@@ -2212,8 +2212,8 @@ const initServer = (opts) => {
|
|
|
2212
2212
|
*/
|
|
2213
2213
|
opts.app.post(LOG_ROUTE_PATH, genRouteHandler({
|
|
2214
2214
|
paramTypes: {
|
|
2215
|
-
|
|
2216
|
-
|
|
2215
|
+
context: ParamType$1.String,
|
|
2216
|
+
subcontext: ParamType$1.String,
|
|
2217
2217
|
tags: ParamType$1.JSON,
|
|
2218
2218
|
metadata: ParamType$1.JSON,
|
|
2219
2219
|
errorMessage: ParamType$1.StringOptional,
|
|
@@ -2226,8 +2226,8 @@ const initServer = (opts) => {
|
|
|
2226
2226
|
const log = logServerEvent((params.errorMessage || params.errorCode || params.errorStack)
|
|
2227
2227
|
// Error
|
|
2228
2228
|
? {
|
|
2229
|
-
|
|
2230
|
-
|
|
2229
|
+
context: params.context,
|
|
2230
|
+
subcontext: params.subcontext,
|
|
2231
2231
|
tags: params.tags,
|
|
2232
2232
|
metadata: params.metadata,
|
|
2233
2233
|
error: {
|
|
@@ -2238,8 +2238,8 @@ const initServer = (opts) => {
|
|
|
2238
2238
|
}
|
|
2239
2239
|
// Action
|
|
2240
2240
|
: {
|
|
2241
|
-
|
|
2242
|
-
|
|
2241
|
+
context: params.context,
|
|
2242
|
+
subcontext: params.subcontext,
|
|
2243
2243
|
tags: params.tags,
|
|
2244
2244
|
metadata: params.metadata,
|
|
2245
2245
|
target: params.target,
|
|
@@ -2574,16 +2574,62 @@ var LogSource;
|
|
|
2574
2574
|
var LogSource$1 = LogSource;
|
|
2575
2575
|
|
|
2576
2576
|
/**
|
|
2577
|
-
* Built-in
|
|
2577
|
+
* Built-in metadata for logs
|
|
2578
2578
|
* @author Gabe Abrams
|
|
2579
2579
|
*/
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2580
|
+
const LogBuiltInMetadata = {
|
|
2581
|
+
// Contexts
|
|
2582
|
+
Context: {
|
|
2583
|
+
Uncategorized: 'n/a',
|
|
2584
|
+
ServerRenderedErrorPage: '_server-rendered-error-page',
|
|
2585
|
+
ServerEndpointError: '_server-endpoint-error',
|
|
2586
|
+
},
|
|
2587
|
+
// Targets
|
|
2588
|
+
Target: {
|
|
2589
|
+
NoSpecificTarget: 'n/a',
|
|
2590
|
+
},
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* Types of actions
|
|
2595
|
+
* @author Gabe Abrams
|
|
2596
|
+
*/
|
|
2597
|
+
var LogAction;
|
|
2598
|
+
(function (LogAction) {
|
|
2599
|
+
// Target was opened by the user (it was not on screen, but now it is)
|
|
2600
|
+
LogAction["Open"] = "open";
|
|
2601
|
+
// Target was closed by the user (it was on screen, but now it is not)
|
|
2602
|
+
LogAction["Close"] = "close";
|
|
2603
|
+
// Target was cancelled by the user (it was on closed without saving)
|
|
2604
|
+
LogAction["Cancel"] = "cancel";
|
|
2605
|
+
// Target was expanded by the user (it always remains on screen, but size was changed)
|
|
2606
|
+
LogAction["Expand"] = "expand";
|
|
2607
|
+
// Target was collapsed by the user (it always remains on screen, but size was changed)
|
|
2608
|
+
LogAction["Collapse"] = "collapse";
|
|
2609
|
+
// Target was viewed by the user (only for items that are not opened or closed, those must use Open/Close actions)
|
|
2610
|
+
LogAction["View"] = "view";
|
|
2611
|
+
// Target interrupted the user (popup, dialog, validation message, etc. appeared without user prompting)
|
|
2612
|
+
LogAction["Interrupt"] = "interrupt";
|
|
2613
|
+
// Target was created by the user (it did not exist before)
|
|
2614
|
+
LogAction["Create"] = "create";
|
|
2615
|
+
// Target was edited by the user (it existed and was changed)
|
|
2616
|
+
LogAction["Edit"] = "edit";
|
|
2617
|
+
// Target was deleted by the user (it existed and now it doesn't)
|
|
2618
|
+
LogAction["Delete"] = "delete";
|
|
2619
|
+
// Target was added by the user (it already existed and was added to another place)
|
|
2620
|
+
LogAction["Add"] = "add";
|
|
2621
|
+
// Target was removed by the user (it was removed from something but still exists)
|
|
2622
|
+
LogAction["Remove"] = "remove";
|
|
2623
|
+
// Target was activated by the user (click, check, tap, keypress, etc.)
|
|
2624
|
+
LogAction["Activate"] = "activate";
|
|
2625
|
+
// Target was deactivated by the user (click away, uncheck, tap outside of, tab away, etc.)
|
|
2626
|
+
LogAction["Deactivate"] = "deactivate";
|
|
2627
|
+
// User showed interest in a target (hover, peek, etc.)
|
|
2628
|
+
LogAction["Peek"] = "peek";
|
|
2629
|
+
// Unknown action
|
|
2630
|
+
LogAction["Unknown"] = "unknown";
|
|
2631
|
+
})(LogAction || (LogAction = {}));
|
|
2632
|
+
var LogAction$1 = LogAction;
|
|
2587
2633
|
|
|
2588
2634
|
/**
|
|
2589
2635
|
* Generate an express API route handler
|
|
@@ -2909,7 +2955,7 @@ const genRouteHandler = (opts) => {
|
|
|
2909
2955
|
* @author Gabe Abrams
|
|
2910
2956
|
*/
|
|
2911
2957
|
const logServerEvent = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2912
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
2958
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2913
2959
|
// NOTE: internally, we slip through an opts.overrideAsClientEvent boolean
|
|
2914
2960
|
// that indicates that this is actually a client event, but we don't
|
|
2915
2961
|
// include that in the LogFunction type because this is internal and
|
|
@@ -2939,27 +2985,25 @@ const genRouteHandler = (opts) => {
|
|
|
2939
2985
|
hour,
|
|
2940
2986
|
minute,
|
|
2941
2987
|
timestamp,
|
|
2942
|
-
|
|
2943
|
-
? opts.
|
|
2944
|
-
: ((_d = ((_c = opts.
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
tags: (_g = opts.tags) !== null && _g !== void 0 ? _g : [],
|
|
2949
|
-
metadata: (_h = opts.metadata) !== null && _h !== void 0 ? _h : {},
|
|
2988
|
+
context: (typeof opts.context === 'string'
|
|
2989
|
+
? opts.context
|
|
2990
|
+
: ((_d = ((_c = opts.context) !== null && _c !== void 0 ? _c : {})._) !== null && _d !== void 0 ? _d : LogBuiltInMetadata.Context.Uncategorized)),
|
|
2991
|
+
subcontext: ((_e = opts.subcontext) !== null && _e !== void 0 ? _e : LogBuiltInMetadata.Context.Uncategorized),
|
|
2992
|
+
tags: (_f = opts.tags) !== null && _f !== void 0 ? _f : [],
|
|
2993
|
+
metadata: (_g = opts.metadata) !== null && _g !== void 0 ? _g : {},
|
|
2950
2994
|
};
|
|
2951
2995
|
// Type-specific info
|
|
2952
2996
|
const typeSpecificInfo = (('error' in opts && opts.error)
|
|
2953
2997
|
? {
|
|
2954
2998
|
type: LogType$1.Error,
|
|
2955
|
-
errorMessage: (
|
|
2956
|
-
errorCode: (
|
|
2957
|
-
errorStack: (
|
|
2999
|
+
errorMessage: (_h = opts.error.message) !== null && _h !== void 0 ? _h : 'Unknown message',
|
|
3000
|
+
errorCode: (_j = opts.error.code) !== null && _j !== void 0 ? _j : ReactKitErrorCode$1.NoCode,
|
|
3001
|
+
errorStack: (_k = opts.error.stack) !== null && _k !== void 0 ? _k : 'No stack',
|
|
2958
3002
|
}
|
|
2959
3003
|
: {
|
|
2960
3004
|
type: LogType$1.Action,
|
|
2961
|
-
target: (
|
|
2962
|
-
action: (
|
|
3005
|
+
target: ((_l = opts.target) !== null && _l !== void 0 ? _l : LogBuiltInMetadata.Target.NoSpecificTarget),
|
|
3006
|
+
action: ((_m = opts.action) !== null && _m !== void 0 ? _m : LogAction$1.Unknown),
|
|
2963
3007
|
});
|
|
2964
3008
|
// Source-specific info
|
|
2965
3009
|
const sourceSpecificInfo = (opts.overrideAsClientEvent
|
|
@@ -3022,8 +3066,8 @@ const genRouteHandler = (opts) => {
|
|
|
3022
3066
|
timestamp: Date.now(),
|
|
3023
3067
|
tags: [],
|
|
3024
3068
|
metadata: {},
|
|
3025
|
-
|
|
3026
|
-
|
|
3069
|
+
context: LogBuiltInMetadata.Context.Uncategorized,
|
|
3070
|
+
subcontext: LogBuiltInMetadata.Context.Uncategorized,
|
|
3027
3071
|
};
|
|
3028
3072
|
const dummyTypeSpecificInfo = {
|
|
3029
3073
|
type: LogType$1.Error,
|
|
@@ -3082,7 +3126,7 @@ const genRouteHandler = (opts) => {
|
|
|
3082
3126
|
send(html, (_a = opts.status) !== null && _a !== void 0 ? _a : 500);
|
|
3083
3127
|
// Log
|
|
3084
3128
|
logServerEvent({
|
|
3085
|
-
|
|
3129
|
+
context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
|
|
3086
3130
|
error: {
|
|
3087
3131
|
message: `${opts.title}: ${opts.description}`,
|
|
3088
3132
|
code: opts.code,
|
|
@@ -3121,7 +3165,7 @@ const genRouteHandler = (opts) => {
|
|
|
3121
3165
|
handleError(res, err);
|
|
3122
3166
|
// Log server-side error
|
|
3123
3167
|
logServerEvent({
|
|
3124
|
-
|
|
3168
|
+
context: LogBuiltInMetadata.Context.ServerEndpointError,
|
|
3125
3169
|
error: err,
|
|
3126
3170
|
});
|
|
3127
3171
|
return;
|
|
@@ -3328,14 +3372,12 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3328
3372
|
path: LOG_ROUTE_PATH,
|
|
3329
3373
|
method: 'POST',
|
|
3330
3374
|
params: {
|
|
3331
|
-
|
|
3332
|
-
? opts.
|
|
3333
|
-
: ((_b = ((_a = opts.
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
tags: JSON.stringify((_e = opts.tags) !== null && _e !== void 0 ? _e : []),
|
|
3338
|
-
metadata: JSON.stringify((_f = opts.metadata) !== null && _f !== void 0 ? _f : {}),
|
|
3375
|
+
context: (typeof opts.context === 'string'
|
|
3376
|
+
? opts.context
|
|
3377
|
+
: ((_b = ((_a = opts.context) !== null && _a !== void 0 ? _a : {})._) !== null && _b !== void 0 ? _b : LogBuiltInMetadata.Context.Uncategorized)),
|
|
3378
|
+
subcontext: ((_c = opts.subcontext) !== null && _c !== void 0 ? _c : LogBuiltInMetadata.Context.Uncategorized),
|
|
3379
|
+
tags: JSON.stringify((_d = opts.tags) !== null && _d !== void 0 ? _d : []),
|
|
3380
|
+
metadata: JSON.stringify((_e = opts.metadata) !== null && _e !== void 0 ? _e : {}),
|
|
3339
3381
|
errorMessage: (opts.error
|
|
3340
3382
|
? opts.error.message
|
|
3341
3383
|
: undefined),
|
|
@@ -3345,8 +3387,8 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3345
3387
|
errorStack: (opts.error
|
|
3346
3388
|
? opts.error.stack
|
|
3347
3389
|
: undefined),
|
|
3348
|
-
target: (opts.
|
|
3349
|
-
? opts.target
|
|
3390
|
+
target: (opts.action
|
|
3391
|
+
? ((_f = opts.target) !== null && _f !== void 0 ? _f : LogBuiltInMetadata.Target.NoSpecificTarget)
|
|
3350
3392
|
: undefined),
|
|
3351
3393
|
action: (opts.action
|
|
3352
3394
|
? opts.action
|
|
@@ -3366,8 +3408,8 @@ const initLogCollection = (Collection) => {
|
|
|
3366
3408
|
uniqueIndexKey: 'id',
|
|
3367
3409
|
indexKeys: [
|
|
3368
3410
|
'courseId',
|
|
3369
|
-
'
|
|
3370
|
-
'
|
|
3411
|
+
'context',
|
|
3412
|
+
'subcontext',
|
|
3371
3413
|
'tags',
|
|
3372
3414
|
],
|
|
3373
3415
|
});
|
|
@@ -3389,46 +3431,5 @@ var DayOfWeek;
|
|
|
3389
3431
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
3390
3432
|
var DayOfWeek$1 = DayOfWeek;
|
|
3391
3433
|
|
|
3392
|
-
|
|
3393
|
-
* Types of actions
|
|
3394
|
-
* @author Gabe Abrams
|
|
3395
|
-
*/
|
|
3396
|
-
var LogAction;
|
|
3397
|
-
(function (LogAction) {
|
|
3398
|
-
// Target was opened by the user (it was not on screen, but now it is)
|
|
3399
|
-
LogAction["Open"] = "open";
|
|
3400
|
-
// Target was closed by the user (it was on screen, but now it is not)
|
|
3401
|
-
LogAction["Close"] = "close";
|
|
3402
|
-
// Target was cancelled by the user (it was on closed without saving)
|
|
3403
|
-
LogAction["Cancel"] = "cancel";
|
|
3404
|
-
// Target was expanded by the user (it always remains on screen, but size was changed)
|
|
3405
|
-
LogAction["Expand"] = "expand";
|
|
3406
|
-
// Target was collapsed by the user (it always remains on screen, but size was changed)
|
|
3407
|
-
LogAction["Collapse"] = "collapse";
|
|
3408
|
-
// Target was viewed by the user (only for items that are not opened or closed, those must use Open/Close actions)
|
|
3409
|
-
LogAction["View"] = "view";
|
|
3410
|
-
// Target interrupted the user (popup, dialog, validation message, etc. appeared without user prompting)
|
|
3411
|
-
LogAction["Interrupt"] = "interrupt";
|
|
3412
|
-
// Target was created by the user (it did not exist before)
|
|
3413
|
-
LogAction["Create"] = "create";
|
|
3414
|
-
// Target was edited by the user (it existed and was changed)
|
|
3415
|
-
LogAction["Edit"] = "edit";
|
|
3416
|
-
// Target was deleted by the user (it existed and now it doesn't)
|
|
3417
|
-
LogAction["Delete"] = "delete";
|
|
3418
|
-
// Target was added by the user (it already existed and was added to another place)
|
|
3419
|
-
LogAction["Add"] = "add";
|
|
3420
|
-
// Target was removed by the user (it was removed from something but still exists)
|
|
3421
|
-
LogAction["Remove"] = "remove";
|
|
3422
|
-
// Target was activated by the user (click, check, tap, keypress, etc.)
|
|
3423
|
-
LogAction["Activate"] = "activate";
|
|
3424
|
-
// Target was deactivated by the user (click away, uncheck, tap outside of, tab away, etc.)
|
|
3425
|
-
LogAction["Deactivate"] = "deactivate";
|
|
3426
|
-
// User showed interest in a target (hover, peek, etc.)
|
|
3427
|
-
LogAction["Peek"] = "peek";
|
|
3428
|
-
// Unknown action
|
|
3429
|
-
LogAction["Unknown"] = "unknown";
|
|
3430
|
-
})(LogAction || (LogAction = {}));
|
|
3431
|
-
var LogAction$1 = LogAction;
|
|
3432
|
-
|
|
3433
|
-
export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek$1 as DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInCategory$1 as LogBuiltInCategory, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
3434
|
+
export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek$1 as DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
3434
3435
|
//# sourceMappingURL=index.js.map
|