Refactor newSentryTransaction to use improved API

This change is based on a suggestion by Sentry staff. It requires SDK version > 8.4.0

https://github.com/getsentry/sentry-javascript/issues/12116#issuecomment-2132812315
https://github.com/getsentry/sentry-javascript/pull/12138
This commit is contained in:
Sebastian Serth
2024-05-27 10:36:24 +02:00
committed by Sebastian Serth
parent 016971f4c2
commit a99d86068a

View File

@ -205,12 +205,9 @@ var CodeOceanEditor = {
newSentryTransaction: function (initiator, callback) {
// based on Sentry recommendation.
// See https://github.com/getsentry/sentry-javascript/issues/12116
return Sentry.continueTrace({ sentryTrace: '', baggage: '' }, () => {
// inside of this we have a new trace!
return Sentry.withActiveSpan(null, () => {
// inside of this there is no parent span, no matter what!
return Sentry.startNewTrace(() => {
const cause = initiator.data('cause') || initiator.prop('id');
return Sentry.startSpan({name: cause, op: "transaction", forceTransaction: true}, async () => {
return Sentry.startSpan({name: cause, op: "transaction"}, async () => {
// Execute the desired custom code
try {
return await callback();
@ -223,7 +220,6 @@ var CodeOceanEditor = {
}
});
});
});
},
resizeAceEditors: function (own_solution = false) {