Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Log__c & LoggerSettings__c fields #218

Merged
merged 34 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2fd95b3
Added new field Log__c.Scenario__c, set via Logger.setScenario(String)
jongpie Sep 30, 2021
e444731
Added support for setting scenario via Flow classes
jongpie Oct 6, 2021
66cf459
Added support for setting scenario via logger lwc
jongpie Oct 6, 2021
3b17f45
Added example usage of setScenario in loggerLWCDemo.js
jongpie Oct 6, 2021
db9ecb3
Bumped package version number
jongpie Oct 6, 2021
c0cfdef
Created new package version
jongpie Oct 6, 2021
98870aa
Added Logger.CURRENT_VERSION_NUMBER, added new script to auto-sync ve…
jongpie Oct 7, 2021
accaf94
Added new field Log__c.LoggerVersionNumber__c
jongpie Oct 7, 2021
db86893
Standardized the internal calls to System.debug() to include a 'Logge…
jongpie Oct 7, 2021
dcf5bf7
Created new package version
jongpie Oct 7, 2021
e30ab43
Cleaned up scripts directory
jongpie Oct 7, 2021
926ec5e
Added 2 new LoggerSettings__c fields - one to disable calls to System…
jongpie Oct 7, 2021
707e10d
Added check in pipeline to ensure that the current package version nu…
jongpie Oct 9, 2021
57cce12
Updated CONTRIBUTING.md
jongpie Oct 9, 2021
76bc075
Automated creating pkg version and updating sfdx-project.json + READM…
jongpie Oct 10, 2021
568e4f2
Fixed some JS lint issues + enabled more lint rules
jongpie Oct 10, 2021
81534bf
Fixed some Apex PMD issues + enabled more PMD rules
jongpie Oct 10, 2021
d396f4c
Updated deploy.yml so it checks out the PR branch instead of the commit
jongpie Oct 10, 2021
df23254
Added pwsh script to verify that Apex docs have been generated & comm…
jongpie Oct 10, 2021
10f1b42
Created new package version
actions-user Oct 10, 2021
949ec59
Updated version name & description to better reflect the included cha…
jongpie Oct 10, 2021
7c34bd2
Created new package version
actions-user Oct 10, 2021
7f26a72
Added missing step to install package version into demo sandbox
jongpie Oct 11, 2021
d1ca055
Fixed #224 by adding a check for UserInfo.getSessionId() to avoid a g…
jongpie Oct 11, 2021
35e53b5
Created new package version
actions-user Oct 11, 2021
0b3a2bb
Created new package version
actions-user Oct 11, 2021
a03a7e8
Fixed #223 by adding an extra filter in Log__c query to include/delet…
jongpie Oct 12, 2021
8951dfb
Created new package version
actions-user Oct 12, 2021
48fb053
New buttons for package install links & 'view milestone' in README
jongpie Oct 14, 2021
8bdacaf
Created new package version
actions-user Oct 14, 2021
a8860c4
Added missing 'default save method' field to settings list view, shor…
jongpie Oct 14, 2021
2c6b575
Created new package version
actions-user Oct 14, 2021
487bd0c
Added missing check for isConsoleLoggingEnabled is logger.js
jongpie Oct 14, 2021
a497f89
Created new package version
actions-user Oct 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,66 @@
"plugins": ["@lwc/eslint-plugin-lwc", "@salesforce/eslint-plugin-aura"],
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"rules": {
"eqeqeq": "warn",
"no-console": "off",
"no-unused-expressions": "warn",
"semi": "warn",
"@lwc/lwc/consistent-component-name": "error",
"@lwc/lwc/no-api-reassignments": "off",
"@lwc/lwc/no-async-operation": "warn",
"@lwc/lwc/no-api-reassignments": "error",
"@lwc/lwc/no-async-operation": "error",
"@lwc/lwc/no-attributes-during-construction": "error",
"@lwc/lwc/no-deprecated": "error",
"@lwc/lwc/no-document-query": "error",
"@lwc/lwc/valid-api": "error"
"@lwc/lwc/no-dupe-class-members": "error",
"@lwc/lwc/no-inner-html": "error",
"@lwc/lwc/no-leading-uppercase-api-name": "error",
"@lwc/lwc/prefer-custom-event": "error",
"@lwc/lwc/valid-api": "error",
"array-callback-return": "error",
"consistent-return": "error",
"default-case": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"no-alert": "error",
"no-caller": "error",
"no-confusing-arrow": "error",
"no-console": "error",
"no-else-return": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-loop-func": "error",
"no-multi-str": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
"no-shadow": "error",
"no-throw-literal": "error",
"no-undef-init": "error",
"no-unused-expressions": "error",
"no-unused-vars": "error",
"no-use-before-define": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-void": "error",
"no-with": "error",
"radix": "error",
"semi": "error",
"vars-on-top": "error",
"wrap-iife": "error"
}
}
54 changes: 36 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- 'devops/**'
paths-ignore:
- 'content/**'
- 'docs/**'
Expand All @@ -14,7 +15,7 @@ on:
- '.gitignore'
- '.prettierignore'
- '.prettierrc'
- 'Contributing.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'package.json'
- 'README.md'
Expand All @@ -31,7 +32,7 @@ on:
- '.gitignore'
- '.prettierignore'
- '.prettierrc'
- 'Contributing.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'package.json'
- 'README.md'
Expand All @@ -40,7 +41,7 @@ on:

jobs:
code-quality-tests:
name: 'Code Quality Tests'
name: 'Run Code Quality Tests'
runs-on: ubuntu-latest
environment: Test
steps:
Expand All @@ -64,17 +65,29 @@ jobs:
- name: 'Install Salesforce CLI'
run: npm install sfdx-cli --global

- name: 'LWC Lint verification'
- name: 'Verify package version number is updated'
run: |
echo ${{ env.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt
sfdx auth:sfdxurl:store --sfdxurlfile ./DEVHUB_SFDX_URL.txt --setalias nebula-logger-packaging --setdefaultdevhubusername
rm ./DEVHUB_SFDX_URL.txt
npm run package:version:number:verify
env:
DEVHUB_SFDX_URL: ${{ secrets.DEVHUB_SFDX_URL }}

- name: 'Verify LWC with ESLint'
run: npm run lint:verify

- name: 'Apex SFDX Scanner verification'
run: npm run prepare && npm run scan
- name: 'Verify Apex with SFDX Scanner'
run: npm run scan

- name: 'Verify docs are updated'
run: npm run docs:verify

- name: 'Prettier formatting verification'
- name: 'Verify formatting with Prettier'
run: npm run prettier:verify

lwc-tests:
name: 'LWC Tests'
name: 'Run LWC Tests'
needs: [code-quality-tests]
runs-on: ubuntu-latest
environment: Test
Expand Down Expand Up @@ -106,7 +119,7 @@ jobs:
flags: LWC

scratch-org-tests:
name: 'Scratch Org Tests'
name: 'Run Scratch Org Tests'
needs: [code-quality-tests]
runs-on: ubuntu-latest
environment: Test
Expand Down Expand Up @@ -181,15 +194,17 @@ jobs:
run: npm run org:delete:noprompt
if: ${{ always() }}

create-and-install-test-package-version:
name: 'Create & Install Test Package Version'
create-and-install-package-version:
name: 'Create & Install Package Version'
needs: [lwc-tests, scratch-org-tests]
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
environment: Test
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: 'Restore node_modules cache'
id: cache-npm
Expand Down Expand Up @@ -222,11 +237,14 @@ jobs:
sfdx auth:sfdxurl:store --sfdxurlfile ./DEVHUB_SFDX_URL.txt --setalias nebula-logger-packaging --setdefaultdevhubusername
sfdx auth:sfdxurl:store --sfdxurlfile ./NEBULA_PKG_DEMO_SANDBOX_SFDX_URL.txt --setalias nebula-logger-package-demo

- name: 'Create & Install Unvalidated Package Version'
run: npx pwsh ./scripts/create-and-install-unvalidated-package-version.ps1 -targetusername nebula-logger-package-demo
- name: 'Create & Install Package Version'
run: npx pwsh ./scripts/build/create-and-install-package-version.ps1 -targetusername nebula-logger-package-demo

- name: 'Reinstall Latest Released Package Version'
run: npx pwsh ./scripts/install-latest-released-unlocked-package-version.ps1 -targetusername nebula-logger-package-demo

- name: 'Delete Unvalidated Package Version'
run: npx pwsh ./scripts/delete-unvalidated-package-version.ps1
- name: 'Commit New Package Version'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta try this stuff out!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coming along nicely - the last issue I'm trying to figure out is with the PR status checks. When this step runs a commit/push, it ends up clearing the PR status checks for the build, codecov, etc. If I can't get that figured out soon, I might revert some of these changes for now/finish in a future PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah. If you see my pipeline, I made the codecov check not required and because the commit has the same name as the required status check, it ends up … checking out … so to speak. That was a hack to still have at least one required check while still automating the recommit

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense - and I guess it's not a huge deal if the PR status checks get cleared, they're only getting cleared if everything in the pipeline works successfully, so maybe I won't worry about it for now. Plus, having the package creation automated is incredibly nice - I've spent so much extra time manually running those steps (create package version, updated README, install in a test sandbox, etc.), so I'll probably keep the pipeline as-is, and maybe worry about the status checks later.

run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action Bot"
npx prettier --write ./sfdx-project.json
git add ./sfdx-project.json
git commit -m "Created new package version"
git push
30 changes: 24 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# Contributing / Development
# Contributing

Contributions to Nebula Logger are welcome, however we ask that Apex Prettier be run on prior to any pull requests being submitted to this repo.
Contributions to Nebula Logger are welcome - following these guidelines will help make it easier & faster to review & merge any changes you want to contribute. When contributing, the typical process is:

When developing, to get started:
1. Familiarize yourself with the codebase - you can check out the [wiki](https://github.com/jongpie/NebulaLogger/wiki) and the [Apex docs site](https://jongpie.github.io/NebulaLogger/) to learn more about the code.
2. Before starting your work, create a new issue (or add a comment to an existing issue you want to contribute to) so that we can keep track of who is actively working on an item.
3. Fork this repository.
4. Create a `feature` or `bugfix` branch in your fork based on the `main` branch.
5. Edit the code/metadata in your fork.
6. Send us a pull request when you are done. We'll review your code, provide feedback for any suggestions or required changes, and then merge it when everything is ready.

- run `npm -i` or `npm install` or `yarn` to grab the latest version of our dependencies
- when using VS Code: ensure that your "Format On Save" editor option is set to `true` (in `settings.json`: `"editor.formatOnSave": true`)
- all unit tests should be run and passing prior to submitting a PR
# Development

Once you're ready to start working on an issue, you can develop your changes in any scratch org, sandbox, or developer-edition org of your choosing. Using SFDX (Salesforce CLI), VS Code and npm are recommended - this repository includes several scripts and automations using these tools. However, you can use any tools that you prefer, so long as the resulting code changes still conform to the repository's coding standards.

- Clone your fork of the Nebula Logger repository locally
- Run `npm -i` or `npm install` to grab the latest version of our dependencies, and setup the repository's git hooks
- When committing your changes in `git`, the repository's git hooks automatically run to:
1. Automatically fix/standardize some quality standards - for example, all Apex files will automatically be formatted using `prettier`
2. Automatically verify coding standards - for example, all Apex files will be automatically scanned for PMD rule violations, based on the repository's configured PMD rules.
- Run all unit tests for LWC and Apex, and verify everything is passing prior to submitting a pull request

# Pull Requests

- All pull requests should use the `main` branch as the base branch
- Your pull request should have a detailed description that describes your changes, and include any screenshots of noteworthy UI changes (when applicable)
- Pull request merging is restricted to only 'squash and merge'
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@

Designed for Salesforce admins, developers & architects. A robust logger for Apex, Lightning Components, Flow, Process Builder & Integrations.

[![Install Unlocked Package](./content/btn-install-unlocked-package.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015kqtQAA)
[![Install Managed Package](./content/btn-install-managed-package.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015keOQAQ)
## Unlocked Package v4.6.10

[![Install Unlocked Package](./content/btn-install-unlocked-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015l27QAA)
[![Install Unlocked Package](./content/btn-install-unlocked-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015l27QAA)
[![View Documentation](./content/btn-view-documentation.png)](https://jongpie.github.io/NebulaLogger/)

## Managed Package v4.6.0

[![Install Managed Package](./content/btn-install-managed-package-sandbox.png)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015keOQAQ)
[![Install Managed Package](./content/btn-install-managed-package-production.png)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y0000015keOQAQ)
[![View Milestone](./content/btn-view-managed-package-milestone.png)](https://github.com/jongpie/NebulaLogger/milestone/6)

---

## Features

1. Easily add log entries via Apex, Lightning Components (lwc & aura), Flow & Process Builder to generate 1 consolidate log
1. Easily add log entries via Apex, Lightning Components (lwc & aura), Flow & Process Builder to generate 1 consolidated, unified log
2. Manage & report on logging data using the `Log__c` and `LogEntry__c` objects
3. Leverage `LogEntryEvent__e` platform events for real-time monitoring & integrations
4. Enable logging and set the logging level for different users & profiles using `LoggerSettings__c` custom hierarchy setting
Expand Down Expand Up @@ -683,8 +691,6 @@ Once you've created your Apex or Flow plugin(s), you will also need to configure
- 'Logger Plugin' - use the custom metadata type `LoggerPlugin__mdt` to define your plugin, including the plugin type (Apex or Flow) and the API name of your plugin's Apex class or Flow
- 'Logger Parameter' - use the custom metadata type `LoggerParameter__mdt` to define any configurable parameters needed for your plugin, such as environment-specific URLs and other similar configurations

![Logger plugin: configuration](./content/slack-plugin-configuration.png)

Note: the logger plugin framework is not available in the managed package due to some platform limitations & considerations with some of the underlying code. The unlocked package is recommended (instead of the managed package) when possible, including if you want to be able to leverage the plugin framework in your org.

### Beta Plugin: Slack Integration
Expand All @@ -698,7 +704,7 @@ The optional [Slack plugin](./nebula-logger-plugins/Slack/) leverages the Nebula

Check out the [Slack plugin](./nebula-logger-plugins/Slack/) for more details on how to install & customize the plugin

![Slack plugin: notification](./content/slack-plugin-notification.png)
![Slack plugin: notification](./nebula-logger-plugins/Slack/.content/slack-plugin-notification.png)

---

Expand Down
17 changes: 0 additions & 17 deletions config/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,14 @@
<exclude name="AvoidLogicInTrigger" />
</rule>
<rule ref="category/apex/codestyle.xml">
<exclude name="FieldNamingConventions" />
<exclude name="MethodNamingConventions" />
<exclude name="PropertyNamingConventions" />
<exclude name="VariableNamingConventions" />
</rule>
<rule ref="category/apex/design.xml">
<exclude name="AvoidDeeplyNestedIfStmts" />
<exclude name="CognitiveComplexity" />
<exclude name="CyclomaticComplexity" />
<exclude name="ExcessiveClassLength" />
<exclude name="ExcessiveParameterList" />
<exclude name="ExcessivePublicCount" />
<exclude name="NcssConstructorCount" />
<exclude name="NcssMethodCount" />
<exclude name="StdCyclomaticComplexity" />
<exclude name="TooManyFields" />
</rule>
<rule ref="category/apex/documentation.xml">
<exclude name="ApexDoc" />
</rule>
<rule ref="category/apex/errorprone.xml">
<exclude name="EmptyStatementBlock" />
</rule>
<rule ref="category/apex/performance.xml">
<exclude name="AvoidDebugStatements" />
</rule>
<rule ref="category/apex/security.xml">
</rule>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/btn-install-managed-package-sandbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified content/btn-install-unlocked-package.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/btn-view-managed-package-milestone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/configuration/LoggerParameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ Provides a centralized way to load parameters for SObject handlers &amp; plugins

#### `CALL_STATUS_API` → `Boolean`

Indicates if Logger will make an async callout to https://api.status.salesforce.com to get additional details about the current org, which is then stored on the Log\_\_c record. Controlled by the custom metadata record LoggerParamer.CallStatusApi @return The configured value, or `false` as the default

#### `ENABLE_SYSTEM_MESSAGES` → `Boolean`

Indicates if Logger will append its own log entries about the logging system. Controlled by the custom metadata record LoggerParamer.EnableLoggerSystemMessages @return The configured value, or `false` as the default

#### `SYSTEM_DEBUG_MESSAGE_FORMAT` → `String`

The merge-field syntax to use when calling System.debug(). Controlled by the custom metadata record LoggerParamer.SystebugMessageFormat @return The configured value, or `{OriginLocation__c}\n{Message__c}` as the default

#### `TAGGING_IS_ENABLED` → `Boolean`

Indicates if Logger&apos;s tagging system is enabled. Controlled by the custom metadata record LoggerParamer.EnableTagging @return The configured value, or `true` as the default

#### `TAG_USING_TOPICS` → `Boolean`

Indicates if Logger&apos;s tagging will use Topic and TopicAssignment for storing tags @return The configured value, or `false` as the default

---

### Methods
Expand Down
12 changes: 10 additions & 2 deletions docs/logger-engine/ComponentLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ The value to use as the log entry&apos;s message

(Optional) The record ID to relate to the log entry

###### `scenario` → `String`

Optionally specify the name to use for the current transaction&apos;s scenario

###### `stack` → `String`

The JavaScript stack trace from when the log entry was created
Expand All @@ -126,17 +130,21 @@ A DTO object used for passing `LoggerSettings__c` details to lightning component

##### Properties

###### `isConsoleLoggingEnabled` → `Boolean`

Indicates if logging via the browser&apos;s `console.log()` is enabled for the current user, based on `Logger.IsComponentConsoleLoggingEnabled__c`

###### `isEnabled` → `Boolean`

Indicates if logging is enabled for the current user, based on `Logger.isEnabled()`
Indicates if logging is enabled for the current user, based on `LoggerSettings__c.IsEnabled__c`

###### `supportedLoggingLevels` → `Map<String, Integer>`

A map of the supported `LoggingLevel` enum values

###### `userLoggingLevel` → `ComponentLoggingLevel`

The configured `LoggingLevel` for the current user, based on `Logger.getUserLoggingLevel()`
The configured `LoggingLevel` for the current user, based on `LoggerSettings__c.LoggingLevel__c`

---

Expand Down
4 changes: 4 additions & 0 deletions docs/logger-engine/FlowCollectionLogEntry.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The records to relate to this log entry - the records&apos; JSON is automaticall

Optionally choose to save any pending log entries

#### `scenario` → `String`

Optionally specify the name to use for the current transaction&apos;s scenario

#### `tagsString` → `String`

Optionally provide a comma-separated String of tags to dynamically assign to the log entry
Expand Down
4 changes: 4 additions & 0 deletions docs/logger-engine/FlowLogEntry.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Optionally relate the log entry to a particular record ID

Optionally choose to save any pending log entries.

#### `scenario` → `String`

Optionally specify the name to use for the current transaction&apos;s scenario

#### `tagsString` → `String`

Optionally provide a comma-separated String of tags to dynamically assign to the log entry
Expand Down
4 changes: 4 additions & 0 deletions docs/logger-engine/FlowLogger.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ General message to log.

boolean used to determine if logs are saved to Salesforce.

###### `scenario` → `String`

Optionally specify the name to use for the current transaction&apos;s scenario

###### `tagsString` → `String`

String of tags / topics.
Expand Down
Loading