UNPKG

@dynatrace/react-native-plugin

Version:

This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.

53 lines (52 loc) 2.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ReactRuntime = require("react/jsx-runtime"); const Types_1 = require("../model/Types"); const FunctionalComponent_1 = require("./components/FunctionalComponent"); const ClassComponent_1 = require("./components/ClassComponent"); const ElementHelper_1 = require("./ElementHelper"); const instrumentJsxCall = (jsxFunction) => (...args) => { if (args[0] !== undefined && args[0]._dtInfo !== undefined && !(0, ElementHelper_1.isDtActionIgnore)(args[1])) { if (args[0]._dtInfo.type === Types_1.Types.FunctionalComponent) { const wrapperProps = { children: jsxFunction(...args), }; wrapperProps.dtActionName = args[1] !== undefined && args[1].dtActionName !== undefined ? args[1].dtActionName : args[0]._dtInfo.name; if (args[2] !== undefined) { return jsxFunction(FunctionalComponent_1.DynatraceFunctionalComponent, wrapperProps, args[2] + '_dt'); } else { return jsxFunction(FunctionalComponent_1.DynatraceFunctionalComponent, wrapperProps); } } else if (args[0]._dtInfo.type === Types_1.Types.ClassComponent && args[0].prototype !== undefined && args[0].prototype.isReactComponent !== undefined) { const wrapperProps = { children: jsxFunction(...args), }; if (args[2] !== undefined) { return jsxFunction(ClassComponent_1.DynatraceClassComponent, wrapperProps, args[2] + '_dt'); } else { return jsxFunction(ClassComponent_1.DynatraceClassComponent, wrapperProps); } } (0, ElementHelper_1.modifyElement)(args[0], args[1]); } return jsxFunction(...args); }; try { const jsx = instrumentJsxCall(ReactRuntime.jsx); const jsxs = instrumentJsxCall(ReactRuntime.jsxs); module.exports = Object.assign(Object.assign({}, ReactRuntime), { jsx, jsxs }); } catch (error) { module.exports = {}; }