@envelop/newrelic 4.1.0-alpha-c0cc559.0 → 5.0.0-alpha-d0d0776.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +17 -20
  2. package/index.mjs +3 -5
  3. package/package.json +19 -7
package/index.js CHANGED
@@ -2,28 +2,27 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const core = require('@envelop/core');
6
+ const graphql = require('graphql');
7
+
5
8
  function _interopNamespace(e) {
6
- if (e && e.__esModule) { return e; } else {
7
- var n = {};
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- var d = Object.getOwnPropertyDescriptor(e, k);
9
+ if (e && e.__esModule) return e;
10
+ const n = Object.create(null);
11
+ if (e) {
12
+ for (const k in e) {
13
+ if (k !== 'default') {
14
+ const d = Object.getOwnPropertyDescriptor(e, k);
11
15
  Object.defineProperty(n, k, d.get ? d : {
12
16
  enumerable: true,
13
- get: function () {
14
- return e[k];
15
- }
17
+ get: function () { return e[k]; }
16
18
  });
17
- });
19
+ }
18
20
  }
19
- n['default'] = e;
20
- return n;
21
21
  }
22
+ n["default"] = e;
23
+ return Object.freeze(n);
22
24
  }
23
25
 
24
- const core = require('@envelop/core');
25
- const graphql = require('graphql');
26
-
27
26
  var AttributeName;
28
27
  (function (AttributeName) {
29
28
  AttributeName["COMPONENT_NAME"] = "Envelop_NewRelic_Plugin";
@@ -58,7 +57,7 @@ const useNewRelic = (rawOptions) => {
58
57
  };
59
58
  options.isExecuteVariablesRegex = options.includeExecuteVariables instanceof RegExp;
60
59
  options.isResolverArgsRegex = options.includeResolverArgs instanceof RegExp;
61
- const instrumentationApi$ = new Promise(function (resolve) { resolve(_interopNamespace(require('newrelic'))); })
60
+ const instrumentationApi$ = Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('newrelic')); })
62
61
  .then(m => m.default || m)
63
62
  .then(({ shim }) => {
64
63
  shim.agent.metrics.getOrCreateMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`).incrementCallCount();
@@ -71,7 +70,6 @@ const useNewRelic = (rawOptions) => {
71
70
  });
72
71
  return {
73
72
  async onExecute({ args }) {
74
- var _a, _b;
75
73
  const instrumentationApi = await instrumentationApi$;
76
74
  const transactionNameState = instrumentationApi.agent.tracer.getTransaction().nameState;
77
75
  const spanContext = instrumentationApi.agent.tracer.getSpanContext();
@@ -79,9 +77,9 @@ const useNewRelic = (rawOptions) => {
79
77
  const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === graphql.Kind.OPERATION_DEFINITION);
80
78
  const operationType = rootOperation.operation;
81
79
  const document = graphql.print(args.document);
82
- const operationName = ((_a = options.extractOperationName) === null || _a === void 0 ? void 0 : _a.call(options, args.contextValue)) ||
80
+ const operationName = options.extractOperationName?.(args.contextValue) ||
83
81
  args.operationName ||
84
- ((_b = rootOperation.name) === null || _b === void 0 ? void 0 : _b.value) ||
82
+ rootOperation.name?.value ||
85
83
  AttributeName.ANONYMOUS_OPERATION;
86
84
  let rootFields = null;
87
85
  if (options.rootFieldsNaming) {
@@ -138,7 +136,6 @@ const useNewRelic = (rawOptions) => {
138
136
  onResolverCalled,
139
137
  onExecuteDone({ result }) {
140
138
  const sendResult = (singularResult) => {
141
- var _a;
142
139
  if (singularResult.data && options.includeRawResult) {
143
140
  spanContext.addCustomAttribute(AttributeName.EXECUTION_RESULT, JSON.stringify(singularResult));
144
141
  }
@@ -146,7 +143,7 @@ const useNewRelic = (rawOptions) => {
146
143
  const agent = instrumentationApi.agent;
147
144
  const transaction = instrumentationApi.tracer.getTransaction();
148
145
  for (const error of singularResult.errors) {
149
- if ((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, error))
146
+ if (options.skipError?.(error))
150
147
  continue;
151
148
  agent.errors.add(transaction, JSON.stringify(error));
152
149
  }
package/index.mjs CHANGED
@@ -48,7 +48,6 @@ const useNewRelic = (rawOptions) => {
48
48
  });
49
49
  return {
50
50
  async onExecute({ args }) {
51
- var _a, _b;
52
51
  const instrumentationApi = await instrumentationApi$;
53
52
  const transactionNameState = instrumentationApi.agent.tracer.getTransaction().nameState;
54
53
  const spanContext = instrumentationApi.agent.tracer.getSpanContext();
@@ -56,9 +55,9 @@ const useNewRelic = (rawOptions) => {
56
55
  const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === Kind.OPERATION_DEFINITION);
57
56
  const operationType = rootOperation.operation;
58
57
  const document = print(args.document);
59
- const operationName = ((_a = options.extractOperationName) === null || _a === void 0 ? void 0 : _a.call(options, args.contextValue)) ||
58
+ const operationName = options.extractOperationName?.(args.contextValue) ||
60
59
  args.operationName ||
61
- ((_b = rootOperation.name) === null || _b === void 0 ? void 0 : _b.value) ||
60
+ rootOperation.name?.value ||
62
61
  AttributeName.ANONYMOUS_OPERATION;
63
62
  let rootFields = null;
64
63
  if (options.rootFieldsNaming) {
@@ -115,7 +114,6 @@ const useNewRelic = (rawOptions) => {
115
114
  onResolverCalled,
116
115
  onExecuteDone({ result }) {
117
116
  const sendResult = (singularResult) => {
118
- var _a;
119
117
  if (singularResult.data && options.includeRawResult) {
120
118
  spanContext.addCustomAttribute(AttributeName.EXECUTION_RESULT, JSON.stringify(singularResult));
121
119
  }
@@ -123,7 +121,7 @@ const useNewRelic = (rawOptions) => {
123
121
  const agent = instrumentationApi.agent;
124
122
  const transaction = instrumentationApi.tracer.getTransaction();
125
123
  for (const error of singularResult.errors) {
126
- if ((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, error))
124
+ if (options.skipError?.(error))
127
125
  continue;
128
126
  agent.errors.add(transaction, JSON.stringify(error));
129
127
  }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@envelop/newrelic",
3
- "version": "4.1.0-alpha-c0cc559.0",
3
+ "version": "5.0.0-alpha-d0d0776.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-c0cc559.0",
6
+ "@envelop/core": "3.0.0-alpha-d0d0776.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
8
8
  "newrelic": "^7 || ^8.0.0"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/dotansimha/envelop.git",
12
+ "url": "https://github.com/n1ru4l/envelop.git",
13
13
  "directory": "packages/plugins/newrelic"
14
14
  },
15
15
  "author": "Santino Puleio <santinopuleio@gmail.com>",
@@ -22,12 +22,24 @@
22
22
  },
23
23
  "exports": {
24
24
  ".": {
25
- "require": "./index.js",
26
- "import": "./index.mjs"
25
+ "require": {
26
+ "default": "./index.js",
27
+ "types": "./index.d.ts"
28
+ },
29
+ "import": {
30
+ "default": "./index.mjs",
31
+ "types": "./index.d.ts"
32
+ }
27
33
  },
28
34
  "./*": {
29
- "require": "./*.js",
30
- "import": "./*.mjs"
35
+ "require": {
36
+ "default": "./*.js",
37
+ "types": "./*.d.ts"
38
+ },
39
+ "import": {
40
+ "default": "./*.mjs",
41
+ "types": "./*.d.ts"
42
+ }
31
43
  },
32
44
  "./package.json": "./package.json"
33
45
  }