reactjs - null 不是对象(评估'InstrumentationConstants_1.InstrumentationConstants.BREADCRUMB_VISIBILITY_CRASHES_ONLY')
问题描述
当我使用 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
此外,我避免在 javascript 中导入 AppDynamics,方法是在运行时要求它,仅在 Android 中。
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,
});
}
推荐阅读
- c# - 接口和集合中的协方差
- vim - 你如何重新映射 :w 到 :w! 和 :q 到 :q! 在我的 vimrc 中?
- swiftui - 使用 Timer 时,SwiftUI 中 ObservedObject 的奇怪行为
- .net - 以编程方式生成 SAS 令牌 c#
- mailgun - 在 Mailgun 上,日志显示错误:4.7.1 Received too many messages from a new or untrusted IP
- c++ - C++ 双向链表:使用矩阵类成员创建和填充列表
- pytorch - pytorch 没有 tensorflow/tensorflow:latest-gpu-jupyter 的等价物吗?
- c++ - 找到最小值
- go - 为什么 `utf8.Valid()` 认为某些有效的 UTF-8 代码无效?
- flutter - 何时在 Flutter 中使用资产