-
Notifications
You must be signed in to change notification settings - Fork 4
feat(react-native): add maskTestIDs and unmaskTestIDs masking options #528
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
07be3b2
feat(react-native): add maskTestIDs and unmaskTestIDs options
beekld 932fb9b
test(react-native): add MaskingScreen and env-var setup for example app
beekld 752772e
chore(react-native): bump observability-android dep to 0.45.0
beekld 648b2c4
fix(react-native): keep maskAccessibilityIdentifiers a no-op on Android
beekld 4d16967
fix(react-native): mask RN <Text> on iOS when maskLabels is on
beekld 486e5cb
test(react-native): stub testID hasKey calls in Android bridge test
beekld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
sdk/@launchdarkly/react-native-ld-session-replay/example/src/MaskingScreen.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| import { Image, ScrollView, StyleSheet, Text, View } from 'react-native'; | ||
|
|
||
| /** | ||
| * Manual test screen for `maskTestIDs` / `unmaskTestIDs`. The plugin in `App.tsx` is configured | ||
| * with `maskTestIDs: ['password', 'ssn']` and `unmaskTestIDs: ['safe']`. Each row's testID is | ||
| * picked to exercise a specific case; the inline comment on each row explains the expected | ||
| * behavior under whatever values of `maskLabels` / `maskImages` are currently set in the plugin | ||
| * config. | ||
| * | ||
| * Section headers use `testID="safe"` so they remain readable in the recording regardless of | ||
| * `maskLabels`. | ||
| */ | ||
| export default function MaskingScreen() { | ||
| return ( | ||
| <ScrollView contentContainerStyle={styles.scroll}> | ||
| <Text testID="safe" style={styles.intro}> | ||
| Some rows below will be masked in replays, depending on the plugin's | ||
| config. | ||
| </Text> | ||
|
|
||
| <Text testID="safe" style={styles.sectionHeader}> | ||
| Text rows | ||
| </Text> | ||
|
|
||
| {/* Always masked: testID is in maskTestIDs (explicit-mask wins regardless of | ||
| maskLabels). */} | ||
| <Text testID="password" style={styles.row}> | ||
| my password is hunter2 | ||
| </Text> | ||
|
|
||
| {/* Always masked: testID is in maskTestIDs. */} | ||
| <Text testID="ssn" style={styles.row}> | ||
| ssn: 123-45-6789 | ||
| </Text> | ||
|
|
||
| {/* Always unmasked: testID is in unmaskTestIDs (explicit-unmask overrides | ||
| maskLabels). */} | ||
| <Text testID="safe" style={styles.row}> | ||
| safe text — should always be visible | ||
| </Text> | ||
|
|
||
| {/* Masked iff maskLabels is on. testID does not match any list — falls through to | ||
| the global maskLabels rule. */} | ||
| <Text testID="other" style={styles.row}> | ||
| plain text with non-matching testID | ||
| </Text> | ||
|
|
||
| <Text testID="safe" style={styles.sectionHeader}> | ||
| Image rows | ||
| </Text> | ||
|
|
||
| {/* Always masked: testID is in maskTestIDs (explicit-mask wins regardless of | ||
| maskImages). */} | ||
| <View style={styles.imageRow}> | ||
| <Image testID="password" source={LOGO} style={styles.image} /> | ||
| <Text testID="safe" style={styles.imageLabel}> | ||
| testID="password" | ||
| </Text> | ||
| </View> | ||
|
|
||
| {/* Always unmasked: testID is in unmaskTestIDs (explicit-unmask overrides | ||
| maskImages). */} | ||
| <View style={styles.imageRow}> | ||
| <Image testID="safe" source={LOGO} style={styles.image} /> | ||
| <Text testID="safe" style={styles.imageLabel}> | ||
| testID="safe" | ||
| </Text> | ||
| </View> | ||
|
|
||
| {/* Masked iff maskImages is on. testID does not match any list — falls through to | ||
| the global maskImages rule. */} | ||
| <View style={styles.imageRow}> | ||
| <Image testID="other" source={LOGO} style={styles.image} /> | ||
| <Text testID="safe" style={styles.imageLabel}> | ||
| testID="other" | ||
| </Text> | ||
| </View> | ||
| </ScrollView> | ||
| ); | ||
| } | ||
|
|
||
| const LOGO = { uri: 'https://reactnative.dev/img/tiny_logo.png' }; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| scroll: { | ||
| padding: 16, | ||
| gap: 12, | ||
| }, | ||
| intro: { | ||
| color: '#CAC4D0', | ||
| fontSize: 14, | ||
| fontStyle: 'italic', | ||
| }, | ||
| sectionHeader: { | ||
| color: '#fff', | ||
| fontSize: 20, | ||
| fontWeight: 'bold', | ||
| marginTop: 8, | ||
| }, | ||
| row: { | ||
| color: '#fff', | ||
| fontSize: 16, | ||
| paddingVertical: 6, | ||
| }, | ||
| imageRow: { | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| gap: 12, | ||
| }, | ||
| image: { | ||
| width: 64, | ||
| height: 64, | ||
| }, | ||
| imageLabel: { | ||
| color: '#fff', | ||
| fontSize: 16, | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.