diff --git a/packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js b/packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js index 643e2c130a4e9..24d35b52a45d0 100644 --- a/packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js +++ b/packages/react-native-renderer/src/legacy-events/ResponderTouchHistoryStore.js @@ -184,8 +184,21 @@ function printTouchBank(): string { return printed; } +let instrumentationCallback: ?(string, TouchEvent) => void; + const ResponderTouchHistoryStore = { + /** + * Registers a listener which can be used to instrument every touch event. + */ + instrument(callback: (string, TouchEvent) => void): void { + instrumentationCallback = callback; + }, + recordTouchTrack(topLevelType: string, nativeEvent: TouchEvent): void { + if (instrumentationCallback != null) { + instrumentationCallback(topLevelType, nativeEvent); + } + if (isMoveish(topLevelType)) { nativeEvent.changedTouches.forEach(recordTouchMove); } else if (isStartish(topLevelType)) {