Skip to content

sdk-core, node: In memory proper attribute filtering#368

Open
konraddysput wants to merge 1 commit intomainfrom
bugfix/in-memory-attribute-support
Open

sdk-core, node: In memory proper attribute filtering#368
konraddysput wants to merge 1 commit intomainfrom
bugfix/in-memory-attribute-support

Conversation

@konraddysput
Copy link
Copy Markdown
Collaborator

Why

Per @GT1990 comment, InMemoryAttributes are not covered. Therefore, I decided to move the implementation to the BreacrumbManager and always pass prepared attributes to the storage.

Comment on lines +236 to +245
const unknownValue = value as unknown;
try {
if (unknownValue instanceof Date) {
result[key] = unknownValue.toISOString();
} else if (unknownValue instanceof URL) {
result[key] = unknownValue.toString();
}
} catch {
// revoked proxy or broken object — drop it
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you would extract switch to a separate method, you could try/catch for result[key] = prepareSingleAttribute(unknownValue.toJSON());, if toJSON method is available. URL and Date return toString() and toISOString() respectively under toJSON, so you would have them handled, and potentially other things.

Be sure to limit the depth in case of toJSON returning a value that is the same object, or also a value that has a toJSON function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

limitObjectDepth should be enough. I removed this change because the problem was existing somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants