applicationinsights
Version:
Microsoft Application Insights module for Node.js
30 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function sdkAlreadyExists(_logger) {
try {
// appInstance should either resolve to user SDK or crash. If it resolves to attach SDK, user probably modified their NODE_PATH
var appInstance = void 0;
try {
// Node 8.9+
appInstance = require.resolve("applicationinsights", { paths: [process.cwd()] });
}
catch (e) {
// Node <8.9
appInstance = require.resolve(process.cwd() + "/node_modules/applicationinsights");
}
var attachInstance = require.resolve("../applicationinsights");
if (appInstance !== attachInstance) {
_logger.logMessage("applicationinsights module is already installed in this application; not re-attaching. Installed SDK location: " +
appInstance);
return true;
}
// User probably modified their NODE_PATH to resolve to this instance. Attach appinsights
return false;
}
catch (e) {
// crashed while trying to resolve "applicationinsights", so SDK does not exist. Attach appinsights
return false;
}
}
exports.sdkAlreadyExists = sdkAlreadyExists;
//# sourceMappingURL=Helpers.js.map