Skip to content

Commit

Permalink
Fixed #776 by updating logic in loggerStackTrace.js to better handle …
Browse files Browse the repository at this point in the history
…parsing when lightning debug mode is disabled

Previously, stack traces worked when debug mode was enabled, but was inaccurate when debug mode was off due to some subtle differences in the generated stack traces

Also incorporated some code review feedback from @jamessimone

Also removed opera stack trace parsing in loggerStackTrace.js - there was no test coverage for this, I haven't heard of anyone using Opera in years, and I just... don't want to have to test another browser. If/when someone says Opera support is needed, it can be revisited[D
  • Loading branch information
jongpie committed Oct 10, 2024
1 parent 2188a7e commit f43a62b
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 232 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build](https://github.com/jongpie/NebulaLogger/actions/workflows/build.yml/badge.svg)](https://github.com/jongpie/NebulaLogger/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/jongpie/NebulaLogger/branch/main/graph/badge.svg?token=1DJPDRM3N4)](https://codecov.io/gh/jongpie/NebulaLogger)

The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, Process Builder & integrations.
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.

## Unlocked Package - v4.14.13

Expand Down
4 changes: 2 additions & 2 deletions docs/apex/Logger-Engine/ComponentLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ return The transaction ID (based on `Logger.getTransactionId())`

### Inner Classes

#### ComponentLogger.ComponentBrowser class
#### ComponentLogger.ComponentBrowserContext class

A DTO object used to log details about the user's browser

Expand Down Expand Up @@ -123,7 +123,7 @@ A DTO object used to create log entries for lightning components

##### Properties

###### `browser``ComponentBrowser`
###### `browser``ComponentBrowserContext`

Context about the user's browser, automatically captured by Nebula Logger

Expand Down
162 changes: 87 additions & 75 deletions docs/lightning-components/LogEntryBuilder.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,101 @@
<a name="LogEntryBuilder"></a>

## LogEntryBuilder

**Kind**: global class

- [LogEntryBuilder](#LogEntryBuilder)
- [new LogEntryBuilder(loggingLevel)](#new_LogEntryBuilder_new)
- [.setMessage(message)](#LogEntryBuilder+setMessage) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setRecordId(recordId)](#LogEntryBuilder+setRecordId) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setRecord(record)](#LogEntryBuilder+setRecord) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setScenario(scenario)](#LogEntryBuilder+setScenario) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setError(error)](#LogEntryBuilder+setError) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setExceptionDetails(exception)](#LogEntryBuilder+setExceptionDetails) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.setField(fieldToValue)](#LogEntryBuilder+setField) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.parseStackTrace(originStackTraceError)](#LogEntryBuilder+parseStackTrace) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.addTag(tag)](#LogEntryBuilder+addTag) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.addTags(tags)](#LogEntryBuilder+addTags) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
- [.getComponentLogEntry()](#LogEntryBuilder+getComponentLogEntry) <code>ComponentLogEntry</code>

<a name="new_LogEntryBuilder_new"></a>

### new LogEntryBuilder(loggingLevel)

Constructor used to generate each JavaScript-based log entry event
This class is the JavaScript-equivalent of the Apex class `LogEntryBuilder`

| Param | Type | Description |
| ------------ | ------------------- | ------------------------------------------------------------------------------- |
| loggingLevel | <code>String</code> | The `LoggingLevel` enum to use for the builder's instance of `LogEntryEvent__e` |

<a name="LogEntryBuilder+setMessage"></a>

### logEntryBuilder.setMessage(message) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## Functions

<dl>
<dt><a href="#setMessage">setMessage(message)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets the log entry event&#39;s message field</p>
</dd>
<dt><a href="#setRecordId">setRecordId(recordId)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets the log entry event&#39;s record fields</p>
</dd>
<dt><a href="#setRecord">setRecord(record)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets the log entry event&#39;s record fields</p>
</dd>
<dt><a href="#setScenario">setScenario(scenario)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets the log entry event&#39;s scenario field</p>
</dd>
<dt><a href="#setError">setError(error)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Deprecated - use <code>setExceptionDetails(exception)</code> instead
The name of this method is very similar to the logger function logger.error(),
resulting in confusion when used together:
<code>logger.error(&#39;Unexpected error&#39;).setError(someErrorObject);</code>
The new <code>setExceptionDetails(exception)</code> function provides the exact same functionality,
but aligns with the Apex builder&#39;s method name, and helps reduce the confusion with <code>logger.error()</code></p>
</dd>
<dt><a href="#setExceptionDetails">setExceptionDetails(exception)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets the log entry event&#39;s exception fields</p>
</dd>
<dt><a href="#setField">setField(fieldToValue)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Sets multiple field values on the builder&#39;s <code>LogEntryEvent__e</code> record</p>
</dd>
<dt><a href="#parseStackTrace">parseStackTrace(originStackTraceError)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Parses the provided error&#39;s stack trace and sets the log entry&#39;s origin &amp; stack trace fields</p>
</dd>
<dt><a href="#addTag">addTag(tag)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Appends the tag to the existing list of tags</p>
</dd>
<dt><a href="#addTags">addTags(tags)</a> <code>LogEntryBuilder</code></dt>
<dd><p>Appends the tag to the existing list of tags</p>
</dd>
<dt><a href="#getComponentLogEntry">getComponentLogEntry()</a> <code>ComponentLogEntry</code></dt>
<dd><p>Returns the object used to save log entry data</p>
</dd>
</dl>

<a name="setMessage"></a>

## setMessage(message) <code>LogEntryBuilder</code>

Sets the log entry event's message field

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ------- | ------------------- | -------------------------------------------------- |
| message | <code>String</code> | The string to use to set the entry's message field |

<a name="LogEntryBuilder+setRecordId"></a>
<a name="setRecordId"></a>

### logEntryBuilder.setRecordId(recordId) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setRecordId(recordId) <code>LogEntryBuilder</code>

Sets the log entry event's record fields

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| -------- | ------------------- | ------------------------------------------------- |
| recordId | <code>String</code> | The ID of the SObject record related to the entry |

<a name="LogEntryBuilder+setRecord"></a>
<a name="setRecord"></a>

### logEntryBuilder.setRecord(record) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setRecord(record) <code>LogEntryBuilder</code>

Sets the log entry event's record fields

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ------ | ------------------- | ----------------------------------------------------------------------------------------------------- |
| record | <code>Object</code> | The `SObject` record related to the entry. The JSON of the record is automatically added to the entry |

<a name="LogEntryBuilder+setScenario"></a>
<a name="setScenario"></a>

### logEntryBuilder.setScenario(scenario) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setScenario(scenario) <code>LogEntryBuilder</code>

Sets the log entry event's scenario field

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| -------- | ------------------- | --------------------------------------------------- |
| scenario | <code>String</code> | The string to use to set the entry's scenario field |

<a name="LogEntryBuilder+setError"></a>
<a name="setError"></a>

### logEntryBuilder.setError(error) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setError(error) <code>LogEntryBuilder</code>

Deprecated - use `setExceptionDetails(exception)` instead
The name of this method is very similar to the logger function logger.error(),
Expand All @@ -92,83 +104,83 @@ resulting in confusion when used together:
The new `setExceptionDetails(exception)` function provides the exact same functionality,
but aligns with the Apex builder's method name, and helps reduce the confusion with `logger.error()`

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ----- | ------------------ | -------------------------------------------------------------------------------- |
| error | <code>Error</code> | The instance of a JavaScript `Error` object to use, or an Apex HTTP error to use |

<a name="LogEntryBuilder+setExceptionDetails"></a>
<a name="setExceptionDetails"></a>

### logEntryBuilder.setExceptionDetails(exception) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setExceptionDetails(exception) <code>LogEntryBuilder</code>

Sets the log entry event's exception fields

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| --------- | ------------------ | -------------------------------------------------------------------------------- |
| exception | <code>Error</code> | The instance of a JavaScript `Error` object to use, or an Apex HTTP error to use |

<a name="LogEntryBuilder+setField"></a>
<a name="setField"></a>

### logEntryBuilder.setField(fieldToValue) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## setField(fieldToValue) <code>LogEntryBuilder</code>

Sets multiple field values on the builder's `LogEntryEvent__e` record

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fieldToValue | <code>Object</code> | An object containing the custom field name as a key, with the corresponding value to store. Example: `{"SomeField__c": "some value", "AnotherField__c": "another value"}` |

<a name="LogEntryBuilder+parseStackTrace"></a>
<a name="parseStackTrace"></a>

### logEntryBuilder.parseStackTrace(originStackTraceError) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## parseStackTrace(originStackTraceError) <code>LogEntryBuilder</code>

Parses the provided error's stack trace and sets the log entry's origin & stack trace fields

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| --------------------- | ------------------ | ----------------------------------------------------------------------- |
| originStackTraceError | <code>Error</code> | The instance of a JavaScript `Error` object with a stack trace to parse |

<a name="LogEntryBuilder+addTag"></a>
<a name="addTag"></a>

### logEntryBuilder.addTag(tag) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## addTag(tag) <code>LogEntryBuilder</code>

Appends the tag to the existing list of tags

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ----- | ------------------- | ---------------------------------------------------- |
| tag | <code>String</code> | The string to add as a tag for the current log entry |

<a name="LogEntryBuilder+addTags"></a>
<a name="addTags"></a>

### logEntryBuilder.addTags(tags) [<code>LogEntryBuilder</code>](#LogEntryBuilder)
## addTags(tags) <code>LogEntryBuilder</code>

Appends the tag to the existing list of tags

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Returns**: [<code>LogEntryBuilder</code>](#LogEntryBuilder) - The same instance of `LogEntryBuilder`, useful for chaining methods
**Kind**: global function
**Returns**: <code>LogEntryBuilder</code> - The same instance of `LogEntryBuilder`, useful for chaining methods

| Param | Type | Description |
| ----- | --------------------------------- | -------------------------------------------------------- |
| tags | <code>Array.&lt;String&gt;</code> | The list of strings to add as tags for the current entry |

<a name="LogEntryBuilder+getComponentLogEntry"></a>
<a name="getComponentLogEntry"></a>

### logEntryBuilder.getComponentLogEntry() <code>ComponentLogEntry</code>
## getComponentLogEntry() <code>ComponentLogEntry</code>

Returns the object used to save log entry data

**Kind**: instance method of [<code>LogEntryBuilder</code>](#LogEntryBuilder)
**Kind**: global function
**Returns**: <code>ComponentLogEntry</code> - An instance of `ComponentLogEntry` that matches the Apex class `ComponentLogger.ComponentLogEntry`
Loading

0 comments on commit f43a62b

Please sign in to comment.