newrelic-experimental / NewRelicReactNativeModule

Experimental module for mobile applications built with React Native.
Apache License 2.0
30 stars 7 forks source link

NewRelicRNModule.js has wrong module name in the file #4

Closed khsydney closed 3 years ago

khsydney commented 4 years ago

import {NativeModules} from 'react-native';

module.exports = NativeModules.NewRelicRNModule; -->> needs to be module.exports = NativeModules.NewRelicModule

Thank you.

gjones-sans commented 4 years ago

FWIW it actually looks like on iOS it's NewRelicModule and on android it's exposing NewRelicRNModule

https://github.com/newrelic-experimental/NewRelicReactNativeModule/blob/master/ios/rnnewrelic/NewRelicModule.m#L7 vs https://github.com/newrelic-experimental/NewRelicReactNativeModule/blob/master/android/app/src/main/java/com/rnnewrelic/NewRelicModule.java#L33

apstone commented 3 years ago

@gjones-sans Did this fix work for you? Doing to change mentioned in OPs comment, I still get an error like:

TypeError: null is not an object (evaluating '_NewRelicRNModule.default.nrInit')
gjones-sans commented 3 years ago

@apstone I changed the Android NewRelicModule.java getName() method to return NewRelicModule so it is consistent with the iOS version and also the OP change.

felixnoriel commented 3 years ago

@gjones-sans did those steps worked for you? I followed your steps but the error still occurs on my app. everything else are fine, the problem is when calling the functions from NewRelicRNModule.js

CDBridger commented 3 years ago

I too get

TypeError: null is not an object (evaluating '_NewRelicRNModule.default.nrInit')

regardless if its named one way or the other on ios simulator. Which makes me think I somehow haven't included the two files NewRelicModule.h and NewRelicModule.m correctly into my project although I do see them there.

(I'm never sure if the rnnewrelic folder should be in

 Pods
 MyProject
   | -> rnnewrelic

or

 Pods
 MyProject
   | -> MyProject -> rnnewrelic

or even if makes a difference.

As a side note I did struggle a little with the installation instructions as my project did not have a pch file and the linked instructions didn't tell you what to do if you didn't. it wasn't until I looked further under the configuration section did it mention anything about missing pch (which looks outdated anyway, but absolutely should've been linked as part of the installation instructions). Regardless I don't know if it actually DOES anything as I still have to include

#import "NewRelic/NewRelic.h"

to my AppDelegate.m file to be able to run NewRelic startWithApplication token and see the stats come up in one.newrelic.com. Nowhere here or in the installation instructions at newrelic do they mention adding that line to the AppDelegate.m file, I assume the pch file is supposed to cover that which just means my pch is doing nothing/the instructions for adding a pch on new relic do not work.

Another issue was the the import doesn't work when using angled brackets although the installation instructions dictate to use the angled brackets import, I only started using double quotes when I noticed the NewRelicModule.m used that, which I copied across to my AppDelegate to get the build working.

Sowed commented 3 years ago

@CDBridger, in a similar situation like you. No .pch as per instructions but somehow managed to make it work with the default network logging. However trying to set up and run the javascript side logging like screens and custom meta data, I fail at...

import { NativeModules } from 'react-native';
module.exports = NativeModules.NewRelicRNModule;

I have logged whatever I receive from importing NewRelicRNModule but it's always null since the logged NativeModules is also always an empty object. I think there is something we are missing in the docs. They are so convoluted.

CDBridger commented 3 years ago

This PR didn't fix it. As I mentioned I had already tried changing the file to what was done in the PR #10 , I even tried what was suggested in this issue #16 but I still get ERROR TypeError: null is not an object (evaluating '_NewRelicRNModule.default.nrInit') either way