Skip to content

Commit

Permalink
Add RawEventTelemetryEventEmitter interface to ReactNativePrivateInte…
Browse files Browse the repository at this point in the history
…rface

Summary:
This will be used from the React JS renderer in a followup PR.

Changelog: [Added][JS] New event telemetry mechanism exposed from JS to supercede the Pressability-specific telemetry mechanism

Reviewed By: ryancat

Differential Revision: D33986916

fbshipit-source-id: 912d0b351869348f0ca6e5f6a882fc0501c2c7f0
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 7, 2022
1 parent 97ce240 commit 1f15a64
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Libraries/Core/RawEventTelemetryEventEmitter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

import EventEmitter from '../vendor/emitter/EventEmitter';
import type {IEventEmitter} from '../vendor/emitter/EventEmitter';

export type RawEventTelemetryEvent = $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),
// and a stateNode of the native element/Fiber the event was emitted to.
nativeEvent: {[string]: mixed},
|}>;

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

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

export default RawEventTelemetryEventEmitter;
4 changes: 4 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +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';

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

0 comments on commit 1f15a64

Please sign in to comment.