@envelop/newrelic 4.1.0-alpha-e9434aa.0 → 4.1.0-alpha-731c100.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 (2) hide show
  1. package/esm/index.js +11 -38
  2. package/package.json +2 -2
package/esm/index.js CHANGED
@@ -1,31 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useNewRelic = exports.defaultSkipError = void 0;
27
- const core_1 = require("@envelop/core");
28
- const graphql_1 = require("graphql");
1
+ import { isAsyncIterable, EnvelopError } from '@envelop/core';
2
+ import { print, Kind } from 'graphql';
29
3
  var AttributeName;
30
4
  (function (AttributeName) {
31
5
  AttributeName["COMPONENT_NAME"] = "Envelop_NewRelic_Plugin";
@@ -50,18 +24,18 @@ const DEFAULT_OPTIONS = {
50
24
  rootFieldsNaming: false,
51
25
  skipError: defaultSkipError,
52
26
  };
53
- function defaultSkipError(error) {
54
- return error.originalError instanceof core_1.EnvelopError;
27
+ export function defaultSkipError(error) {
28
+ return error.originalError instanceof EnvelopError;
55
29
  }
56
- exports.defaultSkipError = defaultSkipError;
57
- const useNewRelic = (rawOptions) => {
30
+ export const useNewRelic = (rawOptions) => {
58
31
  const options = {
59
32
  ...DEFAULT_OPTIONS,
60
33
  ...(rawOptions || {}),
61
34
  };
62
35
  options.isExecuteVariablesRegex = options.includeExecuteVariables instanceof RegExp;
63
36
  options.isResolverArgsRegex = options.includeResolverArgs instanceof RegExp;
64
- const instrumentationApi$ = Promise.resolve().then(() => __importStar(require('newrelic'))).then(m => m.default || m)
37
+ const instrumentationApi$ = import('newrelic')
38
+ .then(m => m.default || m)
65
39
  .then(({ shim }) => {
66
40
  shim.agent.metrics.getOrCreateMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`).incrementCallCount();
67
41
  return shim;
@@ -78,16 +52,16 @@ const useNewRelic = (rawOptions) => {
78
52
  const transactionNameState = instrumentationApi.agent.tracer.getTransaction().nameState;
79
53
  const spanContext = instrumentationApi.agent.tracer.getSpanContext();
80
54
  const delimiter = transactionNameState.delimiter;
81
- const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === graphql_1.Kind.OPERATION_DEFINITION);
55
+ const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === Kind.OPERATION_DEFINITION);
82
56
  const operationType = rootOperation.operation;
83
- const document = (0, graphql_1.print)(args.document);
57
+ const document = print(args.document);
84
58
  const operationName = ((_a = options.extractOperationName) === null || _a === void 0 ? void 0 : _a.call(options, args.contextValue)) ||
85
59
  args.operationName ||
86
60
  ((_b = rootOperation.name) === null || _b === void 0 ? void 0 : _b.value) ||
87
61
  AttributeName.ANONYMOUS_OPERATION;
88
62
  let rootFields = null;
89
63
  if (options.rootFieldsNaming) {
90
- const fieldNodes = rootOperation.selectionSet.selections.filter(selectionNode => selectionNode.kind === graphql_1.Kind.FIELD);
64
+ const fieldNodes = rootOperation.selectionSet.selections.filter(selectionNode => selectionNode.kind === Kind.FIELD);
91
65
  rootFields = fieldNodes.map(fieldNode => fieldNode.name.value);
92
66
  }
93
67
  transactionNameState.setName(transactionNameState.prefix, transactionNameState.verb, delimiter, operationType + delimiter + operationName + (rootFields ? delimiter + rootFields.join('&') : ''));
@@ -154,7 +128,7 @@ const useNewRelic = (rawOptions) => {
154
128
  }
155
129
  }
156
130
  };
157
- if ((0, core_1.isAsyncIterable)(result)) {
131
+ if (isAsyncIterable(result)) {
158
132
  return {
159
133
  onNext: ({ result: singularResult }) => {
160
134
  sendResult(singularResult);
@@ -172,7 +146,6 @@ const useNewRelic = (rawOptions) => {
172
146
  },
173
147
  };
174
148
  };
175
- exports.useNewRelic = useNewRelic;
176
149
  function flattenPath(fieldPath, delimiter = '/') {
177
150
  const pathArray = [];
178
151
  let thisPath = fieldPath;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/newrelic",
3
- "version": "4.1.0-alpha-e9434aa.0",
3
+ "version": "4.1.0-alpha-731c100.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-e9434aa.0",
6
+ "@envelop/core": "2.4.0-alpha-731c100.0",
7
7
  "newrelic": "^7 || ^8.0.0",
8
8
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
9
9
  },