Skip to content

Commit

Permalink
Rename RawEventTelemetryEventEmitter to RawEventEmitter
Browse files Browse the repository at this point in the history
Summary:
This event listener does nothing by default and will do nothing if (developer) users don't explicitly create some telemetry system for their own app.

This EventEmitter makes that easier but isn't necessarily tied to telemetry, especially since it does nothing at all by default.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D34060116

fbshipit-source-id: 9345a52f502e0225358fdaa1431c052a70fa54ce
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 8, 2022
1 parent 1f15a64 commit 271b913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import EventEmitter from '../vendor/emitter/EventEmitter';
import type {IEventEmitter} from '../vendor/emitter/EventEmitter';

export type RawEventTelemetryEvent = $ReadOnly<{|
export type RawEventEmitterEvent = $ReadOnly<{|
eventName: string,
// We expect, but do not/cannot require, that nativeEvent is an object
// with the properties: key, elementType (string), type (string), tag (numeric),
Expand All @@ -20,10 +20,19 @@ export type RawEventTelemetryEvent = $ReadOnly<{|
|}>;

type RawEventDefinitions = {
[eventChannel: string]: [RawEventTelemetryEvent],
[eventChannel: string]: [RawEventEmitterEvent],
};

const RawEventTelemetryEventEmitter: IEventEmitter<RawEventDefinitions> =
const RawEventEmitter: IEventEmitter<RawEventDefinitions> =
new EventEmitter<RawEventDefinitions>();

export default RawEventTelemetryEventEmitter;
// See the React renderer / react repo for how this is used.
// Raw events are emitted here when they are received in JS
// and before any event Plugins process them or before components
// have a chance to respond to them. This allows you to implement
// app-specific perf monitoring, which is unimplemented by default,
// making this entire RawEventEmitter do nothing by default until
// *you* add listeners for your own app.
// Besides perf monitoring and maybe debugging, this RawEventEmitter
// should not be used.
export default RawEventEmitter;
6 changes: 3 additions & 3 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import typeof flattenStyle from '../StyleSheet/flattenStyle';
import {type DangerouslyImpreciseStyleProp} from '../StyleSheet/StyleSheet';
import typeof ReactFiberErrorDialog from '../Core/ReactFiberErrorDialog';
import typeof legacySendAccessibilityEvent from '../Components/AccessibilityInfo/legacySendAccessibilityEvent';
import typeof RawEventTelemetryEventEmitter from '../Core/RawEventTelemetryEventEmitter';
import typeof RawEventEmitter from '../Core/RawEventEmitter';

// flowlint unsafe-getters-setters:off
module.exports = {
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = {
get legacySendAccessibilityEvent(): legacySendAccessibilityEvent {
return require('../Components/AccessibilityInfo/legacySendAccessibilityEvent');
},
get RawEventTelemetryEventEmitter(): RawEventTelemetryEventEmitter {
return require('../Core/RawEventTelemetryEventEmitter').default;
get RawEventEmitter(): RawEventEmitter {
return require('../Core/RawEventEmitter').default;
},
};

0 comments on commit 271b913

Please sign in to comment.