Repository navigation
API parity: bridge the native methods RN was missing, and guard the rest #190
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
Open
krassx
wants to merge
25
commits into
main
Choose a base branch
from
feat/native-api-parity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ac868c9
Launch options: a typed accessor for every option either SDK registers
krassx 1def1ef
API parity: bridge the native methods RN was missing, and guard the rest
krassx 4c2d8a0
Address review: own-key legacy lookup, number-compatible enum setters…
krassx 7cd5761
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx 83809c0
Address review: tie the SDK API snapshot to the pinned versions
krassx 4cfa03a
Address review: refuse before writing, and measure the SDK version
krassx 9417c54
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx 4db1477
Address review: stamp the SDK API snapshot with the measured version
krassx 1d74d50
Address review: compute every fixture first, write them together
krassx 0481985
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx a35eb28
Gate build and publish on the option manifests the SDK releases publish
krassx 0f48e0f
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx c8945dd
Address review: 6.x warning advice follows the running platform
krassx f466b4f
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx 7a6056b
Check the accessors, types and defaults against the published manifests
krassx 4057ae3
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx 25a086a
Address CodeQL: escape backslashes in table cells and regex keys
krassx 9eccd41
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx 744fa49
Address review: strict manifest parsing, accessor docs that stay in t…
krassx 9319ba0
Merge branch 'feat/launch-options-parity' into feat/native-api-parity
krassx c74fa3f
Do not expose showVideoCapturePreview / hideVideoCapturePreview
krassx 61c54b1
Merge main into feat/native-api-parity
krassx 7bd6a0b
Address review: read Android method declarations across lines
krassx c9a87be
Address review: read annotated Android method declarations
krassx 6283813
Address review: accept modifiers between `public` and `static`
krassx 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Native API parity | ||
|
|
||
| Every public method of the Android `Bugsee` class (7.4.2) and the iOS `Bugsee` interface (7.0.x) is either exposed | ||
| by `@bugsee/react-native` or deliberately not, with a reason. The mapping is | ||
| [`scripts/sdk-api-map.ts`](../scripts/sdk-api-map.ts); `scripts/sdk-api.json` holds the SDKs' method names, and a test | ||
| fails when either side drifts (a method a new SDK release adds, an entry naming nothing, or a mapping pointing at an RN | ||
| member that does not exist). Regenerate the names with `scripts/cli-extract-sdk-api.ts`, pointing it at checkouts of the | ||
| versions in `native-versions.json`. | ||
|
|
||
| ## Platform-specific calls | ||
|
|
||
| These exist in only one SDK, and are no-ops on the other platform. | ||
|
|
||
| | Method | Android | iOS | | ||
| |---|---|---| | ||
| | `resetVideoCapturePermission()` | forgets the stored fullscreen-capture consent | no-op | | ||
| | `addSecureActivity(className)`, `removeSecureActivity(className)` | hides the activity from capture | no-op | | ||
| | `isSecureActivity(className)` | whether the activity is secure | `false` | | ||
|
|
||
| ## Not exposed, and why | ||
|
|
||
| | SDK method | Reason | | ||
| |---|---| | ||
| | `addSecureWebView` | needs a native WebView instance, which JavaScript never holds. Cover web content with `<BugseeSecure>` or `setSecureRectangles`. | | ||
| | `getAllSecureRectangles` | the wrapper owns the rectangles it publishes (`setSecureRectangles` replaces them); the SDK's list is not read back. | | ||
| | `ext`, `registerExt` | native extension lookup and registration. Extension SPIs (Leak's `watchObject`, the OkHttp interceptor) take native objects. | | ||
| | `getDefaultNetworkSanitizer`, `getExchangeFactory` | used inside the wrapper's own filter and event bridges. | | ||
| | `getVideoFrameConsumer` | SPI for wrappers that feed their own video frames; this one records natively. | | ||
| | `setWrapper`, `onUncaughtException`, `delegate`, `sharedInstance` | the wrapper's own plumbing. | | ||
| | `showVideoCapturePreview`, `hideVideoCapturePreview` (iOS) | an SDK debug overlay for checking video capture; deliberately not exposed. | | ||
| | `getLaunched`, `launched` | `await getStatus()` against `Status.Launched`. | | ||
| | `addSecureViews`, `setLogFilter` (Android) | deprecated in the SDK. | | ||
|
|
||
| `relaunch()` with no argument keeps the options the app supplied (it replays `getHostLaunchOptions()`); the native SDKs' | ||
| bare relaunch restarts with defaults. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| jest.mock('react-native', () => ({ Platform: { OS: 'android' } })); | ||
| jest.mock('../exceptions/handlers', () => ({ | ||
| installExceptionHandlers: jest.fn(), | ||
| setExceptionCaptureEnabled: jest.fn(), | ||
| setCrashDetectionOptedOut: jest.fn(), | ||
| })); | ||
| jest.mock('../console/capture', () => ({ installConsoleCapture: jest.fn() })); | ||
| jest.mock('../NativeBugsee', () => require('../__mocks__/native').nativeMock); | ||
|
|
||
| import Bugsee from '../index'; | ||
| import { native } from '../__mocks__/native'; | ||
|
|
||
| beforeEach(() => native.reset()); | ||
|
|
||
| describe('getHostLaunchOptions', () => { | ||
| it('returns what native reports', async () => { | ||
| native.getHostLaunchOptions.mockResolvedValue({ | ||
| 'com.bugsee.option.reporting.triggers.shake': false, | ||
| }); | ||
| await expect(Bugsee.getHostLaunchOptions()).resolves.toEqual({ | ||
| 'com.bugsee.option.reporting.triggers.shake': false, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('relaunch', () => { | ||
| const hosted = { | ||
| 'com.bugsee.option.reporting.triggers.shake': false, | ||
| 'com.bugsee.option.capture.logs.level': 2, | ||
| }; | ||
|
|
||
| it('with no argument replays the options the app supplied, so nothing resets', async () => { | ||
| native.getHostLaunchOptions.mockResolvedValue(hosted); | ||
| await Bugsee.relaunch(); | ||
| expect(native.relaunch).toHaveBeenCalledWith(hosted); | ||
| }); | ||
|
|
||
| it('with an argument sends exactly that and never asks for the host options', async () => { | ||
| native.getHostLaunchOptions.mockResolvedValue(hosted); | ||
| const next = { 'com.bugsee.option.capture.logs': false }; | ||
| await Bugsee.relaunch(next); | ||
| expect(native.relaunch).toHaveBeenCalledWith(next); | ||
| expect(native.getHostLaunchOptions).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('with an explicit empty map still resets to the SDK defaults', async () => { | ||
| native.getHostLaunchOptions.mockResolvedValue(hosted); | ||
| await Bugsee.relaunch({}); | ||
| expect(native.relaunch).toHaveBeenCalledWith({}); | ||
| expect(native.getHostLaunchOptions).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('sends an empty map when the app supplied nothing', async () => { | ||
| native.getHostLaunchOptions.mockResolvedValue({}); | ||
| await Bugsee.relaunch(); | ||
| expect(native.relaunch).toHaveBeenCalledWith({}); | ||
| }); | ||
|
|
||
| it('does not relaunch when the host options cannot be read, rather than resetting every setting', async () => { | ||
| native.getHostLaunchOptions.mockRejectedValue(new Error('x')); | ||
| await expect(Bugsee.relaunch()).rejects.toThrow(); | ||
| expect(native.relaunch).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('platform-specific calls forward to native', () => { | ||
| it('resetVideoCapturePermission', () => { | ||
| Bugsee.resetVideoCapturePermission(); | ||
| expect(native.resetVideoCapturePermission).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('addSecureActivity and removeSecureActivity pass the class name', () => { | ||
| Bugsee.addSecureActivity('com.example.MainActivity'); | ||
| Bugsee.removeSecureActivity('com.example.MainActivity'); | ||
| expect(native.addSecureActivity).toHaveBeenCalledWith('com.example.MainActivity'); | ||
| expect(native.removeSecureActivity).toHaveBeenCalledWith('com.example.MainActivity'); | ||
| }); | ||
|
|
||
| it('isSecureActivity returns the native answer', async () => { | ||
| native.isSecureActivity.mockResolvedValue(true); | ||
| await expect(Bugsee.isSecureActivity('com.example.A')).resolves.toBe(true); | ||
| expect(native.isSecureActivity).toHaveBeenCalledWith('com.example.A'); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity: P2 Medium
Problem: The iOS signatures were inventoried from
origin/release("7.0.x"), but the pin innative-versions.jsonis the stable7.0.0(SPM binary).getHostLaunchOptions,showVideoCapturePreviewandhideVideoCapturePrevieware only guaranteed to exist if they shipped in the 7.0.0 tag.Impact: If any of the three is missing from 7.0.0, the iOS target fails to compile. The PR says CI is the first iOS compile, so the first signal would be a red build. The parity test cannot catch this, because
sdk-api.jsonwas extracted from an unreleased branch.Scenario:
releasehas moved past 7.0.0 and these were added after the tag.yarn jestpasses and the iOS build fails withno known class method for selector 'getHostLaunchOptions'.Fix: Regenerate
sdk-api.jsonfrom the 7.0.0 tag, as the extractor's own doc says ("checkouts at the PINNED versions"). Or confirm that the three selectors are in the 7.0.0 header.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked against the 7.0.0 release itself rather than the branch: the commit that bumped iOS to 7.0.0 (478d5165a) has a
Bugsee.hbyte-identical toorigin/release, andgetHostLaunchOptions,showVideoCapturePreviewandhideVideoCapturePrevieware declared in it. So the iOS snapshot describes 7.0.0 and the three selectors exist in the pinned SDK. The snapshot now records the versions it was extracted at (see the other thread), so this claim is checked from here on.