Repository navigation
fix(ios): Keep manual time to display working without legacy interop #7015
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
97d5812
fix(ios): Keep manual time to display working without legacy interop
antonis af5d6cf
docs(ios): Link the PR in the changelog entry
antonis 6910f43
fix(ios): Include the on-draw reporter codegen spec in the package
antonis 0ff2743
Merge remote-tracking branch 'origin/main' into fix/ios-ondraw-report…
antonis 6132cff
docs(android): Note that new Fabric components must be listed for aut…
antonis 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #import <Sentry/SentryDefines.h> | ||
|
|
||
| #if SENTRY_HAS_UIKIT | ||
|
|
||
| # ifdef RCT_NEW_ARCH_ENABLED | ||
| # import <React/RCTViewComponentView.h> | ||
|
|
||
| /** | ||
| * Fabric version of the on-draw reporter, used only when React Native is built without the legacy | ||
| * component interop layer. Other builds keep the legacy view manager. | ||
| */ | ||
| @interface RNSentryOnDrawReporterComponentView : RCTViewComponentView | ||
| @end | ||
|
|
||
| # endif | ||
|
|
||
| #endif |
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,94 @@ | ||
| #import <Sentry/SentryDefines.h> | ||
|
|
||
| #if SENTRY_HAS_UIKIT | ||
|
|
||
| # ifdef RCT_NEW_ARCH_ENABLED | ||
|
|
||
| # import "RNSentryOnDrawReporter.h" | ||
| # import "RNSentryOnDrawReporterComponentView.h" | ||
|
|
||
| # import <React/RCTComponentViewFactory.h> | ||
| # import <React/UIView+React.h> | ||
| # import <react/renderer/components/RNSentrySpec/ComponentDescriptors.h> | ||
| # import <react/renderer/components/RNSentrySpec/Props.h> | ||
| # import <react/renderer/components/RNSentrySpec/RCTComponentViewHelpers.h> | ||
| // RCTFabricComponentsPlugins needed for RNSentryOnDrawReporterCls | ||
| # import <React/RCTFabricComponentsPlugins.h> | ||
|
|
||
| @interface RNSentryOnDrawReporterComponentView () <RCTRNSentryOnDrawReporterViewProtocol> | ||
| @end | ||
|
|
||
| @implementation RNSentryOnDrawReporterComponentView { | ||
| // Holds the timing logic and is never mounted. Listening for frames doesn't need a window. | ||
| RNSentryOnDrawReporterView *_reporter; | ||
| } | ||
|
|
||
| # ifdef RCT_REMOVE_LEGACY_COMPONENT_INTEROP | ||
| // Registered here rather than through `componentProvider`, which React Native prefers over interop. | ||
| // Apps that keep the interop layer stay on the legacy view manager. | ||
| + (void)load | ||
| { | ||
| [[RCTComponentViewFactory currentComponentViewFactory] registerComponentViewClass:self]; | ||
| } | ||
| # endif | ||
|
|
||
| // Fabric requires typed default props, or mounting aborts in -updateProps:oldProps:. | ||
| - (instancetype)initWithFrame:(CGRect)frame | ||
| { | ||
| if (self = [super initWithFrame:frame]) { | ||
| static const auto defaultProps | ||
| = std::make_shared<const facebook::react::RNSentryOnDrawReporterProps>(); | ||
| _props = defaultProps; | ||
| } | ||
| return self; | ||
| } | ||
|
|
||
| + (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider | ||
| { | ||
| return facebook::react::concreteComponentDescriptorProvider< | ||
| facebook::react::RNSentryOnDrawReporterComponentDescriptor>(); | ||
| } | ||
|
|
||
| - (void)updateProps:(const facebook::react::Props::Shared &)props | ||
| oldProps:(const facebook::react::Props::Shared &)oldProps | ||
| { | ||
| [super updateProps:props oldProps:oldProps]; | ||
|
|
||
| const auto &newProps | ||
| = *std::static_pointer_cast<const facebook::react::RNSentryOnDrawReporterProps>(props); | ||
|
|
||
| if (_reporter == nil) { | ||
| _reporter = [[RNSentryOnDrawReporterView alloc] init]; | ||
| } | ||
| _reporter.initialDisplay = newProps.initialDisplay; | ||
| _reporter.fullDisplay = newProps.fullDisplay; | ||
| // Codegen represents an unset string as empty, while the reporter treats nil as "no span". | ||
| _reporter.parentSpanId = newProps.parentSpanId.empty() | ||
| ? nil | ||
| : [NSString stringWithUTF8String:newProps.parentSpanId.c_str()]; | ||
| [_reporter didSetProps:@[]]; | ||
| } | ||
|
|
||
| // Fabric reuses component views, and a stale span id would suppress the next screen's report. | ||
| - (void)prepareForRecycle | ||
| { | ||
| [super prepareForRecycle]; | ||
| _reporter = nil; | ||
| } | ||
|
|
||
| @end | ||
|
|
||
| Class<RCTComponentViewProtocol> | ||
| RNSentryOnDrawReporterCls(void) | ||
| { | ||
| # ifdef RCT_REMOVE_LEGACY_COMPONENT_INTEROP | ||
| return RNSentryOnDrawReporterComponentView.class; | ||
| # else | ||
| // Nil makes React Native fall through to the legacy interop layer. | ||
| return nil; | ||
| # endif | ||
| } | ||
|
|
||
| # endif | ||
|
|
||
| #endif |
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
16 changes: 16 additions & 0 deletions
16
packages/core/src/js/RNSentryOnDrawReporterNativeComponent.ts
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,16 @@ | ||
| import type { HostComponent, ViewProps } from 'react-native'; | ||
|
|
||
| // The default export exists in the file but the linter doesn't see it | ||
| import { codegenNativeComponent } from 'react-native'; | ||
|
|
||
| export interface NativeProps extends ViewProps { | ||
| initialDisplay?: boolean; | ||
| fullDisplay?: boolean; | ||
| parentSpanId?: string; | ||
| } | ||
|
|
||
| // Only iOS builds without the legacy interop layer use this component. Android has no flag to remove | ||
| // interop, so it keeps its legacy view manager (see `componentDescriptors` in react-native.config.js). | ||
| export default codegenNativeComponent<NativeProps>('RNSentryOnDrawReporter', { | ||
| excludedPlatforms: ['android'], | ||
| }) as HostComponent<NativeProps>; |
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
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.