javascript - Add properties to context in cordova plugin for Application Insights -
i use cordova plugin application insight named cordova-plugin-ms-appinsights (https://github.com/msopentech/cordova-plugin-ms-appinsights/blob/master/readme.md) , tried add properties context, through each request application send additional info, example code name of application.
i tried below:
appinsights.context.application.codename = "code name app"; appinsights.trackevent("my event");
and did not work. can add additional info context?
there 2 issues:
1) cordova plugin seems use old version of js sdk. can try update manually after pulls down old 1 (take recent 1 https://github.com/microsoft/applicationinsights-js/blob/master/dist/ai.0.js)
2) feature adds data all telemetry items not released yet. implemented - see js sdk commit on github. can either wait bit until it's released or latest master , compile (and take result /javascript/min/ai.min.js)
a hacky alternative may create wrapper on top of sdk methods trackevent() adds data need (i'm sorry giving js sdk code equivalent haven't used cordova plugin myself):
// implementation of custom data attached // telemetry items. // needs return json - it's expected format custom properties. // in specific case you'll create custom property 'hey' value 'yo' var getmydatajson = function() { return { hey: "yo"}; } // wrapper, you'll call instead of appinsights.trackevent() var mytrackevent = function(data) { var tobeattachedtoallitems = getmydatajson(); appinsights.trackevent(data, tobeattachedtoallitems); } <...> // somewhere later track telemetry // call getmydatajson() function which'll attach // custom data event. mytrackevent("tracked!")
Comments
Post a Comment