Skip to content

Commit

Permalink
Merge branch 'develop' into 146-async-await
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed May 7, 2024
2 parents 34c2d06 + 3448946 commit 8acd4b1
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 91 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions examples/express-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Raygun + ExpressJS sample

This is a sample Express application to show how to use Raygun4Node and ExpressJS together.

This example uses the local `raygun4node` package in the project root directory by simply pointing to the root directory as a dependency in package.json:

```
"raygun": "file:../..",
```

## Run the sample

First, install the `raygun4node` package.

To do so, navigate to the project root directory, then:

npm install

Once the package is installed, set your API key in the sample's `config/default.json` and run:

npm install && npm start

in the subdirectory where you found this README.md file.

## Interesting files to look

- `app.js`
- Setup of Raygun (lines 9-12)
- Sets the user (lines 27-29)
- Attaches Raygun to Express (line 60)
- `routes/index.js`
- Tries to use a fake object, which bounces up to the Express handler (lines 11-15)
24 changes: 0 additions & 24 deletions examples/express-sample/readme.md

This file was deleted.

File renamed without changes.
29 changes: 24 additions & 5 deletions lib/raygun.messageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,37 @@ type UserMessageData = RawUserData | string | undefined;
const humanString = require("object-to-human-string");
const packageDetails = require("../package.json");

function filterKeys(obj: object, filters: string[]): object {
/**
* Filter properties in obj according to provided filters.
* Also removes any recursive self-referencing object.
* @param obj object to apply filter
* @param filters list of keys to filter
* @param explored Set that contains already explored nodes, used internally
*/
function filterKeys(
obj: object,
filters: string[],
explored: Set<object> | null = null,
): object {
if (!obj || !filters || typeof obj !== "object") {
return obj;
}

// create or update the explored set with the incoming object
const _explored = explored?.add(obj) || new Set([obj]);

// Make temporary copy of the object to avoid mutating the original
// Cast to Record<string, object> to enforce type check and avoid using any
const _obj = { ...obj } as Record<string, object>;
Object.keys(obj).forEach(function (i) {
if (filters.indexOf(i) > -1) {
delete _obj[i];

Object.keys(obj).forEach(function (key) {
// Remove child if:
// - the key is in the filter array
// - the value is already in the explored Set
if (filters.indexOf(key) > -1 || _explored.has(_obj[key])) {
delete _obj[key];
} else {
_obj[i] = filterKeys(_obj[i], filters);
_obj[key] = filterKeys(_obj[key], filters, _explored);
}
});
return _obj;
Expand Down
114 changes: 57 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.14.0",
"homepage": "https://github.com/MindscapeHQ/raygun4node",
"author": {
"name": "MindscapeHQ",
"name": "Raygun",
"email": "[email protected]"
},
"repository": {
Expand Down Expand Up @@ -44,8 +44,8 @@
"test": "tap --node-arg=-r --node-arg=ts-node/register --disable-coverage test/*_test.js"
},
"devDependencies": {
"@eslint/js": "^9.1.1",
"@types/node": "^20.12.7",
"@eslint/js": "^9.2.0",
"@types/node": "^20.12.8",
"@types/stack-trace": "0.0.33",
"@types/uuid": "^9.0.8",
"eslint": "^8.57.0",
Expand All @@ -58,7 +58,7 @@
"tap": "^18.7.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.1",
"typescript-eslint": "^7.8.0",
"verror": "^1.10.1"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 8acd4b1

Please sign in to comment.