dce-reactkit 3.6.20 → 3.6.21
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/dist/cjs/index.js +33 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/logClientEvent.d.ts +12 -0
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/index.js +33 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/logClientEvent.d.ts +12 -0
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/index.d.ts +13 -1
- package/package.json +1 -1
- package/src/helpers/logClientEvent.tsx +44 -1
- package/src/index.ts +2 -1
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import LogFunction from '../types/LogFunction';
|
|
2
|
+
type MetadataPopulator = () => Promise<{
|
|
3
|
+
[k: string]: any;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Set the metadata populator function that will be called before every client
|
|
7
|
+
* event is logged. The function should return a set of metadata values that
|
|
8
|
+
* will be added to all client events
|
|
9
|
+
* @author Gabe Abrams
|
|
10
|
+
* @param metadataPopulator function to call that will return a set of metadata
|
|
11
|
+
* values that will be added to all client events
|
|
12
|
+
*/
|
|
13
|
+
export declare const setClientEventMetadataPopulator: (newMetadataPopulator: MetadataPopulator) => void;
|
|
2
14
|
/**
|
|
3
15
|
* Log a user action on the client (cannot be used on the server)
|
|
4
16
|
* @author Gabe Abrams
|
|
@@ -51,7 +51,7 @@ import getPartOfDay from './helpers/getPartOfDay';
|
|
|
51
51
|
import stringsToHumanReadableList from './helpers/stringsToHumanReadableList';
|
|
52
52
|
import onlyKeepLetters from './helpers/onlyKeepLetters';
|
|
53
53
|
import parallelLimit from './helpers/parallelLimit';
|
|
54
|
-
import logClientEvent from './helpers/logClientEvent';
|
|
54
|
+
import logClientEvent, { setClientEventMetadataPopulator } from './helpers/logClientEvent';
|
|
55
55
|
import initLogCollection from './server/initLogCollection';
|
|
56
56
|
import getMonthName from './helpers/getMonthName';
|
|
57
57
|
import genCSV from './helpers/genCSV';
|
|
@@ -88,4 +88,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
88
88
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
89
89
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
90
90
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
91
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
|
91
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
package/dist/esm/index.js
CHANGED
|
@@ -747,23 +747,50 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
|
|
|
747
747
|
return body;
|
|
748
748
|
});
|
|
749
749
|
|
|
750
|
+
// Current metadata populator function
|
|
751
|
+
let metadataPopulator;
|
|
752
|
+
/**
|
|
753
|
+
* Set the metadata populator function that will be called before every client
|
|
754
|
+
* event is logged. The function should return a set of metadata values that
|
|
755
|
+
* will be added to all client events
|
|
756
|
+
* @author Gabe Abrams
|
|
757
|
+
* @param metadataPopulator function to call that will return a set of metadata
|
|
758
|
+
* values that will be added to all client events
|
|
759
|
+
*/
|
|
760
|
+
const setClientEventMetadataPopulator = (newMetadataPopulator) => {
|
|
761
|
+
metadataPopulator = newMetadataPopulator;
|
|
762
|
+
};
|
|
763
|
+
/* -------------- Main -------------- */
|
|
750
764
|
/**
|
|
751
765
|
* Log a user action on the client (cannot be used on the server)
|
|
752
766
|
* @author Gabe Abrams
|
|
753
767
|
*/
|
|
754
768
|
const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
755
769
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
770
|
+
// Populate metadata
|
|
771
|
+
let metadata = ((_a = opts.metadata) !== null && _a !== void 0 ? _a : {});
|
|
772
|
+
if (metadataPopulator) {
|
|
773
|
+
try {
|
|
774
|
+
const autoPopulatedMetadata = yield metadataPopulator();
|
|
775
|
+
metadata = Object.assign(Object.assign({}, autoPopulatedMetadata), metadata);
|
|
776
|
+
}
|
|
777
|
+
catch (err) {
|
|
778
|
+
// Add error to metadata
|
|
779
|
+
metadata = Object.assign({ autoPopulatedMetadataNotAvailable: true }, metadata);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
// Send to server
|
|
756
783
|
return visitServerEndpoint({
|
|
757
784
|
path: LOG_ROUTE_PATH,
|
|
758
785
|
method: 'POST',
|
|
759
786
|
params: {
|
|
760
787
|
context: (typeof opts.context === 'string'
|
|
761
788
|
? opts.context
|
|
762
|
-
: ((
|
|
763
|
-
subcontext: ((
|
|
764
|
-
level: ((
|
|
765
|
-
tags: JSON.stringify((
|
|
766
|
-
metadata: JSON.stringify(
|
|
789
|
+
: ((_c = ((_b = opts.context) !== null && _b !== void 0 ? _b : {})._) !== null && _c !== void 0 ? _c : LogBuiltInMetadata.Context.Uncategorized)),
|
|
790
|
+
subcontext: ((_d = opts.subcontext) !== null && _d !== void 0 ? _d : LogBuiltInMetadata.Context.Uncategorized),
|
|
791
|
+
level: ((_e = opts.level) !== null && _e !== void 0 ? _e : LogLevel$1.Info),
|
|
792
|
+
tags: JSON.stringify((_f = opts.tags) !== null && _f !== void 0 ? _f : []),
|
|
793
|
+
metadata: JSON.stringify(metadata),
|
|
767
794
|
errorMessage: (opts.error
|
|
768
795
|
? opts.error.message
|
|
769
796
|
: undefined),
|
|
@@ -43406,5 +43433,5 @@ var DayOfWeek;
|
|
|
43406
43433
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
43407
43434
|
var DayOfWeek$1 = DayOfWeek;
|
|
43408
43435
|
|
|
43409
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
43436
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
43410
43437
|
//# sourceMappingURL=index.js.map
|