expensify-common 2.0.170 → 2.0.173
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/ExpensiMark.js +6 -0
- package/dist/Logger.d.ts +4 -1
- package/dist/Logger.js +12 -1
- package/package.json +1 -1
package/dist/ExpensiMark.js
CHANGED
|
@@ -807,6 +807,9 @@ class ExpensiMark {
|
|
|
807
807
|
* If not provided, all available rules will be applied. If provided, the rules in the array will be skipped.
|
|
808
808
|
*/
|
|
809
809
|
replace(text, { filterRules = [], shouldEscapeText = true, shouldKeepRawInput = false, disabledRules = [], extras = EXTRAS_DEFAULT } = {}) {
|
|
810
|
+
if (!text) {
|
|
811
|
+
return '';
|
|
812
|
+
}
|
|
810
813
|
// This ensures that any html the user puts into the comment field shows as raw html
|
|
811
814
|
let replacedText = shouldEscapeText ? Utils.escapeText(text) : text;
|
|
812
815
|
const rules = this.getHtmlRuleset(filterRules, disabledRules, shouldKeepRawInput);
|
|
@@ -1056,6 +1059,9 @@ class ExpensiMark {
|
|
|
1056
1059
|
* Replaces HTML with markdown
|
|
1057
1060
|
*/
|
|
1058
1061
|
htmlToMarkdown(htmlString, extras = EXTRAS_DEFAULT) {
|
|
1062
|
+
if (!htmlString) {
|
|
1063
|
+
return '';
|
|
1064
|
+
}
|
|
1059
1065
|
let generatedMarkdown = htmlString;
|
|
1060
1066
|
const body = /<(body)(?:"[^"]*"|'[^']*'|[^'"><])*>(?:\n|\r\n)?([\s\S]*?)(?:\n|\r\n)?<\/\1>(?![^<]*(<\/pre>|<\/code>))/im;
|
|
1061
1067
|
const parseBodyTag = generatedMarkdown.match(body);
|
package/dist/Logger.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ type LogLine = {
|
|
|
12
12
|
parameters: Parameters;
|
|
13
13
|
onlyFlushWithOthers?: boolean;
|
|
14
14
|
timestamp: Date;
|
|
15
|
+
email?: string | null;
|
|
15
16
|
};
|
|
16
17
|
type LoggerOptions = {
|
|
17
18
|
serverLoggingCallback: ServerLoggingCallback;
|
|
18
19
|
isDebug: boolean;
|
|
19
20
|
clientLoggingCallback: ClientLoggingCallBack;
|
|
20
21
|
maxLogLinesBeforeFlush?: number;
|
|
22
|
+
getContextEmail?: () => string | null;
|
|
21
23
|
};
|
|
22
24
|
export default class Logger {
|
|
23
25
|
logLines: LogLine[];
|
|
@@ -25,7 +27,8 @@ export default class Logger {
|
|
|
25
27
|
clientLoggingCallback: ClientLoggingCallBack;
|
|
26
28
|
isDebug: boolean;
|
|
27
29
|
maxLogLinesBeforeFlush: number;
|
|
28
|
-
|
|
30
|
+
getContextEmail?: () => string | null;
|
|
31
|
+
constructor({ serverLoggingCallback, isDebug, clientLoggingCallback, maxLogLinesBeforeFlush, getContextEmail }: LoggerOptions);
|
|
29
32
|
/**
|
|
30
33
|
* Ask the server to write the log message
|
|
31
34
|
*/
|
package/dist/Logger.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const MAX_LOG_LINES_BEFORE_FLUSH = 50;
|
|
4
4
|
class Logger {
|
|
5
|
-
constructor({ serverLoggingCallback, isDebug, clientLoggingCallback, maxLogLinesBeforeFlush }) {
|
|
5
|
+
constructor({ serverLoggingCallback, isDebug, clientLoggingCallback, maxLogLinesBeforeFlush, getContextEmail }) {
|
|
6
6
|
// An array of log lines that limits itself to a certain number of entries (deleting the oldest)
|
|
7
7
|
this.logLines = [];
|
|
8
8
|
this.serverLoggingCallback = serverLoggingCallback;
|
|
9
9
|
this.clientLoggingCallback = clientLoggingCallback;
|
|
10
10
|
this.isDebug = isDebug;
|
|
11
11
|
this.maxLogLinesBeforeFlush = maxLogLinesBeforeFlush || MAX_LOG_LINES_BEFORE_FLUSH;
|
|
12
|
+
this.getContextEmail = getContextEmail;
|
|
12
13
|
// Public Methods
|
|
13
14
|
this.info = this.info.bind(this);
|
|
14
15
|
this.alert = this.alert.bind(this);
|
|
@@ -51,11 +52,21 @@ class Logger {
|
|
|
51
52
|
* @param onlyFlushWithOthers A request will never be sent to the server if all loglines have this set to true
|
|
52
53
|
*/
|
|
53
54
|
add(message, parameters, forceFlushToServer, onlyFlushWithOthers = false, extraData = '') {
|
|
55
|
+
// Capture the user's email at the moment this specific log line is created
|
|
56
|
+
// This ensures the log retains user context even if the session is cleared before sending
|
|
57
|
+
let email = null;
|
|
58
|
+
try {
|
|
59
|
+
email = this.getContextEmail ? this.getContextEmail() : null;
|
|
60
|
+
}
|
|
61
|
+
catch (_a) {
|
|
62
|
+
// Silently fail if getContextEmail throws - logging should not crash
|
|
63
|
+
}
|
|
54
64
|
const length = this.logLines.push({
|
|
55
65
|
message,
|
|
56
66
|
parameters,
|
|
57
67
|
onlyFlushWithOthers,
|
|
58
68
|
timestamp: new Date(),
|
|
69
|
+
email,
|
|
59
70
|
});
|
|
60
71
|
if (this.isDebug) {
|
|
61
72
|
this.client(`${message} - ${JSON.stringify(parameters)}`, extraData);
|