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

Sentry - Support browser #22

Merged
merged 22 commits into from
Nov 28, 2019
Merged

Sentry - Support browser #22

merged 22 commits into from
Nov 28, 2019

Conversation

lejard-h
Copy link
Contributor

@lejard-h lejard-h commented Aug 1, 2018

  • Refactor to support browser
    • SentryClient from package:sentry/sentry.dart with conditional import
    • SentryBrowserClient for web from package:sentry/browser_client.dart
    • SentryIOClient for VM and Flutter from package:sentry/io_client.dart
  • Write test for browser
  • Working Angular Sentry packages => https://github.com/leftyio/angular_sentry

Main implementation difference are:

  • gzip compressing not available on browser
  • javascript stacktrace need to be prefix with window.location.origin to be resolve by sentry

@lejard-h lejard-h changed the title Support browser Sentry: Support browser Aug 1, 2018
@lejard-h lejard-h changed the title Sentry: Support browser WIP Sentry - Support browser Aug 1, 2018
@yjbanov
Copy link
Contributor

yjbanov commented Aug 1, 2018

Thanks for the PR! A couple of things before we can move forward. This PR needs two reviews, one to cover the dart-for-web side of things and one to cover the Flutter/VM parts. We have a few people on the Flutter team (including myself) who can provide the latter, but not the former. Therefore we need to find someone on our team who would be willing to own the Web functionality for flutter/sentry.

@kevmoo, @matanlurey, can you help with this?

If you need to move fast and can't wait for these organizational/ownership issues to be resolved, one option is to fork this library (Go open source!).

@lejard-h
Copy link
Contributor Author

lejard-h commented Aug 1, 2018

I already have a fork that we use in production and that is used by angular_sentry for a few month now.

I don't need to move fast, the coming release of dart 2 and angular 5 seems to be a good opportunity to build a strong library for sentry.

@matanlurey
Copy link

It is unlikely my team will be able to own this anytime soon @yjbanov

@lejard-h lejard-h changed the title WIP Sentry - Support browser Sentry - Support browser Aug 6, 2018
@lejard-h
Copy link
Contributor Author

lejard-h commented Aug 6, 2018

angular implementation => leftyio/angular_sentry#1

@Hixie
Copy link

Hixie commented Aug 28, 2018

@yjbanov Are you able to continue to shepherd this through?

@yjbanov
Copy link
Contributor

yjbanov commented Aug 29, 2018

Unfortunately, no.

@eseidelGoogle
Copy link

https://github.com/getsentry maintains official Sentry plugins, it's possible they would be interested in taking on a fuller-featured sentry plugin for Dart server, browser and flutter.

@Hixie
Copy link

Hixie commented Oct 30, 2018

@lejard-h We've moved this to the packages repo. I'm not sure we have anyone who would be able to review the change, still, but in the meantime, would you be willing to resubmit the PR to the other repo?

@lejard-h
Copy link
Contributor Author

lejard-h commented Nov 6, 2018

I will do that 👍

lejard-h added a commit to lejard-h/packages that referenced this pull request Mar 17, 2019
asked here getsentry/sentry-dart#22 (comment)

move the current sentry packages without modifications, except fixing warnings due to new analysis_options.
@listepo
Copy link

listepo commented Jun 9, 2019

Any news? (Flutter for a web already presented)

@yjbanov
Copy link
Contributor

yjbanov commented Jun 13, 2019

Any news? (Flutter for a web already presented)

Yes, this will have to align with the Flutter for web efforts, likely after we merge the Web support into Flutter proper.

@Standaa
Copy link

Standaa commented Oct 22, 2019

Any updates as to when this PR will be accepted ?

@yjbanov
Copy link
Contributor

yjbanov commented Oct 22, 2019

As of September 10, 2019, Flutter for web merged into the mainline Flutter SDK, so we can certainly reopen this discussion.

@lejard-h
Copy link
Contributor Author

I fixed the conflicts.

Test are passing but I still need to check my angular_sentry implementation and run additional tests on real env.

I also added conditional import support on package:sentry/sentry.dart so it should not be breaking change.

@jaumard
Copy link

jaumard commented Nov 3, 2019

I've added sentry without checking first if it's support web :( shame on me lool can't run on web anymore.

But now I'm interested to see this merged ^^

@yjbanov
Copy link
Contributor

yjbanov commented Nov 4, 2019

I'm reviewing this PR right now in between other high-priority tasks that have been assigned to me, but it's big! :) So it will take some time.

Map<String, dynamic> data,
Map<String, String> headers,
) =>
// Gzip compression is not available on browser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be more precise gzip is available in web browsers but it is done implicitly.

lib/src/base.dart Show resolved Hide resolved
@@ -70,3 +82,9 @@ String _absolutePathForCrashReport(Frame frame) {

return '${frame.uri}';
}

class EmptyStacktraceException implements Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document all public API, including the class and public members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually It was not used, It just removed it


/// The SDK name reported to Sentry.io in the submitted events.
const String sdkName = 'dart';

/// The name of the SDK platform reported to Sentry.io in the submitted events.
/// Used for IO version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate paragraphs with one blank line. End the sentence with a period.

const String sdkPlatform = 'dart';

/// Used to report browser Stacktrace to sentry
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

End the sentence with a period.

import 'src/utils.dart';
import 'src/version.dart';

export 'src/base.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the license header.

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// A pure Dart client for Sentry.io crash reporting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment would be most useful in lib/sentry.dart than here. Let's move it there.

@@ -1,7 +0,0 @@
#!/bin/sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean-up! Thanks.

CHANGELOG.md Outdated
@@ -1,5 +1,12 @@
# package:sentry changelog

## 2.4.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making it a 3.0.0-dev0, given how big and probably subtly breaking this change is?

import 'client_stub.dart'
// ignore: uri_does_not_exist
if (dart.library.html) 'browser.dart'
// ignore: uri_does_not_exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are ignores necessary?

Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do browser_client.dart and io_client.dart add much value on top of the configurable imports?

const String _testDsnWithPort =
'https://public:[email protected]:8888/1';
void main() {
group('$SentryBrowserClient', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also do group(SentryBrowserClient, ...

@@ -0,0 +1,425 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a lot of the test code is identical with the io version. Would it be possible to have shared test code configurable via a typedef SentryClientFactory that provides either io or browser implementation of the client??

Copy link
Contributor Author

@lejard-h lejard-h Nov 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional import made it really simple to do, I moved all common and configurable tests under the test_utils.dart file using a single function

runTest({Codec<List<int>, List<int>> gzip, bool isWeb = false})

Also moved Event test under event_test.dart file.

@jaumard
Copy link

jaumard commented Nov 26, 2019

All good now @yjbanov ? :)

@yjbanov
Copy link
Contributor

yjbanov commented Nov 26, 2019

Thanks for the ping @jaumard.

@lejard-h Is this ready for another pass? This looks almost there.

lib/sentry.dart Outdated
@@ -1,653 +1,8 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Copyright 2019 The Chromium Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the original year.

@@ -0,0 +1,16 @@
import 'package:http/http.dart';
Copy link
Contributor

@yjbanov yjbanov Nov 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a license header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be good now

@yjbanov
Copy link
Contributor

yjbanov commented Nov 28, 2019

@lejard-h I can't thank you enough for your boundless patience! As I read through the history of this PR, I'm amazed at how things have changed since August 2018, when it was first filed. This PR survived tectonic shifts in Flutter and Dart.

lgtm

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

Successfully merging this pull request may close these issues.

8 participants