Skip to content

Commit 472c228

Browse files
authored
ref(nuxt): Revert Sentry Pinia plugin (#14134)
reverts #14047 This change needs to be re-evaluated as it currently adds bundle size for all users.
1 parent c98377b commit 472c228

File tree

8 files changed

+6
-195
lines changed

8 files changed

+6
-195
lines changed

dev-packages/e2e-tests/test-applications/nuxt-4/app/pages/pinia-cart.vue

Lines changed: 0 additions & 73 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/nuxt-4/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineNuxtConfig({
44
compatibilityDate: '2024-04-03',
55
imports: { autoImport: false },
66

7-
modules: ['@pinia/nuxt', '@sentry/nuxt/module'],
7+
modules: ['@sentry/nuxt/module'],
88

99
runtimeConfig: {
1010
public: {

dev-packages/e2e-tests/test-applications/nuxt-4/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"test:assert": "pnpm test"
1515
},
1616
"dependencies": {
17-
"@pinia/nuxt": "^0.5.5",
1817
"@sentry/nuxt": "latest || *",
1918
"nuxt": "^3.13.2"
2019
},

dev-packages/e2e-tests/test-applications/nuxt-4/sentry.client.config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,4 @@ Sentry.init({
77
tunnel: `http://localhost:3031/`, // proxy server
88
tracesSampleRate: 1.0,
99
trackComponents: true,
10-
trackPinia: {
11-
actionTransformer: action => `Transformed: ${action}`,
12-
stateTransformer: state => ({
13-
transformed: true,
14-
...state,
15-
}),
16-
},
1710
});

dev-packages/e2e-tests/test-applications/nuxt-4/stores/cart.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

dev-packages/e2e-tests/test-applications/nuxt-4/tests/pinia.test.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/nuxt/src/common/types.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
import type { init as initNode } from '@sentry/node';
22
import type { SentryRollupPluginOptions } from '@sentry/rollup-plugin';
33
import type { SentryVitePluginOptions } from '@sentry/vite-plugin';
4-
import type { createSentryPiniaPlugin, init as initVue } from '@sentry/vue';
4+
import type { init as initVue } from '@sentry/vue';
55

66
// Omitting 'app' as the Nuxt SDK will add the app instance in the client plugin (users do not have to provide this)
7-
export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & object, 'app'> & {
8-
/**
9-
* Control if an existing Pinia store should be monitored.
10-
* Set this to `true` to track with default options or provide your custom Pinia plugin options.
11-
*
12-
* This only works if "@pinia/nuxt" is added to the `modules` array.
13-
*
14-
* @default false
15-
*/
16-
trackPinia?: true | Parameters<typeof createSentryPiniaPlugin>[0];
17-
};
18-
7+
export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & object, 'app'>;
198
export type SentryNuxtServerOptions = Omit<Parameters<typeof initNode>[0] & object, 'app'>;
209

2110
type SourceMapsOptions = {

packages/nuxt/src/runtime/plugins/sentry.client.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getClient } from '@sentry/core';
2-
import { consoleSandbox } from '@sentry/utils';
3-
import { browserTracingIntegration, createSentryPiniaPlugin, vueIntegration } from '@sentry/vue';
2+
import { browserTracingIntegration, vueIntegration } from '@sentry/vue';
43
import { defineNuxtPlugin } from 'nuxt/app';
54
import { reportNuxtError } from '../utils';
65

@@ -35,36 +34,18 @@ export default defineNuxtPlugin({
3534
name: 'sentry-client-integrations',
3635
dependsOn: ['sentry-client-config'],
3736
async setup(nuxtApp) {
38-
const sentryClient = getClient();
39-
const clientOptions = sentryClient && sentryClient.getOptions();
40-
4137
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside
4238
// will get tree-shaken away
4339
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
40+
const sentryClient = getClient();
41+
4442
if (sentryClient && '$router' in nuxtApp) {
4543
sentryClient.addIntegration(
4644
browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }),
4745
);
4846
}
4947
}
5048

51-
if (clientOptions && 'trackPinia' in clientOptions && clientOptions.trackPinia) {
52-
if ('$pinia' in nuxtApp) {
53-
(nuxtApp.$pinia as { use: (plugin: unknown) => void }).use(
54-
// `trackPinia` is an object with custom options or `true` (pass `undefined` to use default options)
55-
createSentryPiniaPlugin(clientOptions.trackPinia === true ? undefined : clientOptions.trackPinia),
56-
);
57-
} else {
58-
clientOptions.debug &&
59-
consoleSandbox(() => {
60-
// eslint-disable-next-line no-console
61-
console.warn(
62-
'[Sentry] You set `trackPinia`, but the Pinia module was not found. Make sure to add `"@pinia/nuxt"` to your modules array.',
63-
);
64-
});
65-
}
66-
}
67-
6849
nuxtApp.hook('app:created', vueApp => {
6950
const sentryClient = getClient();
7051

0 commit comments

Comments
 (0)