-
Notifications
You must be signed in to change notification settings - Fork 11
Using this with react-native #46
Comments
Hey @shortstevenn this is probably a fault of the README. This repo is meant to be only a dependency of the main repo (https://github.com/Microsoft/ApplicationInsights-JS/tree/master/AISKU#getting-started), and not directly used by itself. Perhaps it should just link there or copy the other readme altogether. Please try the Getting Started guide and open an issue in the main repo if you face the same problems!
import { ApplicationInsights } from '@microsoft/applicationinsights-web' const appInsights = new ApplicationInsights({ config: {
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE',
/* ...Other Configuration Options... */
}});
appInsights.loadAppInsights(); |
@markwolff thanks. I saw that one (and the nodejs one too lol) but it's web specific so react-native gives all that "document is not defined" fun. Your library was core js so I was hopeful I could shim it in without the web dependencies. It seems like I'm close - I think I just need to write my own channel to the ai http posting api. |
@shortstevenn Actually we have something exactly for this scenario (specifically webworkers). You can use our "basic sku" which does not have any dependencies on the DOM. It comes with a channel builtin & ready to go. You will need to write a shim for all of the "tracks" you want to do, which it seems like you've already done. You just call https://github.com/Microsoft/ApplicationInsights-JS/tree/master/AISKU#application-insights-web-basic |
I can see this library isn't exactly "production ready" - pretty sure it's not really meant for me to start using it yet, so I don't expect a whole lot of support - but I figured I'd ask :)
That said, I'm trying to get it going - and yes I know there is appcenter for react-native apis, but I really don't want to eject my expo app.
I've got it imported and I'm constructing the AppInsightsCore object. When I call .initialize though - it blows up on "no channels available".
it('AI', () => {
const ai = new AppInsightsCore();
let config2 = {
endpointUrl: "https://company.services.visualstudio.com/v2/track",
instrumentationKey: "my-instrumentation-key",
loglevelConsole:2,
loggingLevelTelemetry:2
};
ai.initialize(config2);
can't read property foreach of undefined.
So I made it happy with
ai.initialize(config2, [])
but that get's no channels available.
That's where I'm stuck at the moment.
The code seems clean and well written - I'm just not clear on exactly what channels are or where they come from.
I'd be happy to just get a hello world traced to my ai service though. So I was hoping there might be some extra docs/examples available to get a stub going.
The text was updated successfully, but these errors were encountered: