Skip to content
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

React Native raw event EventEmitter - intended for app-specific perf listeners and debugging #23232

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

const ReactNativeEventPluginOrder = [
'ReactNativeEventTelemetryPlugin', // We want telemetry to run before any other work is done.
'ResponderEventPlugin',
'ReactNativeBridgeEventPlugin',
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {RawEventTelemetryEventEmitter} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const ReactNativeEventTelemetryPlugin = {
extractEvents: function(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Concise notation.

Suggested change
extractEvents: function(
extractEvents(

topLevelType,
targetInst,
nativeEvent,
nativeEventTarget,
eventSystemFlags
) {
RawEventTelemetryEventEmitter.emitEvent(topLevelType, nativeEvent);

// We never extract events here, we just forward to the telemetry system.
// Thus, returning null here unconditionally is optimal.
return null;
}
};

export default ReactNativeEventTelemetryPlugin;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
injectEventPluginsByName,
} from './legacy-events/EventPluginRegistry';

import ReactNativeEventTelemetryPlugin from './ReactNativeEventTelemetryPlugin';
import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';

Expand All @@ -35,6 +36,7 @@ injectEventPluginOrder(ReactNativeEventPluginOrder);
* them).
*/
injectEventPluginsByName({
ReactNativeEventTelemetryPlugin: ReactNativeEventTelemetryPlugin,
ResponderEventPlugin: ResponderEventPlugin,
ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const RawEventTelemetryEventEmitter = {
emitEvent: jest.fn(),
};

module.exports = RawEventTelemetryEventEmitter;
JoshuaGross marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ module.exports = {
get legacySendAccessibilityEvent() {
return require('./legacySendAccessibilityEvent');
},
get RawEventTelemetryEventEmitter() {
return require('./RawEventTelemetryEventEmitter');
},
};