问题描述
当我使用appdynamics对我的React本机应用程序进行检测时,react本机应用程序会收到运行时错误
'null不是对象(评估 'InstrumentationConstants_1.InstrumentationConstants.BREADCRUMB_VISIBILITY_CRASHES_ONLY')'
在我进行集成时,它仍然可以很好地进行集成,但是一旦我检测到该应用程序便停止运行。 整合后我用过
Instrumentation.start({
appKey: "AD-AAB-AAY-BHY",collectorURL: "https://col.eum-appdynamics.com",});
和
import { Instrumentation } from "@appdynamics/react-native-agent";
在文件顶部。
还完成了android手动链接的所有步骤。
我这里缺少什么吗?
解决方法
我意识到已经有一段时间了,但是无论如何我都会做出贡献,因为它也可能会帮助其他人。
就我而言,在iOS中导入Instrumentation会导致此错误;在最新版本的@ appdynamics / react-native-agent(撰写本文时为20.7.0版)中,这似乎是一个问题。
我改用本机代码(在AppDelegate.m文件中)初始化AppDynamics,如下所示:
#import <ADEUMInstrumentation/ADEumInstrumentation.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
ADEumAgentConfiguration *adeumAgentConfig = [[ADEumAgentConfiguration alloc] initWithAppKey:@"YOUR IOS KEY"];
// AppDynamics swizzles some methods for making requests and may mess up other libraries; disable automatic instrumentation if it causes problems to you.
adeumAgentConfig.enableAutoInstrument = NO;
// Initialize AppDynamics
[ADEumInstrumentation initWithConfiguration:adeumAgentConfig];
// Leaving screnshots enabled may cause lag during touches; block screenshots if you experience that.
[ADEumInstrumentation blockScreenshots];
...
return YES;
}
有关更多信息,请查看iOS指南: https://docs.appdynamics.com/display/PRO45/Instrument+an+iOS+Application
此外,我避免通过在运行时(仅在Android中)要求在JavaScript中导入AppDynamics。
if (Platform.OS === 'android') {
const { Instrumentation } = require('@appdynamics/react-native-agent');
const appKey = 'YOUR ANDROID KEY';
console.log(`Starting AppDynamics with key ${appKey}.`);
Instrumentation.start({
appKey,});
}