@dynatrace/react-native-plugin 2.307.1 → 2.309.1
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.
- package/README.md +7 -3
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceAppStartModule.kt +128 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceInternalModule.kt +22 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +411 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceReactPackage.kt +54 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +86 -0
- package/android/src/main/java/com/dynatrace/android/agent/model/AppStartMeasurement.kt +15 -0
- package/android/src/main/java/com/dynatrace/android/agent/model/AppStartMeasurementType.kt +18 -0
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +228 -0
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +258 -0
- package/files/plugin.gradle +1 -1
- package/index.js +10 -10
- package/instrumentation/DynatraceInstrumentation.js +1 -0
- package/{lib → instrumentation/jsx}/CreateElement.js +6 -5
- package/{lib/instrumentor/base → instrumentation/jsx}/ElementHelper.js +14 -12
- package/{lib/jsx-dev-runtime.js → instrumentation/jsx/JsxDevRuntime.js} +10 -19
- package/instrumentation/jsx/JsxRuntime.js +63 -0
- package/instrumentation/jsx/JsxRuntimeUtil.js +31 -0
- package/instrumentation/jsx/components/ClassComponent.js +49 -0
- package/instrumentation/jsx/components/ComponentUtil.js +33 -0
- package/instrumentation/jsx/components/FunctionalComponent.js +20 -0
- package/{lib/instrumentor/base → instrumentation/jsx/components}/Picker.js +1 -1
- package/{lib/instrumentor/base → instrumentation/jsx/components}/RefreshControl.js +1 -1
- package/{lib/instrumentor/base → instrumentation/jsx/components}/Switch.js +1 -1
- package/{lib/instrumentor/base → instrumentation/jsx/components}/Touchable.js +5 -5
- package/instrumentation/libs/community/Picker.InstrInfo.js +20 -0
- package/{lib → instrumentation/libs}/community/Picker.js +1 -1
- package/instrumentation/libs/community/gesture-handler/Touchables.InstrInfo.js +23 -0
- package/{lib → instrumentation/libs}/community/gesture-handler/Touchables.js +1 -1
- package/{lib → instrumentation/libs}/react-native/RefreshControl.InstrInfo.js +2 -2
- package/{lib → instrumentation/libs}/react-native/RefreshControl.js +5 -5
- package/{lib → instrumentation/libs}/react-native/Switch.InstrInfo.js +2 -2
- package/{lib → instrumentation/libs}/react-native/Switch.js +5 -5
- package/instrumentation/libs/react-native/Touchables.InstrInfo.js +25 -0
- package/{lib → instrumentation/libs}/react-native/Touchables.js +1 -1
- package/{lib → instrumentation/libs}/react-navigation/ReactNavigation.js +6 -5
- package/{lib/instrumentor → instrumentation}/model/Types.js +1 -14
- package/instrumentation/model/TypesUtil.js +17 -0
- package/ios/DynatraceRNBridge.h +10 -1
- package/ios/DynatraceRNBridge.mm +152 -0
- package/jsx-dev-runtime.js +1 -1
- package/jsx-runtime.js +1 -1
- package/lib/core/Application.js +20 -0
- package/lib/{instrumentor/base → core}/Dynatrace.js +57 -48
- package/lib/{instrumentor/base → core}/DynatraceAction.js +23 -22
- package/lib/core/DynatraceInternal.js +46 -0
- package/lib/{instrumentor/base → core}/DynatraceRootAction.js +5 -4
- package/lib/{instrumentor/base → core}/DynatraceWebRequestTiming.js +6 -5
- package/lib/{instrumentor/base → core}/ErrorHandler.js +6 -5
- package/lib/{instrumentor/base → core}/configuration/Configuration.js +1 -1
- package/lib/{instrumentor/base → core}/configuration/ConfigurationDefaults.js +1 -2
- package/lib/{instrumentor/base → core}/configuration/ConfigurationHandler.js +2 -2
- package/lib/{instrumentor/base → core}/configuration/ManualStartupConfiguration.js +1 -1
- package/lib/core/logging/ConsoleLogger.js +27 -0
- package/lib/core/logging/LogLevel.js +12 -0
- package/lib/dynatrace-transformer.js +1 -1
- package/lib/next/Dynatrace.js +86 -0
- package/lib/next/DynatraceSecondGenForwarder.js +17 -0
- package/lib/next/IDynatrace.js +2 -0
- package/lib/next/IDynatraceForwarder.js +2 -0
- package/lib/next/appstart/AppStartObserver.js +32 -0
- package/lib/next/appstart/AppStartType.js +38 -0
- package/lib/next/events/EventCreator.js +77 -0
- package/lib/next/events/EventPipeline.js +57 -0
- package/lib/next/events/EventTimestamp.js +24 -0
- package/lib/next/events/ViewInfoCreator.js +27 -0
- package/lib/next/events/modifier/BaseDataEventModifier.js +31 -0
- package/lib/next/events/modifier/EventLimitation.js +69 -0
- package/lib/next/events/modifier/EventModifierUtil.js +88 -0
- package/lib/next/events/modifier/IEventModifier.js +2 -0
- package/lib/next/events/modifier/ModifyEventValidation.js +187 -0
- package/lib/next/events/modifier/NonFiniteNumbersModifier.js +50 -0
- package/lib/next/events/modifier/SendEventValidation.js +84 -0
- package/lib/next/events/spec/EventFieldKeysEnum.js +2 -0
- package/lib/next/events/spec/EventSpecContstants.js +46 -0
- package/lib/next/events/spec/IAppStartEvent.js +2 -0
- package/lib/next/events/spec/ICrashEvent.js +2 -0
- package/lib/next/events/spec/IErrorCodeEvent.js +2 -0
- package/lib/next/events/spec/IErrorExceptionEvent.js +2 -0
- package/lib/next/events/spec/IReactNativeEvent.js +2 -0
- package/lib/next/events/spec/IRumEvent.js +2 -0
- package/lib/next/provider/ITimestampProvider.js +2 -0
- package/lib/next/provider/TimestampProvider.js +10 -0
- package/package.json +41 -33
- package/react-native-dynatrace.podspec +1 -1
- package/src/lib/{instrumentor/base → core}/interface/NativeDynatraceBridge.ts +8 -0
- package/typings/react-native-dynatrace.d.ts +0 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.java +0 -366
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceReactPackage.java +0 -67
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.java +0 -108
- package/android/src/main/java/com/dynatrace/android/agent/PrivateDTBridge.java +0 -28
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.java +0 -192
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.java +0 -194
- package/lib/community/Picker.InstrInfo.js +0 -20
- package/lib/community/gesture-handler/Touchables.InstrInfo.js +0 -56
- package/lib/instrumentor/DynatraceInstrumentation.js +0 -1
- package/lib/instrumentor/base/Application.js +0 -16
- package/lib/instrumentor/base/DynatraceInternal.js +0 -34
- package/lib/instrumentor/base/Logger.js +0 -16
- package/lib/instrumentor/base/model/LogLevel.js +0 -17
- package/lib/jsx-runtime.js +0 -69
- package/lib/react/Component.js +0 -90
- package/lib/react-native/Touchables.InstrInfo.js +0 -60
- /package/{lib/instrumentor/base/interface → instrumentation/jsx}/IDynatraceProperties.js +0 -0
- /package/{lib → instrumentation/libs}/community/gesture-handler/index.js +0 -0
- /package/{lib → instrumentation/libs}/gesture-handler.js +0 -0
- /package/{lib → instrumentation/libs}/react-native/index.js +0 -0
- /package/{lib → instrumentation/libs}/react-native.js +0 -0
- /package/{lib/instrumentor → instrumentation}/model/Reference.js +0 -0
- /package/{lib/instrumentor → instrumentation}/parser/Babel.js +0 -0
- /package/lib/{instrumentor/base → core}/DynatraceBridge.js +0 -0
- /package/lib/{instrumentor/base → core}/NullAction.js +0 -0
- /package/lib/{instrumentor/base → core}/NullRootAction.js +0 -0
- /package/lib/{instrumentor/base → core}/NullWebRequestTiming.js +0 -0
- /package/lib/{instrumentor/base → core}/UserPrivacyOptions.js +0 -0
- /package/lib/{instrumentor/base → core}/configuration/ConfigurationBuilder.js +0 -0
- /package/lib/{instrumentor/base → core}/configuration/ConfigurationPreset.js +0 -0
- /package/lib/{instrumentor/base → core}/configuration/IConfiguration.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/IDynatrace.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/IDynatraceAction.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/IDynatraceInternal.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/IDynatraceRootAction.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/IWebRequestTiming.js +0 -0
- /package/lib/{instrumentor/base → core}/interface/NativeDynatraceBridge.js +0 -0
- /package/lib/{instrumentor/base/interface → core/logging}/ILogger.js +0 -0
- /package/lib/{instrumentor/base → core}/model/DataCollectionLevel.js +0 -0
- /package/lib/{instrumentor/base → core}/model/Json.js +0 -0
- /package/lib/{instrumentor/base → core}/model/Platform.js +0 -0
- /package/lib/{instrumentor/base → core}/util/StringUtils.js +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
package com.dynatrace.android.agent
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableArray
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.facebook.react.bridge.ReadableType
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @author matthias.hochrieser
|
|
9
|
+
*/
|
|
10
|
+
internal object DynatraceUtils {
|
|
11
|
+
// https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java#L56
|
|
12
|
+
private fun toArrayList(array: ReadableArray?): ArrayList<Any?> {
|
|
13
|
+
val arrayList = ArrayList<Any?>(array!!.size())
|
|
14
|
+
var i = 0
|
|
15
|
+
val size = array.size()
|
|
16
|
+
while (i < size) {
|
|
17
|
+
when (array.getType(i)) {
|
|
18
|
+
ReadableType.Null -> arrayList.add(null)
|
|
19
|
+
ReadableType.Boolean -> arrayList.add(array.getBoolean(i))
|
|
20
|
+
ReadableType.Number -> {
|
|
21
|
+
val value = array.getDouble(i)
|
|
22
|
+
if (java.lang.Double.isFinite(value)) {
|
|
23
|
+
if (value >= Int.MIN_VALUE && value <= Int.MAX_VALUE && value == value.toInt()
|
|
24
|
+
.toDouble()
|
|
25
|
+
) {
|
|
26
|
+
// This is a int
|
|
27
|
+
arrayList.add(array.getDouble(i).toInt())
|
|
28
|
+
}
|
|
29
|
+
if (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE && value == value.toLong()
|
|
30
|
+
.toDouble()
|
|
31
|
+
) {
|
|
32
|
+
// This is a long
|
|
33
|
+
arrayList.add(array.getDouble(i).toLong())
|
|
34
|
+
}
|
|
35
|
+
break
|
|
36
|
+
}
|
|
37
|
+
arrayList.add(array.getDouble(i))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ReadableType.String -> arrayList.add(array.getString(i))
|
|
41
|
+
ReadableType.Map -> arrayList.add(toHashMap(array.getMap(i)))
|
|
42
|
+
ReadableType.Array -> arrayList.add(toArrayList(array.getArray(i)))
|
|
43
|
+
else -> throw IllegalArgumentException("Could not convert object at index: $i.")
|
|
44
|
+
}
|
|
45
|
+
i++
|
|
46
|
+
}
|
|
47
|
+
return arrayList
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun toHashMap(map: ReadableMap?): HashMap<String, Any?> {
|
|
51
|
+
val hashMap = HashMap<String, Any?>()
|
|
52
|
+
val iterator = map!!.keySetIterator()
|
|
53
|
+
while (iterator.hasNextKey()) {
|
|
54
|
+
val key = iterator.nextKey()
|
|
55
|
+
when (map.getType(key)) {
|
|
56
|
+
ReadableType.Null -> hashMap[key] = null
|
|
57
|
+
ReadableType.Boolean -> hashMap[key] = map.getBoolean(key)
|
|
58
|
+
ReadableType.Number -> {
|
|
59
|
+
val value = map.getDouble(key)
|
|
60
|
+
if (java.lang.Double.isFinite(value)) {
|
|
61
|
+
if (value >= Int.MIN_VALUE && value <= Int.MAX_VALUE && value == value.toInt()
|
|
62
|
+
.toDouble()
|
|
63
|
+
) {
|
|
64
|
+
// This is a int
|
|
65
|
+
hashMap[key] = map.getDouble(key).toInt()
|
|
66
|
+
}
|
|
67
|
+
if (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE && value == value.toLong()
|
|
68
|
+
.toDouble()
|
|
69
|
+
) {
|
|
70
|
+
// This is a long
|
|
71
|
+
hashMap[key] = map.getDouble(key).toLong()
|
|
72
|
+
}
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
hashMap[key] = map.getDouble(key)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ReadableType.String -> hashMap[key] = map.getString(key)
|
|
79
|
+
ReadableType.Map -> hashMap[key] = toHashMap(map.getMap(key))
|
|
80
|
+
ReadableType.Array -> hashMap[key] = toArrayList(map.getArray(key))
|
|
81
|
+
else -> throw IllegalArgumentException("Could not convert object with key: $key.")
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return hashMap
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.dynatrace.android.agent.model
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Class which holds the values for app start measurements
|
|
5
|
+
*/
|
|
6
|
+
data class AppStartMeasurement(
|
|
7
|
+
/**
|
|
8
|
+
* Name of the app start measurement so it can be identified on the js side
|
|
9
|
+
*/
|
|
10
|
+
val name: String,
|
|
11
|
+
/**
|
|
12
|
+
* timestamp when the measurement happened
|
|
13
|
+
*/
|
|
14
|
+
val timestamp: Long
|
|
15
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.dynatrace.android.agent.model
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enum to identify the different measurement types and handle them in js as well
|
|
5
|
+
*/
|
|
6
|
+
enum class AppStartMeasurementType(
|
|
7
|
+
/**
|
|
8
|
+
* Name of the app start measurement so it can be identified on the js side
|
|
9
|
+
*/
|
|
10
|
+
val value: String
|
|
11
|
+
) {
|
|
12
|
+
DOWNLOAD_START("downloadStart"),
|
|
13
|
+
DOWNLOAD_END("downloadEnd"),
|
|
14
|
+
RELOAD("reload"),
|
|
15
|
+
RUN_JS_BUNDLE_START("runJsBundleStart"),
|
|
16
|
+
RUN_JS_BUNDLE_END("runJsBundleEnd"),
|
|
17
|
+
CONTENT_APPEARED("contentAppeared")
|
|
18
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
package com.dynatrace.android.agent
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
|
|
7
|
+
class DynatraceRNBridge(
|
|
8
|
+
reactContext: ReactApplicationContext,
|
|
9
|
+
internalModule: DynatraceInternalModule
|
|
10
|
+
) : NativeDynatraceBridgeSpec(reactContext) {
|
|
11
|
+
private val impl: DynatraceRNBridgeImpl
|
|
12
|
+
|
|
13
|
+
init {
|
|
14
|
+
impl = DynatraceRNBridgeImpl(reactContext, internalModule)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun getName(): String {
|
|
18
|
+
return BRIDGE_NAME;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun getTypedExportedConstants(): Map<String, Any> {
|
|
22
|
+
return impl.getConstants()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun start(configuration: ReadableMap, promise: Promise) {
|
|
26
|
+
impl.start(configuration, promise)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun enterAction(name: String, key: String, platform: String?) {
|
|
30
|
+
impl.enterAction(name, key, platform)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun enterManualAction(name: String, key: String, platform: String?) {
|
|
34
|
+
impl.enterManualAction(name, key, platform)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun enterManualActionWithParent(
|
|
38
|
+
name: String,
|
|
39
|
+
key: String,
|
|
40
|
+
parentKey: String,
|
|
41
|
+
platform: String?
|
|
42
|
+
) {
|
|
43
|
+
impl.enterManualActionWithParent(name, key, parentKey, platform)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun leaveAction(key: String, leave: Boolean, platform: String?) {
|
|
47
|
+
impl.leaveAction(key, leave, platform)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun cancelAction(key: String, platform: String?) {
|
|
51
|
+
impl.cancelAction(key, platform)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun endVisit(platform: String?) {
|
|
55
|
+
impl.endVisit(platform)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun reportErrorWithoutStacktrace(errorName: String, errorCode: Double, platform: String?) {
|
|
59
|
+
impl.reportErrorWithoutStacktrace(errorName, errorCode.toInt(), platform)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override fun reportError(
|
|
63
|
+
errorName: String,
|
|
64
|
+
errorValue: String,
|
|
65
|
+
reason: String,
|
|
66
|
+
stacktrace: String,
|
|
67
|
+
platform: String?
|
|
68
|
+
) {
|
|
69
|
+
impl.reportError(errorName, errorValue, reason, stacktrace, platform)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override fun reportCrash(
|
|
73
|
+
errorName: String,
|
|
74
|
+
reason: String,
|
|
75
|
+
stacktrace: String,
|
|
76
|
+
isRealError: Boolean,
|
|
77
|
+
platform: String?
|
|
78
|
+
) {
|
|
79
|
+
impl.reportCrash(errorName, reason, stacktrace, isRealError, platform)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
override fun storeCrash(errorName: String, reason: String, stacktrace: String) {
|
|
83
|
+
// Empty on Purpose
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
override fun reportErrorInAction(
|
|
87
|
+
key: String,
|
|
88
|
+
errorName: String,
|
|
89
|
+
errorCode: Double,
|
|
90
|
+
platform: String?
|
|
91
|
+
) {
|
|
92
|
+
impl.reportErrorInAction(key, errorName, errorCode.toInt(), platform)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override fun reportValue(key: String, valueName: String, value: String, platform: String?) {
|
|
96
|
+
impl.reportValue(key, valueName, value, platform)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
override fun getRequestTag(key: String, url: String, promise: Promise) {
|
|
100
|
+
impl.getRequestTag(key, url, promise)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override fun startWebRequestTiming(requestTag: String?, url: String) {
|
|
104
|
+
impl.startWebRequestTiming(requestTag, url)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
override fun stopWebRequestTiming(
|
|
108
|
+
requestTag: String?,
|
|
109
|
+
url: String,
|
|
110
|
+
responseCode: Double,
|
|
111
|
+
responseMessage: String
|
|
112
|
+
) {
|
|
113
|
+
impl.stopWebRequestTiming(requestTag, url, responseCode.toInt(), responseMessage)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
override fun stopWebRequestTimingWithSize(
|
|
117
|
+
requestTag: String?,
|
|
118
|
+
url: String,
|
|
119
|
+
responseCode: Double,
|
|
120
|
+
responseMessage: String,
|
|
121
|
+
requestSize: Double,
|
|
122
|
+
responseSize: Double
|
|
123
|
+
) {
|
|
124
|
+
impl.stopWebRequestTimingWithSize(
|
|
125
|
+
requestTag,
|
|
126
|
+
url,
|
|
127
|
+
responseCode.toInt(),
|
|
128
|
+
responseMessage,
|
|
129
|
+
requestSize.toLong(),
|
|
130
|
+
responseSize.toLong()
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
override fun identifyUser(user: String, platform: String?) {
|
|
135
|
+
impl.identifyUser(user, platform)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
override fun reportEventInAction(actionKey: String, name: String, platform: String?) {
|
|
139
|
+
impl.reportEventInAction(actionKey, name, platform)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
override fun reportStringValueInAction(
|
|
143
|
+
actionKey: String,
|
|
144
|
+
name: String,
|
|
145
|
+
value: String,
|
|
146
|
+
platform: String?
|
|
147
|
+
) {
|
|
148
|
+
impl.reportStringValueInAction(actionKey, name, value, platform)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
override fun reportIntValueInAction(
|
|
152
|
+
actionKey: String,
|
|
153
|
+
name: String,
|
|
154
|
+
value: Double,
|
|
155
|
+
platform: String?
|
|
156
|
+
) {
|
|
157
|
+
impl.reportIntValueInAction(actionKey, name, value.toInt(), platform)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
override fun reportDoubleValueInAction(
|
|
161
|
+
actionKey: String,
|
|
162
|
+
name: String,
|
|
163
|
+
value: Double,
|
|
164
|
+
platform: String?
|
|
165
|
+
) {
|
|
166
|
+
impl.reportDoubleValueInAction(actionKey, name, value, platform)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
override fun sendBizEvent(type: String, attributes: ReadableMap, platform: String?) {
|
|
170
|
+
impl.sendBizEvent(type, attributes, platform)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
override fun forwardEvent(attributes: ReadableMap) {
|
|
174
|
+
impl.forwardEvent(attributes)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
override fun startView(name: String) {
|
|
178
|
+
impl.startView(name)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
override fun stopView() {
|
|
182
|
+
impl.stopView()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
override fun setGPSLocation(latitude: Double, longitude: Double, platform: String?) {
|
|
186
|
+
impl.setGPSLocation(latitude, longitude, platform)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
override fun flushEvents(platform: String?) {
|
|
190
|
+
impl.flushEvents(platform)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
override fun isCrashReportingOptedIn(platform: String?, promise: Promise) {
|
|
194
|
+
impl.isCrashReportingOptedIn(platform, promise)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
override fun setCrashReportingOptedIn(crashReporting: Boolean, platform: String?) {
|
|
198
|
+
impl.setCrashReportingOptedIn(crashReporting, platform)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
override fun setDataCollectionLevel(collectionLevel: String, platform: String?) {
|
|
202
|
+
impl.setDataCollectionLevel(collectionLevel, platform)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
override fun getDataCollectionLevel(platform: String?, promise: Promise) {
|
|
206
|
+
impl.getDataCollectionLevel(platform, promise)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
override fun setBeaconHeaders(headers: ReadableMap?, platform: String?) {
|
|
210
|
+
impl.setBeaconHeaders(headers, platform)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
override fun applyUserPrivacyOptions(userPrivacyOptions: ReadableMap, platform: String?) {
|
|
214
|
+
impl.applyUserPrivacyOptions(userPrivacyOptions, platform)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
override fun getUserPrivacyOptions(platform: String?, promise: Promise) {
|
|
218
|
+
impl.getUserPrivacyOptions(platform, promise)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
override fun addListener(eventName: String) {
|
|
222
|
+
impl.addListener(eventName)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
override fun removeListeners(count: Double) {
|
|
226
|
+
impl.removeListeners(count)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
package com.dynatrace.android.agent
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
|
|
9
|
+
class DynatraceRNBridge(
|
|
10
|
+
reactContext: ReactApplicationContext,
|
|
11
|
+
internalModule: DynatraceInternalModule
|
|
12
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
13
|
+
private val impl: DynatraceRNBridgeImpl
|
|
14
|
+
|
|
15
|
+
init {
|
|
16
|
+
impl = DynatraceRNBridgeImpl(reactContext, internalModule)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getName(): String {
|
|
20
|
+
return BRIDGE_NAME;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun getConstants(): Map<String, Any>? {
|
|
24
|
+
return impl.getConstants()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun start(configuration: ReadableMap, promise: Promise) {
|
|
29
|
+
impl.start(configuration, promise)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
fun enterAction(name: String, key: String, platform: String?) {
|
|
34
|
+
impl.enterAction(name, key, platform)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ReactMethod
|
|
38
|
+
fun enterManualAction(name: String, key: String, platform: String?) {
|
|
39
|
+
impl.enterManualAction(name, key, platform)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
fun enterManualActionWithParent(
|
|
44
|
+
name: String,
|
|
45
|
+
key: String,
|
|
46
|
+
parentKey: String,
|
|
47
|
+
platform: String?
|
|
48
|
+
) {
|
|
49
|
+
impl.enterManualActionWithParent(name, key, parentKey, platform)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
fun leaveAction(key: String, leave: Boolean, platform: String?) {
|
|
54
|
+
impl.leaveAction(key, leave, platform)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
fun cancelAction(key: String, platform: String?) {
|
|
59
|
+
impl.cancelAction(key, platform)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@ReactMethod
|
|
63
|
+
fun endVisit(platform: String?) {
|
|
64
|
+
impl.endVisit(platform)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactMethod
|
|
68
|
+
fun reportErrorWithoutStacktrace(errorName: String, errorCode: Int, platform: String?) {
|
|
69
|
+
impl.reportErrorWithoutStacktrace(errorName, errorCode, platform)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@ReactMethod
|
|
73
|
+
fun reportError(
|
|
74
|
+
errorName: String,
|
|
75
|
+
errorValue: String,
|
|
76
|
+
reason: String,
|
|
77
|
+
stacktrace: String,
|
|
78
|
+
platform: String?
|
|
79
|
+
) {
|
|
80
|
+
impl.reportError(errorName, errorValue, reason, stacktrace, platform)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ReactMethod
|
|
84
|
+
fun reportCrash(
|
|
85
|
+
errorName: String,
|
|
86
|
+
reason: String,
|
|
87
|
+
stacktrace: String,
|
|
88
|
+
isRealError: Boolean,
|
|
89
|
+
platform: String?
|
|
90
|
+
) {
|
|
91
|
+
impl.reportCrash(errorName, reason, stacktrace, isRealError, platform)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Suppress("UNUSED_PARAMETER")
|
|
95
|
+
@ReactMethod
|
|
96
|
+
fun storeCrash(errorName: String, reason: String, stacktrace: String) {
|
|
97
|
+
// Empty on Purpose
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@ReactMethod
|
|
101
|
+
fun reportErrorInAction(key: String, errorName: String, errorCode: Int, platform: String?) {
|
|
102
|
+
impl.reportErrorInAction(key, errorName, errorCode, platform)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@ReactMethod
|
|
106
|
+
fun reportValue(key: String, valueName: String, value: String, platform: String?) {
|
|
107
|
+
impl.reportValue(key, valueName, value, platform)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@ReactMethod
|
|
111
|
+
fun getRequestTag(key: String, url: String, promise: Promise) {
|
|
112
|
+
impl.getRequestTag(key, url, promise)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@ReactMethod
|
|
116
|
+
fun startWebRequestTiming(requestTag: String?, url: String) {
|
|
117
|
+
impl.startWebRequestTiming(requestTag, url)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@ReactMethod
|
|
121
|
+
fun stopWebRequestTiming(
|
|
122
|
+
requestTag: String?,
|
|
123
|
+
url: String,
|
|
124
|
+
responseCode: Int,
|
|
125
|
+
responseMessage: String
|
|
126
|
+
) {
|
|
127
|
+
impl.stopWebRequestTiming(requestTag, url, responseCode, responseMessage)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
fun stopWebRequestTimingWithSize(
|
|
132
|
+
requestTag: String?,
|
|
133
|
+
url: String,
|
|
134
|
+
responseCode: Int,
|
|
135
|
+
responseMessage: String,
|
|
136
|
+
requestSize: Double,
|
|
137
|
+
responseSize: Double
|
|
138
|
+
) {
|
|
139
|
+
impl.stopWebRequestTimingWithSize(
|
|
140
|
+
requestTag,
|
|
141
|
+
url,
|
|
142
|
+
responseCode,
|
|
143
|
+
responseMessage,
|
|
144
|
+
requestSize.toLong(),
|
|
145
|
+
responseSize.toLong()
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@ReactMethod
|
|
150
|
+
fun identifyUser(user: String, platform: String?) {
|
|
151
|
+
impl.identifyUser(user, platform)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@ReactMethod
|
|
155
|
+
fun reportEventInAction(actionKey: String, name: String, platform: String?) {
|
|
156
|
+
impl.reportEventInAction(actionKey, name, platform)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@ReactMethod
|
|
160
|
+
fun reportStringValueInAction(
|
|
161
|
+
actionKey: String,
|
|
162
|
+
name: String,
|
|
163
|
+
value: String,
|
|
164
|
+
platform: String?
|
|
165
|
+
) {
|
|
166
|
+
impl.reportStringValueInAction(actionKey, name, value, platform)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@ReactMethod
|
|
170
|
+
fun reportIntValueInAction(actionKey: String, name: String, value: Int, platform: String?) {
|
|
171
|
+
impl.reportIntValueInAction(actionKey, name, value, platform)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@ReactMethod
|
|
175
|
+
fun reportDoubleValueInAction(
|
|
176
|
+
actionKey: String,
|
|
177
|
+
name: String,
|
|
178
|
+
value: Double,
|
|
179
|
+
platform: String?
|
|
180
|
+
) {
|
|
181
|
+
impl.reportDoubleValueInAction(actionKey, name, value, platform)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@ReactMethod
|
|
185
|
+
fun sendBizEvent(type: String, attributes: ReadableMap, platform: String?) {
|
|
186
|
+
impl.sendBizEvent(type, attributes, platform)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@ReactMethod
|
|
190
|
+
fun forwardEvent(attributes: ReadableMap) {
|
|
191
|
+
impl.forwardEvent(attributes)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@ReactMethod
|
|
195
|
+
fun startView(name: String) {
|
|
196
|
+
impl.startView(name)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@ReactMethod
|
|
200
|
+
fun stopView() {
|
|
201
|
+
impl.stopView()
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@ReactMethod
|
|
205
|
+
fun setGPSLocation(latitude: Double, longitude: Double, platform: String?) {
|
|
206
|
+
impl.setGPSLocation(latitude, longitude, platform)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@ReactMethod
|
|
210
|
+
fun flushEvents(platform: String?) {
|
|
211
|
+
impl.flushEvents(platform)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@ReactMethod
|
|
215
|
+
fun isCrashReportingOptedIn(platform: String?, promise: Promise) {
|
|
216
|
+
impl.isCrashReportingOptedIn(platform, promise)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@ReactMethod
|
|
220
|
+
fun setCrashReportingOptedIn(crashReporting: Boolean, platform: String?) {
|
|
221
|
+
impl.setCrashReportingOptedIn(crashReporting, platform)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@ReactMethod
|
|
225
|
+
fun setDataCollectionLevel(collectionLevel: String, platform: String?) {
|
|
226
|
+
impl.setDataCollectionLevel(collectionLevel, platform)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@ReactMethod
|
|
230
|
+
fun getDataCollectionLevel(platform: String?, promise: Promise) {
|
|
231
|
+
impl.getDataCollectionLevel(platform, promise)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@ReactMethod
|
|
235
|
+
fun setBeaconHeaders(headers: ReadableMap?, platform: String?) {
|
|
236
|
+
impl.setBeaconHeaders(headers, platform)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@ReactMethod
|
|
240
|
+
fun applyUserPrivacyOptions(userPrivacyOptions: ReadableMap, platform: String?) {
|
|
241
|
+
impl.applyUserPrivacyOptions(userPrivacyOptions, platform)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@ReactMethod
|
|
245
|
+
fun getUserPrivacyOptions(platform: String?, promise: Promise) {
|
|
246
|
+
impl.getUserPrivacyOptions(platform, promise)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@ReactMethod
|
|
250
|
+
fun addListener(eventName: String) {
|
|
251
|
+
impl.addListener(eventName)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@ReactMethod
|
|
255
|
+
fun removeListeners(count: Double) {
|
|
256
|
+
impl.removeListeners(count)
|
|
257
|
+
}
|
|
258
|
+
}
|
package/files/plugin.gradle
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { Dynatrace } from './lib/
|
|
2
|
-
export { DataCollectionLevel } from './lib/
|
|
3
|
-
export { ManualStartupConfiguration } from './lib/
|
|
4
|
-
export { ConfigurationBuilder } from './lib/
|
|
5
|
-
export { Platform } from './lib/
|
|
6
|
-
export { LogLevel } from './lib/
|
|
7
|
-
export { ApplicationHandler } from './lib/
|
|
8
|
-
export { UserPrivacyOptions } from './lib/
|
|
9
|
-
export { DynatraceWebRequestTiming } from './lib/
|
|
10
|
-
export { createElement } from './
|
|
1
|
+
export { Dynatrace } from './lib/core/Dynatrace';
|
|
2
|
+
export { DataCollectionLevel } from './lib/core/model/DataCollectionLevel';
|
|
3
|
+
export { ManualStartupConfiguration } from './lib/core/configuration/ManualStartupConfiguration';
|
|
4
|
+
export { ConfigurationBuilder } from './lib/core/configuration/ConfigurationBuilder';
|
|
5
|
+
export { Platform } from './lib/core/model/Platform';
|
|
6
|
+
export { LogLevel } from './lib/core/logging/LogLevel';
|
|
7
|
+
export { ApplicationHandler } from './lib/core/Application';
|
|
8
|
+
export { UserPrivacyOptions } from './lib/core/UserPrivacyOptions';
|
|
9
|
+
export { DynatraceWebRequestTiming } from './lib/core/DynatraceWebRequestTiming';
|
|
10
|
+
export { createElement } from './instrumentation/jsx/CreateElement';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u,n=require("@babel/runtime/helpers/interopRequireDefault"),r=n(require("@babel/runtime/helpers/toConsumableArray")),a=(Object.defineProperty(exports,"t",{value:!0}),exports.instrument=void 0,require("path")),c=require("jscodeshift"),i=require("jscodeshift/src/Collection"),e=require("../scripts/FileOperationHelper"),t=require("../scripts/PathsConstants"),o=require("./libs/react-native/Touchables.InstrInfo"),l=require("./libs/react-native/RefreshControl.InstrInfo"),f=require("./libs/react-native/Switch.InstrInfo"),s=require("./libs/community/gesture-handler/Touchables.InstrInfo"),d=require("./libs/community/Picker.InstrInfo"),v=require("./parser/Babel"),p=require("./model/Types"),m=(!function(n){n[n.i=-1]="Filtered",n[n.o=0]="Normal",n[n.u=1]="ReactNative",n[n.l=2]="React"}(u=u||{}),[]),y=(m.push.apply(m,(0,r.default)(o.instrumentationInfo)),m.push.apply(m,(0,r.default)(l.instrumentationInfo)),m.push.apply(m,(0,r.default)(f.instrumentationInfo)),m.push.apply(m,(0,r.default)(s.instrumentationInfo)),m.push.apply(m,(0,r.default)(d.instrumentationInfo)),["AppRegistry","renderApplication","setUpErrorHandling"]),g="@dynatrace/react-native-plugin/instrumentation/libs",instrument=function(n,r,e){r=w(r);var t=V(r);if(t!==u.i){var i=!1,o=N(r,n);if(t===u.l)T(o),i=!0;else if(t===u.u)r.endsWith("AppRegistry.js")?void 0!==e&&e.autoStart&&(U(o),i=!0):r.endsWith("renderApplication.js")?(q(o),i=!0):r.endsWith("setUpErrorHandling.js")&&void 0!==e&&e.autoStart&&e.errorHandler.enabled&&(J(o,e.autoStart,e.errorHandler.reportFatalErrorAsCrash),i=!0);else{var t=B(r,e);if(e.custom.reactnavigation&&b(r,o))i=!0;else{if(!t.input&&!t.lifecycle)return null!=e&&e.debug&&console.log("Dynatrace - Filtered All: ".concat(r)),E(r),n;t.lifecycle&&q(o)&&(i=!0),t.input&&m.forEach(function(n){n=K(o,n);o=n.root,i=i||n.v})}}i?(n=o.toSource({quote:"single"}),H(n,r)):E(r),null!=e&&e.debug&&i&&console.log("Dynatrace - Modified Filename: "+r)}else r.includes(a.join("@dynatrace","react-native-plugin"))&&r.endsWith(a.join("lib","core","configuration","ConfigurationPreset.js"))&&void 0!==e&&(t=N(r,n),void 0!==e.lifecycle&&h(t,"getLifecycleUpdate",e.lifecycle.includeUpdate),void 0!==e.debug&&h(t,"getLogLevel",e.debug?0:1),void 0!==e.bundleName&&h(t,"getBundleName",e.bundleName),void 0!==e.bundleVersion&&h(t,"getBundleVersion",e.bundleVersion),void 0!==e.input&&void 0!==e.input.actionNamePrivacy&&h(t,"getActionNamePrivacy",e.input.actionNamePrivacy),void 0!==e.errorHandler&&(h(t,"isErrorHandlerEnabled",e.errorHandler.enabled),h(t,"isReportFatalErrorAsCrash",e.errorHandler.reportFatalErrorAsCrash)),e.autoStart&&h(t,"isAutoStartupEnabled",e.autoStart),n=t.toSource({quote:"single"}),H(n,r));return n},b=(exports.instrument=instrument,function(n,r){return!!O(n,r)&&(n="import { registerListener } from '".concat(g,"/react-navigation/ReactNavigation';"),r.find(c.ImportDeclaration).at(0).insertBefore(n),!0)}),O=function(n,r){var e=!1;return n.includes("react-navigation")&&n.includes("NavigationContainer.tsx")&&r.find(c.VariableDeclarator).forEach(function(n){e||null==n.value||null==n.value.id||"refContainer"!==n.value.id.name||null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.type&&"VariableDeclaration"===n.parent.value.type&&(n.parent.insertAfter("registerListener(refContainer);"),e=!0)}),e},q=function(n){var r=n.findJSXElements(),t=!1;return 0<r.length&&(n.find(c.FunctionDeclaration).forEach(function(n){var r,e=(0,i.fromPaths)([n]);0<e.findJSXElements().length&&null!=n&&null!=n.value&&null!=n.value.id&&n.value.id.name&&(r=e.find(c.ClassDeclaration),e=e.find(c.ClassExpression),0===r.length)&&0===e.length&&(A(n,p.Types.FunctionalComponent,n.value.id.name),t=!0)}),n.find(c.ClassDeclaration).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n&&null!=n.value&&n.value.id&&n.value.id.name&&(A(n,p.Types.ClassComponent,n.value.id.name),t=!0)}),n.find(c.ArrowFunctionExpression).forEach(function(n){0<(0,i.fromPaths)([n]).findJSXElements().length&&null!=n.parent&&null!=n.parent.value&&null!=n.parent.value.id&&null!=n.parent.value.id.name&&(A(n,p.Types.FunctionalComponent,n.parent.value.id.name),t=!0)})),t},A=function(n,r,e){for(r=c.expressionStatement(c.assignmentExpression("=",c.memberExpression(c.identifier(e),c.identifier("_dtInfo")),P(r,e)));void 0!==n.parentPath&&"body"!==n.parentPath.name;)n=n.parentPath;void 0!==n.parentPath&&n.insertAfter(r)},P=function(n,r){return c.objectExpression([c.objectProperty(c.identifier("type"),c.numericLiteral(n)),c.objectProperty(c.identifier("name"),c.stringLiteral(r))])},h=function(n,r,e){var n=n.find(c.Identifier).filter(function(n){return n.node.name===r});1===n.length&&"ReturnStatement"===(n=n.paths()[0].parent.value.body.body[0]).type&&("boolean"==typeof e&&(n.argument=c.booleanLiteral(e)),"string"==typeof e&&(n.argument=c.stringLiteral(e)),"number"==typeof e)&&(n.argument=c.numericLiteral(e))},N=function(n,r){return c.withParser((0,v.babelParser)(a.extname(n)))(r)},w=function(n){return a.isAbsolute(n)?n.replace(t.default.getApplicationPath()+a.sep,""):n},E=function(n){try{var r=a.join(t.default.getBuildPath(),n+".dtx");e.default.checkIfFileExistsSync(r),e.default.deleteFileSync(r)}catch(n){}},H=function(n,r){r=a.join(t.default.getBuildPath(),r);try{e.default.checkIfFileExistsSync(a.dirname(r))}catch(n){e.default.createDirectorySync(a.dirname(r))}e.default.writeTextToFileSync(r+".dtx",n)},B=function(n,r){var e={input:!1,lifecycle:!1};return void 0!==r&&(void 0!==r.lifecycle&&void 0!==r.lifecycle.instrument&&r.lifecycle.instrument(n)&&(e.lifecycle=!0),void 0!==r.input)&&void 0!==r.input.instrument&&r.input.instrument(n)&&(e.input=!0),e},T=function(n){var r,n=n.find(c.Program);1===n.length&&(r=c.expressionStatement(c.callExpression(c.memberExpression(c.callExpression(c.identifier("require"),[c.stringLiteral("@dynatrace/react-native-plugin/instrumentation/jsx/ElementHelper")]),c.identifier("instrumentCreateElement")),[c.memberExpression(c.identifier("module"),c.identifier("exports"))])),n.paths()[0].node.body.push(r))},U=function(n){var r=M(n,"runApplication",!0);1===r.length&&(en(n,{p:"_DynatraceApplicationHandler",module:"@dynatrace/react-native-plugin",reference:"ApplicationHandler"}),I(r.paths()[0].parent.value.body.body,0,D("_DynatraceApplicationHandler","startup",[])))},J=function(n,r,e){n=n.paths()[0].value.program.body;null!=n&&(I(n,n.length,_({p:"_DynatraceErrorHandler",module:"@dynatrace/react-native-plugin/lib/core/ErrorHandler",reference:""})),I(n,n.length,D("_DynatraceErrorHandler","registerErrorHandler",[c.literal(e)])))},I=function(n,r){for(var e=arguments.length,t=new Array(2<e?e-2:0),i=2;i<e;i++)t[i-2]=arguments[i];return n.splice.apply(n,[r,0].concat(t))},M=function(n,r,t){for(var e=arguments.length,i=new Array(3<e?e-3:0),o=3;o<e;o++)i[o-3]=arguments[o];return n.find(c.Identifier).filter(function(n){return n.node.name===r}).filter(function(n){return void 0!==n.parent&&void 0!==n.parent.value&&void 0!==n.parent.value.params}).filter(function(n){var r=void 0!==n.parent&&void 0!==n.parent.value;t||(r=r&&n.parent.value.params.length===i.length);for(var e=0;e<0;e++)r=r&&n.parent.value.params[e].name===i[e];return r})},V=function(n){if(n.includes("@dynatrace"))return u.i;var r=a.extname(n);if(".js"!==r&&".ts"!==r&&".tsx"!==r&&".jsx"!==r)return u.i;for(var e=a.parse(n),t=e.dir.split(a.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 y.includes(e.name)?u.u:u.i;if("react"===t[i+1]&&"index"===e.name)return u.l}return u.o},k=function(n,r,e){var t=z(n,r,e);return G(n,r,e)||t},z=function(n,r,e){var t=Q(n,r);return 0<t.length&&(void 0!==(t=C(t,r.reference,!1))&&(e.p=t.localName),nn(n,e),!0)},G=function(n,r,e){var t=j(n,r.module);if(1===t.length){t=C(t,r.reference,!0);if(void 0!==t)return rn(n,e.defaultImport,t.localName,"ImportNamespaceSpecifier"===t.type),!0}return!1},K=function(n,r){var e=JSON.parse(JSON.stringify(r.new));return{root:n,v:k(n,r.old,e)||W(n,r.old,r.new.defaultImport)}},Q=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module&&null!=n.node.specifiers&&n.node.specifiers.some(function(n){return x(n)&&n.imported.name===r.reference||n.local&&n.local.name===r.reference})})},x=function(n){return void 0!==n.imported},W=function(n,r,e){var t=!1;return n.find(c.CallExpression).filter(function(n){return X(n.node.callee)&&Y(n.node.arguments[0])&&n.node.arguments[0].value===r.module&&void 0!==n.parent}).forEach(function(n){(void 0===n.parent.value.property||void 0!==n.parent.value.property&&void 0!==n.parent.value.property.name&&n.parent.value.property.name===r.reference)&&(n.node.arguments[0].value=e,t=t||!0)}),t},X=function(n){return"require"===n.name},Y=function(n){return"StringLiteral"===n.type||"Literal"===n.type},j=function(n,r){return n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r})},C=function(n,e,t){var i;return n.forEach(function(n){void 0!==n.node.specifiers&&(n.node.specifiers=n.node.specifiers.filter(function(n){var r;return x(n)&&!t?((r=n.imported.name!==e)||null==n.local||n.imported.name===n.local.name||(i={localName:n.local.name,type:n.type}),r):!(!x(n)&&t&&(null!=n.local&&(i={localName:n.local.name,type:n.type}),1))}),0===n.node.specifiers.length)&&n.prune()}),i},Z=function(n,r){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r.module}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(F(r))})},$=function(n,r,e){n.find(c.ImportDeclaration).filter(function(n){return n.node.source.value===r}).forEach(function(n){null!=n.node.specifiers&&n.node.specifiers.push(e)})},R=function(n,r,e){var t=n.find(c.ImportDeclaration);0<t.length?c(t.paths()[0]).insertAfter(S(r,e)):1===(t=n.find(c.Program)).length&&t.paths()[0].node.body.unshift(S(r,e))},nn=function(n,r){0<j(n,r.module).length?Z(n,r):R(n,r.module,[F(r)])},rn=function(n,r,e,t){var i=j(n,r),t=(t?ln:cn)(e);0<i.length?$(n,r,t):R(n,r,[t])},en=function(n,r){n=n.find(c.VariableDeclaration);0<n.length&&c(n.paths()[0]).insertAfter(_(r))},D=function(n,r,e){return c.expressionStatement(tn(n,r,e))},tn=function(n,r,e){return c.callExpression(an(n,r),e)},_=function(n){return c.variableDeclaration("var",[on(n)])},on=function(n){return c.variableDeclarator(void 0!==n.p?c.identifier(n.p):c.identifier(n.reference),(0<n.reference.length?un:L)(n))},un=function(n){return c.memberExpression(L(n),c.identifier(n.reference))},an=function(n,r){return c.memberExpression(c.identifier(n),c.identifier(r))},L=function(n){return c.callExpression(c.identifier("require"),[c.literal(n.module)])},S=function(n,r){return c.importDeclaration(r,c.literal(n))},F=function(n){return void 0!==n.p?c.importSpecifier(c.identifier(n.reference),c.identifier(n.p)):c.importSpecifier(c.identifier(n.reference))},cn=function(n){return c.importDefaultSpecifier(c.identifier(n))},ln=function(n){return c.importNamespaceSpecifier(c.identifier(n))};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const Types_1 = require("../model/Types");
|
|
4
|
+
const ElementHelper_1 = require("./ElementHelper");
|
|
5
|
+
const ClassComponent_1 = require("./components/ClassComponent");
|
|
6
|
+
const FunctionalComponent_1 = require("./components/FunctionalComponent");
|
|
6
7
|
const _createElement = require('react').createElement;
|
|
7
8
|
const createElement = (type, props, ...children) => {
|
|
8
9
|
if (type != null && type._dtInfo != null && !(0, ElementHelper_1.isDtActionIgnore)(props)) {
|
|
9
10
|
if (type._dtInfo.type === Types_1.Types.FunctionalComponent) {
|
|
10
|
-
return _createElement(
|
|
11
|
+
return _createElement(FunctionalComponent_1.DynatraceFunctionalComponent, {}, _createElement(type, props, ...children));
|
|
11
12
|
}
|
|
12
13
|
else if (type._dtInfo.type === Types_1.Types.ClassComponent &&
|
|
13
14
|
type.prototype !== undefined &&
|
|
14
15
|
type.prototype.isReactComponent !== undefined) {
|
|
15
|
-
return _createElement(
|
|
16
|
+
return _createElement(ClassComponent_1.DynatraceClassComponent, {}, _createElement(type, props, ...children));
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
19
|
(0, ElementHelper_1.modifyElement)(type, props, ...children);
|