@dynatrace/agent-api
Advanced tools
Comparing version 1.1.3 to 1.2.0
"use strict"; | ||
const debug = require("debug")("dynatrace-agent-api"); | ||
const path = require("path"); | ||
var debug = require("debug")("dynatrace-agent-api"); | ||
var path = require("path"); | ||
@@ -16,13 +16,20 @@ // Dummy AgentApi, which acts as a nop | ||
function findAgent() { | ||
return Object.keys(require("module")._cache).find((m) => { | ||
if(m.includes("nodejsagent.js") && (m.includes("dynatrace") || m.includes("ruxit"))) return m; | ||
}) || null; | ||
var cache = Object.keys(require("module")._cache); | ||
var i = 0; | ||
while (i < cache.length) { | ||
var m = cache[i]; | ||
if ((m.indexOf("nodejsagent.js") !== -1) && ((m.indexOf("dynatrace") !== -1) || (m.indexOf("ruxit") !== -1))) { | ||
return m; | ||
} | ||
i++; | ||
} | ||
return null; | ||
} | ||
function getLegacyAgentApi() { | ||
const agentPath = findAgent(); | ||
var agentPath = findAgent(); | ||
if(agentPath) { | ||
if (agentPath) { | ||
try { | ||
const directAsyncWrap = require(path.dirname(agentPath) + "/lib/core").directAsyncWrap; | ||
var directAsyncWrap = require(path.dirname(agentPath) + "/lib/core").directAsyncWrap; | ||
if (typeof(directAsyncWrap) !== "function") { | ||
@@ -40,3 +47,3 @@ debug("Failed to get core.directAsyncWrap() from agent"); | ||
passContext: function passContext(f) { | ||
const fname = f.prototype ? f.prototype.name : "anonymous function"; | ||
var fname = f.prototype ? f.prototype.name : "anonymous function"; | ||
return directAsyncWrap(f, {}, "callback for " + fname); | ||
@@ -43,0 +50,0 @@ } |
{ | ||
"name": "@dynatrace/agent-api", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Node.js bindings for Dynatrace OneAgent", | ||
"engines":{"node": ">= 4.0.0"}, | ||
"engines":{"node": ">= 0.10.0"}, | ||
"main": "./lib/index.js", | ||
@@ -7,0 +7,0 @@ "scripts": { |
@@ -31,6 +31,6 @@ # Node.js API for Dynatrace OneAgent | ||
```js | ||
const dta = require('dynatrace-agent-api')(); | ||
const dta = require('@dynatrace/agent-api')(); | ||
function couchMiddleware(req, res, next) { | ||
couch.get("testdb", "123a3354452ddfa2973ec0a477000f7a").then(dta.passContext(couchCallback), err => { | ||
couch.get('testdb', '123a3354452ddfa2973ec0a477000f7a').then(dta.passContext(couchCallback), err => { | ||
if(err) throw err; | ||
@@ -37,0 +37,0 @@ }).then(dta.passContext(next)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8652
65
1