react-native-google-analytics icon indicating copy to clipboard operation
react-native-google-analytics copied to clipboard

"Received data was not a string, or was not a recognised encoding."

Open adamrainsby opened this issue 8 years ago • 17 comments

It seems to be getting picked up by google analytics but I'm getting this warning. Any idea why?

I'm running ios version 9.2 and this is how I'm calling it.

    let screenView = new GAHits.ScreenView(
      config.app.name,
      screenName,
      config.app.version,
      config.app.id,
      null,
      null
    );

adamrainsby avatar Mar 09 '16 17:03 adamrainsby

Same here. But it seems that this appears only when running my application via the iOS simulator; when testing with iPhone, the warning doesn't pop up.

miro avatar Mar 17 '16 11:03 miro

+1

CodeTitanian avatar Apr 11 '16 07:04 CodeTitanian

+1

vkshrestha avatar Apr 24 '16 12:04 vkshrestha

+1

mofelee avatar Apr 25 '16 04:04 mofelee

+1

kevinhylant avatar May 13 '16 20:05 kevinhylant

@lwansbrough Any update on this issue or is this something that is a bug with the RN core code?

kevinhylant avatar May 13 '16 20:05 kevinhylant

I think a recent version of React Native may have addressed the problem of receiving generic data from XHR requests. Is anyone still getting this warning with React Native 0.25?

lwansbrough avatar May 14 '16 00:05 lwansbrough

We're running RN at 0.23 right now, will try updating to see if it is resolved & let you know soon as I have - thanks!

kevinhylant avatar May 14 '16 03:05 kevinhylant

@lwansbrough still getting this warning on RN 26

adeelraza avatar Jun 06 '16 23:06 adeelraza

@adeelraza @lwansbrough - I can confirm the same.

kevinhylant avatar Jun 06 '16 23:06 kevinhylant

The other option is to use Image.prefetch instead of XHR but that's kind of an abuse of ram. Though 1x1 images are really small.

lwansbrough avatar Jun 07 '16 00:06 lwansbrough

Hi I'm getting this issue too, I don't know if this is preventing my GA to collect the data, or if the error just happens on my app and the GA should gather the info properly (which is not happening), I don't even know if this is the right place to ask for help on this XD I'm running RN 0.23, I'm trying on the iOS emulator and on my android device. EDIT: Actually I found out GA is actually gathering the info properly, so the issue is only on the app.

Alons-Oh avatar Jun 07 '16 18:06 Alons-Oh

We're using this library in production in several apps without a problem. The only issue is the warning in dev mode. If anyone wants to try and sub the fetch call with Image.prefetch that would be helpful.

lwansbrough avatar Jun 08 '16 00:06 lwansbrough

+1

xiaolv899 avatar Jun 16 '16 04:06 xiaolv899

+1

oportocala avatar Jun 20 '16 23:06 oportocala

Guys please stop +1ing this, GitHub has reactions now if you wish to indicate your interest/support. Beyond that, this issue is a problem with React Native itself. I'm tempted to close this as wontfix but I think there might be a better solution than that.

lwansbrough avatar Jun 20 '16 23:06 lwansbrough

Substituting Image.prefetch for fetch isn't ideal because that can flush out actual useful images from the image cache.

How about using the underlying XMLHttpRequest?

In Analytics.js, replace fetch with:

return new Promise(function (resolve, reject) {
      let xhr = new XMLHttpRequest();
      xhr.open('GET', request);
      xhr.setRequestHeader('User-Agent', this.userAgent);
      xhr.onload = resolve;
      xhr.onerror = reject;
      xhr.send();
});

Scratch that. Still getting the yellow box warnings with XMLHttpRequest. Looks like this needs to be fixed in RN itself.

peacechen avatar May 31 '18 15:05 peacechen