Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2025-Present Datadog, Inc.

// ignore_for_file: invalid_use_of_visible_for_testing_member

import 'package:datadog_common_test/datadog_common_test.dart';
import 'package:datadog_session_replay/datadog_session_replay.dart';
import 'package:datadog_session_replay/src/capture/capture_node.dart';
import 'package:datadog_session_replay/src/capture/recorder.dart';
import 'package:datadog_session_replay/src/datadog_session_replay_platform_interface.dart';
import 'package:datadog_session_replay/src/rum_context.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';

import 'golden_test_helpers.dart';
import 'mock_platform.dart';

void main() {
late SessionReplayRecorder recorder;
late RUMContext context;
late MockDatadogSessionReplayPlatform platform;

setUp(() {
recorder = SessionReplayRecorder(
defaultCapturePrivacy: TreeCapturePrivacy(
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskSensitiveInputs,
imagePrivacyLevel: ImagePrivacyLevel.maskNone,
),
touchPrivacyLevel: TouchPrivacyLevel.show,
);
platform = MockDatadogSessionReplayPlatform();
DatadogSessionReplayPlatform.instance = platform;

registerFallbackValue(
CapturedViewAttributes(paintBounds: Rect.zero, scaleX: 1.0, scaleY: 1.0),
);

context = RUMContext(
applicationId: randomString(),
sessionId: randomString(),
);
recorder.updateContext(context);
});

tearDown(() {
platform.clearImages();
});

Widget createIconFixture() {
return Padding(
padding: EdgeInsets.all(12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.favorite, color: Colors.red, size: 48),
Icon(Icons.home, color: Colors.blue, size: 48),
Icon(Icons.settings, size: 48),
],
),
);
}

testWidgets('global mask all icons', (tester) async {
recorder.defaultTreeCapturePrivacy = TreeCapturePrivacy(
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskAll,
imagePrivacyLevel: ImagePrivacyLevel.maskAll,
);

final fixture = MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Mask All Icons')),
body: createIconFixture(),
),
);
await snapshotTest(tester, recorder, fixture);
});

testWidgets('global mask none icons', (tester) async {
recorder.defaultTreeCapturePrivacy = TreeCapturePrivacy(
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskAll,
imagePrivacyLevel: ImagePrivacyLevel.maskNone,
);

final fixture = MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Mask No Icons')),
body: createIconFixture(),
),
);
await snapshotTest(tester, recorder, fixture);
});

testWidgets('global mask non-asset icons', (tester) async {
recorder.defaultTreeCapturePrivacy = TreeCapturePrivacy(
textAndInputPrivacyLevel: TextAndInputPrivacyLevel.maskAll,
imagePrivacyLevel: ImagePrivacyLevel.maskNonAssetsOnly,
);

final fixture = MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Mask Non-Asset Icons')),
body: createIconFixture(),
),
);
await snapshotTest(tester, recorder, fixture);
});

testWidgets('override mask all icons', (tester) async {
final fixture = MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Override Mask All Icons')),
body: SessionReplayPrivacy(
imagePrivacyLevel: ImagePrivacyLevel.maskAll,
child: createIconFixture(),
),
),
);
await snapshotTest(tester, recorder, fixture);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class _ImagesScreenState extends State<ImagesScreen> {
body: SingleChildScrollView(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Icon(Icons.favorite, color: Colors.red, size: 32),
Icon(Icons.home, color: Colors.blue, size: 32),
Icon(Icons.settings, size: 32),
],
),
),
Image.asset('assets/dd_logo_v_rgb.png'),
Image.network(
'https://placehold.co/200x200.png',
Expand Down
10 changes: 10 additions & 0 deletions packages/datadog_session_replay/lib/datadog_session_replay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ class DatadogSessionReplayConfiguration {
/// Defaults to approximately 800×800 decoded pixels.
int maxImagePixelBudget;

/// Logical size (dp) at which icon glyphs are rasterized for session replay.
///
/// The replay player scales the bitmap to the widget's on-screen bounds.
/// Smaller values reduce CPU/GPU work and memory; larger values improve
/// sharpness when icons are displayed big.
///
/// Defaults to `20`.
double iconRasterLogicalSize;

DatadogSessionReplayConfiguration({
required this.replaySampleRate,
this.textAndInputPrivacyLevel = TextAndInputPrivacyLevel.maskAll,
Expand All @@ -203,6 +212,7 @@ class DatadogSessionReplayConfiguration {
this.fontFamilyTransform = const FontFamilyTransformConfig(),
this.imageDownscaling = ImageDownscaling.disabled,
this.maxImagePixelBudget = defaultMaxImagePixelBudget,
this.iconRasterLogicalSize = 20.0,
});
}

Expand Down
Loading