getsentry / sentry-dart

Sentry SDK for Dart and Flutter
https://sentry.io/for/flutter/
MIT License
761 stars 239 forks source link

Sentry events displayed inappropriately while filtering #2175

Closed GowthamanRavichandran3 closed 4 months ago

GowthamanRavichandran3 commented 4 months ago

Platform

Dart

Obfuscation

Enabled

Debug Info

Enabled

Doctor

[√] Flutter (Channel stable, 3.19.4, on Microsoft Windows [Version 10.0.19045.4651], locale en-US)
    • Flutter version 3.19.4 on channel stable at D:\Flutter SDK\flutter     
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68bfaea224 (4 months ago), 2024-03-20 15:36:31 -0700
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\GowthamanRavichandra\AppData\Local\Android\sdk     
    • Platform android-34, build-tools 34.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java      
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[!] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] Android Studio (version 2022.3)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)

[√] VS Code, 64-bit edition (version 1.85.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.92.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.4651]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 126.0.6478.127
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 126.0.2592.102

[√] Network resources
    • All expected network resources are available.

Version

8.3.0

Steps to Reproduce

  1. Set the user with a unique ID. Change the ID while running the app every time. image
  2. Throw an exception in your application with some unique string to identify the event in Sentry, image
  3. Now run the app multiple times.
  4. The events are logged in Sentry, now filter with the ID that is set while running the application first time.

Use the following sample code:

import 'dart:isolate';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

void main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = 'My dsn';
    },
    appRunner: () => runApp(MyApp()),
  );

  Sentry.configureScope(
    (scope) => scope..setUser(SentryUser(id: '1234')),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sentry',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  void _throwError() {
    throw IsolateSpawnException(generateRandomString(10));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Sentry Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Press the button to throw an error:',
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: _throwError,
              child: const Text('Throw Error'),
            ),
          ],
        ),
      ),
    );
  }
}

String generateRandomString(int length) {
  const String chars =
      'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  Random random = Random();

  return List.generate(length, (index) => chars[random.nextInt(chars.length)])
      .join();
}

Expected Result

While filtering with a user ID, it should display the events that are logged for the filtered user. But it displayed the most recent log.

Actual Result

While filtering with a user ID, it displayed the most recent event.

  1. I have filtered with the user ID as '1234' image
  2. Open the event which is displayed,
  3. In the event overview page, the title and the content both are different. image

image

Are you willing to submit a PR?

None

kahest commented 4 months ago

Thanks for the detailed report - what you see is expected. Since these are all the same events (same stack trace, same location in code, etc.), they are getting grouped together into a single issue. If you filter the issue stream by a user id, you will see all issues that contain at least one event for this user. The title and description of the issue (what you see in screenshot 1, and at the top of screenshot 2) might come from a different event, therefore these often don't align.

The information below the issue header on screenshot 2 is specific to the event, so it contains the actual unique id and user id. The same is true for the event list in screenshot 3.

You can read more about issue grouping in the docs: