From 2029418c7a0e9768b68c047edecb752698d95171 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Wed, 1 Jul 2026 14:22:34 +0200 Subject: [PATCH 1/4] ref!: Make clone() internal; drop protocol clones clone() on Hub, Scope, NoOpHub, HubAdapter and Sentry is intended for SDK-internal use only, so mark it @internal. The protocol clone() methods (Contexts and its children) were already @Deprecated and formed a dead subtree with no remaining callers, so remove them along with the alias-only clone context test. BREAKING CHANGE: The deprecated clone() on protocol classes is removed, and clone() on Hub/Scope is now @internal. Fixes GH-3824 Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/dart/lib/src/hub.dart | 1 + packages/dart/lib/src/hub_adapter.dart | 1 + packages/dart/lib/src/noop_hub.dart | 1 + packages/dart/lib/src/protocol/contexts.dart | 21 ---------- .../dart/lib/src/protocol/sentry_app.dart | 16 -------- .../dart/lib/src/protocol/sentry_browser.dart | 7 ---- .../dart/lib/src/protocol/sentry_culture.dart | 10 ----- .../dart/lib/src/protocol/sentry_device.dart | 41 ------------------- .../lib/src/protocol/sentry_feature_flag.dart | 3 -- .../src/protocol/sentry_feature_flags.dart | 3 -- .../lib/src/protocol/sentry_feedback.dart | 3 -- .../dart/lib/src/protocol/sentry_gpu.dart | 20 --------- .../src/protocol/sentry_operating_system.dart | 12 ------ .../lib/src/protocol/sentry_response.dart | 9 ---- .../dart/lib/src/protocol/sentry_runtime.dart | 11 ----- .../src/protocol/sentry_trace_context.dart | 15 ------- packages/dart/lib/src/scope.dart | 1 + packages/dart/lib/src/sentry.dart | 1 + packages/dart/test/contexts_test.dart | 24 ----------- 19 files changed, 5 insertions(+), 195 deletions(-) diff --git a/packages/dart/lib/src/hub.dart b/packages/dart/lib/src/hub.dart index 6c4e182dc1..286d7de4ff 100644 --- a/packages/dart/lib/src/hub.dart +++ b/packages/dart/lib/src/hub.dart @@ -432,6 +432,7 @@ class Hub { } /// Clones the Hub + @internal Hub clone() { if (!_isEnabled) { _options.log(SentryLevel.warning, 'Disabled Hub cloned.'); diff --git a/packages/dart/lib/src/hub_adapter.dart b/packages/dart/lib/src/hub_adapter.dart index 3a73411773..cd85850be1 100644 --- a/packages/dart/lib/src/hub_adapter.dart +++ b/packages/dart/lib/src/hub_adapter.dart @@ -84,6 +84,7 @@ class HubAdapter implements Hub { withScope: withScope, ); + @internal @override Hub clone() => Sentry.clone(); diff --git a/packages/dart/lib/src/noop_hub.dart b/packages/dart/lib/src/noop_hub.dart index 395bebe688..0594650c5c 100644 --- a/packages/dart/lib/src/noop_hub.dart +++ b/packages/dart/lib/src/noop_hub.dart @@ -62,6 +62,7 @@ class NoOpHub implements Hub { }) async => SentryId.empty(); + @internal @override Hub clone() => this; diff --git a/packages/dart/lib/src/protocol/contexts.dart b/packages/dart/lib/src/protocol/contexts.dart index f8530441e1..74d7ebeb4c 100644 --- a/packages/dart/lib/src/protocol/contexts.dart +++ b/packages/dart/lib/src/protocol/contexts.dart @@ -322,27 +322,6 @@ class Contexts extends MapView { return json; } - @Deprecated('Will be removed in a future version.') - Contexts clone() { - final copy = Contexts( - device: device?.clone(), - operatingSystem: operatingSystem?.clone(), - app: app?.clone(), - browser: browser?.clone(), - culture: culture?.clone(), - gpu: gpu?.clone(), - trace: trace?.clone(), - response: response?.clone(), - runtimes: runtimes.map((runtime) => runtime.clone()).toList(), - feedback: feedback?.clone(), - flags: flags?.clone(), - )..addEntries( - entries.where((element) => !defaultFields.contains(element.key)), - ); - - return copy; - } - @Deprecated( 'Will be removed in a future version. Assign values directly to the instance.') Contexts copyWith({ diff --git a/packages/dart/lib/src/protocol/sentry_app.dart b/packages/dart/lib/src/protocol/sentry_app.dart index 8ce387baf1..aeea8efa80 100644 --- a/packages/dart/lib/src/protocol/sentry_app.dart +++ b/packages/dart/lib/src/protocol/sentry_app.dart @@ -144,22 +144,6 @@ class SentryApp { return attributes; } - @Deprecated('Will be removed in a future version.') - SentryApp clone() => SentryApp( - name: name, - version: version, - identifier: identifier, - build: build, - buildType: buildType, - startTime: startTime, - deviceAppHash: deviceAppHash, - appMemory: appMemory, - inForeground: inForeground, - viewNames: viewNames, - textScale: textScale, - unknown: unknown, - ); - @Deprecated('Assign values directly to the instance.') SentryApp copyWith({ String? name, diff --git a/packages/dart/lib/src/protocol/sentry_browser.dart b/packages/dart/lib/src/protocol/sentry_browser.dart index 9ba214dac9..f9d6bd14ed 100644 --- a/packages/dart/lib/src/protocol/sentry_browser.dart +++ b/packages/dart/lib/src/protocol/sentry_browser.dart @@ -40,13 +40,6 @@ class SentryBrowser { }; } - @Deprecated('Will be removed in a future version.') - SentryBrowser clone() => SentryBrowser( - name: name, - version: version, - unknown: unknown, - ); - @Deprecated('Assign values directly to the instance.') SentryBrowser copyWith({ String? name, diff --git a/packages/dart/lib/src/protocol/sentry_culture.dart b/packages/dart/lib/src/protocol/sentry_culture.dart index bab61d5864..0b9a949aa5 100644 --- a/packages/dart/lib/src/protocol/sentry_culture.dart +++ b/packages/dart/lib/src/protocol/sentry_culture.dart @@ -98,16 +98,6 @@ class SentryCulture { }; } - @Deprecated('Will be removed in a future version.') - SentryCulture clone() => SentryCulture( - calendar: calendar, - displayName: displayName, - locale: locale, - is24HourFormat: is24HourFormat, - timezone: timezone, - unknown: unknown, - ); - @Deprecated('Assign values directly to the instance.') SentryCulture copyWith({ String? calendar, diff --git a/packages/dart/lib/src/protocol/sentry_device.dart b/packages/dart/lib/src/protocol/sentry_device.dart index 4d319d8e16..e7b7024221 100644 --- a/packages/dart/lib/src/protocol/sentry_device.dart +++ b/packages/dart/lib/src/protocol/sentry_device.dart @@ -427,47 +427,6 @@ class SentryDevice { return attributes; } - @Deprecated('Will be removed in a future version.') - SentryDevice clone() => SentryDevice( - name: name, - family: family, - model: model, - modelId: modelId, - arch: arch, - batteryLevel: batteryLevel, - orientation: orientation, - manufacturer: manufacturer, - brand: brand, - screenHeightPixels: screenHeightPixels, - screenWidthPixels: screenWidthPixels, - screenDensity: screenDensity, - screenDpi: screenDpi, - online: online, - charging: charging, - lowMemory: lowMemory, - simulator: simulator, - memorySize: memorySize, - freeMemory: freeMemory, - usableMemory: usableMemory, - storageSize: storageSize, - freeStorage: freeStorage, - externalStorageSize: externalStorageSize, - externalFreeStorage: externalFreeStorage, - bootTime: bootTime, - processorCount: processorCount, - cpuDescription: cpuDescription, - processorFrequency: processorFrequency, - deviceType: deviceType, - batteryStatus: batteryStatus, - deviceUniqueIdentifier: deviceUniqueIdentifier, - supportsVibration: supportsVibration, - supportsAccelerometer: supportsAccelerometer, - supportsGyroscope: supportsGyroscope, - supportsAudio: supportsAudio, - supportsLocationService: supportsLocationService, - unknown: unknown, - ); - @Deprecated('Assign values directly to the instance.') SentryDevice copyWith({ String? name, diff --git a/packages/dart/lib/src/protocol/sentry_feature_flag.dart b/packages/dart/lib/src/protocol/sentry_feature_flag.dart index b9d13cbf8f..8bb4e84d2c 100644 --- a/packages/dart/lib/src/protocol/sentry_feature_flag.dart +++ b/packages/dart/lib/src/protocol/sentry_feature_flag.dart @@ -55,7 +55,4 @@ class SentryFeatureFlag { unknown: unknown ?? this.unknown, ); } - - @Deprecated('Will be removed in a future version.') - SentryFeatureFlag clone() => copyWith(); } diff --git a/packages/dart/lib/src/protocol/sentry_feature_flags.dart b/packages/dart/lib/src/protocol/sentry_feature_flags.dart index 34900f2696..10b764d4be 100644 --- a/packages/dart/lib/src/protocol/sentry_feature_flags.dart +++ b/packages/dart/lib/src/protocol/sentry_feature_flags.dart @@ -57,7 +57,4 @@ class SentryFeatureFlags { unknown: unknown ?? this.unknown, ); } - - @Deprecated('Will be removed in a future version.') - SentryFeatureFlags clone() => copyWith(); } diff --git a/packages/dart/lib/src/protocol/sentry_feedback.dart b/packages/dart/lib/src/protocol/sentry_feedback.dart index a7af41407f..8e5a74d3a3 100644 --- a/packages/dart/lib/src/protocol/sentry_feedback.dart +++ b/packages/dart/lib/src/protocol/sentry_feedback.dart @@ -76,7 +76,4 @@ class SentryFeedback { associatedEventId: associatedEventId ?? this.associatedEventId, unknown: unknown ?? this.unknown, ); - - @Deprecated('Will be removed in a future version.') - SentryFeedback clone() => copyWith(); } diff --git a/packages/dart/lib/src/protocol/sentry_gpu.dart b/packages/dart/lib/src/protocol/sentry_gpu.dart index 6ef704978a..39bf899b91 100644 --- a/packages/dart/lib/src/protocol/sentry_gpu.dart +++ b/packages/dart/lib/src/protocol/sentry_gpu.dart @@ -111,26 +111,6 @@ class SentryGpu { ); } - @Deprecated('Will be removed in a future version.') - SentryGpu clone() => SentryGpu( - name: name, - id: id, - vendorId: vendorId, - vendorName: vendorName, - memorySize: memorySize, - apiType: apiType, - multiThreadedRendering: multiThreadedRendering, - version: version, - npotSupport: npotSupport, - graphicsShaderLevel: graphicsShaderLevel, - maxTextureSize: maxTextureSize, - supportsComputeShaders: supportsComputeShaders, - supportsDrawCallInstancing: supportsDrawCallInstancing, - supportsGeometryShaders: supportsGeometryShaders, - supportsRayTracing: supportsRayTracing, - unknown: unknown, - ); - /// Produces a [Map] that can be serialized to JSON. Map toJson() { return { diff --git a/packages/dart/lib/src/protocol/sentry_operating_system.dart b/packages/dart/lib/src/protocol/sentry_operating_system.dart index 3c524eab72..0e7e77a06d 100644 --- a/packages/dart/lib/src/protocol/sentry_operating_system.dart +++ b/packages/dart/lib/src/protocol/sentry_operating_system.dart @@ -127,18 +127,6 @@ class SentryOperatingSystem { return attributes; } - @Deprecated('Will be removed in a future version.') - SentryOperatingSystem clone() => SentryOperatingSystem( - name: name, - version: version, - build: build, - kernelVersion: kernelVersion, - rooted: rooted, - rawDescription: rawDescription, - theme: theme, - unknown: unknown, - ); - @Deprecated('Assign values directly to the instance.') SentryOperatingSystem copyWith({ String? name, diff --git a/packages/dart/lib/src/protocol/sentry_response.dart b/packages/dart/lib/src/protocol/sentry_response.dart index 4d14c0696e..451a11e1ee 100644 --- a/packages/dart/lib/src/protocol/sentry_response.dart +++ b/packages/dart/lib/src/protocol/sentry_response.dart @@ -94,13 +94,4 @@ class SentryResponse { statusCode: statusCode ?? this.statusCode, data: data ?? this.data, ); - - @Deprecated('Will be removed in a future version.') - SentryResponse clone() => SentryResponse( - bodySize: bodySize, - headers: headers, - cookies: cookies, - statusCode: statusCode, - data: data, - ); } diff --git a/packages/dart/lib/src/protocol/sentry_runtime.dart b/packages/dart/lib/src/protocol/sentry_runtime.dart index 295a526457..8399c1f3b5 100644 --- a/packages/dart/lib/src/protocol/sentry_runtime.dart +++ b/packages/dart/lib/src/protocol/sentry_runtime.dart @@ -102,17 +102,6 @@ class SentryRuntime { }; } - @Deprecated('Will be removed in a future version.') - SentryRuntime clone() => SentryRuntime( - key: key, - name: name, - version: version, - compiler: compiler, - rawDescription: rawDescription, - build: build, - unknown: unknown, - ); - SentryRuntime copyWith({ String? key, String? name, diff --git a/packages/dart/lib/src/protocol/sentry_trace_context.dart b/packages/dart/lib/src/protocol/sentry_trace_context.dart index 96f806ba39..6f897c6b37 100644 --- a/packages/dart/lib/src/protocol/sentry_trace_context.dart +++ b/packages/dart/lib/src/protocol/sentry_trace_context.dart @@ -84,21 +84,6 @@ class SentryTraceContext { }; } - @Deprecated('Will be removed in a future version.') - SentryTraceContext clone() => SentryTraceContext( - operation: operation, - traceId: traceId, - spanId: spanId, - description: description, - status: status, - parentSpanId: parentSpanId, - sampled: sampled, - origin: origin, - unknown: unknown, - replayId: replayId, - data: data, - ); - SentryTraceContext({ SentryId? traceId, SpanId? spanId, diff --git a/packages/dart/lib/src/scope.dart b/packages/dart/lib/src/scope.dart index a224900f55..fb054587c5 100644 --- a/packages/dart/lib/src/scope.dart +++ b/packages/dart/lib/src/scope.dart @@ -466,6 +466,7 @@ class Scope { } /// Clones the current Scope + @internal Scope clone() { final clone = Scope(_options) ..level = level diff --git a/packages/dart/lib/src/sentry.dart b/packages/dart/lib/src/sentry.dart index 9bb0095dc7..408f70f432 100644 --- a/packages/dart/lib/src/sentry.dart +++ b/packages/dart/lib/src/sentry.dart @@ -332,6 +332,7 @@ class Sentry { _hub.configureScope(callback); /// Clones the current Hub + @internal static Hub clone() => _hub.clone(); /// Binds a different client to the current hub diff --git a/packages/dart/test/contexts_test.dart b/packages/dart/test/contexts_test.dart index 060207adf5..4cec711b59 100644 --- a/packages/dart/test/contexts_test.dart +++ b/packages/dart/test/contexts_test.dart @@ -126,30 +126,6 @@ void main() { ); }); - test('clone context', () { - // ignore: deprecated_member_use_from_same_package - final clone = contexts.clone(); - - expect(clone.app!.toJson(), contexts.app!.toJson()); - expect(clone.browser!.toJson(), contexts.browser!.toJson()); - expect(clone.device!.toJson(), contexts.device!.toJson()); - expect( - clone.operatingSystem!.toJson(), contexts.operatingSystem!.toJson()); - expect(clone.gpu!.toJson(), contexts.gpu!.toJson()); - expect(clone.flags!.toJson(), contexts.flags!.toJson()); - for (final element in contexts.runtimes) { - expect( - clone.runtimes.where( - (clone) => MapEquality().equals(element.toJson(), clone.toJson()), - ), - isNotEmpty, - ); - } - - expect(clone['theme'], {'value': 'material'}); - expect(clone['version'], {'value': 9}); - }); - test('set runtimes', () { final contexts = Contexts(); contexts.runtimes = [ From 1ce443a119522e389accb1ef7ed29b9a853c9a0d Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 6 Jul 2026 13:23:57 +0200 Subject: [PATCH 2/4] ref: Rename feature flag copy() to clone() Align internal naming with Hub.clone() and Scope.clone(). The copy name existed only to avoid clashing with the deprecated public clone() API, which this branch removes. Co-Authored-By: Claude Fable 5 --- packages/dart/lib/src/protocol/sentry_feature_flag.dart | 3 +-- packages/dart/lib/src/protocol/sentry_feature_flags.dart | 5 ++--- packages/dart/lib/src/scope.dart | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/dart/lib/src/protocol/sentry_feature_flag.dart b/packages/dart/lib/src/protocol/sentry_feature_flag.dart index 8bb4e84d2c..34b773c6bf 100644 --- a/packages/dart/lib/src/protocol/sentry_feature_flag.dart +++ b/packages/dart/lib/src/protocol/sentry_feature_flag.dart @@ -33,9 +33,8 @@ class SentryFeatureFlag { }; } - // Uses copy rather than clone because clone is currently a deprecated public API. @internal - SentryFeatureFlag copy() { + SentryFeatureFlag clone() { return SentryFeatureFlag( flag: flag, result: result, diff --git a/packages/dart/lib/src/protocol/sentry_feature_flags.dart b/packages/dart/lib/src/protocol/sentry_feature_flags.dart index 10b764d4be..9e6f2841da 100644 --- a/packages/dart/lib/src/protocol/sentry_feature_flags.dart +++ b/packages/dart/lib/src/protocol/sentry_feature_flags.dart @@ -36,12 +36,11 @@ class SentryFeatureFlags { }; } - // Uses copy rather than clone because clone is currently a deprecated public API. @internal - SentryFeatureFlags copy() { + SentryFeatureFlags clone() { final unknown = this.unknown; return SentryFeatureFlags( - values: values.map((flag) => flag.copy()).toList(growable: false), + values: values.map((flag) => flag.clone()).toList(growable: false), unknown: unknown == null ? null : Map.from(unknown), ); } diff --git a/packages/dart/lib/src/scope.dart b/packages/dart/lib/src/scope.dart index fb054587c5..286541b9f5 100644 --- a/packages/dart/lib/src/scope.dart +++ b/packages/dart/lib/src/scope.dart @@ -505,7 +505,7 @@ class Scope { clone._setContextsSync( entry.key, entry.key == SentryFeatureFlags.type && value is SentryFeatureFlags - ? value.copy() + ? value.clone() : value, ); } From 81d0b0716a2dfa026f3dd5317259472f55a73e3a Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 6 Jul 2026 13:35:13 +0200 Subject: [PATCH 3/4] test(flutter): Fix OnProcessSpan calls missing Hint PR #3847 added a required hint parameter to OnProcessSpan but missed the five call sites in thread_info_integration_test.dart, which landed in parallel. This breaks compilation of the flutter test suite and the analyze gate on v10-branch, failing CI for every PR based on it. Co-Authored-By: Claude Fable 5 --- .../integrations/thread_info_integration_test.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/flutter/test/integrations/thread_info_integration_test.dart b/packages/flutter/test/integrations/thread_info_integration_test.dart index 8ff1482746..231a88fda5 100644 --- a/packages/flutter/test/integrations/thread_info_integration_test.dart +++ b/packages/flutter/test/integrations/thread_info_integration_test.dart @@ -425,7 +425,7 @@ void main() { ); await fixture.options.lifecycleRegistry.dispatchCallback( - OnProcessSpan(span), + OnProcessSpan(span, Hint()), ); expect( @@ -454,7 +454,7 @@ void main() { ); await fixture.options.lifecycleRegistry.dispatchCallback( - OnProcessSpan(span), + OnProcessSpan(span, Hint()), ); expect( @@ -481,7 +481,7 @@ void main() { ); await fixture.options.lifecycleRegistry.dispatchCallback( - OnProcessSpan(span), + OnProcessSpan(span, Hint()), ); expect( @@ -506,7 +506,7 @@ void main() { ); await fixture.options.lifecycleRegistry.dispatchCallback( - OnProcessSpan(span), + OnProcessSpan(span, Hint()), ); // sync == false is not synchronous, so blocked_main_thread is not set. @@ -532,7 +532,7 @@ void main() { span.setAttribute('sync', SentryAttribute.bool(true)); await fixture.options.lifecycleRegistry.dispatchCallback( - OnProcessSpan(span), + OnProcessSpan(span, Hint()), ); expect( From 08ed76c2e4bca92b618cdcd40702bcce9a41344f Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 6 Jul 2026 13:44:41 +0200 Subject: [PATCH 4/4] chore(metrics): Raise Android binary size budget The v10 feature work pushed the with-Sentry APK size diff to ~1409 KiB, past the 1350 KiB budget, failing the SDK metrics job on v10-branch and every PR based on it. Raise diffMax to 1450 KiB, following the same pattern as #3324 and #3567. Co-Authored-By: Claude Fable 5 --- metrics/metrics-android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/metrics-android.yml b/metrics/metrics-android.yml index a8dffd5ee1..ef02099ab7 100644 --- a/metrics/metrics-android.yml +++ b/metrics/metrics-android.yml @@ -13,4 +13,4 @@ startupTimeTest: binarySizeTest: diffMin: 900 KiB - diffMax: 1350 KiB + diffMax: 1450 KiB