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

feat: enable wasm compilation #2113

Merged
merged 32 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion .github/actions/dart-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runs:
working-directory: ${{ inputs.directory }}

- name: Test VM
run: dart test -p vm --coverage=coverage --test-randomize-ordering-seed=random --chain-stack-traces
run: dart test -p vm ${{ (runner.os == 'Linux' && matrix.sdk == 'stable' && '--coverage=coverage') || '' }} --test-randomize-ordering-seed=random --chain-stack-traces
shell: bash
working-directory: ${{ inputs.directory }}

Expand All @@ -32,3 +32,9 @@ runs:
run: dart test -p chrome --test-randomize-ordering-seed=random --chain-stack-traces
shell: bash
working-directory: ${{ inputs.directory }}

- name: Test dart2wasm
if: ${{ inputs.web == 'true' && (matrix.sdk == 'stable' || matrix.sdk == 'beta') && runner.os != 'Windows' }}
run: dart test -p chrome --compiler dart2wasm --test-randomize-ordering-seed=random --chain-stack-traces
shell: bash
working-directory: ${{ inputs.directory }}
4 changes: 2 additions & 2 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- run: ${{ inputs.sdk }} pub get
- run: dart format --set-exit-if-changed ./

- name: dart analyze
uses: invertase/github-action-dart-analyzer@e981b01a458d0bab71ee5da182e5b26687b7101b # [email protected]
with:
Expand Down Expand Up @@ -78,6 +78,6 @@ jobs:
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < ${{ inputs.panaThreshold }} ))
then
echo Score too low!
echo "Score too low ($PERCENTAGE % is less than the expected ${{ inputs.panaThreshold }} %)!"
exit 1
fi
39 changes: 19 additions & 20 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,28 @@ jobs:
access_token: ${{ github.token }}

build:
name: Build ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}
name: Dart ${{matrix.sdk}} on ${{matrix.os}}
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
sdk: [stable, beta]
exclude:
- os: windows-latest
sdk: beta
- os: macos-latest
sdk: beta
os: [ubuntu]
sdk:
- '2.18'
- '2.19'
- '3.0'
- '3.1'
- '3.2'
- '3.3'
- '3.4'
- stable
- beta
include:
- os: windows
sdk: stable
- os: macos
sdk: stable
steps:
- uses: actions/checkout@v4

Expand All @@ -49,24 +58,14 @@ jobs:
coverage: sentry
min-coverage: 85

- name: Install webdev
if: runner.os != 'Windows'
run: dart pub global activate webdev

- name: Build example
working-directory: dart/example
run: |
dart pub get
dart compile aot-snapshot bin/example.dart

- name: Build Web example
denrase marked this conversation as resolved.
Show resolved Hide resolved
if: runner.os != 'Windows'
working-directory: dart/example_web
run: |
dart pub get
webdev build

analyze:
uses: ./.github/workflows/analyze.yml
with:
package: dart
panaThreshold: 87
1 change: 1 addition & 0 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jobs:
with:
package: flutter
sdk: flutter
panaThreshold: 87

pod-lint:
runs-on: macos-latest
Expand Down
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- Support WebAssembly compilation (dart2wasm) ([#2113](https://github.com/getsentry/sentry-dart/pull/2113))

### Dependencies

- Bump Cocoa SDK from v8.29.0 to v8.29.1 ([#2109](https://github.com/getsentry/sentry-dart/pull/2109))
Expand Down Expand Up @@ -122,7 +126,7 @@ This release contains breaking changes, please read the changelog carefully.

### Features

- Experimental: Add support for Sentry Developer Metrics ([#1940](https://github.com/getsentry/sentry-dart/pull/1940), [#1949](https://github.com/getsentry/sentry-dart/pull/1949), [#1954](https://github.com/getsentry/sentry-dart/pull/1954), [#1958](https://github.com/getsentry/sentry-dart/pull/1958))
- Experimental: Add support for Sentry Developer Metrics ([#1940](https://github.com/getsentry/sentry-dart/pull/1940), [#1949](https://github.com/getsentry/sentry-dart/pull/1949), [#1954](https://github.com/getsentry/sentry-dart/pull/1954), [#1958](https://github.com/getsentry/sentry-dart/pull/1958))
Use the Metrics API to track processing time, download sizes, user signups, and conversion rates and correlate them back to tracing data in order to get deeper insights and solve issues faster. Our API supports counters, distributions, sets, gauges and timers, and it's easy to get started:
```dart
Sentry.metrics()
Expand Down Expand Up @@ -235,14 +239,14 @@ This release contains breaking changes, please read the changelog carefully.
- Now the device context from Android is available in `BeforeSendCallback`
- Set ip_address to {{auto}} by default, even if sendDefaultPII is disabled ([#1665](https://github.com/getsentry/sentry-dart/pull/1665))
- Instead use the "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io
### Fixes

### Fixes

- Remove Flutter dependency from Drift integration ([#1867](https://github.com/getsentry/sentry-dart/pull/1867))
- Remove dead code, cold start bool is now always present ([#1861](https://github.com/getsentry/sentry-dart/pull/1861))
- Fix iOS "Arithmetic Overflow" ([#1874](https://github.com/getsentry/sentry-dart/pull/1874))

### Dependencies
### Dependencies

- Bump Cocoa SDK from v8.19.0 to v8.20.0 ([#1856](https://github.com/getsentry/sentry-dart/pull/1856))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8200)
Expand Down
1 change: 1 addition & 0 deletions dart/example_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ environment:
dependencies:
sentry:
path: ../../dart/
web: ^0.5.1

dev_dependencies:
build_runner: ^2.4.2
Expand Down
33 changes: 23 additions & 10 deletions dart/example_web/web/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dart:async';
import 'dart:html';
import 'package:web/web.dart';

import 'package:sentry/sentry.dart';
import 'package:sentry/src/version.dart';
Expand All @@ -24,7 +24,7 @@ Future<void> main() async {
Future<void> runApp() async {
print('runApp');

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

await Sentry.addBreadcrumb(
Breadcrumb(
Expand Down Expand Up @@ -57,12 +57,20 @@ Future<void> runApp() async {
);
});

querySelector('#btEvent')
document
.querySelector('#btEvent')
?.onClick
.listen((event) => captureCompleteExampleEvent());
querySelector('#btMessage')?.onClick.listen((event) => captureMessage());
querySelector('#btException')?.onClick.listen((event) => captureException());
querySelector('#btUnhandledException')
document
.querySelector('#btMessage')
?.onClick
.listen((event) => captureMessage());
document
.querySelector('#btException')
?.onClick
.listen((event) => captureException());
document
.querySelector('#btUnhandledException')
?.onClick
.listen((event) => captureUnhandledException());
}
Expand All @@ -76,7 +84,8 @@ Future<void> captureMessage() async {
);
print('capture message result : $sentryId');
if (sentryId != SentryId.empty()) {
querySelector('#messageResult')?.style.display = 'block';
(document.querySelector('#messageResult') as HTMLElement?)?.style.display =
'block';
}
}

Expand All @@ -93,13 +102,16 @@ Future<void> captureException() async {
print('Capture exception : SentryId: $sentryId');

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

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

await buildCard();
}
Expand All @@ -111,7 +123,8 @@ Future<void> captureCompleteExampleEvent() async {
print('Response SentryId: $sentryId');

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

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.3.0
build_web_compilers: ^3.2.3
lints: ^2.0.0
webdev: ^2.7.0
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.
Loading
Loading