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

fix: Only set ip.address: '{{auto}}' when sendDefaultPii: true #1079

Merged
merged 2 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions src/main/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ export function init(userOptions: ElectronMainOptions): void {

const client = new NodeClient(options);

client.on('postprocessEvent', addAutoIpAddressToUser);
client.on('beforeSendSession', addAutoIpAddressToSession);
if (options.sendDefaultPii === true) {
client.on('postprocessEvent', addAutoIpAddressToUser);
client.on('beforeSendSession', addAutoIpAddressToSession);
}

scope.setClient(client);
client.init();
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/test-apps/other/no-pii/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Event } from '@sentry/core';
import { expect } from 'vitest';

import { TestServerEvent } from '../../../server';

export async function execute(events: TestServerEvent<Event>[]): Promise<void> {
expect(events.length).greaterThanOrEqual(1);

for (const event of events) {
expect(event.data.user?.ip_address).toBeUndefined();
}
}
8 changes: 8 additions & 0 deletions test/e2e/test-apps/other/no-pii/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "javascript-no-pii",
"version": "1.0.0",
"main": "src/main.js",
"dependencies": {
"@sentry/electron": "5.6.0"
}
}
3 changes: 3 additions & 0 deletions test/e2e/test-apps/other/no-pii/recipe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
description: No PII
category: JavaScript
command: yarn
19 changes: 19 additions & 0 deletions test/e2e/test-apps/other/no-pii/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<script>
const { init } = require('@sentry/electron/renderer');

init({
debug: true,
});

setTimeout(() => {
throw new Error('Some renderer error');
}, 500);
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions test/e2e/test-apps/other/no-pii/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require('path');

const { app, BrowserWindow } = require('electron');
const { init } = require('@sentry/electron/main');

init({
dsn: '__DSN__',
debug: true,
integrations: (integrations) => integrations.filter((i) => i.name !== 'MainProcessSession'),
onFatalError: () => {},
});

app.on('ready', () => {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});

mainWindow.loadFile(path.join(__dirname, 'index.html'));
});
Loading