@dynatrace/react-native-plugin 2.225.0 → 2.231.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 (91) hide show
  1. package/README.md +31 -6
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridge.java +10 -0
  4. package/files/plugin.gradle +1 -1
  5. package/ios/DynatraceRNBridge.m +11 -0
  6. package/ios/lib/Dynatrace.xcframework/Info.plist +69 -0
  7. package/ios/lib/Dynatrace.xcframework/ios-arm64_armv7/Dynatrace.framework/Dynatrace +0 -0
  8. package/ios/lib/Dynatrace.xcframework/ios-arm64_armv7/Dynatrace.framework/Headers/Dynatrace.h +952 -0
  9. package/ios/lib/Dynatrace.xcframework/ios-arm64_armv7/Dynatrace.framework/Headers/Framework.h +18 -0
  10. package/ios/lib/Dynatrace.xcframework/ios-arm64_armv7/Dynatrace.framework/Info.plist +0 -0
  11. package/ios/lib/Dynatrace.xcframework/ios-arm64_armv7/Dynatrace.framework/Modules/module.modulemap +6 -0
  12. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/Dynatrace +0 -0
  13. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/Headers/Dynatrace.h +952 -0
  14. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/Headers/Framework.h +18 -0
  15. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/Info.plist +0 -0
  16. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/Modules/module.modulemap +6 -0
  17. package/ios/lib/Dynatrace.xcframework/ios-arm64_i386_x86_64-simulator/Dynatrace.framework/_CodeSignature/CodeResources +147 -0
  18. package/ios/lib/Dynatrace.xcframework/tvos-arm64/Dynatrace.framework/Dynatrace +0 -0
  19. package/ios/lib/Dynatrace.xcframework/tvos-arm64/Dynatrace.framework/Headers/Dynatrace.h +952 -0
  20. package/ios/lib/Dynatrace.xcframework/tvos-arm64/Dynatrace.framework/Headers/Framework.h +18 -0
  21. package/ios/lib/Dynatrace.xcframework/tvos-arm64/Dynatrace.framework/Info.plist +0 -0
  22. package/ios/lib/Dynatrace.xcframework/tvos-arm64/Dynatrace.framework/Modules/module.modulemap +6 -0
  23. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/Dynatrace +0 -0
  24. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/Headers/Dynatrace.h +952 -0
  25. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/Headers/Framework.h +18 -0
  26. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/Info.plist +0 -0
  27. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/Modules/module.modulemap +6 -0
  28. package/ios/lib/Dynatrace.xcframework/tvos-arm64_x86_64-simulator/Dynatrace.framework/_CodeSignature/CodeResources +135 -0
  29. package/lib/community/Picker.js +33 -0
  30. package/lib/dynatrace-reporter.js +30 -0
  31. package/lib/dynatrace-transformer.js +50 -0
  32. package/lib/instrumentor/base/Application.js +17 -0
  33. package/lib/instrumentor/base/Dynatrace.js +275 -0
  34. package/lib/instrumentor/base/DynatraceAction.js +66 -0
  35. package/lib/instrumentor/base/DynatraceBridge.js +5 -0
  36. package/lib/instrumentor/base/ElementHelper.js +58 -0
  37. package/lib/instrumentor/base/ErrorHandler.js +52 -0
  38. package/lib/instrumentor/base/Logger.js +15 -0
  39. package/lib/instrumentor/base/NullAction.js +27 -0
  40. package/lib/instrumentor/base/Picker.js +32 -0
  41. package/lib/instrumentor/base/RefreshControl.js +35 -0
  42. package/lib/instrumentor/base/Touchable.js +103 -0
  43. package/lib/instrumentor/base/UserPrivacyOptions.js +22 -0
  44. package/lib/instrumentor/base/configuration/AutoStartupConfiguration.js +17 -0
  45. package/lib/instrumentor/base/configuration/Configuration.js +26 -0
  46. package/lib/instrumentor/base/configuration/ConfigurationDefaults.js +13 -0
  47. package/lib/instrumentor/base/configuration/ManualStartupConfiguration.js +34 -0
  48. package/lib/instrumentor/base/interface/IAutoConfiguration.js +2 -0
  49. package/lib/instrumentor/base/interface/IDynatrace.js +2 -0
  50. package/lib/instrumentor/base/interface/IDynatraceAction.js +2 -0
  51. package/lib/instrumentor/base/interface/IDynatraceBridge.js +2 -0
  52. package/lib/instrumentor/base/interface/IDynatraceProperties.js +2 -0
  53. package/lib/instrumentor/base/interface/ILogger.js +2 -0
  54. package/lib/instrumentor/base/model/DataCollectionLevel.js +11 -0
  55. package/lib/instrumentor/base/model/LogLevel.js +8 -0
  56. package/lib/instrumentor/base/model/Platform.js +9 -0
  57. package/lib/instrumentor/base/util/StringUtils.js +8 -0
  58. package/lib/instrumentor/dynatrace-instrumentation.js +1 -0
  59. package/lib/instrumentor/model/reference.js +2 -0
  60. package/lib/instrumentor/model/types.js +16 -0
  61. package/lib/instrumentor/parser/babel.js +63 -0
  62. package/lib/jsx-runtime.js +41 -0
  63. package/lib/metro/getSourceMapInfo.js +22 -0
  64. package/lib/react/Component.js +68 -0
  65. package/lib/react-native/RefreshControl.js +14 -0
  66. package/lib/react-native/Touchables.js +63 -0
  67. package/lib/react-native/index.js +12 -0
  68. package/lib/react-native.js +25 -0
  69. package/package.json +155 -1
  70. package/scripts/android.js +123 -0
  71. package/scripts/api/CustomArguments.js +2 -0
  72. package/scripts/api/CustomArgumentsBuilder.js +2 -0
  73. package/scripts/api/model/Platform.js +8 -0
  74. package/scripts/config.js +73 -0
  75. package/scripts/core/CustomArgumentsBuilderImpl.js +22 -0
  76. package/scripts/core/CustomArgumentsImpl.js +33 -0
  77. package/scripts/core/InstrumentCall.js +89 -0
  78. package/scripts/fileOperationHelper.js +184 -0
  79. package/scripts/install.js +47 -0
  80. package/scripts/instrument.js +7 -0
  81. package/scripts/ios.js +179 -0
  82. package/scripts/logger.js +79 -0
  83. package/scripts/pathsConstants.js +60 -0
  84. package/scripts/start.js +6 -0
  85. package/scripts/uninstall.js +80 -0
  86. package/scripts/util/CustomArgumentUtil.js +57 -0
  87. package/scripts/util/SourceMapUtil.js +30 -0
  88. package/scripts/util/StartUtil.js +9 -0
  89. package/scripts/util/instrumentUtil.js +28 -0
  90. package/typings/react-native-dynatrace.d.ts +6 -0
  91. package/util/constants.js +0 -4
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDtActionIgnore = exports.modifyElement = exports.instrumentCreateElement = void 0;
4
+ const types_1 = require("../model/types");
5
+ const Dynatrace_1 = require("./Dynatrace");
6
+ const Logger_1 = require("./Logger");
7
+ const Picker_1 = require("./Picker");
8
+ const Touchable_1 = require("./Touchable");
9
+ const Component_1 = require("../../react/Component");
10
+ function instrumentCreateElement(reactModule) {
11
+ if (reactModule && reactModule.createElement) {
12
+ const reactCreateElement = reactModule.createElement;
13
+ reactModule.createElement = (type, props, ...children) => {
14
+ if (type && type._dtInfo && !isDtActionIgnore(props)) {
15
+ if (type._dtInfo.type === types_1.Types.FunctionalComponent) {
16
+ return reactCreateElement(Component_1.DynatraceFnWrapper, {}, reactCreateElement(type, props, ...children));
17
+ }
18
+ else if (type._dtInfo.type === types_1.Types.ClassComponent &&
19
+ type.prototype != undefined && type.prototype.isReactComponent != undefined) {
20
+ return reactCreateElement(Component_1.DynatraceClassWrapper, {}, reactCreateElement(type, props, ...children));
21
+ }
22
+ else {
23
+ modifyElement(type, props, ...children);
24
+ }
25
+ }
26
+ return reactCreateElement(type, props, ...children);
27
+ };
28
+ }
29
+ }
30
+ exports.instrumentCreateElement = instrumentCreateElement;
31
+ function modifyElement(type, props, ...children) {
32
+ if (props) {
33
+ if (type._dtInfo.type === types_1.Types.Button ||
34
+ type._dtInfo.type === types_1.Types.Text ||
35
+ type._dtInfo.type === types_1.Types.TouchableHighlight ||
36
+ type._dtInfo.type === types_1.Types.TouchableWithoutFeedback ||
37
+ type._dtInfo.type === types_1.Types.TouchableOpacity ||
38
+ type._dtInfo.type === types_1.Types.TouchableNativeFeedback ||
39
+ type._dtInfo.type === types_1.Types.Pressable) {
40
+ if (props.onPress) {
41
+ props.onPress = Touchable_1.TouchableHelper(Dynatrace_1.Dynatrace, Logger_1.Logger).attachOnPress(false, props, children);
42
+ }
43
+ if (props.onLongPress) {
44
+ props.onLongPress = Touchable_1.TouchableHelper(Dynatrace_1.Dynatrace, Logger_1.Logger).attachOnPress(true, props, children);
45
+ }
46
+ }
47
+ else if (props.onValueChange && type._dtInfo.type === types_1.Types.Picker) {
48
+ props.onValueChange = Picker_1.PickerHelper(Dynatrace_1.Dynatrace, Logger_1.Logger).attachToOnValueChange(props.onValueChange, props.children);
49
+ }
50
+ }
51
+ }
52
+ exports.modifyElement = modifyElement;
53
+ function isDtActionIgnore(props) {
54
+ return (props != undefined &&
55
+ props != null &&
56
+ String(props.dtActionIgnore).toLowerCase() == 'true');
57
+ }
58
+ exports.isDtActionIgnore = isDtActionIgnore;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorHandler = void 0;
4
+ const StringUtils_1 = require("./util/StringUtils");
5
+ function _isReactNativeGlobal(globalScope) {
6
+ return globalScope.ErrorUtils !== undefined;
7
+ }
8
+ exports.ErrorHandler = (Dynatrace, Logger) => {
9
+ return {
10
+ registerErrorHandler() {
11
+ if (global !== undefined && _isReactNativeGlobal(global)) {
12
+ const oldHandler = global.ErrorUtils.getGlobalHandler();
13
+ global.ErrorUtils.setGlobalHandler((error, isFatal) => {
14
+ this._reportErrorToDynatrace(error, isFatal, oldHandler);
15
+ });
16
+ const setter = global.ErrorUtils.setGlobalHandler;
17
+ global.ErrorUtils.setGlobalHandler = (errorHandler) => {
18
+ setter((error, isFatal) => {
19
+ this._reportErrorToDynatrace(error, isFatal, errorHandler);
20
+ });
21
+ };
22
+ }
23
+ },
24
+ _reportErrorToDynatrace(exception, isFatal, oldHandler) {
25
+ if (exception && isExceptionAnError(exception)) {
26
+ if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(exception.name)) {
27
+ if (isFatal === undefined) {
28
+ isFatal = false;
29
+ }
30
+ if (exception.stack) {
31
+ Dynatrace.reportErrorFromHandler(isFatal, String(exception.name), exception.message, exception.stack);
32
+ Logger.logDebug('Report Error with stacktrace: ' + exception.message);
33
+ }
34
+ else {
35
+ Dynatrace.reportError(String(exception.name) + ': ' + exception.message, -1);
36
+ Logger.logDebug('Report Error: ' + exception);
37
+ }
38
+ }
39
+ }
40
+ else {
41
+ Dynatrace.reportError(String(exception), -1);
42
+ Logger.logDebug('Report Error: ' + exception);
43
+ }
44
+ if (oldHandler !== undefined) {
45
+ oldHandler(exception, isFatal);
46
+ }
47
+ },
48
+ };
49
+ };
50
+ function isExceptionAnError(exception) {
51
+ return exception.message != undefined;
52
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ const Configuration_1 = require("./configuration/Configuration");
5
+ const LOG_PREFIX = 'DYNATRACE: ';
6
+ exports.Logger = {
7
+ logDebug(message) {
8
+ if (Configuration_1.Configuration.isDebugEnabled()) {
9
+ console.log(LOG_PREFIX + message);
10
+ }
11
+ },
12
+ logInfo(message) {
13
+ console.log(LOG_PREFIX + message);
14
+ },
15
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullAction = void 0;
4
+ class NullAction {
5
+ reportError(errorName, errorCode, platform) {
6
+ return;
7
+ }
8
+ reportEvent(eventName, platform) {
9
+ return;
10
+ }
11
+ reportStringValue(valueName, value, platform) {
12
+ return;
13
+ }
14
+ reportIntValue(valueName, value, platform) {
15
+ return;
16
+ }
17
+ reportDoubleValue(valueName, value, platform) {
18
+ return;
19
+ }
20
+ leaveAction(platform) {
21
+ return;
22
+ }
23
+ cancel(platfrom) {
24
+ return;
25
+ }
26
+ }
27
+ exports.NullAction = NullAction;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PickerHelper = void 0;
4
+ exports.PickerHelper = (Dynatrace, Logger) => {
5
+ return {
6
+ attachToOnValueChange: function (onValueChange, children) {
7
+ return (itemValue, itemNumber) => {
8
+ const value = this.getPickerItemValue(children, itemNumber, itemValue);
9
+ const action = Dynatrace.enterAction(`Picked Value: ${value}`);
10
+ if (onValueChange !== undefined) {
11
+ onValueChange(itemValue, itemNumber);
12
+ }
13
+ if (action) {
14
+ action.leaveAction();
15
+ }
16
+ };
17
+ },
18
+ getPickerItemValue(children, index, value) {
19
+ if (children && index >= 0) {
20
+ if (children &&
21
+ children.length >= index &&
22
+ isPickerItemProps(children[index].props)) {
23
+ return children[index].props.label;
24
+ }
25
+ }
26
+ return value;
27
+ },
28
+ };
29
+ };
30
+ function isPickerItemProps(props) {
31
+ return props.label !== undefined;
32
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RefreshControlHelper = void 0;
4
+ exports.RefreshControlHelper = (Dynatrace, Logger) => {
5
+ return {
6
+ attachToRender(refreshControl) {
7
+ if (refreshControl.render !== undefined) {
8
+ const renderOrig = refreshControl.render.bind(refreshControl);
9
+ refreshControl.render = () => {
10
+ return this.renderRefreshControl(renderOrig);
11
+ };
12
+ }
13
+ },
14
+ renderRefreshControl(renderOrig) {
15
+ const refreshControlRender = renderOrig();
16
+ if (refreshControlRender &&
17
+ refreshControlRender.props &&
18
+ refreshControlRender.props.onRefresh) {
19
+ return Object.assign(Object.assign({}, refreshControlRender), { props: Object.assign(Object.assign({}, refreshControlRender.props), { onRefresh: () => {
20
+ this.onRefresh(refreshControlRender);
21
+ } }) });
22
+ }
23
+ else {
24
+ return refreshControlRender;
25
+ }
26
+ },
27
+ onRefresh(refreshControl) {
28
+ const action = Dynatrace.enterAction('Swipe to Refesh');
29
+ if (refreshControl.props.onRefresh !== undefined) {
30
+ refreshControl.props.onRefresh();
31
+ }
32
+ action.leaveAction();
33
+ },
34
+ };
35
+ };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TouchableHelper = void 0;
4
+ exports.TouchableHelper = (Dynatrace, Logger) => {
5
+ return {
6
+ attachOnPress: function (longPress, props, children) {
7
+ const origFunction = longPress && this._isLongPress(props)
8
+ ? props.onLongPress
9
+ : props.onPress;
10
+ const nameOfAction = this._findActionName(props, children);
11
+ if (nameOfAction == null) {
12
+ return origFunction;
13
+ }
14
+ return (event) => {
15
+ const action = Dynatrace.enterAction(`Touch on ${nameOfAction}`);
16
+ if (action != null) {
17
+ if (origFunction != null) {
18
+ origFunction(event);
19
+ }
20
+ action.leaveAction();
21
+ }
22
+ };
23
+ },
24
+ _findActionName: function (props, children) {
25
+ if (this._isDynatraceProperties(props)) {
26
+ return props.dtActionName;
27
+ }
28
+ else if (this._isPropsButton(props) && props.title != null) {
29
+ return props.title;
30
+ }
31
+ else if (props.accessibilityLabel != null) {
32
+ return props.accessibilityLabel;
33
+ }
34
+ else if (children &&
35
+ children.length == 1 &&
36
+ typeof children[0] === 'string') {
37
+ return children[0];
38
+ }
39
+ else {
40
+ return this._walkChildrenToFindText(children);
41
+ }
42
+ },
43
+ _isPropsButton(props) {
44
+ return props.title != null;
45
+ },
46
+ _isImageButton(props) {
47
+ return props.source != null;
48
+ },
49
+ _isLongPress(props) {
50
+ return props.onLongPress != null;
51
+ },
52
+ _isImageURISourceType(source) {
53
+ return source.uri != null;
54
+ },
55
+ _isIconButton(element) {
56
+ const type = element.type;
57
+ return type != null && type.name === 'Icon';
58
+ },
59
+ _walkTreeToFindText: function (element) {
60
+ if (element == null || element.props == null) {
61
+ return null;
62
+ }
63
+ else if (this._isImageButton(element.props)) {
64
+ if (this._isImageURISourceType(element.props.source)) {
65
+ return 'Image Button: ' + element.props.source.uri;
66
+ }
67
+ else {
68
+ return 'Image Button';
69
+ }
70
+ }
71
+ else if (this._isIconButton(element) && element.props.name != null) {
72
+ return 'Icon Button: ' + element.props.name;
73
+ }
74
+ return this._walkChildrenToFindText(element.props.children);
75
+ },
76
+ _walkChildrenToFindText: function (children) {
77
+ if (typeof children === 'string') {
78
+ return children;
79
+ }
80
+ else if (Array.isArray(children)) {
81
+ for (let i = 0; i < children.length; i++) {
82
+ const childrenValueElem = children[i];
83
+ if (this._isReactElement(childrenValueElem)) {
84
+ const name = this._walkTreeToFindText(childrenValueElem);
85
+ if (name != null) {
86
+ return name;
87
+ }
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+ else {
93
+ return this._walkTreeToFindText(children);
94
+ }
95
+ },
96
+ _isReactElement(node) {
97
+ return node != null && node.props != null;
98
+ },
99
+ _isDynatraceProperties(properties) {
100
+ return properties.dtActionName !== undefined;
101
+ },
102
+ };
103
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserPrivacyOptions = void 0;
4
+ class UserPrivacyOptions {
5
+ constructor(dataCollectionLevel, crashReportingOptedIn) {
6
+ this._dataCollectionLevel = dataCollectionLevel;
7
+ this._crashReportingOptedIn = crashReportingOptedIn;
8
+ }
9
+ get dataCollectionLevel() {
10
+ return this._dataCollectionLevel;
11
+ }
12
+ set dataCollectionLevel(dataCollectionLevel) {
13
+ this._dataCollectionLevel = dataCollectionLevel;
14
+ }
15
+ get crashReportingOptedIn() {
16
+ return this._crashReportingOptedIn;
17
+ }
18
+ set crashReportingOptedIn(crashReportingOptedIn) {
19
+ this._crashReportingOptedIn = crashReportingOptedIn;
20
+ }
21
+ }
22
+ exports.UserPrivacyOptions = UserPrivacyOptions;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoStartupConfiguration = void 0;
4
+ const ConfigurationDefaults_1 = require("./ConfigurationDefaults");
5
+ class AutoStartupConfiguration {
6
+ constructor(logLevel, lifecycleUpdate) {
7
+ this.lifecycleUpdate = ConfigurationDefaults_1.DEFAULT_LIFECYCLE_UPDATE_AUTO;
8
+ this.logLevel = ConfigurationDefaults_1.DEFAULT_LOGLEVEL_AUTO;
9
+ if (lifecycleUpdate !== undefined) {
10
+ this.lifecycleUpdate = lifecycleUpdate;
11
+ }
12
+ if (logLevel !== undefined) {
13
+ this.logLevel = logLevel;
14
+ }
15
+ }
16
+ }
17
+ exports.AutoStartupConfiguration = AutoStartupConfiguration;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Configuration = void 0;
4
+ const LogLevel_1 = require("../model/LogLevel");
5
+ const AutoStartupConfiguration_1 = require("./AutoStartupConfiguration");
6
+ let mainConfig;
7
+ exports.Configuration = {
8
+ setConfiguration(configuration) {
9
+ this.loadConfiguration();
10
+ mainConfig.logLevel = configuration.logLevel;
11
+ mainConfig.lifecycleUpdate = configuration.lifecycleUpdate;
12
+ },
13
+ loadConfiguration() {
14
+ mainConfig = new AutoStartupConfiguration_1.AutoStartupConfiguration();
15
+ return mainConfig;
16
+ },
17
+ isConfigurationAvailable() {
18
+ return mainConfig != undefined;
19
+ },
20
+ isDebugEnabled() {
21
+ return mainConfig.logLevel == LogLevel_1.LogLevel.Debug;
22
+ },
23
+ isLifecycleUpdateEnabled() {
24
+ return mainConfig.lifecycleUpdate;
25
+ },
26
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_USER_OPT_IN = exports.DEFAULT_CERTIFICATE_VALIDATION = exports.DEFAULT_REPORT_CRASH = exports.DEFAULT_LOGLEVEL_AUTO = exports.DEFAULT_LOGLEVEL = exports.DEFAULT_LIFECYCLE_UPDATE_AUTO = exports.DEFAULT_LIFECYCLE_UPDATE = void 0;
4
+ const LogLevel_1 = require("../model/LogLevel");
5
+ const debugAuto = false;
6
+ const lifecycleUpdateAuto = false;
7
+ exports.DEFAULT_LIFECYCLE_UPDATE = false;
8
+ exports.DEFAULT_LIFECYCLE_UPDATE_AUTO = lifecycleUpdateAuto;
9
+ exports.DEFAULT_LOGLEVEL = LogLevel_1.LogLevel.Info;
10
+ exports.DEFAULT_LOGLEVEL_AUTO = debugAuto ? LogLevel_1.LogLevel.Debug : LogLevel_1.LogLevel.Info;
11
+ exports.DEFAULT_REPORT_CRASH = true;
12
+ exports.DEFAULT_CERTIFICATE_VALIDATION = true;
13
+ exports.DEFAULT_USER_OPT_IN = false;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManualStartupConfiguration = void 0;
4
+ const ConfigurationDefaults_1 = require("./ConfigurationDefaults");
5
+ class ManualStartupConfiguration {
6
+ constructor(beaconUrl, applicationId, reportCrash, logLevel, lifecycleUpdate, certificateValidation, userOptIn) {
7
+ this.reportCrash = ConfigurationDefaults_1.DEFAULT_REPORT_CRASH;
8
+ this.certificateValidation = ConfigurationDefaults_1.DEFAULT_CERTIFICATE_VALIDATION;
9
+ this.userOptIn = ConfigurationDefaults_1.DEFAULT_USER_OPT_IN;
10
+ this.logLevel = ConfigurationDefaults_1.DEFAULT_LOGLEVEL;
11
+ this.lifecycleUpdate = ConfigurationDefaults_1.DEFAULT_LIFECYCLE_UPDATE;
12
+ if (!applicationId || !beaconUrl) {
13
+ throw new Error('Dynatrace Startup Configuration is not correct! Missing applicationId and beaconUrl!');
14
+ }
15
+ this.applicationId = applicationId;
16
+ this.beaconUrl = beaconUrl;
17
+ if (reportCrash != null) {
18
+ this.reportCrash = reportCrash;
19
+ }
20
+ if (certificateValidation != null) {
21
+ this.certificateValidation = certificateValidation;
22
+ }
23
+ if (userOptIn != null) {
24
+ this.userOptIn = userOptIn;
25
+ }
26
+ if (logLevel != null) {
27
+ this.logLevel = logLevel;
28
+ }
29
+ if (lifecycleUpdate != null) {
30
+ this.lifecycleUpdate = lifecycleUpdate;
31
+ }
32
+ }
33
+ }
34
+ exports.ManualStartupConfiguration = ManualStartupConfiguration;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataCollectionLevel = void 0;
4
+ const DynatraceBridge_1 = require("../DynatraceBridge");
5
+ var DataCollectionLevel;
6
+ (function (DataCollectionLevel) {
7
+ DataCollectionLevel[DataCollectionLevel["Off"] = DynatraceBridge_1.DynatraceNative.DATA_COLLECTION_OFF] = "Off";
8
+ DataCollectionLevel[DataCollectionLevel["Performance"] = DynatraceBridge_1.DynatraceNative.DATA_COLLECTION_PERFORMANCE] = "Performance";
9
+ DataCollectionLevel[DataCollectionLevel["User"] = DynatraceBridge_1.DynatraceNative.DATA_COLLECTION_USERBEHAVIOR] = "User";
10
+ DataCollectionLevel[DataCollectionLevel["UserBehavior"] = DynatraceBridge_1.DynatraceNative.DATA_COLLECTION_USERBEHAVIOR] = "UserBehavior";
11
+ })(DataCollectionLevel = exports.DataCollectionLevel || (exports.DataCollectionLevel = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogLevel = void 0;
4
+ var LogLevel;
5
+ (function (LogLevel) {
6
+ LogLevel[LogLevel["Debug"] = 0] = "Debug";
7
+ LogLevel[LogLevel["Info"] = 1] = "Info";
8
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Platform = void 0;
4
+ const DynatraceBridge_1 = require("../DynatraceBridge");
5
+ var Platform;
6
+ (function (Platform) {
7
+ Platform[Platform["Android"] = DynatraceBridge_1.DynatraceNative.PLATFORM_ANDROID] = "Android";
8
+ Platform[Platform["Ios"] = DynatraceBridge_1.DynatraceNative.PLATFORM_IOS] = "Ios";
9
+ })(Platform = exports.Platform || (exports.Platform = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringUtils = void 0;
4
+ exports.StringUtils = {
5
+ isStringNullEmptyOrUndefined(value) {
6
+ return !value;
7
+ },
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"e",{value:!0}),exports.instrument=void 0;var o,c=require("jscodeshift"),l=require("path"),r=require("./parser/babel"),a=require("./model/types"),t=require("../../scripts/fileOperationHelper"),i=require("../../scripts/pathsConstants"),u=require("jscodeshift/src/Collection");!function(e){e[e.n=-1]="Filtered",e[e.r=0]="Normal",e[e.t=1]="ReactNative",e[e.i=2]="React"}(o=o||{});var f=[];f.push({a:{c:"react-native",u:"TouchableHighlight"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"TouchableHighlight",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"TouchableOpacity"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"TouchableOpacity",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"TouchableNativeFeedback"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"TouchableNativeFeedback",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"TouchableWithoutFeedback"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"TouchableWithoutFeedback",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"Button"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"Button",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"RefreshControl"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"RefreshControl",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"Text"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"Text",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"react-native",u:"Pressable"},o:{c:"@dynatrace/react-native-plugin/lib/react-native/",u:"Pressable",l:"@dynatrace/react-native-plugin/lib/react-native"}}),f.push({a:{c:"@react-native-community/picker",u:"Picker"},o:{c:"@dynatrace/react-native-plugin/lib/community/Picker",u:"Picker",l:"@dynatrace/react-native-plugin/lib/community/Picker"}}),f.push({a:{c:"@react-native-community/picker",u:"PickerIOS"},o:{c:"@dynatrace/react-native-plugin/lib/community/Picker",u:"PickerIOS",l:"@dynatrace/react-native-plugin/lib/community/Picker"}});var d=["AppRegistry","renderApplication"];function instrument(e,n,r){var t,i=x(n=b(n));if(i!=o.n){var a=!1,c=y(n,e);if(i==o.i)I(c),a=!0;else if(i==o.t)n.endsWith("AppRegistry.js")?null!=r&&r.autoStart&&(A(c),a=!0):n.endsWith("renderApplication.js")&&(v(c),a=!0);else{var u=k(n,r);if(!u.input&&!u.lifecycle)return null!=r&&r.debug&&console.log("Dynatrace - Filtered All: ".concat(n)),g(n),e;u.lifecycle&&v(c)&&(a=!0),u.input&&f.forEach(function(e){var n=j(c,e);c=n.f,a=a||n.d})}a?h(e=c.toSource({v:"single"}),n):g(n),null!=r&&r.debug&&a&&console.log("Dynatrace - Modified Filename: "+n)}else{n.includes(l.join("@dynatrace","react-native-plugin"))&&n.endsWith(l.join("lib","instrumentor","base","configuration","ConfigurationDefaults.js"))&&void 0!==r&&(t=y(n,e),void 0!==r.debug&&s(t,"debugAuto",r.debug),void 0!==r.lifecycle&&s(t,"lifecycleUpdateAuto",r.lifecycle.includeUpdate),h(e=t.toSource({v:"single"}),n))}return e}function v(e){var n=e.findJSXElements(),i=!1;return 0<n.length&&(e.find(c.FunctionDeclaration).forEach(function(e){var n,r,t=u.fromPaths([e]);0<t.findJSXElements().length&&e&&e.value&&e.value.id&&e.value.id.name&&(n=t.find(c.ClassDeclaration),r=t.find(c.p),0==n.length&&0==r.length&&(p(e,a.Types.FunctionalComponent,e.value.id.name),i=!0))}),e.find(c.ClassDeclaration).forEach(function(e){0<u.fromPaths([e]).findJSXElements().length&&e&&e.value&&e.value.id&&e.value.id.name&&(p(e,a.Types.ClassComponent,e.value.id.name),i=!0)}),e.find(c.ArrowFunctionExpression).forEach(function(e){0<u.fromPaths([e]).findJSXElements().length&&e.parent&&e.parent.value&&e.parent.value.id&&e.parent.value.id.name&&(p(e,a.Types.FunctionalComponent,e.parent.value.id.name),i=!0)})),i}function p(e,n,r){for(var t=c.expressionStatement(c.assignmentExpression("=",c.memberExpression(c.identifier(r),c.identifier("_dtInfo")),m(n,r)));null!=e.parentPath&&"body"!=e.parentPath.name;)e=e.parentPath;null!=e.parentPath&&e.insertAfter(t)}function m(e,n){return c.objectExpression([c.objectProperty(c.identifier("type"),c.numericLiteral(e)),c.objectProperty(c.identifier("name"),c.stringLiteral(n))])}function s(e,n,r){var t,i=e.find(c.Identifier).filter(function(e){return e.node.name===n&&"VariableDeclarator"==e.parent.value.type});1===i.length&&("NumericLiteral"===(t=i.paths()[0].parent.value).init.type&&"number"==typeof r?t.init=c.numericLiteral(r):"StringLiteral"===t.init.type&&"string"==typeof r?t.init=c.stringLiteral(r):"BooleanLiteral"===t.init.type&&"boolean"==typeof r&&(t.init=c.booleanLiteral(r)))}function y(e,n){return c.withParser(r.babelParser(l.extname(e)))(n)}function b(e){return l.isAbsolute(e)?e.replace(i.default.m()+l.sep,""):e}function g(e){try{var n=l.join(i.default.getBuildPath(),e+".dtx");t.default.checkIfFileExistsSync(n),t.default.deleteFileSync(n)}catch(e){}}function h(e,n){var r=l.join(i.default.getBuildPath(),n);try{t.default.checkIfFileExistsSync(l.dirname(r))}catch(e){t.default.createDirectorySync(l.dirname(r))}t.default.writeTextToFileSync(r+".dtx",e)}function k(e,n){var r={input:!1,lifecycle:!1};return void 0!==n&&(void 0!==n.lifecycle&&void 0!==n.lifecycle.instrument&&n.lifecycle.instrument(e)&&(r.lifecycle=!0),void 0!==n.input&&void 0!==n.input.instrument&&n.input.instrument(e)&&(r.input=!0)),r}function I(e){var n,r=e.find(c.Program);1===r.length&&(n=c.expressionStatement(c.callExpression(c.memberExpression(c.callExpression(c.identifier("require"),[c.stringLiteral("@dynatrace/react-native-plugin/lib/instrumentor/base/ElementHelper")]),c.identifier("instrumentCreateElement")),[c.memberExpression(c.identifier("module"),c.identifier("exports"))])),r.paths()[0].node.body.push(n))}function A(e){var n=w(e,"runApplication",!0);1===n.length&&(M(e,{s:"_DynatraceApplicationHandler",c:"@dynatrace/react-native-plugin",u:"ApplicationHandler"}),q(n.paths()[0].parent.value.body.body,0,W("_DynatraceApplicationHandler","startup")))}function q(e,n){for(var r=arguments.length,t=new Array(2<r?r-2:0),i=2;i<r;i++)t[i-2]=arguments[i];return e.splice.apply(e,[n,0].concat(t))}function w(e,n,t){for(var r=arguments.length,i=new Array(3<r?r-3:0),a=3;a<r;a++)i[a-3]=arguments[a];return e.find(c.Identifier).filter(function(e){return e.node.name===n}).filter(function(e){var n=void 0!==e.parent&&void 0!==e.parent.value;t||(n=n&&void 0!==e.parent.value.params&&e.parent.value.params.length===i.length);for(var r=0;r<0;r++)n=n&&e.parent.value.params[r].name===i[r];return n})}function x(e){if(e.includes("@dynatrace"))return o.n;var n=l.extname(e);if(".js"!==n&&".ts"!==n&&".tsx"!==n&&".jsx"!==n)return o.n;for(var r=l.parse(e),t=r.dir.split(l.sep),i=0;i<t.length;i++)if("node_modules"===t[i]){if("react-native"===t[i+1]||"create-react-class"===t[i+1]||"react-clone-referenced-element"===t[i+1])return d.includes(r.name)?o.t:o.n;if("react"===t[i+1]&&"index"===r.name)return o.i}return o.r}function N(e,n,r){var t=P(e,n,r);return T(e,n,r)||t}function P(e,n,r){var t=O(e,n);if(0<t.length){var i=R(t,n.u,!1);return void 0!==i&&(r.s=i.localName),E(e,r),!0}return!1}function T(e,n,r){var t=D(e,n.c);if(1===t.length){var i=R(t,n.u,!0);if(void 0!==i)return J(e,r.l,i.localName,"ImportNamespaceSpecifier"===i.type),!0}return!1}function j(e,n){var r=JSON.parse(JSON.stringify(n.o));return{f:e,d:N(e,n.a,r)||H(e,n.a,n.o.l)}}function O(e,n){return e.find(c.ImportDeclaration).filter(function(e){return e.node.source.value===n.c&&e.node.specifiers.some(function(e){return F(e)&&e.imported.name===n.u||e.local&&e.local.name===n.u})})}function F(e){return void 0!==e.imported}function H(e,n,r){var t=!1;return e.find(c.CallExpression).filter(function(e){return S(e.node.callee)&&C(e.node.arguments[0])&&e.node.arguments[0].value===n.c&&void 0!==e.parent}).forEach(function(e){(null==e.parent.value.property||null!=e.parent.value.property&&null!=e.parent.value.property.name&&e.parent.value.property.name===n.u)&&(e.node.arguments[0].value=r,t=t||!0)}),t}function S(e){return"require"===e.name}function C(e){return"StringLiteral"===e.type||"Literal"===e.type}function D(e,n){return e.find(c.ImportDeclaration).filter(function(e){return e.node.source.value===n})}function R(e,r,t){var i;return e.forEach(function(e){void 0!==e.node.specifiers&&(e.node.specifiers=e.node.specifiers.filter(function(e){if(!F(e)||t)return!(!F(e)&&t)||(null!==e.local&&(i={localName:e.local.name,type:e.type}),!1);var n=e.imported.name!==r;return n||null===e.local||e.imported.name===e.local.name||(i={localName:e.local.name,type:e.type}),n}),0===e.node.specifiers.length&&e.prune())}),i}function _(e,n){e.find(c.ImportDeclaration).filter(function(e){return e.node.source.value===n.c}).forEach(function(e){e.node.specifiers.push(X(n))})}function L(e,n,r){e.find(c.ImportDeclaration).filter(function(e){return e.node.source.value===n}).forEach(function(e){e.node.specifiers.push(r)})}function B(e,n,r){var t,i=e.find(c.ImportDeclaration);0<i.length?c(i.paths()[0]).insertAfter(Q(n,r)):1===(t=e.find(c.Program)).length&&t.paths()[0].node.body.unshift(Q(n,r))}function E(e,n){0<D(e,n.c).length?_(e,n):B(e,n.c,[X(n)])}function J(e,n,r,t){var i=D(e,n),a=(t?Z:Y)(r);0<i.length?L(e,n,a):B(e,n,[a])}function M(e,n){var r=e.find(c.VariableDeclaration);0<r.length&&c(r.paths()[0]).insertAfter(V(n))}function W(e,n){return c.expressionStatement(U(e,n,[]))}function U(e,n,r){return c.callExpression(G(e,n),r)}function V(e){return c.variableDeclaration("var",[n(e)])}function n(e){return c.variableDeclarator(void 0!==e.s?c.identifier(e.s):c.identifier(e.u),z(e))}function z(e){return c.memberExpression(K(e),c.identifier(e.u))}function G(e,n){return c.memberExpression(c.identifier(e),c.identifier(n))}function K(e){return c.callExpression(c.identifier("require"),[c.literal(e.c)])}function Q(e,n){return c.importDeclaration(n,c.literal(e))}function X(e){return void 0!==e.s?c.importSpecifier(c.identifier(e.u),c.identifier(e.s)):c.importSpecifier(c.identifier(e.u))}function Y(e){return c.importDefaultSpecifier(c.identifier(e))}function Z(e){return c.importNamespaceSpecifier(c.identifier(e))}exports.instrument=instrument;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Types = void 0;
4
+ var Types;
5
+ (function (Types) {
6
+ Types[Types["FunctionalComponent"] = 0] = "FunctionalComponent";
7
+ Types[Types["ClassComponent"] = 1] = "ClassComponent";
8
+ Types[Types["Button"] = 2] = "Button";
9
+ Types[Types["TouchableOpacity"] = 3] = "TouchableOpacity";
10
+ Types[Types["TouchableHighlight"] = 4] = "TouchableHighlight";
11
+ Types[Types["TouchableNativeFeedback"] = 5] = "TouchableNativeFeedback";
12
+ Types[Types["TouchableWithoutFeedback"] = 6] = "TouchableWithoutFeedback";
13
+ Types[Types["Text"] = 7] = "Text";
14
+ Types[Types["Picker"] = 8] = "Picker";
15
+ Types[Types["Pressable"] = 9] = "Pressable";
16
+ })(Types = exports.Types || (exports.Types = {}));
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.babelParser = void 0;
5
+ const babel = require("@babel/parser");
6
+ exports.babelParser = (parser) => {
7
+ return {
8
+ parse: (source, options) => {
9
+ const ast = babel.parse(source, getParserOptions(parser));
10
+ if (isASTNode(ast)) {
11
+ return ast;
12
+ }
13
+ throw new Error('This is not an AST Node!');
14
+ },
15
+ };
16
+ };
17
+ function getParserOptions(parser) {
18
+ switch (parser) {
19
+ case '.ts':
20
+ return defaultOptionsTs;
21
+ case '.tsx':
22
+ return defaultOptionsTsx;
23
+ default:
24
+ return defaultOptions;
25
+ }
26
+ }
27
+ const defaultOptionsTs = require('jscodeshift/parser/tsOptions.js');
28
+ const defaultOptionsTsx = JSON.parse(JSON.stringify(require('jscodeshift/parser/tsOptions.js')));
29
+ (_a = defaultOptionsTsx.plugins) === null || _a === void 0 ? void 0 : _a.push('jsx');
30
+ const defaultOptions = {
31
+ sourceType: 'module',
32
+ allowImportExportEverywhere: true,
33
+ allowReturnOutsideFunction: true,
34
+ startLine: 1,
35
+ tokens: true,
36
+ plugins: [
37
+ ['flow', { all: true }],
38
+ 'jsx',
39
+ 'asyncGenerators',
40
+ 'bigInt',
41
+ 'classProperties',
42
+ 'classPrivateProperties',
43
+ 'classPrivateMethods',
44
+ ['decorators', { decoratorsBeforeExport: true }],
45
+ 'doExpressions',
46
+ 'dynamicImport',
47
+ 'exportDefaultFrom',
48
+ 'exportNamespaceFrom',
49
+ 'functionBind',
50
+ 'functionSent',
51
+ 'importMeta',
52
+ 'nullishCoalescingOperator',
53
+ 'numericSeparator',
54
+ 'objectRestSpread',
55
+ 'optionalCatchBinding',
56
+ 'optionalChaining',
57
+ ['pipelineOperator', { proposal: 'minimal' }],
58
+ 'throwExpressions',
59
+ ],
60
+ };
61
+ function isASTNode(ast) {
62
+ return ast.loc != null;
63
+ }