Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a9838a9
feat: migrates to package:web and js_interop
josh-burton May 20, 2024
9a156fb
fix: enhances comment
josh-burton Jun 4, 2024
4266881
chore: Adds changelog
josh-burton Jun 4, 2024
7dfc42e
chore: formatting
josh-burton Jun 4, 2024
2bf4b4f
fix: changes min flutter version to 3.13.0 and dart sdk 3.1.0 to be c…
josh-burton Jun 4, 2024
c4f9ba0
Merge branch 'main' into package-web
vaind Jun 20, 2024
3d07b8e
compat with dart:html & dart:web
vaind Jun 20, 2024
75014d1
fixups
vaind Jun 20, 2024
f945e9a
more fixups
vaind Jun 20, 2024
de46ce3
analyzer
vaind Jun 20, 2024
99391f4
chore: changelog entry
vaind Jun 20, 2024
31bac33
Merge branch 'main' into package-web
vaind Jun 20, 2024
80a0e2b
run dart test for all supported dart version
vaind Jun 20, 2024
e3e6c56
update web example tests
vaind Jun 20, 2024
fe1e91d
update ci
vaind Jun 20, 2024
f170986
update deps so that we can run test with old dart versions
vaind Jun 20, 2024
d05cf9d
fix ci
vaind Jun 20, 2024
78a78a2
fix web enricher test
vaind Jun 20, 2024
ac61607
fix ci
vaind Jun 20, 2024
8317804
ci fixes
vaind Jun 20, 2024
f5f9c7b
ignore pana error
vaind Jun 20, 2024
74e5f50
Merge branch 'main' into package-web
vaind Jun 20, 2024
f6e32d0
fix CI
vaind Jun 20, 2024
2c52eeb
fix ci
vaind Jun 20, 2024
f9d80f0
remove dart 2.17 build
vaind Jun 20, 2024
b19f0ad
fixes
vaind Jun 20, 2024
529e4f4
fix CI
vaind Jun 20, 2024
5750e5c
test dart2wasm
vaind Jun 20, 2024
5375cf2
cleanup
vaind Jun 20, 2024
a939163
disable dart2wasm on windows
vaind Jun 20, 2024
cec7756
fix tests for wasm
vaind Jun 20, 2024
3216f42
Merge branch 'main' into package-web
vaind Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compat with dart:html & dart:web
  • Loading branch information
vaind committed Jun 20, 2024
commit 3d07b8ecbc88c62d89d5c490d712bae1e36d89e2
6 changes: 3 additions & 3 deletions .github/workflows/min_version_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # [email protected]
with:
flutter-version: "3.13.0"
flutter-version: "3.0.0"

- name: Build Android
run: |
Expand All @@ -53,7 +53,7 @@ jobs:

- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # [email protected]
with:
flutter-version: "3.13.0"
flutter-version: "3.0.0"

- name: Build iOS
run: |
Expand All @@ -70,7 +70,7 @@ jobs:

- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # [email protected]
with:
flutter-version: "3.13.0"
flutter-version: "3.0.0"

- name: Build web
run: |
Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

### Dependencies

- Bump Cocoa SDK from v8.25.2 to v8.26.0 ([#2060](https://github.com/getsentry/sentry-dart/pull/2060))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8260)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.25.2...8.26.0)
- Migrates to package:web and js_interop ([#2064](https://github.com/getsentry/sentry-dart/pull/2064))
- Bump `sqflite` minimum version from `^2.0.0` to `^2.2.8` ([#2075](https://github.com/getsentry/sentry-dart/pull/2075))
- This is not a breaking change since we are using api internally that is only valid from that version.
- Bump Cocoa SDK from v8.25.2 to v8.29.0 ([#2060](https://github.com/getsentry/sentry-dart/pull/2060), [#2092](https://github.com/getsentry/sentry-dart/pull/2092), [#2100](https://github.com/getsentry/sentry-dart/pull/2100))
Expand Down
9 changes: 9 additions & 0 deletions dart/example_web_legacy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files and directories created by pub
.dart_tool/
.packages

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/
8 changes: 8 additions & 0 deletions dart/example_web_legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Sentry Dart : web example

```sh
dart pub get

# run the project ( see https://dart.dev/tools/webdev#serve )
dart run webdev serve --release
```
5 changes: 5 additions & 0 deletions dart/example_web_legacy/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:lints/recommended.yaml

analyzer:
errors:
path_does_not_exist: ignore
17 changes: 17 additions & 0 deletions dart/example_web_legacy/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: sentry_dart_web_example
description: An absolute bare-bones web app.

publish_to: 'none'

environment:
sdk: '>=2.17.0 <4.0.0'

dependencies:
sentry:
path: ../../dart/

dev_dependencies:
build_runner: ^2.4.2
build_web_compilers: ^4.0.3
lints: ^2.0.0
webdev: ^3.0.4
76 changes: 76 additions & 0 deletions dart/example_web_legacy/web/event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:sentry/src/protocol.dart';

final event = SentryEvent(
logger: 'main',
serverName: 'server.dart',
release: '1.4.0-preview.1',
environment: 'Test',
message: SentryMessage('This is an example Dart event.'),
tags: const <String, String>{'project-id': '7371'},
// ignore: deprecated_member_use, deprecated_member_use_from_same_package
extra: const <String, String>{'section': '1'},
// fingerprint: const <String>['example-dart'],
user: SentryUser(
id: '800',
username: 'first-user',
email: '[email protected]',
// ipAddress: '127.0.0.1',
data: <String, String>{'first-sign-in': '2020-01-01'},
),
breadcrumbs: [
Breadcrumb(
message: 'UI Lifecycle',
timestamp: DateTime.now().toUtc(),
category: 'ui.lifecycle',
type: 'navigation',
data: {'screen': 'MainActivity', 'state': 'created'},
level: SentryLevel.info,
)
],
contexts: Contexts(
operatingSystem: const SentryOperatingSystem(
name: 'Android',
version: '5.0.2',
build: 'LRX22G.P900XXS0BPL2',
kernelVersion:
'Linux version 3.4.39-5726670 (dpi@SWHC3807) (gcc version 4.8 (GCC) ) #1 SMP PREEMPT Thu Dec 1 19:42:39 KST 2016',
rooted: false,
),
runtimes: [const SentryRuntime(name: 'ART', version: '5')],
app: SentryApp(
name: 'Example Dart App',
version: '1.42.0',
identifier: 'HGT-App-13',
build: '93785',
buildType: 'release',
deviceAppHash: '5afd3a6',
startTime: DateTime.now().toUtc(),
),
browser: const SentryBrowser(name: 'Firefox', version: '42.0.1'),
device: SentryDevice(
name: 'SM-P900',
family: 'SM-P900',
model: 'SM-P900 (LRX22G)',
modelId: 'LRX22G',
arch: 'armeabi-v7a',
batteryLevel: 99,
orientation: SentryOrientation.landscape,
manufacturer: 'samsung',
brand: 'samsung',
screenDensity: 2.1,
screenDpi: 320,
online: true,
charging: true,
lowMemory: true,
simulator: false,
memorySize: 1500,
freeMemory: 200,
usableMemory: 4294967296,
storageSize: 4294967296,
freeStorage: 2147483648,
externalStorageSize: 8589934592,
externalFreeStorage: 2863311530,
bootTime: DateTime.now().toUtc(),
),
),
);
Binary file added dart/example_web_legacy/web/favicon.ico
Binary file not shown.
69 changes: 69 additions & 0 deletions dart/example_web_legacy/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>

<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.

The path provided below has to start and end with a slash "/" in order for
it to work correctly.

For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="scaffolded-by" content="https://github.com/dart-lang/stagehand">
<title>dart_web</title>
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="favicon.ico">

<style>
.bloc {
display: flex;
margin: 1rem;
}

.result {
padding-left: 1rem;
color: green;
display: none;
}
</style>

<script defer src="main.dart.js"></script>
</head>

<body>

<div id="output"></div>

<div class="bloc">
<button id="btEvent">Capture Event</button>
<div id="eventResult" class="result">Captured</div>
</div>

<div class="bloc">
<button id="btMessage">Capture Message</button>
<div id="messageResult" class="result">Captured</div>
</div>

<div class="bloc">
<button id="btException">Capture Exception</button>
<div id="exceptionResult" class="result">Captured</div>
</div>

<div class="bloc">
<button id="btUnhandledException">Capture Unhandled Exception</button>
<div id="unhandledResult" class="result">Captured</div>
</div>

</body>
</html>
135 changes: 135 additions & 0 deletions dart/example_web_legacy/web/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import 'dart:async';
import 'dart:html';

import 'package:sentry/sentry.dart';
import 'package:sentry/src/version.dart';

import 'event.dart';

// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const dsn =
'https://[email protected]/5428562';

Future<void> main() async {
await Sentry.init(
(options) => options
..dsn = dsn
..debug = true
..sendDefaultPii = true
..addEventProcessor(TagEventProcessor()),
appRunner: runApp,
);
}

Future<void> runApp() async {
print('runApp');

querySelector('#output')?.text = 'Your Dart app is running.';

await Sentry.addBreadcrumb(
Breadcrumb(
message: 'Authenticated user',
category: 'auth',
type: 'debug',
data: {
'admin': true,
'permissions': [1, 2, 3]
},
),
);

await Sentry.configureScope((scope) async {
scope
// ..fingerprint = ['example-dart']
..transaction = '/example/app'
..level = SentryLevel.warning;
await scope.setTag('build', '579');
await scope.setExtra('company-name', 'Dart Inc');

await scope.setUser(
SentryUser(
id: '800',
username: 'first-user',
email: '[email protected]',
// ipAddress: '127.0.0.1',
data: <String, String>{'first-sign-in': '2020-01-01'},
),
);
});

querySelector('#btEvent')
?.onClick
.listen((event) => captureCompleteExampleEvent());
querySelector('#btMessage')?.onClick.listen((event) => captureMessage());
querySelector('#btException')?.onClick.listen((event) => captureException());
querySelector('#btUnhandledException')
?.onClick
.listen((event) => captureUnhandledException());
}

Future<void> captureMessage() async {
print('Capturing Message : ');
final sentryId = await Sentry.captureMessage(
'Message 2',
template: 'Message %s',
params: ['2'],
);
print('capture message result : $sentryId');
if (sentryId != SentryId.empty()) {
querySelector('#messageResult')?.style.display = 'block';
}
}

Future<void> captureException() async {
try {
await buildCard();
} catch (error, stackTrace) {
print('\nReporting the following stack trace: ');
final sentryId = await Sentry.captureException(
error,
stackTrace: stackTrace,
);

print('Capture exception : SentryId: $sentryId');

if (sentryId != SentryId.empty()) {
querySelector('#exceptionResult')?.style.display = 'block';
}
}
}

Future<void> captureUnhandledException() async {
querySelector('#unhandledResult')?.style.display = 'block';

await buildCard();
}

Future<void> captureCompleteExampleEvent() async {
print('\nReporting a complete event example: $sdkName');
final sentryId = await Sentry.captureEvent(event);

print('Response SentryId: $sentryId');

if (sentryId != SentryId.empty()) {
querySelector('#eventResult')?.style.display = 'block';
}
}

Future<void> buildCard() async {
await loadData();
}

Future<void> loadData() async {
await parseData();
}

Future<void> parseData() async {
throw StateError('This is a test error');
}

class TagEventProcessor implements EventProcessor {
@override
SentryEvent? apply(SentryEvent event, Hint hint) {
return event..tags?.addAll({'page-locale': 'en-us'});
}
}
14 changes: 14 additions & 0 deletions dart/example_web_legacy/web/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import url(https://fonts.googleapis.com/css?family=Roboto);

html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
}

#output {
padding: 20px;
text-align: center;
}
3 changes: 2 additions & 1 deletion dart/lib/src/environment/environment_variables.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '../platform_checker.dart';
import '_io_environment_variables.dart'
if (dart.library.js_interop) '_web_environment_variables.dart' as env;
if (dart.library.js_interop) '_web_environment_variables.dart'
if (dart.library.html) '_web_environment_variables.dart' as env;

/// Reads environment variables from the system.
/// In an Flutter environment these can be set via
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import '../../event_processor.dart';
import '../../sentry_options.dart';
import 'io_enricher_event_processor.dart'
if (dart.library.js_interop) 'web_enricher_event_processor.dart';
if (dart.library.js_interop) 'web_enricher_event_processor.dart'
if (dart.library.html) 'html_enricher_event_processor.dart';

abstract class EnricherEventProcessor implements EventProcessor {
factory EnricherEventProcessor(SentryOptions options) =>
Expand Down
Loading