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

[Nuxt] beforeSend() is not called #13588

Closed
3 tasks done
lud-hu opened this issue Sep 4, 2024 · 3 comments
Closed
3 tasks done

[Nuxt] beforeSend() is not called #13588

lud-hu opened this issue Sep 4, 2024 · 3 comments
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@lud-hu
Copy link

lud-hu commented Sep 4, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

8.28.0

Framework Version

Nuxt 3.13.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

import * as Sentry from "@sentry/nuxt";
import { useRuntimeConfig } from "#imports";

const sentryConfig = useRuntimeConfig().public.sentry;

Sentry.init({
  environment: sentryConfig.environment,
  release: sentryConfig.release,
  enabled: sentryConfig.enabled,
  dsn: sentryConfig.dsn,
  integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],
  debug: true,
  tracesSampleRate: 1.0,
  tracePropagationTargets: [],
  replaysSessionSampleRate: 0.2,
  replaysOnErrorSampleRate: 1.0,

  // Called for message and error events
  beforeSend(event) {
    console.log("Event", event); // Not visible in console :(
    if (event.user) {
      delete event.user.ip_address; // Does not have any effect on the event payload sent to sentry
      delete event.user.geo;
      delete event.user.sentry_user;
      event.user.test = "123";
    }
    return event;
  },
});

Steps to Reproduce

  1. e.g. create a button that throws an error
  2. the error will be sent to the sentry console
  3. check event payload there and see that all changes made in beforeSend() do not have any effect

Expected Result

The event payload can be modified in the beforeSend() as seen in the docs

Actual Result

The event payload stays the same (and includes all user data I want to scrub before sending the event) no matter what I do in the Sentry.init()

@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Sep 4, 2024
@Lms24
Copy link
Member

Lms24 commented Sep 5, 2024

Hi @lud-hu thanks for writing in! This sounds a bit off to be honest as the Nuxt SDK doesn't do anything special here as opposed to our other SDKs. Could you provide a minimal reproduction that we can use to check ourselves? Alternatively, I'd suggest to check the request payload in your browser dev tools network tab and check if the values are really still there.

One thing that comes to my mind: If you check the issue in the Sentry UI, we don't always show you the latest event of the same issue. Any chance that you were looking at an older event that still has the data? You can jump to the latest event by clicking this button:

Image

@lud-hu
Copy link
Author

lud-hu commented Sep 5, 2024

Thank you @Lms24 for the insights!

I now found out some more details on why my code didn't work: The event does not contain the user property at all.
Image
My setup did strip the console log, that's why I have not seen the event payload so far.

But even though there is no user in the transferred data, the Sentry UI shows the ip of the user (exactly as shown in your screenshot).
Is the IP derived from the request or sth? How can I disable sending the IP or better replace it with some kind of hash?

@lud-hu
Copy link
Author

lud-hu commented Sep 5, 2024

OK, I now found some Sentry docs pointing me to the "Prevent Storing of IP Addresses" setting in the project settings which turns of server side derivation of IP adresses ("Serverside SDKs that instrument incoming requests will attempt to pull the IP address from the HTTP request data).

So everything seems to work fine with the nuxt/JS SDK. Sorry and thanks for your reply!!

@lud-hu lud-hu closed this as completed Sep 5, 2024
@lud-hu lud-hu reopened this Sep 5, 2024
@lud-hu lud-hu closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Archived in project
Development

No branches or pull requests

2 participants