cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Microsoft safalkishore
Microsoft

Application Insights (External NPM Dependency): Error packaging

We tried to add the App Insights (https://www.npmjs.com/package/applicationinsights) npm package to our custom visual in order to track all logs/events from the same.

However we ran into issues (shown below) when we try to run or package the visual. This seems related to how pbiviz uses webpack internally and bundles files, in addition to including external dependencies.

We also did try to add external dependencies on the 'pbiviz.json' file as shown below. Yet we face the same errors.

In addition we did add other npm packages on our 'package.json' that the app inisghts npm makes use of, so for example :

-applicationinsights-native-metrics
-async_hook
-async-listener

etc..

Is this allowed in the first place ? Is there anyone who has done this before and has a fix or suggestions ?

Below are the changes made to the project :

package.json (removed other dependicies for now)
---------------

 

 

"dependencies": {
"applicationinsights": "^1.7.3"
}

 

 

 

visual.ts
---------------

 

 

import * as appInsights from 'applicationinsights';

constructor(options: VisualConstructorOptions) {
// App Insights Set-up
appInsights.setup(config.instrumentKey);
}

 

 

 

pbiviz.json
---------------

 

 

,
"externalJS": [
"node_modules/async-listener/index.js",
"node_modules/continuation-local-storage/context.js",
"node_modules/applicationinsights/out/AutoCollection/CorrelationContextManager.js",
"node_modules/applicationinsights/out/applicationinsights.js"
],

 

 


Errors:
===================
WARNING in ./node_modules/applicationinsights/out/AutoCollection/NativePerformance.js
Module not found: Error: Can't resolve 'applicationinsights-native-metrics' in 'C:\Users\safalk\Source\Repos\FUN-ESF-FE-OCVPowerBIVisual\node_modules\applicationinsights\out\AutoCollection'
@ ./node_modules/applicationinsights/out/AutoCollection/NativePerformance.js
@ ./node_modules/applicationinsights/out/applicationinsights.js
@ ./src/visual.ts
@ ./.tmp/precompile/visualPlugin.ts
@ multi ./.tmp/precompile/visualPlugin.ts

ERROR in ./node_modules/cls-hooked/context.js
Module not found: Error: Can't resolve 'async_hooks' in 'C:\Users\safalk\Source\Repos\FUN-ESF-FE-OCVPowerBIVisual\node_modules\cls-hooked'
@ ./node_modules/cls-hooked/context.js 10:18-40
@ ./node_modules/cls-hooked/index.js
@ ./node_modules/applicationinsights/out/AutoCollection/CorrelationContextManager.js
@ ./node_modules/applicationinsights/out/applicationinsights.js
@ ./src/visual.ts
@ ./.tmp/precompile/visualPlugin.ts
@ multi ./.tmp/precompile/visualPlugin.ts

ERROR in ./node_modules/applicationinsights/out/Library/Sender.js
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\safalk\Source\Repos\FUN-ESF-FE-OCVPowerBIVisual\node_modules\applicationinsights\out\Library'
@ ./node_modules/applicationinsights/out/Library/Sender.js 11:20-44
@ ./node_modules/applicationinsights/out/Library/TelemetryClient.js
@ ./node_modules/applicationinsights/out/Library/NodeClient.js
@ ./node_modules/applicationinsights/out/applicationinsights.js
@ ./src/visual.ts
@ ./.tmp/precompile/visualPlugin.ts
@ multi ./.tmp/precompile/visualPlugin.ts

 

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications