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

[Question]: Puppeteer event parsing #193

Open
Valerioageno opened this issue Feb 22, 2024 · 7 comments
Open

[Question]: Puppeteer event parsing #193

Valerioageno opened this issue Feb 22, 2024 · 7 comments

Comments

@Valerioageno
Copy link

I'm trying to use the library with playwrigth (that uses puppeteer under the hood) but I have an issue with the events sent with the /envelope sentry's endpoint.

Basically the event envelope type on puppeteer is not recorded on the reports array.

// testkit.ts
const createPuppeteerHandler = (baseUrl: string) => (request: any) => {
    const url = request.url()
    if (!url.startsWith(baseUrl)) {
      return
    }
    const path = url.substring(baseUrl.length)
    if (/\/api\/[0-9]*\/store/.test(path)) {
      reports.push(transformReport(JSON.parse(request.postData())))
    }
    if (/\/api\/[0-9]*\/envelope/.test(path)) { // <-- Here we are not handling the event
      const { type, payload } = parseEnvelopeRequest(request.postData())
      if (type === 'transaction') {
        transactions.push(transformTransaction(payload))
      }
    }
  }
// parser.ts
export function handleEnvelopeRequestData( // <-- This function correctly handles the "event"
  requestBody: any,
  testkit: Testkit
): void {
  const { type, payload } = parseEnvelopeRequest(requestBody)

  if (type === 'transaction') {
    testkit.transactions().push(transformTransaction(payload))
  } else if (type === 'event') {
    testkit.reports().push(transformReport(payload))
  }
}

Is there a reason for that? Eventually I can open a Pull Request for it.

@zivl
Copy link
Owner

zivl commented Mar 11, 2024

hey @Valerioageno
yeah sure it looks like a good feature to add, would appreciate a PR for it

Copy link
Contributor

Stale issue message

Copy link
Contributor

Stale issue message

Copy link
Contributor

github-actions bot commented Jan 1, 2025

Stale issue message

Copy link
Contributor

github-actions bot commented Mar 3, 2025

Stale issue message

@zivl
Copy link
Owner

zivl commented Mar 5, 2025

@Valerioageno we are now working on releasing the next major version of sentry-testkit.
would you like to PR your suggestion?

@Valerioageno
Copy link
Author

Sorry @zivl, I completely forgot about this issue... I don't have room right now to do the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants