@@ -47,8 +47,9 @@ class SentryWebInterop
4747 'autoSessionTracking' : options.enableAutoSessionTracking,
4848 'attachStacktrace' : options.attachStacktrace,
4949 'maxBreadcrumbs' : options.maxBreadcrumbs,
50- 'replaysSessionSampleRate' : 0 ,
51- 'replaysOnErrorSampleRate' : 0 ,
50+ 'replaysSessionSampleRate' :
51+ options.experimental.replay.sessionSampleRate,
52+ 'replaysOnErrorSampleRate' : options.experimental.replay.errorSampleRate,
5253 // using defaultIntegrations ensures the we can control which integrations are added
5354 'defaultIntegrations' : [
5455 replay,
@@ -61,38 +62,35 @@ class SentryWebInterop
6162
6263 SentryJsBridge .init (config.jsify ());
6364
64- await startReplay ();
65+ // SpotlightBridge.init();
66+
67+ // await startReplay();
6568 });
6669 }
6770
6871 @override
69- Future <void > captureEvent (SentryEvent event) async {
70- tryCatchSync ('captureEvent' , () {
71- print (event.toJson ());
72- SentryJsBridge .captureEvent (event.toJson ().jsify ());
73- });
74- }
72+ Future <void > captureEvent (SentryEvent event) async {}
7573
7674 @override
7775 Future <void > captureEnvelope (SentryEnvelope envelope) async {
7876 return tryCatchAsync ('captureEnvelope' , () async {
7977 final List <dynamic > jsItems = [];
8078
8179 for (final item in envelope.items) {
82- // todo: add support for different type of items
83- // maybe add a generic to sentryenvelope?
8480 final originalObject = item.originalObject;
85- final List <dynamic > jsItem = [(await item.header.toJson ())];
86- if (originalObject is SentryTransaction ) {
87- jsItem.add (originalObject.toJson ().jsify ());
88- }
81+ jsItems.add ([
82+ (await item.header.toJson ()),
83+ (await originalObject? .getPayload ())
84+ ]);
85+
8986 if (originalObject is SentryEvent ) {
90- jsItem.add (originalObject.toJson ().jsify ());
87+ final session = SentryJsBridge .getSession ();
88+ if (envelope.containsUnhandledException) {
89+ session? .status = 'crashed' .toJS;
90+ }
91+ session? .errors = originalObject.exceptions? .length.toJS ?? 0. toJS;
92+ SentryJsBridge .captureSession ();
9193 }
92- if (originalObject is SentryAttachment ) {
93- jsItem.add (await originalObject.bytes);
94- }
95- jsItems.add (jsItem);
9694 }
9795
9896 final jsEnvelope = [envelope.header.toJson (), jsItems].jsify ();
@@ -108,11 +106,6 @@ class SentryWebInterop
108106 });
109107 }
110108
111- @override
112- Future <void > startReplay () async {
113- replay.startBuffering ();
114- }
115-
116109 @override
117110 Future <void > flushReplay () async {
118111 replay.flush ();
@@ -133,6 +126,10 @@ Future<void> _loadSentryScripts(SentryFlutterOptions options,
133126
134127 // todo: put this somewhere else so we can auto-update it as well and only enable non minified bundles in dev mode
135128 final scripts = [
129+ // {
130+ // 'url':
131+ // 'https://unpkg.com/@spotlightjs/overlay@latest/dist/sentry-spotlight.iife.js',
132+ // },
136133 {
137134 'url' : 'https://browser.sentry-cdn.com/8.24.0/bundle.tracing.replay.js' ,
138135 // 'integrity':
0 commit comments