Skip to content

Commit ec78a02

Browse files
author
Luca Forstner
committed
adress review
1 parent ec70b54 commit ec78a02

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/react/src/redux.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,17 @@ function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>):
108108
if (typeof transformedState !== 'undefined' && transformedState !== null) {
109109
const client = getCurrentHub().getClient();
110110
const options = client && client.getOptions();
111-
const normalizationDepth = options && options.normalizeDepth;
111+
const normalizationDepth = (options && options.normalizeDepth) || 3; // default state normalization depth to 3
112112

113113
// Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback
114+
const newStateContext = { state: { type: 'redux', value: transformedState } };
114115
addNonEnumerableProperty(
115-
transformedState,
116+
newStateContext,
116117
'__sentry_override_normalization_depth__',
117-
normalizationDepth || 3,
118+
3 + // 3 layers for `state.value.transformedState`
119+
normalizationDepth, // rest for the actual state
118120
);
119121

120-
// Make sure the state is always reached during normalization
121-
const newStateContext = { state: { type: 'redux', value: transformedState } };
122-
addNonEnumerableProperty(newStateContext, '__sentry_override_normalization_depth__', 3);
123-
124122
scope.setContext('state', newStateContext);
125123
} else {
126124
scope.setContext('state', null);

packages/utils/src/normalize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function visit(
105105
// have already been normalized.
106106
let overriddenDepth = depth;
107107

108-
if ((value as ObjOrArray<unknown>)['__sentry_override_normalization_depth__']) {
108+
if (typeof (value as ObjOrArray<unknown>)['__sentry_override_normalization_depth__'] === 'number') {
109109
overriddenDepth = (value as ObjOrArray<unknown>)['__sentry_override_normalization_depth__'] as number;
110110
}
111111

0 commit comments

Comments
 (0)