diff --git a/CHANGELOG.md b/CHANGELOG.md index f717d595b..f42ed0feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- feat(angular): Set `sendDefaultPii: true` by default ([#1057](https://github.com/getsentry/sentry-wizard/pull/1057)) - feat(nextjs): Update turbopack warning ([#1089](https://github.com/getsentry/sentry-wizard/pull/1089)) - feat(nextjs): Set `sendDefaultPii: true` by default ([#1052](https://github.com/getsentry/sentry-wizard/pull/1052)) - feat(nuxt): Set `sendDefaultPii: true` by default ([#1060](https://github.com/getsentry/sentry-wizard/pull/1060)) diff --git a/e2e-tests/tests/angular-17.test.ts b/e2e-tests/tests/angular-17.test.ts index ad64a2b17..fef7b145f 100644 --- a/e2e-tests/tests/angular-17.test.ts +++ b/e2e-tests/tests/angular-17.test.ts @@ -233,6 +233,7 @@ function checkAngularProject( 'replaysSessionSampleRate: 0.1', 'replaysOnErrorSampleRate: 1', 'enableLogs: true', + 'sendDefaultPii: true', ]); }); diff --git a/e2e-tests/tests/angular-19.test.ts b/e2e-tests/tests/angular-19.test.ts index ed7037fdc..0894c3f61 100644 --- a/e2e-tests/tests/angular-19.test.ts +++ b/e2e-tests/tests/angular-19.test.ts @@ -231,6 +231,7 @@ function checkAngularProject( 'replaysSessionSampleRate: 0.1', 'replaysOnErrorSampleRate: 1', 'enableLogs: true', + 'sendDefaultPii: true', ]); }); diff --git a/src/angular/codemods/main.ts b/src/angular/codemods/main.ts index 787088d0d..a8fa0790b 100644 --- a/src/angular/codemods/main.ts +++ b/src/angular/codemods/main.ts @@ -99,6 +99,8 @@ export function getInitCallArgs( initCallArgs.enableLogs = true; } + initCallArgs.sendDefaultPii = true; + return initCallArgs; } diff --git a/test/angular/angular-wizard.test.ts b/test/angular/angular-wizard.test.ts index 64c240946..e58071a94 100644 --- a/test/angular/angular-wizard.test.ts +++ b/test/angular/angular-wizard.test.ts @@ -1,30 +1,135 @@ import { describe, expect, it, vi } from 'vitest'; import { buildOutroMessage } from '../../src/angular/angular-wizard'; +import { getInitCallArgs } from '../../src/angular/codemods/main'; vi.mock('../../src/utils/clack/mcp-config', () => ({ offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined), })); -describe('buildOutroMessage', () => { - it('returns the correct outro message if example component was created', () => { - expect(buildOutroMessage(true)).toMatchInlineSnapshot(` - " - Successfully installed the Sentry Angular SDK! +describe('angular-wizard', () => { + describe('buildOutroMessage', () => { + it('returns the correct outro message if example component was created', () => { + expect(buildOutroMessage(true)).toMatchInlineSnapshot(` + " + Successfully installed the Sentry Angular SDK! - You can validate your setup by starting your dev environment (ng serve) and throwing an error in the example component. + You can validate your setup by starting your dev environment (ng serve) and throwing an error in the example component. - Check out the SDK documentation for further configuration: - https://docs.sentry.io/platforms/javascript/guides/angular/" - `); + Check out the SDK documentation for further configuration: + https://docs.sentry.io/platforms/javascript/guides/angular/" + `); + }); + it('returns the correct outro message if example component creation was skipped', () => { + expect(buildOutroMessage(false)).toMatchInlineSnapshot(` + " + Successfully installed the Sentry Angular SDK! + + Check out the SDK documentation for further configuration: + https://docs.sentry.io/platforms/javascript/guides/angular/" + `); + }); }); - it('returns the correct outro message if example component creation was skipped', () => { - expect(buildOutroMessage(false)).toMatchInlineSnapshot(` - " - Successfully installed the Sentry Angular SDK! - - Check out the SDK documentation for further configuration: - https://docs.sentry.io/platforms/javascript/guides/angular/" - `); + + describe('getInitCallArgs', () => { + it('returns the correct init call arguments when all features are enabled', () => { + const args = getInitCallArgs('https://example.com', { + performance: true, + replay: true, + logs: true, + }); + expect(args).toMatchInlineSnapshot(` + { + "dsn": "https://example.com", + "enableLogs": true, + "integrations": [ + {}, + {}, + ], + "replaysOnErrorSampleRate": 1, + "replaysSessionSampleRate": 0.1, + "sendDefaultPii": true, + "tracesSampleRate": 1, + } + `); + }); + + it('returns the correct init call arguments when performance is disabled', () => { + const args = getInitCallArgs('https://example.com', { + performance: false, + replay: true, + logs: true, + }); + + expect(args).toMatchInlineSnapshot(` + { + "dsn": "https://example.com", + "enableLogs": true, + "integrations": [ + {}, + ], + "replaysOnErrorSampleRate": 1, + "replaysSessionSampleRate": 0.1, + "sendDefaultPii": true, + } + `); + }); + + it('returns the correct init call arguments when replay is disabled', () => { + const args = getInitCallArgs('https://example.com', { + performance: true, + replay: false, + logs: true, + }); + + expect(args).toMatchInlineSnapshot(` + { + "dsn": "https://example.com", + "enableLogs": true, + "integrations": [ + {}, + ], + "sendDefaultPii": true, + "tracesSampleRate": 1, + } + `); + }); + + it('returns the correct init call arguments when logs are disabled', () => { + const args = getInitCallArgs('https://example.com', { + performance: true, + replay: true, + logs: false, + }); + + expect(args).toMatchInlineSnapshot(` + { + "dsn": "https://example.com", + "integrations": [ + {}, + {}, + ], + "replaysOnErrorSampleRate": 1, + "replaysSessionSampleRate": 0.1, + "sendDefaultPii": true, + "tracesSampleRate": 1, + } + `); + }); + + it('returns the correct init call arguments when all features are disabled', () => { + const args = getInitCallArgs('https://example.com', { + performance: false, + replay: false, + logs: false, + }); + + expect(args).toMatchInlineSnapshot(` + { + "dsn": "https://example.com", + "sendDefaultPii": true, + } + `); + }); }); });