dce-reactkit 3.2.0-beta.9 → 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 +40 -44
- 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 +2 -2
- package/dist/cjs/types/types/LogFunction.d.ts +2 -4
- package/dist/esm/index.js +40 -44
- 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 +2 -2
- package/dist/esm/types/types/LogFunction.d.ts +2 -4
- package/dist/index.d.ts +7 -9
- package/package.json +1 -1
- package/src/helpers/genRouteHandler.ts +12 -16
- package/src/helpers/logClientEvent.tsx +8 -12
- 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 +3 -3
- package/src/types/LogFunction.ts +4 -4
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,12 +2582,12 @@ 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
2588
|
const LogBuiltInMetadata = {
|
|
2589
|
-
//
|
|
2590
|
-
|
|
2589
|
+
// Contexts
|
|
2590
|
+
Context: {
|
|
2591
2591
|
Uncategorized: 'n/a',
|
|
2592
2592
|
ServerRenderedErrorPage: '_server-rendered-error-page',
|
|
2593
2593
|
ServerEndpointError: '_server-endpoint-error',
|
|
@@ -2963,7 +2963,7 @@ const genRouteHandler = (opts) => {
|
|
|
2963
2963
|
* @author Gabe Abrams
|
|
2964
2964
|
*/
|
|
2965
2965
|
const logServerEvent = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2966
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
2966
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2967
2967
|
// NOTE: internally, we slip through an opts.overrideAsClientEvent boolean
|
|
2968
2968
|
// that indicates that this is actually a client event, but we don't
|
|
2969
2969
|
// include that in the LogFunction type because this is internal and
|
|
@@ -2993,27 +2993,25 @@ const genRouteHandler = (opts) => {
|
|
|
2993
2993
|
hour,
|
|
2994
2994
|
minute,
|
|
2995
2995
|
timestamp,
|
|
2996
|
-
|
|
2997
|
-
? opts.
|
|
2998
|
-
: ((_d = ((_c = opts.
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
tags: (_g = opts.tags) !== null && _g !== void 0 ? _g : [],
|
|
3003
|
-
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 : {},
|
|
3004
3002
|
};
|
|
3005
3003
|
// Type-specific info
|
|
3006
3004
|
const typeSpecificInfo = (('error' in opts && opts.error)
|
|
3007
3005
|
? {
|
|
3008
3006
|
type: LogType$1.Error,
|
|
3009
|
-
errorMessage: (
|
|
3010
|
-
errorCode: (
|
|
3011
|
-
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',
|
|
3012
3010
|
}
|
|
3013
3011
|
: {
|
|
3014
3012
|
type: LogType$1.Action,
|
|
3015
|
-
target: ((
|
|
3016
|
-
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),
|
|
3017
3015
|
});
|
|
3018
3016
|
// Source-specific info
|
|
3019
3017
|
const sourceSpecificInfo = (opts.overrideAsClientEvent
|
|
@@ -3076,8 +3074,8 @@ const genRouteHandler = (opts) => {
|
|
|
3076
3074
|
timestamp: Date.now(),
|
|
3077
3075
|
tags: [],
|
|
3078
3076
|
metadata: {},
|
|
3079
|
-
|
|
3080
|
-
|
|
3077
|
+
context: LogBuiltInMetadata.Context.Uncategorized,
|
|
3078
|
+
subcontext: LogBuiltInMetadata.Context.Uncategorized,
|
|
3081
3079
|
};
|
|
3082
3080
|
const dummyTypeSpecificInfo = {
|
|
3083
3081
|
type: LogType$1.Error,
|
|
@@ -3136,7 +3134,7 @@ const genRouteHandler = (opts) => {
|
|
|
3136
3134
|
send(html, (_a = opts.status) !== null && _a !== void 0 ? _a : 500);
|
|
3137
3135
|
// Log
|
|
3138
3136
|
logServerEvent({
|
|
3139
|
-
|
|
3137
|
+
context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
|
|
3140
3138
|
error: {
|
|
3141
3139
|
message: `${opts.title}: ${opts.description}`,
|
|
3142
3140
|
code: opts.code,
|
|
@@ -3175,7 +3173,7 @@ const genRouteHandler = (opts) => {
|
|
|
3175
3173
|
handleError(res, err);
|
|
3176
3174
|
// Log server-side error
|
|
3177
3175
|
logServerEvent({
|
|
3178
|
-
|
|
3176
|
+
context: LogBuiltInMetadata.Context.ServerEndpointError,
|
|
3179
3177
|
error: err,
|
|
3180
3178
|
});
|
|
3181
3179
|
return;
|
|
@@ -3377,19 +3375,17 @@ const parallelLimit = (taskFunctions, limit) => __awaiter(void 0, void 0, void 0
|
|
|
3377
3375
|
* @author Gabe Abrams
|
|
3378
3376
|
*/
|
|
3379
3377
|
const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3380
|
-
var _a, _b, _c, _d, _e, _f
|
|
3378
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3381
3379
|
return visitServerEndpoint({
|
|
3382
3380
|
path: LOG_ROUTE_PATH,
|
|
3383
3381
|
method: 'POST',
|
|
3384
3382
|
params: {
|
|
3385
|
-
|
|
3386
|
-
? opts.
|
|
3387
|
-
: ((_b = ((_a = opts.
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
tags: JSON.stringify((_e = opts.tags) !== null && _e !== void 0 ? _e : []),
|
|
3392
|
-
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 : {}),
|
|
3393
3389
|
errorMessage: (opts.error
|
|
3394
3390
|
? opts.error.message
|
|
3395
3391
|
: undefined),
|
|
@@ -3400,7 +3396,7 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
3400
3396
|
? opts.error.stack
|
|
3401
3397
|
: undefined),
|
|
3402
3398
|
target: (opts.action
|
|
3403
|
-
? ((
|
|
3399
|
+
? ((_f = opts.target) !== null && _f !== void 0 ? _f : LogBuiltInMetadata.Target.NoSpecificTarget)
|
|
3404
3400
|
: undefined),
|
|
3405
3401
|
action: (opts.action
|
|
3406
3402
|
? opts.action
|
|
@@ -3420,8 +3416,8 @@ const initLogCollection = (Collection) => {
|
|
|
3420
3416
|
uniqueIndexKey: 'id',
|
|
3421
3417
|
indexKeys: [
|
|
3422
3418
|
'courseId',
|
|
3423
|
-
'
|
|
3424
|
-
'
|
|
3419
|
+
'context',
|
|
3420
|
+
'subcontext',
|
|
3425
3421
|
'tags',
|
|
3426
3422
|
],
|
|
3427
3423
|
});
|
|
@@ -3456,7 +3452,7 @@ exports.HOUR_IN_MS = HOUR_IN_MS;
|
|
|
3456
3452
|
exports.ItemPicker = ItemPicker;
|
|
3457
3453
|
exports.LoadingSpinner = LoadingSpinner;
|
|
3458
3454
|
exports.LogAction = LogAction$1;
|
|
3459
|
-
exports.
|
|
3455
|
+
exports.LogBuiltInMetadata = LogBuiltInMetadata;
|
|
3460
3456
|
exports.LogSource = LogSource$1;
|
|
3461
3457
|
exports.LogType = LogType$1;
|
|
3462
3458
|
exports.MINUTE_IN_MS = MINUTE_IN_MS;
|