@opentelemetry/plugin-react-load 0.29.0 → 0.30.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.
@@ -13,7 +13,21 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { __extends } from "tslib";
16
+ var __extends = (this && this.__extends) || (function () {
17
+ var extendStatics = function (d, b) {
18
+ extendStatics = Object.setPrototypeOf ||
19
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
+ return extendStatics(d, b);
22
+ };
23
+ return function (d, b) {
24
+ if (typeof b !== "function" && b !== null)
25
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
+ extendStatics(d, b);
27
+ function __() { this.constructor = d; }
28
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
+ };
30
+ })();
17
31
  import * as api from '@opentelemetry/api';
18
32
  import { isWrapped } from '@opentelemetry/core';
19
33
  import * as shimmer from 'shimmer';
@@ -1 +1 @@
1
- {"version":3,"file":"BaseOpenTelemetryComponent.js","sourceRoot":"","sources":["../../src/BaseOpenTelemetryComponent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;GAEG;AACH;IAAgD,8CAAe;IAO7D;;OAEG;IACH,oCAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAGb;QAbQ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AC;QAE/B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QAE1C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QAChD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE3C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;IAjgBc,kCAAO,GAAmB,GAAG,CAAC,IAAI,CAAC;IAkgBpD,iCAAC;CAAA,AAvgBD,CAAgD,KAAK,CAAC,SAAS,GAugB9D;SAvgBY,0BAA0B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\nimport { isWrapped } from '@opentelemetry/core';\nimport * as shimmer from 'shimmer';\nimport { AttributeNames } from './enums/AttributeNames';\nimport * as React from 'react';\nimport { VERSION } from './version';\nimport {\n RenderFunction,\n ComponentDidMountFunction,\n ComponentDidUpdateFunction,\n ShouldComponentUpdateFunction,\n SetStateFunction,\n ForceUpdateFunction,\n GetSnapshotBeforeUpdateFunction,\n ComponentWillUnmountFunction,\n} from './internal-types';\n\n/**\n * This class is the base component for a React component with lifecycle instrumentation\n */\nexport class BaseOpenTelemetryComponent extends React.Component {\n readonly component: string = 'react-load';\n moduleName = this.component;\n private _parentSpanMap: WeakMap<React.Component, api.Span>;\n private static _tracer: api.Tracer;\n private static _logger: api.DiagLogger = api.diag;\n\n /**\n * @param props Props of the React component\n */\n constructor(props: Readonly<any>) {\n super(props);\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n this.patch();\n }\n\n /**\n * Sets the tracer for all components being instrumented\n * @param name Name of tracer\n * @param version Version of tracer, this is optional. When not provided it will use the latest.\n */\n static setTracer(name: string, version?: string): void {\n BaseOpenTelemetryComponent._tracer = api.trace.getTracer(\n name,\n version ? version : VERSION\n );\n }\n\n /**\n * Sets the logger for all components being instrumented\n * @param logger\n */\n static setLogger(logger: api.DiagLogger): void {\n api.diag.setLogger(logger);\n BaseOpenTelemetryComponent._logger = logger;\n }\n\n /**\n * Creates a new span as a child of the current parent span.\n * If parent span is undefined, just the child is created.\n * @param react React component currently being instrumented\n * @param name Name of span\n * @param parentSpan parent span\n */\n private _createSpanWithParent(\n react: React.Component,\n name: string,\n parentSpan: api.Span\n ): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(\n name,\n {\n attributes: this._getAttributes(react),\n },\n parentSpan\n ? api.trace.setSpan(api.context.active(), parentSpan)\n : undefined\n );\n }\n\n /**\n * Creates a new span\n * @param react React component currently being instrumented\n * @param name Name of span\n */\n private _createSpan(react: React.Component, name: string): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(name, {\n attributes: this._getAttributes(react),\n });\n }\n\n /**\n * Provides instrumentation for a function\n * @param react React component currently instrumenting.\n * @param spanName Name to set the span of the instrumented function to.\n * @param original Original function currently being wrapped.\n * @parentName Name to set parent span to on error.\n */\n private _instrumentFunction(\n react: React.Component,\n spanName: string,\n parent: api.Span,\n original: any\n ) {\n const span = this._createSpanWithParent(react, spanName, parent);\n let wasError = false;\n try {\n return api.context.with(\n api.trace.setSpan(api.context.active(), span),\n () => {\n return original();\n }\n );\n } catch (err: any) {\n span.setAttribute(AttributeNames.REACT_ERROR, err.stack);\n wasError = true;\n throw err;\n } finally {\n span.end();\n if (wasError) {\n this._endParentSpan(react);\n }\n }\n }\n\n /**\n * Ends the current parent span.\n * @param react React component parent span belongs to.\n */\n private _endParentSpan(react: React.Component) {\n const parentSpan = this._parentSpanMap.get(react);\n if (parentSpan) {\n parentSpan.end();\n this._parentSpanMap.delete(react);\n }\n }\n\n /**\n * Returns attributes object for spans\n * @param react React component currently being instrumented\n **/\n private _getAttributes(react: React.Component) {\n let state: string;\n try {\n state = JSON.stringify(react.state);\n } catch {\n state = '{\"message\": \"state could not be turned into string\"}';\n }\n return {\n [AttributeNames.LOCATION_URL]: window.location.href,\n [AttributeNames.REACT_NAME]: react.constructor.name,\n [AttributeNames.REACT_STATE]: state,\n };\n }\n\n /**\n * This function returns a parent span. If the parent doesn't\n * exist, the function creates one\n * @param react React component parent span belongs to.\n */\n private _getParentSpan(react: React.Component, parentName: string): api.Span {\n const parentSpan: api.Span | undefined = this._parentSpanMap.get(react);\n if (!parentSpan) {\n const span = this._createSpan(react, parentName);\n this._parentSpanMap.set(react, span);\n }\n return this._parentSpanMap.get(react)!;\n }\n\n /**\n * Patches the render lifecycle method\n */\n private _patchRender() {\n return (original: RenderFunction): RenderFunction => {\n const plugin = this;\n return function patchRender(\n this: React.Component,\n ...args\n ): React.ReactNode {\n // Render is the first method in the mounting flow, if a parent span wasn't created already then we're in the mounting flow\n let parentSpan: api.Span;\n if (!plugin._parentSpanMap.get(this)) {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n } else {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n }\n\n return plugin._instrumentFunction(this, 'render', parentSpan, () => {\n return original!.apply(this, args);\n });\n };\n };\n }\n\n /**\n * Patches the componentDidMount lifecycle method\n */\n private _patchComponentDidMount() {\n return (original: ComponentDidMountFunction): ComponentDidMountFunction => {\n const plugin = this;\n\n return function patchComponentDidMount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidMount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the setState function\n */\n private _patchSetState() {\n return (original: SetStateFunction): SetStateFunction => {\n const plugin = this;\n return function patchSetState(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'setState()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the forceUpdate function\n */\n private _patchForceUpdate() {\n return (original: ForceUpdateFunction): ForceUpdateFunction => {\n const plugin = this;\n return function patchForceUpdate(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'forceUpdate()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchShouldComponentUpdate() {\n return (\n original: ShouldComponentUpdateFunction\n ): ShouldComponentUpdateFunction => {\n const plugin = this;\n\n return function patchShouldComponentUpdate(\n this: React.Component,\n ...args\n ): boolean {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'shouldComponentUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n // if shouldComponentUpdate returns false, the component does not get\n // updated and no other lifecycle methods get called\n if (!apply) {\n plugin._endParentSpan(this);\n }\n\n return apply;\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchGetSnapshotBeforeUpdate() {\n return (\n original: GetSnapshotBeforeUpdateFunction\n ): GetSnapshotBeforeUpdateFunction => {\n const plugin = this;\n\n return function patchGetSnapshotBeforeUpdate(\n this: React.Component,\n ...args\n ): any {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'getSnapshotBeforeUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the componentDidUpdate lifecycle method\n */\n private _patchComponentDidUpdate() {\n return (\n original: ComponentDidUpdateFunction\n ): ComponentDidUpdateFunction => {\n const plugin = this;\n\n return function patchComponentDidUpdate(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the componentWillUnmount lifecycle method\n */\n private _patchComponentWillUnmount() {\n return (\n original: ComponentWillUnmountFunction\n ): ComponentWillUnmountFunction => {\n const plugin = this;\n\n return function patchComponentWillUnmount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UNMOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentWillUnmount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * patch function which wraps all the lifecycle methods\n */\n public patch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'applying patch to',\n this.moduleName,\n VERSION\n );\n\n if (isWrapped(this.render)) {\n shimmer.unwrap(this, 'render');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method render'\n );\n }\n if (isWrapped(this.componentDidMount)) {\n shimmer.unwrap(this, 'componentDidMount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidMount'\n );\n }\n if (isWrapped(this.shouldComponentUpdate)) {\n shimmer.unwrap(this, 'shouldComponentUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method shouldComponentUpdate'\n );\n }\n if (isWrapped(this.getSnapshotBeforeUpdate)) {\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method getSnapshotBeforeUpdate'\n );\n }\n if (isWrapped(this.setState)) {\n shimmer.unwrap(this, 'setState');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method setState'\n );\n }\n if (isWrapped(this.forceUpdate)) {\n shimmer.unwrap(this, 'forceUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method forceUpdate'\n );\n }\n if (isWrapped(this.componentDidUpdate)) {\n shimmer.unwrap(this, 'componentDidUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidUpdate'\n );\n }\n if (isWrapped(this.componentWillUnmount)) {\n shimmer.unwrap(this, 'componentWillUnmount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentWillUnmount'\n );\n }\n\n // Lifecycle methods must exist when patching, even if not defined in component\n if (!this.render) {\n this.render = () => {\n return null;\n };\n }\n if (!this.componentDidMount) {\n this.componentDidMount = () => {\n return;\n };\n }\n if (!this.shouldComponentUpdate) {\n this.shouldComponentUpdate = () => {\n return true;\n };\n }\n if (!this.getSnapshotBeforeUpdate) {\n this.getSnapshotBeforeUpdate = () => {\n return null;\n };\n }\n if (!this.componentDidUpdate) {\n this.componentDidUpdate = () => {\n return;\n };\n }\n if (!this.componentWillUnmount) {\n this.componentWillUnmount = () => {\n return;\n };\n }\n\n shimmer.wrap(this, 'render', this._patchRender());\n shimmer.wrap(this, 'componentDidMount', this._patchComponentDidMount());\n shimmer.wrap(this, 'setState', this._patchSetState());\n shimmer.wrap(this, 'forceUpdate', this._patchForceUpdate());\n shimmer.wrap(\n this,\n 'shouldComponentUpdate',\n this._patchShouldComponentUpdate()\n );\n shimmer.wrap(\n this,\n 'getSnapshotBeforeUpdate',\n this._patchGetSnapshotBeforeUpdate()\n );\n shimmer.wrap(this, 'componentDidUpdate', this._patchComponentDidUpdate());\n shimmer.wrap(\n this,\n 'componentWillUnmount',\n this._patchComponentWillUnmount()\n );\n }\n\n /**\n * unpatch function to unwrap all the lifecycle methods\n */\n public unpatch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'removing patch from',\n this.moduleName,\n VERSION\n );\n\n shimmer.unwrap(this, 'render');\n\n shimmer.unwrap(this, 'componentDidMount');\n\n shimmer.unwrap(this, 'setState');\n shimmer.unwrap(this, 'forceUpdate');\n shimmer.unwrap(this, 'shouldComponentUpdate');\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n shimmer.unwrap(this, 'componentDidUpdate');\n\n shimmer.unwrap(this, 'componentWillUnmount');\n\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n }\n}\n"]}
1
+ {"version":3,"file":"BaseOpenTelemetryComponent.js","sourceRoot":"","sources":["../../src/BaseOpenTelemetryComponent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;GAEG;AACH;IAAgD,8CAAe;IAO7D;;OAEG;IACH,oCAAY,KAAoB;QAAhC,YACE,kBAAM,KAAK,CAAC,SAGb;QAbQ,eAAS,GAAW,YAAY,CAAC;QAC1C,gBAAU,GAAG,KAAI,CAAC,SAAS,CAAC;QAU1B,KAAI,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AC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QAChD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE3C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;IAjgBc,kCAAO,GAAmB,GAAG,CAAC,IAAI,CAAC;IAkgBpD,iCAAC;CAAA,AAvgBD,CAAgD,KAAK,CAAC,SAAS,GAugB9D;SAvgBY,0BAA0B","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\nimport { isWrapped } from '@opentelemetry/core';\nimport * as shimmer from 'shimmer';\nimport { AttributeNames } from './enums/AttributeNames';\nimport * as React from 'react';\nimport { VERSION } from './version';\nimport {\n RenderFunction,\n ComponentDidMountFunction,\n ComponentDidUpdateFunction,\n ShouldComponentUpdateFunction,\n SetStateFunction,\n ForceUpdateFunction,\n GetSnapshotBeforeUpdateFunction,\n ComponentWillUnmountFunction,\n} from './internal-types';\n\n/**\n * This class is the base component for a React component with lifecycle instrumentation\n */\nexport class BaseOpenTelemetryComponent extends React.Component {\n readonly component: string = 'react-load';\n moduleName = this.component;\n private _parentSpanMap: WeakMap<React.Component, api.Span>;\n private static _tracer: api.Tracer;\n private static _logger: api.DiagLogger = api.diag;\n\n /**\n * @param props Props of the React component\n */\n constructor(props: Readonly<any>) {\n super(props);\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n this.patch();\n }\n\n /**\n * Sets the tracer for all components being instrumented\n * @param name Name of tracer\n * @param version Version of tracer, this is optional. When not provided it will use the latest.\n */\n static setTracer(name: string, version?: string): void {\n BaseOpenTelemetryComponent._tracer = api.trace.getTracer(\n name,\n version ? version : VERSION\n );\n }\n\n /**\n * Sets the logger for all components being instrumented\n * @param logger\n */\n static setLogger(logger: api.DiagLogger): void {\n api.diag.setLogger(logger);\n BaseOpenTelemetryComponent._logger = logger;\n }\n\n /**\n * Creates a new span as a child of the current parent span.\n * If parent span is undefined, just the child is created.\n * @param react React component currently being instrumented\n * @param name Name of span\n * @param parentSpan parent span\n */\n private _createSpanWithParent(\n react: React.Component,\n name: string,\n parentSpan: api.Span\n ): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(\n name,\n {\n attributes: this._getAttributes(react),\n },\n parentSpan\n ? api.trace.setSpan(api.context.active(), parentSpan)\n : undefined\n );\n }\n\n /**\n * Creates a new span\n * @param react React component currently being instrumented\n * @param name Name of span\n */\n private _createSpan(react: React.Component, name: string): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(name, {\n attributes: this._getAttributes(react),\n });\n }\n\n /**\n * Provides instrumentation for a function\n * @param react React component currently instrumenting.\n * @param spanName Name to set the span of the instrumented function to.\n * @param original Original function currently being wrapped.\n * @parentName Name to set parent span to on error.\n */\n private _instrumentFunction(\n react: React.Component,\n spanName: string,\n parent: api.Span,\n original: any\n ) {\n const span = this._createSpanWithParent(react, spanName, parent);\n let wasError = false;\n try {\n return api.context.with(\n api.trace.setSpan(api.context.active(), span),\n () => {\n return original();\n }\n );\n } catch (err: any) {\n span.setAttribute(AttributeNames.REACT_ERROR, err.stack);\n wasError = true;\n throw err;\n } finally {\n span.end();\n if (wasError) {\n this._endParentSpan(react);\n }\n }\n }\n\n /**\n * Ends the current parent span.\n * @param react React component parent span belongs to.\n */\n private _endParentSpan(react: React.Component) {\n const parentSpan = this._parentSpanMap.get(react);\n if (parentSpan) {\n parentSpan.end();\n this._parentSpanMap.delete(react);\n }\n }\n\n /**\n * Returns attributes object for spans\n * @param react React component currently being instrumented\n **/\n private _getAttributes(react: React.Component) {\n let state: string;\n try {\n state = JSON.stringify(react.state);\n } catch {\n state = '{\"message\": \"state could not be turned into string\"}';\n }\n return {\n [AttributeNames.LOCATION_URL]: window.location.href,\n [AttributeNames.REACT_NAME]: react.constructor.name,\n [AttributeNames.REACT_STATE]: state,\n };\n }\n\n /**\n * This function returns a parent span. If the parent doesn't\n * exist, the function creates one\n * @param react React component parent span belongs to.\n */\n private _getParentSpan(react: React.Component, parentName: string): api.Span {\n const parentSpan: api.Span | undefined = this._parentSpanMap.get(react);\n if (!parentSpan) {\n const span = this._createSpan(react, parentName);\n this._parentSpanMap.set(react, span);\n }\n return this._parentSpanMap.get(react)!;\n }\n\n /**\n * Patches the render lifecycle method\n */\n private _patchRender() {\n return (original: RenderFunction): RenderFunction => {\n const plugin = this;\n return function patchRender(\n this: React.Component,\n ...args\n ): React.ReactNode {\n // Render is the first method in the mounting flow, if a parent span wasn't created already then we're in the mounting flow\n let parentSpan: api.Span;\n if (!plugin._parentSpanMap.get(this)) {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n } else {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n }\n\n return plugin._instrumentFunction(this, 'render', parentSpan, () => {\n return original!.apply(this, args);\n });\n };\n };\n }\n\n /**\n * Patches the componentDidMount lifecycle method\n */\n private _patchComponentDidMount() {\n return (original: ComponentDidMountFunction): ComponentDidMountFunction => {\n const plugin = this;\n\n return function patchComponentDidMount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidMount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the setState function\n */\n private _patchSetState() {\n return (original: SetStateFunction): SetStateFunction => {\n const plugin = this;\n return function patchSetState(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'setState()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the forceUpdate function\n */\n private _patchForceUpdate() {\n return (original: ForceUpdateFunction): ForceUpdateFunction => {\n const plugin = this;\n return function patchForceUpdate(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'forceUpdate()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchShouldComponentUpdate() {\n return (\n original: ShouldComponentUpdateFunction\n ): ShouldComponentUpdateFunction => {\n const plugin = this;\n\n return function patchShouldComponentUpdate(\n this: React.Component,\n ...args\n ): boolean {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'shouldComponentUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n // if shouldComponentUpdate returns false, the component does not get\n // updated and no other lifecycle methods get called\n if (!apply) {\n plugin._endParentSpan(this);\n }\n\n return apply;\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchGetSnapshotBeforeUpdate() {\n return (\n original: GetSnapshotBeforeUpdateFunction\n ): GetSnapshotBeforeUpdateFunction => {\n const plugin = this;\n\n return function patchGetSnapshotBeforeUpdate(\n this: React.Component,\n ...args\n ): any {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'getSnapshotBeforeUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the componentDidUpdate lifecycle method\n */\n private _patchComponentDidUpdate() {\n return (\n original: ComponentDidUpdateFunction\n ): ComponentDidUpdateFunction => {\n const plugin = this;\n\n return function patchComponentDidUpdate(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the componentWillUnmount lifecycle method\n */\n private _patchComponentWillUnmount() {\n return (\n original: ComponentWillUnmountFunction\n ): ComponentWillUnmountFunction => {\n const plugin = this;\n\n return function patchComponentWillUnmount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UNMOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentWillUnmount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * patch function which wraps all the lifecycle methods\n */\n public patch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'applying patch to',\n this.moduleName,\n VERSION\n );\n\n if (isWrapped(this.render)) {\n shimmer.unwrap(this, 'render');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method render'\n );\n }\n if (isWrapped(this.componentDidMount)) {\n shimmer.unwrap(this, 'componentDidMount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidMount'\n );\n }\n if (isWrapped(this.shouldComponentUpdate)) {\n shimmer.unwrap(this, 'shouldComponentUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method shouldComponentUpdate'\n );\n }\n if (isWrapped(this.getSnapshotBeforeUpdate)) {\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method getSnapshotBeforeUpdate'\n );\n }\n if (isWrapped(this.setState)) {\n shimmer.unwrap(this, 'setState');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method setState'\n );\n }\n if (isWrapped(this.forceUpdate)) {\n shimmer.unwrap(this, 'forceUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method forceUpdate'\n );\n }\n if (isWrapped(this.componentDidUpdate)) {\n shimmer.unwrap(this, 'componentDidUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidUpdate'\n );\n }\n if (isWrapped(this.componentWillUnmount)) {\n shimmer.unwrap(this, 'componentWillUnmount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentWillUnmount'\n );\n }\n\n // Lifecycle methods must exist when patching, even if not defined in component\n if (!this.render) {\n this.render = () => {\n return null;\n };\n }\n if (!this.componentDidMount) {\n this.componentDidMount = () => {\n return;\n };\n }\n if (!this.shouldComponentUpdate) {\n this.shouldComponentUpdate = () => {\n return true;\n };\n }\n if (!this.getSnapshotBeforeUpdate) {\n this.getSnapshotBeforeUpdate = () => {\n return null;\n };\n }\n if (!this.componentDidUpdate) {\n this.componentDidUpdate = () => {\n return;\n };\n }\n if (!this.componentWillUnmount) {\n this.componentWillUnmount = () => {\n return;\n };\n }\n\n shimmer.wrap(this, 'render', this._patchRender());\n shimmer.wrap(this, 'componentDidMount', this._patchComponentDidMount());\n shimmer.wrap(this, 'setState', this._patchSetState());\n shimmer.wrap(this, 'forceUpdate', this._patchForceUpdate());\n shimmer.wrap(\n this,\n 'shouldComponentUpdate',\n this._patchShouldComponentUpdate()\n );\n shimmer.wrap(\n this,\n 'getSnapshotBeforeUpdate',\n this._patchGetSnapshotBeforeUpdate()\n );\n shimmer.wrap(this, 'componentDidUpdate', this._patchComponentDidUpdate());\n shimmer.wrap(\n this,\n 'componentWillUnmount',\n this._patchComponentWillUnmount()\n );\n }\n\n /**\n * unpatch function to unwrap all the lifecycle methods\n */\n public unpatch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'removing patch from',\n this.moduleName,\n VERSION\n );\n\n shimmer.unwrap(this, 'render');\n\n shimmer.unwrap(this, 'componentDidMount');\n\n shimmer.unwrap(this, 'setState');\n shimmer.unwrap(this, 'forceUpdate');\n shimmer.unwrap(this, 'shouldComponentUpdate');\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n shimmer.unwrap(this, 'componentDidUpdate');\n\n shimmer.unwrap(this, 'componentWillUnmount');\n\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.29.0";
1
+ export declare const VERSION = "0.30.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // this is autogenerated file, see scripts/version-update.js
17
- export var VERSION = '0.29.0';
17
+ export var VERSION = '0.30.0';
18
18
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.30.0';\n"]}
@@ -0,0 +1,106 @@
1
+ import * as api from '@opentelemetry/api';
2
+ import * as React from 'react';
3
+ /**
4
+ * This class is the base component for a React component with lifecycle instrumentation
5
+ */
6
+ export declare class BaseOpenTelemetryComponent extends React.Component {
7
+ readonly component: string;
8
+ moduleName: string;
9
+ private _parentSpanMap;
10
+ private static _tracer;
11
+ private static _logger;
12
+ /**
13
+ * @param props Props of the React component
14
+ */
15
+ constructor(props: Readonly<any>);
16
+ /**
17
+ * Sets the tracer for all components being instrumented
18
+ * @param name Name of tracer
19
+ * @param version Version of tracer, this is optional. When not provided it will use the latest.
20
+ */
21
+ static setTracer(name: string, version?: string): void;
22
+ /**
23
+ * Sets the logger for all components being instrumented
24
+ * @param logger
25
+ */
26
+ static setLogger(logger: api.DiagLogger): void;
27
+ /**
28
+ * Creates a new span as a child of the current parent span.
29
+ * If parent span is undefined, just the child is created.
30
+ * @param react React component currently being instrumented
31
+ * @param name Name of span
32
+ * @param parentSpan parent span
33
+ */
34
+ private _createSpanWithParent;
35
+ /**
36
+ * Creates a new span
37
+ * @param react React component currently being instrumented
38
+ * @param name Name of span
39
+ */
40
+ private _createSpan;
41
+ /**
42
+ * Provides instrumentation for a function
43
+ * @param react React component currently instrumenting.
44
+ * @param spanName Name to set the span of the instrumented function to.
45
+ * @param original Original function currently being wrapped.
46
+ * @parentName Name to set parent span to on error.
47
+ */
48
+ private _instrumentFunction;
49
+ /**
50
+ * Ends the current parent span.
51
+ * @param react React component parent span belongs to.
52
+ */
53
+ private _endParentSpan;
54
+ /**
55
+ * Returns attributes object for spans
56
+ * @param react React component currently being instrumented
57
+ **/
58
+ private _getAttributes;
59
+ /**
60
+ * This function returns a parent span. If the parent doesn't
61
+ * exist, the function creates one
62
+ * @param react React component parent span belongs to.
63
+ */
64
+ private _getParentSpan;
65
+ /**
66
+ * Patches the render lifecycle method
67
+ */
68
+ private _patchRender;
69
+ /**
70
+ * Patches the componentDidMount lifecycle method
71
+ */
72
+ private _patchComponentDidMount;
73
+ /**
74
+ * Patches the setState function
75
+ */
76
+ private _patchSetState;
77
+ /**
78
+ * Patches the forceUpdate function
79
+ */
80
+ private _patchForceUpdate;
81
+ /**
82
+ * Patches the shouldComponentUpdate lifecycle method
83
+ */
84
+ private _patchShouldComponentUpdate;
85
+ /**
86
+ * Patches the shouldComponentUpdate lifecycle method
87
+ */
88
+ private _patchGetSnapshotBeforeUpdate;
89
+ /**
90
+ * Patches the componentDidUpdate lifecycle method
91
+ */
92
+ private _patchComponentDidUpdate;
93
+ /**
94
+ * Patches the componentWillUnmount lifecycle method
95
+ */
96
+ private _patchComponentWillUnmount;
97
+ /**
98
+ * patch function which wraps all the lifecycle methods
99
+ */
100
+ patch(): void;
101
+ /**
102
+ * unpatch function to unwrap all the lifecycle methods
103
+ */
104
+ unpatch(): void;
105
+ }
106
+ //# sourceMappingURL=BaseOpenTelemetryComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseOpenTelemetryComponent.d.ts","sourceRoot":"","sources":["../../src/BaseOpenTelemetryComponent.ts"],"names":[],"mappings":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BvB"}
@@ -0,0 +1,370 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import * as api from '@opentelemetry/api';
17
+ import { isWrapped } from '@opentelemetry/core';
18
+ import * as shimmer from 'shimmer';
19
+ import { AttributeNames } from './enums/AttributeNames';
20
+ import * as React from 'react';
21
+ import { VERSION } from './version';
22
+ /**
23
+ * This class is the base component for a React component with lifecycle instrumentation
24
+ */
25
+ export class BaseOpenTelemetryComponent extends React.Component {
26
+ /**
27
+ * @param props Props of the React component
28
+ */
29
+ constructor(props) {
30
+ super(props);
31
+ this.component = 'react-load';
32
+ this.moduleName = this.component;
33
+ this._parentSpanMap = new WeakMap();
34
+ this.patch();
35
+ }
36
+ /**
37
+ * Sets the tracer for all components being instrumented
38
+ * @param name Name of tracer
39
+ * @param version Version of tracer, this is optional. When not provided it will use the latest.
40
+ */
41
+ static setTracer(name, version) {
42
+ BaseOpenTelemetryComponent._tracer = api.trace.getTracer(name, version ? version : VERSION);
43
+ }
44
+ /**
45
+ * Sets the logger for all components being instrumented
46
+ * @param logger
47
+ */
48
+ static setLogger(logger) {
49
+ api.diag.setLogger(logger);
50
+ BaseOpenTelemetryComponent._logger = logger;
51
+ }
52
+ /**
53
+ * Creates a new span as a child of the current parent span.
54
+ * If parent span is undefined, just the child is created.
55
+ * @param react React component currently being instrumented
56
+ * @param name Name of span
57
+ * @param parentSpan parent span
58
+ */
59
+ _createSpanWithParent(react, name, parentSpan) {
60
+ return BaseOpenTelemetryComponent._tracer.startSpan(name, {
61
+ attributes: this._getAttributes(react),
62
+ }, parentSpan
63
+ ? api.trace.setSpan(api.context.active(), parentSpan)
64
+ : undefined);
65
+ }
66
+ /**
67
+ * Creates a new span
68
+ * @param react React component currently being instrumented
69
+ * @param name Name of span
70
+ */
71
+ _createSpan(react, name) {
72
+ return BaseOpenTelemetryComponent._tracer.startSpan(name, {
73
+ attributes: this._getAttributes(react),
74
+ });
75
+ }
76
+ /**
77
+ * Provides instrumentation for a function
78
+ * @param react React component currently instrumenting.
79
+ * @param spanName Name to set the span of the instrumented function to.
80
+ * @param original Original function currently being wrapped.
81
+ * @parentName Name to set parent span to on error.
82
+ */
83
+ _instrumentFunction(react, spanName, parent, original) {
84
+ const span = this._createSpanWithParent(react, spanName, parent);
85
+ let wasError = false;
86
+ try {
87
+ return api.context.with(api.trace.setSpan(api.context.active(), span), () => {
88
+ return original();
89
+ });
90
+ }
91
+ catch (err) {
92
+ span.setAttribute(AttributeNames.REACT_ERROR, err.stack);
93
+ wasError = true;
94
+ throw err;
95
+ }
96
+ finally {
97
+ span.end();
98
+ if (wasError) {
99
+ this._endParentSpan(react);
100
+ }
101
+ }
102
+ }
103
+ /**
104
+ * Ends the current parent span.
105
+ * @param react React component parent span belongs to.
106
+ */
107
+ _endParentSpan(react) {
108
+ const parentSpan = this._parentSpanMap.get(react);
109
+ if (parentSpan) {
110
+ parentSpan.end();
111
+ this._parentSpanMap.delete(react);
112
+ }
113
+ }
114
+ /**
115
+ * Returns attributes object for spans
116
+ * @param react React component currently being instrumented
117
+ **/
118
+ _getAttributes(react) {
119
+ let state;
120
+ try {
121
+ state = JSON.stringify(react.state);
122
+ }
123
+ catch (_a) {
124
+ state = '{"message": "state could not be turned into string"}';
125
+ }
126
+ return {
127
+ [AttributeNames.LOCATION_URL]: window.location.href,
128
+ [AttributeNames.REACT_NAME]: react.constructor.name,
129
+ [AttributeNames.REACT_STATE]: state,
130
+ };
131
+ }
132
+ /**
133
+ * This function returns a parent span. If the parent doesn't
134
+ * exist, the function creates one
135
+ * @param react React component parent span belongs to.
136
+ */
137
+ _getParentSpan(react, parentName) {
138
+ const parentSpan = this._parentSpanMap.get(react);
139
+ if (!parentSpan) {
140
+ const span = this._createSpan(react, parentName);
141
+ this._parentSpanMap.set(react, span);
142
+ }
143
+ return this._parentSpanMap.get(react);
144
+ }
145
+ /**
146
+ * Patches the render lifecycle method
147
+ */
148
+ _patchRender() {
149
+ return (original) => {
150
+ const plugin = this;
151
+ return function patchRender(...args) {
152
+ // Render is the first method in the mounting flow, if a parent span wasn't created already then we're in the mounting flow
153
+ let parentSpan;
154
+ if (!plugin._parentSpanMap.get(this)) {
155
+ parentSpan = plugin._getParentSpan(this, AttributeNames.MOUNTING_SPAN);
156
+ }
157
+ else {
158
+ parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
159
+ }
160
+ return plugin._instrumentFunction(this, 'render', parentSpan, () => {
161
+ return original.apply(this, args);
162
+ });
163
+ };
164
+ };
165
+ }
166
+ /**
167
+ * Patches the componentDidMount lifecycle method
168
+ */
169
+ _patchComponentDidMount() {
170
+ return (original) => {
171
+ const plugin = this;
172
+ return function patchComponentDidMount(...args) {
173
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.MOUNTING_SPAN);
174
+ const apply = plugin._instrumentFunction(this, 'componentDidMount', parentSpan, () => {
175
+ return original.apply(this, args);
176
+ });
177
+ plugin._endParentSpan(this);
178
+ return apply;
179
+ };
180
+ };
181
+ }
182
+ /**
183
+ * Patches the setState function
184
+ */
185
+ _patchSetState() {
186
+ return (original) => {
187
+ const plugin = this;
188
+ return function patchSetState(...args) {
189
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
190
+ return plugin._instrumentFunction(this, 'setState()', parentSpan, () => {
191
+ return original.apply(this, args);
192
+ });
193
+ };
194
+ };
195
+ }
196
+ /**
197
+ * Patches the forceUpdate function
198
+ */
199
+ _patchForceUpdate() {
200
+ return (original) => {
201
+ const plugin = this;
202
+ return function patchForceUpdate(...args) {
203
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
204
+ return plugin._instrumentFunction(this, 'forceUpdate()', parentSpan, () => {
205
+ return original.apply(this, args);
206
+ });
207
+ };
208
+ };
209
+ }
210
+ /**
211
+ * Patches the shouldComponentUpdate lifecycle method
212
+ */
213
+ _patchShouldComponentUpdate() {
214
+ return (original) => {
215
+ const plugin = this;
216
+ return function patchShouldComponentUpdate(...args) {
217
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
218
+ const apply = plugin._instrumentFunction(this, 'shouldComponentUpdate', parentSpan, () => {
219
+ return original.apply(this, args);
220
+ });
221
+ // if shouldComponentUpdate returns false, the component does not get
222
+ // updated and no other lifecycle methods get called
223
+ if (!apply) {
224
+ plugin._endParentSpan(this);
225
+ }
226
+ return apply;
227
+ };
228
+ };
229
+ }
230
+ /**
231
+ * Patches the shouldComponentUpdate lifecycle method
232
+ */
233
+ _patchGetSnapshotBeforeUpdate() {
234
+ return (original) => {
235
+ const plugin = this;
236
+ return function patchGetSnapshotBeforeUpdate(...args) {
237
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
238
+ return plugin._instrumentFunction(this, 'getSnapshotBeforeUpdate', parentSpan, () => {
239
+ return original.apply(this, args);
240
+ });
241
+ };
242
+ };
243
+ }
244
+ /**
245
+ * Patches the componentDidUpdate lifecycle method
246
+ */
247
+ _patchComponentDidUpdate() {
248
+ return (original) => {
249
+ const plugin = this;
250
+ return function patchComponentDidUpdate(...args) {
251
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
252
+ const apply = plugin._instrumentFunction(this, 'componentDidUpdate', parentSpan, () => {
253
+ return original.apply(this, args);
254
+ });
255
+ plugin._endParentSpan(this);
256
+ return apply;
257
+ };
258
+ };
259
+ }
260
+ /**
261
+ * Patches the componentWillUnmount lifecycle method
262
+ */
263
+ _patchComponentWillUnmount() {
264
+ return (original) => {
265
+ const plugin = this;
266
+ return function patchComponentWillUnmount(...args) {
267
+ const parentSpan = plugin._getParentSpan(this, AttributeNames.UNMOUNTING_SPAN);
268
+ const apply = plugin._instrumentFunction(this, 'componentWillUnmount', parentSpan, () => {
269
+ return original.apply(this, args);
270
+ });
271
+ plugin._endParentSpan(this);
272
+ return apply;
273
+ };
274
+ };
275
+ }
276
+ /**
277
+ * patch function which wraps all the lifecycle methods
278
+ */
279
+ patch() {
280
+ BaseOpenTelemetryComponent._logger.debug('applying patch to', this.moduleName, VERSION);
281
+ if (isWrapped(this.render)) {
282
+ shimmer.unwrap(this, 'render');
283
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method render');
284
+ }
285
+ if (isWrapped(this.componentDidMount)) {
286
+ shimmer.unwrap(this, 'componentDidMount');
287
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentDidMount');
288
+ }
289
+ if (isWrapped(this.shouldComponentUpdate)) {
290
+ shimmer.unwrap(this, 'shouldComponentUpdate');
291
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method shouldComponentUpdate');
292
+ }
293
+ if (isWrapped(this.getSnapshotBeforeUpdate)) {
294
+ shimmer.unwrap(this, 'getSnapshotBeforeUpdate');
295
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method getSnapshotBeforeUpdate');
296
+ }
297
+ if (isWrapped(this.setState)) {
298
+ shimmer.unwrap(this, 'setState');
299
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method setState');
300
+ }
301
+ if (isWrapped(this.forceUpdate)) {
302
+ shimmer.unwrap(this, 'forceUpdate');
303
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method forceUpdate');
304
+ }
305
+ if (isWrapped(this.componentDidUpdate)) {
306
+ shimmer.unwrap(this, 'componentDidUpdate');
307
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentDidUpdate');
308
+ }
309
+ if (isWrapped(this.componentWillUnmount)) {
310
+ shimmer.unwrap(this, 'componentWillUnmount');
311
+ BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentWillUnmount');
312
+ }
313
+ // Lifecycle methods must exist when patching, even if not defined in component
314
+ if (!this.render) {
315
+ this.render = () => {
316
+ return null;
317
+ };
318
+ }
319
+ if (!this.componentDidMount) {
320
+ this.componentDidMount = () => {
321
+ return;
322
+ };
323
+ }
324
+ if (!this.shouldComponentUpdate) {
325
+ this.shouldComponentUpdate = () => {
326
+ return true;
327
+ };
328
+ }
329
+ if (!this.getSnapshotBeforeUpdate) {
330
+ this.getSnapshotBeforeUpdate = () => {
331
+ return null;
332
+ };
333
+ }
334
+ if (!this.componentDidUpdate) {
335
+ this.componentDidUpdate = () => {
336
+ return;
337
+ };
338
+ }
339
+ if (!this.componentWillUnmount) {
340
+ this.componentWillUnmount = () => {
341
+ return;
342
+ };
343
+ }
344
+ shimmer.wrap(this, 'render', this._patchRender());
345
+ shimmer.wrap(this, 'componentDidMount', this._patchComponentDidMount());
346
+ shimmer.wrap(this, 'setState', this._patchSetState());
347
+ shimmer.wrap(this, 'forceUpdate', this._patchForceUpdate());
348
+ shimmer.wrap(this, 'shouldComponentUpdate', this._patchShouldComponentUpdate());
349
+ shimmer.wrap(this, 'getSnapshotBeforeUpdate', this._patchGetSnapshotBeforeUpdate());
350
+ shimmer.wrap(this, 'componentDidUpdate', this._patchComponentDidUpdate());
351
+ shimmer.wrap(this, 'componentWillUnmount', this._patchComponentWillUnmount());
352
+ }
353
+ /**
354
+ * unpatch function to unwrap all the lifecycle methods
355
+ */
356
+ unpatch() {
357
+ BaseOpenTelemetryComponent._logger.debug('removing patch from', this.moduleName, VERSION);
358
+ shimmer.unwrap(this, 'render');
359
+ shimmer.unwrap(this, 'componentDidMount');
360
+ shimmer.unwrap(this, 'setState');
361
+ shimmer.unwrap(this, 'forceUpdate');
362
+ shimmer.unwrap(this, 'shouldComponentUpdate');
363
+ shimmer.unwrap(this, 'getSnapshotBeforeUpdate');
364
+ shimmer.unwrap(this, 'componentDidUpdate');
365
+ shimmer.unwrap(this, 'componentWillUnmount');
366
+ this._parentSpanMap = new WeakMap();
367
+ }
368
+ }
369
+ BaseOpenTelemetryComponent._logger = api.diag;
370
+ //# sourceMappingURL=BaseOpenTelemetryComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseOpenTelemetryComponent.js","sourceRoot":"","sources":["../../src/BaseOpenTelemetryComponent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK,CAAC,SAAS;IAO7D;;OAEG;IACH,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAVN,cAAS,GAAW,YAAY,CAAC;QAC1C,eAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QAU1B,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;QAC/D,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,IAAY,EAAE,OAAgB;QAC7C,0BAA0B,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CACtD,IAAI,EACJ,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAC5B,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAsB;QACrC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3B,0BAA0B,CAAC,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sB,EACtB,IAAI,CAAC,0BAA0B,EAAE,CAClC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,0BAA0B,CAAC,OAAO,CAAC,KAAK,CACtC,qBAAqB,EACrB,IAAI,CAAC,UAAU,EACf,OAAO,CACR,CAAC;QAEF,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE/B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QAE1C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QAChD,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE3C,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;;AAjgBc,kCAAO,GAAmB,GAAG,CAAC,IAAI,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as api from '@opentelemetry/api';\nimport { isWrapped } from '@opentelemetry/core';\nimport * as shimmer from 'shimmer';\nimport { AttributeNames } from './enums/AttributeNames';\nimport * as React from 'react';\nimport { VERSION } from './version';\nimport {\n RenderFunction,\n ComponentDidMountFunction,\n ComponentDidUpdateFunction,\n ShouldComponentUpdateFunction,\n SetStateFunction,\n ForceUpdateFunction,\n GetSnapshotBeforeUpdateFunction,\n ComponentWillUnmountFunction,\n} from './internal-types';\n\n/**\n * This class is the base component for a React component with lifecycle instrumentation\n */\nexport class BaseOpenTelemetryComponent extends React.Component {\n readonly component: string = 'react-load';\n moduleName = this.component;\n private _parentSpanMap: WeakMap<React.Component, api.Span>;\n private static _tracer: api.Tracer;\n private static _logger: api.DiagLogger = api.diag;\n\n /**\n * @param props Props of the React component\n */\n constructor(props: Readonly<any>) {\n super(props);\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n this.patch();\n }\n\n /**\n * Sets the tracer for all components being instrumented\n * @param name Name of tracer\n * @param version Version of tracer, this is optional. When not provided it will use the latest.\n */\n static setTracer(name: string, version?: string): void {\n BaseOpenTelemetryComponent._tracer = api.trace.getTracer(\n name,\n version ? version : VERSION\n );\n }\n\n /**\n * Sets the logger for all components being instrumented\n * @param logger\n */\n static setLogger(logger: api.DiagLogger): void {\n api.diag.setLogger(logger);\n BaseOpenTelemetryComponent._logger = logger;\n }\n\n /**\n * Creates a new span as a child of the current parent span.\n * If parent span is undefined, just the child is created.\n * @param react React component currently being instrumented\n * @param name Name of span\n * @param parentSpan parent span\n */\n private _createSpanWithParent(\n react: React.Component,\n name: string,\n parentSpan: api.Span\n ): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(\n name,\n {\n attributes: this._getAttributes(react),\n },\n parentSpan\n ? api.trace.setSpan(api.context.active(), parentSpan)\n : undefined\n );\n }\n\n /**\n * Creates a new span\n * @param react React component currently being instrumented\n * @param name Name of span\n */\n private _createSpan(react: React.Component, name: string): api.Span {\n return BaseOpenTelemetryComponent._tracer.startSpan(name, {\n attributes: this._getAttributes(react),\n });\n }\n\n /**\n * Provides instrumentation for a function\n * @param react React component currently instrumenting.\n * @param spanName Name to set the span of the instrumented function to.\n * @param original Original function currently being wrapped.\n * @parentName Name to set parent span to on error.\n */\n private _instrumentFunction(\n react: React.Component,\n spanName: string,\n parent: api.Span,\n original: any\n ) {\n const span = this._createSpanWithParent(react, spanName, parent);\n let wasError = false;\n try {\n return api.context.with(\n api.trace.setSpan(api.context.active(), span),\n () => {\n return original();\n }\n );\n } catch (err: any) {\n span.setAttribute(AttributeNames.REACT_ERROR, err.stack);\n wasError = true;\n throw err;\n } finally {\n span.end();\n if (wasError) {\n this._endParentSpan(react);\n }\n }\n }\n\n /**\n * Ends the current parent span.\n * @param react React component parent span belongs to.\n */\n private _endParentSpan(react: React.Component) {\n const parentSpan = this._parentSpanMap.get(react);\n if (parentSpan) {\n parentSpan.end();\n this._parentSpanMap.delete(react);\n }\n }\n\n /**\n * Returns attributes object for spans\n * @param react React component currently being instrumented\n **/\n private _getAttributes(react: React.Component) {\n let state: string;\n try {\n state = JSON.stringify(react.state);\n } catch {\n state = '{\"message\": \"state could not be turned into string\"}';\n }\n return {\n [AttributeNames.LOCATION_URL]: window.location.href,\n [AttributeNames.REACT_NAME]: react.constructor.name,\n [AttributeNames.REACT_STATE]: state,\n };\n }\n\n /**\n * This function returns a parent span. If the parent doesn't\n * exist, the function creates one\n * @param react React component parent span belongs to.\n */\n private _getParentSpan(react: React.Component, parentName: string): api.Span {\n const parentSpan: api.Span | undefined = this._parentSpanMap.get(react);\n if (!parentSpan) {\n const span = this._createSpan(react, parentName);\n this._parentSpanMap.set(react, span);\n }\n return this._parentSpanMap.get(react)!;\n }\n\n /**\n * Patches the render lifecycle method\n */\n private _patchRender() {\n return (original: RenderFunction): RenderFunction => {\n const plugin = this;\n return function patchRender(\n this: React.Component,\n ...args\n ): React.ReactNode {\n // Render is the first method in the mounting flow, if a parent span wasn't created already then we're in the mounting flow\n let parentSpan: api.Span;\n if (!plugin._parentSpanMap.get(this)) {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n } else {\n parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n }\n\n return plugin._instrumentFunction(this, 'render', parentSpan, () => {\n return original!.apply(this, args);\n });\n };\n };\n }\n\n /**\n * Patches the componentDidMount lifecycle method\n */\n private _patchComponentDidMount() {\n return (original: ComponentDidMountFunction): ComponentDidMountFunction => {\n const plugin = this;\n\n return function patchComponentDidMount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.MOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidMount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the setState function\n */\n private _patchSetState() {\n return (original: SetStateFunction): SetStateFunction => {\n const plugin = this;\n return function patchSetState(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'setState()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the forceUpdate function\n */\n private _patchForceUpdate() {\n return (original: ForceUpdateFunction): ForceUpdateFunction => {\n const plugin = this;\n return function patchForceUpdate(this: React.Component, ...args): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'forceUpdate()',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchShouldComponentUpdate() {\n return (\n original: ShouldComponentUpdateFunction\n ): ShouldComponentUpdateFunction => {\n const plugin = this;\n\n return function patchShouldComponentUpdate(\n this: React.Component,\n ...args\n ): boolean {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'shouldComponentUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n // if shouldComponentUpdate returns false, the component does not get\n // updated and no other lifecycle methods get called\n if (!apply) {\n plugin._endParentSpan(this);\n }\n\n return apply;\n };\n };\n }\n\n /**\n * Patches the shouldComponentUpdate lifecycle method\n */\n private _patchGetSnapshotBeforeUpdate() {\n return (\n original: GetSnapshotBeforeUpdateFunction\n ): GetSnapshotBeforeUpdateFunction => {\n const plugin = this;\n\n return function patchGetSnapshotBeforeUpdate(\n this: React.Component,\n ...args\n ): any {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n return plugin._instrumentFunction(\n this,\n 'getSnapshotBeforeUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n };\n };\n }\n\n /**\n * Patches the componentDidUpdate lifecycle method\n */\n private _patchComponentDidUpdate() {\n return (\n original: ComponentDidUpdateFunction\n ): ComponentDidUpdateFunction => {\n const plugin = this;\n\n return function patchComponentDidUpdate(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UPDATING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentDidUpdate',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * Patches the componentWillUnmount lifecycle method\n */\n private _patchComponentWillUnmount() {\n return (\n original: ComponentWillUnmountFunction\n ): ComponentWillUnmountFunction => {\n const plugin = this;\n\n return function patchComponentWillUnmount(\n this: React.Component,\n ...args\n ): void {\n const parentSpan = plugin._getParentSpan(\n this,\n AttributeNames.UNMOUNTING_SPAN\n );\n const apply = plugin._instrumentFunction(\n this,\n 'componentWillUnmount',\n parentSpan,\n () => {\n return original!.apply(this, args);\n }\n );\n plugin._endParentSpan(this);\n return apply;\n };\n };\n }\n\n /**\n * patch function which wraps all the lifecycle methods\n */\n public patch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'applying patch to',\n this.moduleName,\n VERSION\n );\n\n if (isWrapped(this.render)) {\n shimmer.unwrap(this, 'render');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method render'\n );\n }\n if (isWrapped(this.componentDidMount)) {\n shimmer.unwrap(this, 'componentDidMount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidMount'\n );\n }\n if (isWrapped(this.shouldComponentUpdate)) {\n shimmer.unwrap(this, 'shouldComponentUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method shouldComponentUpdate'\n );\n }\n if (isWrapped(this.getSnapshotBeforeUpdate)) {\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method getSnapshotBeforeUpdate'\n );\n }\n if (isWrapped(this.setState)) {\n shimmer.unwrap(this, 'setState');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method setState'\n );\n }\n if (isWrapped(this.forceUpdate)) {\n shimmer.unwrap(this, 'forceUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method forceUpdate'\n );\n }\n if (isWrapped(this.componentDidUpdate)) {\n shimmer.unwrap(this, 'componentDidUpdate');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentDidUpdate'\n );\n }\n if (isWrapped(this.componentWillUnmount)) {\n shimmer.unwrap(this, 'componentWillUnmount');\n BaseOpenTelemetryComponent._logger.warn(\n 'removing previous patch from method componentWillUnmount'\n );\n }\n\n // Lifecycle methods must exist when patching, even if not defined in component\n if (!this.render) {\n this.render = () => {\n return null;\n };\n }\n if (!this.componentDidMount) {\n this.componentDidMount = () => {\n return;\n };\n }\n if (!this.shouldComponentUpdate) {\n this.shouldComponentUpdate = () => {\n return true;\n };\n }\n if (!this.getSnapshotBeforeUpdate) {\n this.getSnapshotBeforeUpdate = () => {\n return null;\n };\n }\n if (!this.componentDidUpdate) {\n this.componentDidUpdate = () => {\n return;\n };\n }\n if (!this.componentWillUnmount) {\n this.componentWillUnmount = () => {\n return;\n };\n }\n\n shimmer.wrap(this, 'render', this._patchRender());\n shimmer.wrap(this, 'componentDidMount', this._patchComponentDidMount());\n shimmer.wrap(this, 'setState', this._patchSetState());\n shimmer.wrap(this, 'forceUpdate', this._patchForceUpdate());\n shimmer.wrap(\n this,\n 'shouldComponentUpdate',\n this._patchShouldComponentUpdate()\n );\n shimmer.wrap(\n this,\n 'getSnapshotBeforeUpdate',\n this._patchGetSnapshotBeforeUpdate()\n );\n shimmer.wrap(this, 'componentDidUpdate', this._patchComponentDidUpdate());\n shimmer.wrap(\n this,\n 'componentWillUnmount',\n this._patchComponentWillUnmount()\n );\n }\n\n /**\n * unpatch function to unwrap all the lifecycle methods\n */\n public unpatch(): void {\n BaseOpenTelemetryComponent._logger.debug(\n 'removing patch from',\n this.moduleName,\n VERSION\n );\n\n shimmer.unwrap(this, 'render');\n\n shimmer.unwrap(this, 'componentDidMount');\n\n shimmer.unwrap(this, 'setState');\n shimmer.unwrap(this, 'forceUpdate');\n shimmer.unwrap(this, 'shouldComponentUpdate');\n shimmer.unwrap(this, 'getSnapshotBeforeUpdate');\n shimmer.unwrap(this, 'componentDidUpdate');\n\n shimmer.unwrap(this, 'componentWillUnmount');\n\n this._parentSpanMap = new WeakMap<React.Component, api.Span>();\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ export declare enum AttributeNames {
2
+ MOUNTING_SPAN = "reactLoad: mounting",
3
+ UPDATING_SPAN = "reactLoad: updating",
4
+ UNMOUNTING_SPAN = "reactLoad: unmounting",
5
+ LOCATION_URL = "location",
6
+ REACT_NAME = "react_component_name",
7
+ REACT_STATE = "react_component_state",
8
+ REACT_ERROR = "react_error"
9
+ }
10
+ //# sourceMappingURL=AttributeNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttributeNames.d.ts","sourceRoot":"","sources":["../../../src/enums/AttributeNames.ts"],"names":[],"mappings":"AAgBA,oBAAY,cAAc;IACxB,aAAa,wBAAwB;IACrC,aAAa,wBAAwB;IACrC,eAAe,0BAA0B;IACzC,YAAY,aAAa;IACzB,UAAU,yBAAyB;IACnC,WAAW,0BAA0B;IACrC,WAAW,gBAAgB;CAC5B"}
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export var AttributeNames;
17
+ (function (AttributeNames) {
18
+ AttributeNames["MOUNTING_SPAN"] = "reactLoad: mounting";
19
+ AttributeNames["UPDATING_SPAN"] = "reactLoad: updating";
20
+ AttributeNames["UNMOUNTING_SPAN"] = "reactLoad: unmounting";
21
+ AttributeNames["LOCATION_URL"] = "location";
22
+ AttributeNames["REACT_NAME"] = "react_component_name";
23
+ AttributeNames["REACT_STATE"] = "react_component_state";
24
+ AttributeNames["REACT_ERROR"] = "react_error";
25
+ })(AttributeNames || (AttributeNames = {}));
26
+ //# sourceMappingURL=AttributeNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttributeNames.js","sourceRoot":"","sources":["../../../src/enums/AttributeNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAN,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,uDAAqC,CAAA;IACrC,uDAAqC,CAAA;IACrC,2DAAyC,CAAA;IACzC,2CAAyB,CAAA;IACzB,qDAAmC,CAAA;IACnC,uDAAqC,CAAA;IACrC,6CAA2B,CAAA;AAC7B,CAAC,EARW,cAAc,KAAd,cAAc,QAQzB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum AttributeNames {\n MOUNTING_SPAN = 'reactLoad: mounting',\n UPDATING_SPAN = 'reactLoad: updating',\n UNMOUNTING_SPAN = 'reactLoad: unmounting',\n LOCATION_URL = 'location',\n REACT_NAME = 'react_component_name',\n REACT_STATE = 'react_component_state',\n REACT_ERROR = 'react_error',\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './BaseOpenTelemetryComponent';
2
+ export * from './enums/AttributeNames';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './BaseOpenTelemetryComponent';
17
+ export * from './enums/AttributeNames';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './BaseOpenTelemetryComponent';\nexport * from './enums/AttributeNames';\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ export declare type RenderFunction = () => React.ReactNode;
3
+ export declare type ComponentDidMountFunction = (() => void) | undefined;
4
+ export declare type ComponentDidUpdateFunction = ((prevProps: Readonly<any>, prevState: Readonly<any>, snapshot?: any) => void) | undefined;
5
+ export declare type ShouldComponentUpdateFunction = ((nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any) => boolean) | undefined;
6
+ export declare type SetStateFunction = <K extends never>(state: any | ((prevState: Readonly<any>, props: Readonly<any>) => any | Pick<any, K> | null) | Pick<any, K> | null, callback?: (() => void) | undefined) => void;
7
+ export declare type ForceUpdateFunction = (callback?: (() => void) | undefined) => void;
8
+ export declare type GetSnapshotBeforeUpdateFunction = ((prevProps: Readonly<any>, prevState: Readonly<any>) => any) | undefined;
9
+ export declare type ComponentWillUnmountFunction = (() => void) | undefined;
10
+ //# sourceMappingURL=internal-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-types.d.ts","sourceRoot":"","sources":["../../src/internal-types.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,oBAAY,cAAc,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC;AAKnD,oBAAY,yBAAyB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;AAKjE,oBAAY,0BAA0B,GAClC,CAAC,CACC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EACxB,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EACxB,QAAQ,CAAC,EAAE,GAAG,KACX,IAAI,CAAC,GACV,SAAS,CAAC;AAKd,oBAAY,6BAA6B,GACrC,CAAC,CACC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EACxB,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EACxB,WAAW,EAAE,GAAG,KACb,OAAO,CAAC,GACb,SAAS,CAAC;AAKd,oBAAY,gBAAgB,GAAG,CAAC,CAAC,SAAS,KAAK,EAC7C,KAAK,EACD,GAAG,GACH,CAAC,CACC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EACxB,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,KACjB,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAC/B,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,GACZ,IAAI,EACR,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,KAChC,IAAI,CAAC;AAKV,oBAAY,mBAAmB,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,KAAK,IAAI,CAAC;AAKhF,oBAAY,+BAA+B,GACvC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,GAC7D,SAAS,CAAC;AAKd,oBAAY,4BAA4B,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export {};
17
+ //# sourceMappingURL=internal-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../../src/internal-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\n\n/*\n * method \"render\" from React.Component\n */\nexport type RenderFunction = () => React.ReactNode;\n\n/*\n * method \"componentDidMount\" from React.Component\n */\nexport type ComponentDidMountFunction = (() => void) | undefined;\n\n/*\n * method \"componentDidUpdate\" from React.Component\n */\nexport type ComponentDidUpdateFunction =\n | ((\n prevProps: Readonly<any>,\n prevState: Readonly<any>,\n snapshot?: any\n ) => void)\n | undefined;\n\n/*\n * method \"shouldComponentUpdate\" from React.Component\n */\nexport type ShouldComponentUpdateFunction =\n | ((\n nextProps: Readonly<any>,\n nextState: Readonly<any>,\n nextContext: any\n ) => boolean)\n | undefined;\n\n/*\n * method \"setState\" from React.Component\n */\nexport type SetStateFunction = <K extends never>(\n state:\n | any\n | ((\n prevState: Readonly<any>,\n props: Readonly<any>\n ) => any | Pick<any, K> | null)\n | Pick<any, K>\n | null,\n callback?: (() => void) | undefined\n) => void;\n\n/*\n * method \"setState\" from React.Component\n */\nexport type ForceUpdateFunction = (callback?: (() => void) | undefined) => void;\n\n/*\n * method \"getSnapshotBeforeUpdate\" from React.Component\n */\nexport type GetSnapshotBeforeUpdateFunction =\n | ((prevProps: Readonly<any>, prevState: Readonly<any>) => any)\n | undefined;\n\n/*\n * method \"componentWillUnmount\" from React.Component\n */\nexport type ComponentWillUnmountFunction = (() => void) | undefined;\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.30.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,OAAO,WAAW,CAAC"}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // this is autogenerated file, see scripts/version-update.js
17
+ export const VERSION = '0.30.0';
18
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.30.0';\n"]}
@@ -14,8 +14,17 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
+ };
17
27
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const tslib_1 = require("tslib");
19
- (0, tslib_1.__exportStar)(require("./BaseOpenTelemetryComponent"), exports);
20
- (0, tslib_1.__exportStar)(require("./enums/AttributeNames"), exports);
28
+ __exportStar(require("./BaseOpenTelemetryComponent"), exports);
29
+ __exportStar(require("./enums/AttributeNames"), exports);
21
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4EAA6C;AAC7C,sEAAuC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './BaseOpenTelemetryComponent';\nexport * from './enums/AttributeNames';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,+DAA6C;AAC7C,yDAAuC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './BaseOpenTelemetryComponent';\nexport * from './enums/AttributeNames';\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.29.0";
1
+ export declare const VERSION = "0.30.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.29.0';
20
+ exports.VERSION = '0.30.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.30.0';\n"]}
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "name": "@opentelemetry/plugin-react-load",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "OpenTelemetry React loading automatic instrumentation package.",
5
5
  "main": "build/src/index.js",
6
6
  "module": "build/esm/index.js",
7
+ "esnext": "build/esnext/index.js",
7
8
  "types": "build/src/index.d.ts",
8
9
  "repository": "open-telemetry/opentelemetry-js-contrib",
9
10
  "scripts": {
10
- "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
11
+ "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
11
12
  "lint": "eslint . --ext .ts",
12
13
  "lint:fix": "eslint . --ext .ts --fix",
13
14
  "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/plugin-react-load --include-dependencies",
14
15
  "prewatch": "npm run precompile",
15
16
  "version:update": "node ../../../scripts/version-update.js",
16
- "compile": "npm run version:update && tsc --build tsconfig.json tsconfig.esm.json",
17
+ "compile": "npm run version:update && tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
17
18
  "prepare": "npm run compile",
18
19
  "tdd": "karma start",
19
20
  "test:browser": "nyc karma start --single-run",
20
- "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json"
21
+ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json"
21
22
  },
22
23
  "keywords": [
23
24
  "opentelemetry",
@@ -36,42 +37,42 @@
36
37
  "build/esm/**/*.js",
37
38
  "build/esm/**/*.map",
38
39
  "build/esm/**/*.d.ts",
40
+ "build/esnext/**/*.js",
41
+ "build/esnext/**/*.map",
42
+ "build/esnext/**/*.d.ts",
39
43
  "build/src/**/*.js",
40
44
  "build/src/**/*.map",
41
- "build/src/**/*.d.ts",
42
- "doc",
43
- "LICENSE",
44
- "README.md"
45
+ "build/src/**/*.d.ts"
45
46
  ],
46
47
  "publishConfig": {
47
48
  "access": "public"
48
49
  },
49
50
  "devDependencies": {
50
- "@babel/core": "7.15.0",
51
+ "@babel/core": "7.22.17",
51
52
  "@jsdevtools/coverage-istanbul-loader": "3.0.5",
52
53
  "@opentelemetry/api": "^1.0.0",
53
54
  "@opentelemetry/propagator-b3": "^1.3.1",
54
55
  "@types/mocha": "7.0.2",
55
- "@types/node": "18.11.7",
56
- "@types/react": "17.0.16",
56
+ "@types/node": "18.6.5",
57
+ "@types/react": "17.0.67",
57
58
  "@types/react-addons-test-utils": "0.14.26",
58
59
  "@types/react-dom": "18.0.2",
59
- "@types/shimmer": "1.0.2",
60
- "@types/sinon": "10.0.2",
60
+ "@types/shimmer": "1.0.3",
61
+ "@types/sinon": "10.0.18",
61
62
  "@types/webpack-env": "1.16.2",
62
63
  "babel-loader": "8.2.2",
63
64
  "karma": "6.3.16",
64
65
  "karma-chrome-launcher": "^3.1.1",
65
66
  "karma-coverage-istanbul-reporter": "3.0.3",
66
67
  "karma-mocha": "2.0.1",
67
- "karma-spec-reporter": "0.0.32",
68
+ "karma-spec-reporter": "0.0.36",
68
69
  "karma-webpack": "4.0.2",
69
70
  "mocha": "7.2.0",
70
71
  "nyc": "15.1.0",
71
72
  "react": "17.0.2",
72
73
  "react-dom": "17.0.2",
73
- "rimraf": "5.0.0",
74
- "sinon": "15.0.1",
74
+ "rimraf": "5.0.5",
75
+ "sinon": "15.2.0",
75
76
  "ts-loader": "8.3.0",
76
77
  "ts-mocha": "10.0.0",
77
78
  "typescript": "4.4.4",
@@ -89,9 +90,8 @@
89
90
  "@opentelemetry/sdk-trace-base": "^1.0.0",
90
91
  "@opentelemetry/sdk-trace-web": "^1.0.0",
91
92
  "@opentelemetry/semantic-conventions": "^1.0.0",
92
- "shimmer": "^1.2.1",
93
- "tslib": "^2.3.1"
93
+ "shimmer": "^1.2.1"
94
94
  },
95
95
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-plugin-react-load#readme",
96
- "gitHead": "f81f8a76a8f0af2101c62dbc73cde442f875d833"
96
+ "gitHead": "607d375595da3ab51b7f773ac360900121c4361b"
97
97
  }