Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
// (c) Copyright 2023 Supertenant Ltd. - all rights reserved.
// See LICENSE file in project root for license terms.
"use strict";const shimmer=require("shimmer");let logger;logger=require("../../../logger").getLogger("tracing/superagent",newLogger=>{logger=newLogger});const requireHook=require("../../../util/requireHook"),cls=require("../../cls");function instrumentThen(originalThen){return function(){if(this.__inctx){const originalThis=this,originalArgs=new Array(arguments.length);for(let i=0;i<arguments.length;i++)originalArgs[i]=arguments[i];return cls.runInAsyncContext(this.__inctx,()=>originalThen.apply(originalThis,originalArgs))}return originalThen.apply(this,arguments)}}exports.init=function(){requireHook.onModuleLoad("superagent",exports.instrument)},exports.instrument=function(superagent){const OriginalRequest=superagent.Request;OriginalRequest&&"function"==typeof OriginalRequest?OriginalRequest.__in?logger.debug("Attempted duplicated instrumentation of superagent. The provided object is already instrumented."):(superagent.Request=function(){var request=new(Function.prototype.bind.apply(OriginalRequest,[null].concat(Array.prototype.slice.call(arguments))));return request.prototype=OriginalRequest.prototype,request.__inctx=cls.getAsyncContext(),request},superagent.Request.__in=!0,superagent.Request.prototype=OriginalRequest.prototype,shimmer.wrap(superagent.Request.prototype,"then",instrumentThen)):logger.debug('Failed to instrument superagent. The provided object has no function named "Request".')},exports.activate=function(){},exports.deactivate=function(){};