Skip to content

Sentry - Support browser - #22

Merged
yjbanov merged 22 commits into
getsentry:masterfrom
lejard-h:web
Nov 28, 2019
Merged

Sentry - Support browser#22
yjbanov merged 22 commits into
getsentry:masterfrom
lejard-h:web

Conversation

@lejard-h

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

Copy link
Copy Markdown
Contributor
  • 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

yjbanov commented Aug 1, 2018

Copy link
Copy Markdown
Contributor

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

lejard-h commented Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

lejard-h commented Aug 6, 2018

Copy link
Copy Markdown
Contributor Author

angular implementation => leftyio/angular_sentry#1

@Hixie

Hixie commented Aug 28, 2018

Copy link
Copy Markdown

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

@yjbanov

yjbanov commented Aug 29, 2018

Copy link
Copy Markdown
Contributor

Unfortunately, no.

@eseidelGoogle

Copy link
Copy Markdown

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

Hixie commented Oct 30, 2018

Copy link
Copy Markdown

@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

lejard-h commented Nov 6, 2018

Copy link
Copy Markdown
Contributor Author

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

listepo commented Jun 9, 2019

Copy link
Copy Markdown

Any news? (Flutter for a web already presented)

@yjbanov

yjbanov commented Jun 13, 2019

Copy link
Copy Markdown
Contributor

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

Standaa commented Oct 22, 2019

Copy link
Copy Markdown

Any updates as to when this PR will be accepted ?

@yjbanov

yjbanov commented Oct 22, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

jaumard commented Nov 3, 2019

Copy link
Copy Markdown

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

yjbanov commented Nov 4, 2019

Copy link
Copy Markdown
Contributor

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.

Comment thread lib/src/browser.dart Outdated
Map<String, dynamic> data,
Map<String, String> headers,
) =>
// Gzip compression is not available on browser

Copy link
Copy Markdown
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.

Comment thread lib/src/base.dart
Comment thread lib/src/stack_trace.dart Outdated
return '${frame.uri}';
}

class EmptyStacktraceException implements Exception {

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread lib/src/version.dart Outdated
const String sdkName = 'dart';

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

Copy link
Copy Markdown
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.

Comment thread lib/src/version.dart Outdated
/// Used for IO version
const String sdkPlatform = 'dart';

/// Used to report browser Stacktrace to sentry

Copy link
Copy Markdown
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.

Comment thread lib/sentry.dart
import 'src/utils.dart';
import 'src/version.dart';

export 'src/base.dart';

Copy link
Copy Markdown
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.

Comment thread lib/src/base.dart Outdated
// 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
Copy Markdown
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.

Comment thread tool/dart2_test.sh
@@ -1,7 +0,0 @@
#!/bin/sh

Copy link
Copy Markdown
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.

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

## 2.4.0

Copy link
Copy Markdown
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?

Comment thread lib/src/base.dart Outdated
import 'client_stub.dart'
// ignore: uri_does_not_exist
if (dart.library.html) 'browser.dart'
// ignore: uri_does_not_exist

Copy link
Copy Markdown
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?

@yjbanov yjbanov left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread test/sentry_browser_test.dart Outdated
const String _testDsnWithPort =
'https://public:secret@sentry.example.com:8888/1';
void main() {
group('$SentryBrowserClient', () {

Copy link
Copy Markdown
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
Copy Markdown
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??

@lejard-h lejard-h Nov 13, 2019

Copy link
Copy Markdown
Contributor Author

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

jaumard commented Nov 26, 2019

Copy link
Copy Markdown

All good now @yjbanov ? :)

@yjbanov

yjbanov commented Nov 26, 2019

Copy link
Copy Markdown
Contributor

Thanks for the ping @jaumard.

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

Comment thread 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
Copy Markdown
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.

Comment thread lib/src/client_stub.dart
@@ -0,0 +1,16 @@
import 'package:http/http.dart';

@yjbanov yjbanov Nov 26, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

yjbanov commented Nov 28, 2019

Copy link
Copy Markdown
Contributor

@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