Skip to content

Commit 58e7b4a

Browse files
jamessimonejongpie
andauthored
Fix Stacktrace Parsing & Reduce logger.test.js (#840)
* Fixes #780 by cleaning up logger.test.js * Fixed an issue in LoggerStackTrace.js that would cause an unintended exception when there isn't a valid JS stack trace --------- Co-authored-by: Jonathan Gillespie <[email protected]>
1 parent dc057c1 commit 58e7b4a

File tree

9 files changed

+148
-1352
lines changed

9 files changed

+148
-1352
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, OmniStudio, and integrations.
77

8-
## Unlocked Package - v4.15.6
8+
## Unlocked Package - v4.15.7
99

10-
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015pEdQAI)
11-
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015pEdQAI)
10+
[![Install Unlocked Package in a Sandbox](./images/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015pEnQAI)
11+
[![Install Unlocked Package in Production](./images/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015pEnQAI)
1212
[![View Documentation](./images/btn-view-documentation.png)](https://github.com/jongpie/NebulaLogger/wiki)
1313

14-
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015pEdQAI`
14+
`sf package install --wait 20 --security-type AdminsOnly --package 04t5Y0000015pEnQAI`
1515

1616
---
1717

nebula-logger/core/main/logger-engine/classes/Logger.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
global with sharing class Logger {
1616
// There's no reliable way to get the version number dynamically in Apex
1717
@TestVisible
18-
private static final String CURRENT_VERSION_NUMBER = 'v4.15.6';
18+
private static final String CURRENT_VERSION_NUMBER = 'v4.15.7';
1919
private static final System.LoggingLevel FALLBACK_LOGGING_LEVEL = System.LoggingLevel.DEBUG;
2020
private static final List<LogEntryEventBuilder> LOG_ENTRIES_BUFFER = new List<LogEntryEventBuilder>();
2121
private static final String MISSING_SCENARIO_ERROR_MESSAGE = 'No logger scenario specified. A scenario is required for logging in this org.';

nebula-logger/core/main/logger-engine/lwc/logger/__tests__/logger.test.js

Lines changed: 112 additions & 1339 deletions
Large diffs are not rendered by default.

nebula-logger/core/main/logger-engine/lwc/logger/__tests__/loggerStackTrace.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ describe('logger stack trace parsing tests', () => {
2020
jest.clearAllMocks();
2121
});
2222

23+
it('correctly handles undefined error', async () => {
24+
const originStackTraceError = undefined;
25+
const loggerStackTrace = new LoggerStackTrace();
26+
27+
const originStackTrace = loggerStackTrace.parse(originStackTraceError);
28+
29+
expect(originStackTrace.componentName).toBeUndefined();
30+
expect(originStackTrace.functionName).toBeUndefined();
31+
expect(originStackTrace.metadataType).toBeUndefined();
32+
});
33+
34+
it('correctly handles non-null error with undefined stack trace', async () => {
35+
const originStackTraceError = new Error();
36+
originStackTraceError.stack = undefined;
37+
const loggerStackTrace = new LoggerStackTrace();
38+
39+
const originStackTrace = loggerStackTrace.parse(originStackTraceError);
40+
41+
expect(originStackTrace.componentName).toBeUndefined();
42+
expect(originStackTrace.functionName).toBeUndefined();
43+
expect(originStackTrace.metadataType).toBeUndefined();
44+
});
45+
2346
it('correctly parses Chrome stack trace when debug mode is enabled', async () => {
2447
const loggerStackTrace = new LoggerStackTrace();
2548

nebula-logger/core/main/logger-engine/lwc/logger/logger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default class Logger extends LightningElement {
2727
* @param {Object} fieldToValue An object containing the custom field name as a key, with the corresponding value to store.
2828
* Example: `{"SomeField__c": "some value", "AnotherField__c": "another value"}`
2929
*/
30+
@api
3031
setField(fieldToValue) {
3132
this.#loggerService.setField(fieldToValue);
3233
}

nebula-logger/core/main/logger-engine/lwc/logger/loggerService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import LoggerServiceTaskQueue from './loggerServiceTaskQueue';
1010
import getSettings from '@salesforce/apex/ComponentLogger.getSettings';
1111
import saveComponentLogEntries from '@salesforce/apex/ComponentLogger.saveComponentLogEntries';
1212

13-
const CURRENT_VERSION_NUMBER = 'v4.15.6';
13+
const CURRENT_VERSION_NUMBER = 'v4.15.7';
1414

1515
const CONSOLE_OUTPUT_CONFIG = {
1616
messagePrefix: `%c Nebula Logger ${CURRENT_VERSION_NUMBER} `,

nebula-logger/core/main/logger-engine/lwc/logger/loggerStackTrace.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
4949

5050
class ErrorStackParser {
5151
parse(error) {
52-
let stackTraceParticles;
52+
let stackTraceParticles = [];
5353
if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
5454
stackTraceParticles = this.parseV8OrIE(error);
5555
} else if (error.stack) {
5656
stackTraceParticles = this.parseFFOrSafari(error);
57-
} else {
58-
throw new Error('Cannot parse given Error object');
5957
}
6058

6159
return stackTraceParticles;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nebula-logger",
3-
"version": "4.15.6",
3+
"version": "4.15.7",
44
"description": "The most robust logger for Salesforce. Works with Apex, Lightning Components, Flow, Process Builder & Integrations. Designed for Salesforce admins, developers & architects.",
55
"author": "Jonathan Gillespie",
66
"license": "MIT",

sfdx-project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"path": "./nebula-logger/core",
1010
"definitionFile": "./config/scratch-orgs/base-scratch-def.json",
1111
"scopeProfiles": true,
12-
"versionNumber": "4.15.6.NEXT",
13-
"versionName": "Adds tryCatch CallableLogger method",
14-
"versionDescription": "tryCatch CallableLogger method for OmniStudio and other decoupled logging usages",
12+
"versionNumber": "4.15.7.NEXT",
13+
"versionName": "Jest test cleanup and stacktrace parsing bugfix",
14+
"versionDescription": "Fixed an issue in LoggerStackTrace.js that would cause an unintended exception when there isn't a valid JS stack trace",
1515
"postInstallUrl": "https://github.com/jongpie/NebulaLogger/wiki",
1616
"releaseNotesUrl": "https://github.com/jongpie/NebulaLogger/releases",
1717
"unpackagedMetadata": {
@@ -211,6 +211,7 @@
211211
"Nebula Logger - [email protected]": "04t5Y0000015oklQAA",
212212
"Nebula Logger - Core@4.15.5-bugfix-for-authsession-with-null-loginhistory-exception-message-handling": "04t5Y0000015p5jQAA",
213213
"Nebula Logger - [email protected]": "04t5Y0000015pEdQAI",
214+
"Nebula Logger - [email protected]": "04t5Y0000015pEnQAI",
214215
"Nebula Logger - Core Plugin - Async Failure Additions": "0Ho5Y000000blO4SAI",
215216
"Nebula Logger - Core Plugin - Async Failure [email protected]": "04t5Y0000015lhiQAA",
216217
"Nebula Logger - Core Plugin - Async Failure [email protected]": "04t5Y0000015lhsQAA",

0 commit comments

Comments
 (0)