From 14ca57b435861d45f4e271eec69c1ef0fa6ea3c0 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 17 Jun 2021 15:09:52 -0700 Subject: [PATCH] Log ImageSource uris that are not using Facebook domain Summary: This diff adds logging to uncover what are the ReactNative screens that are rendering images using NON-Facebook domains changelog: [internal] internal Reviewed By: yungsters Differential Revision: D29179990 fbshipit-source-id: 85f6380848d1ac1461419bc29c4666be389fb87a --- Libraries/Image/Image.android.js | 11 ++++++++--- Libraries/Image/ImageSourceInjection.js | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Libraries/Image/ImageSourceInjection.js diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 81df06415c1..76d3f56306d 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -13,7 +13,7 @@ import ImageViewNativeComponent from './ImageViewNativeComponent'; import * as React from 'react'; import StyleSheet from '../StyleSheet/StyleSheet'; import TextAncestor from '../Text/TextAncestor'; - +import ImageSourceInjection from './ImageSourceInjection'; import ImageAnalyticsTagContext from './ImageAnalyticsTagContext'; import flattenStyle from '../StyleSheet/flattenStyle'; import resolveAssetSource from './resolveAssetSource'; @@ -132,8 +132,13 @@ let Image = (props: ImagePropsType, forwardedRef) => { props.loadingIndicatorSource, ); - if (source && source.uri === '') { - console.warn('source.uri should not be an empty string'); + if (source) { + const uri = source.uri; + if (uri === '') { + console.warn('source.uri should not be an empty string'); + } else if (ImageSourceInjection.unstable_enableUriAnalytics) { + ImageSourceInjection.unstable_enableUriAnalytics(uri); + } } if (props.src) { diff --git a/Libraries/Image/ImageSourceInjection.js b/Libraries/Image/ImageSourceInjection.js new file mode 100644 index 00000000000..ff8fa422aa9 --- /dev/null +++ b/Libraries/Image/ImageSourceInjection.js @@ -0,0 +1,13 @@ +/** + * 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. + * + * @format + * @flow strict + */ + +export default { + unstable_enableUriAnalytics: (null: ?(uri: string) => void), +};