Skip to content

Commit fb62082

Browse files
committed
also do for replay
1 parent eb29c74 commit fb62082

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestUrl
103103
'User-Agent': expect.stringContaining(''),
104104
},
105105
},
106+
user: {
107+
ip_address: '{{auto}}',
108+
},
106109
platform: 'javascript',
107110
});
108111
});

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ sentryTest(
101101
headers: expect.any(Object),
102102
url: expect.any(String),
103103
},
104+
user: {
105+
ip_address: '{{auto}}',
106+
},
104107
sdk: expect.any(Object),
105108
spans: [
106109
{

dev-packages/browser-integration-tests/suites/public-api/withScope/nested_scopes/test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ sentryTest('should allow nested scoping', async ({ getLocalTestUrl, page }) => {
1010
const eventData = await getMultipleSentryEnvelopeRequests<Event>(page, 5, { url });
1111

1212
expect(eventData[0].message).toBe('root_before');
13-
expect(eventData[0].user).toEqual({ id: 'qux' });
13+
expect(eventData[0].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
1414
expect(eventData[0].tags).toBeUndefined();
1515

1616
expect(eventData[1].message).toBe('outer_before');
17-
expect(eventData[1].user).toEqual({ id: 'qux' });
17+
expect(eventData[1].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
1818
expect(eventData[1].tags).toMatchObject({ foo: false });
1919

2020
expect(eventData[2].message).toBe('inner');
21-
expect(eventData[2].user).toBeUndefined();
21+
expect(eventData[2].user).toEqual({ ip_address: '{{auto}}' });
2222
expect(eventData[2].tags).toMatchObject({ foo: false, bar: 10 });
2323

2424
expect(eventData[3].message).toBe('outer_after');
25-
expect(eventData[3].user).toEqual({ id: 'baz' });
25+
expect(eventData[3].user).toEqual({ id: 'baz', ip_address: '{{auto}}' });
2626
expect(eventData[3].tags).toMatchObject({ foo: false });
2727

2828
expect(eventData[4].message).toBe('root_after');
29-
expect(eventData[4].user).toEqual({ id: 'qux' });
29+
expect(eventData[4].user).toEqual({ id: 'qux', ip_address: '{{auto}}' });
3030
expect(eventData[4].tags).toBeUndefined();
3131
});

dev-packages/browser-integration-tests/suites/replay/captureReplay/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ sentryTest('should capture replays (@sentry/browser export)', async ({ getLocalT
5555
'User-Agent': expect.stringContaining(''),
5656
},
5757
},
58+
user: {
59+
ip_address: '{{auto}}',
60+
},
5861
platform: 'javascript',
5962
});
6063

dev-packages/browser-integration-tests/suites/replay/captureReplayFromReplayPackage/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ sentryTest('should capture replays (@sentry-internal/replay export)', async ({ g
5555
'User-Agent': expect.stringContaining(''),
5656
},
5757
},
58+
user: {
59+
ip_address: '{{auto}}',
60+
},
5861
platform: 'javascript',
5962
});
6063

dev-packages/browser-integration-tests/utils/replayEventTemplates.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const DEFAULT_REPLAY_EVENT = {
3737
'User-Agent': expect.any(String),
3838
},
3939
},
40+
user: {
41+
ip_address: '{{auto}}',
42+
},
4043
platform: 'javascript',
4144
};
4245

packages/replay-internal/src/util/prepareReplayEvent.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,15 @@ export async function prepareReplayEvent({
5555
version: version || '0.0.0',
5656
};
5757

58+
// By default, we want to infer the IP address, unless this is explicitly set to `null`
59+
// We do this after all other processing is done
60+
// If `ip_address` is explicitly set to `null` or a value, we leave it as is
61+
if (preparedEvent.user?.ip_address === undefined) {
62+
preparedEvent.user = {
63+
...preparedEvent.user,
64+
ip_address: '{{auto}}',
65+
};
66+
}
67+
5868
return preparedEvent;
5969
}

0 commit comments

Comments
 (0)