@arms/rum-reactnative 0.1.3-beta.3 → 0.1.3-beta.4
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.
|
@@ -14,7 +14,7 @@ var _rumCore = require("@arms/rum-core");
|
|
|
14
14
|
var _reactNative = require("react-native");
|
|
15
15
|
var _NativeRumSdkReactnative = _interopRequireDefault(require("../NativeRumSdkReactnative"));
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
-
const _pkg = {"version":"0.1.3-beta.
|
|
17
|
+
const _pkg = {"version":"0.1.3-beta.4"};
|
|
18
18
|
const VERSION = exports.VERSION = _pkg.version;
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { AppType } from '@arms/rum-core';
|
|
4
4
|
import { Dimensions, Platform } from 'react-native';
|
|
5
5
|
import NativeRumSdkReactnative from "../NativeRumSdkReactnative.js";
|
|
6
|
-
const _pkg = {"version":"0.1.3-beta.
|
|
6
|
+
const _pkg = {"version":"0.1.3-beta.4"};
|
|
7
7
|
export const VERSION = _pkg.version;
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arms/rum-reactnative",
|
|
3
|
-
"version": "0.1.3-beta.
|
|
3
|
+
"version": "0.1.3-beta.4",
|
|
4
4
|
"description": "RUM SDK For ReactNative",
|
|
5
5
|
"homepage": "https://help.aliyun.com/zh/arms/user-experience-monitoring/",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"lib",
|
|
24
|
+
"src/NativeRumSdkReactnative.ts",
|
|
24
25
|
"android",
|
|
25
26
|
"ios",
|
|
26
27
|
"docs",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"typescript": "^5.8.3"
|
|
108
109
|
},
|
|
109
110
|
"peerDependencies": {
|
|
110
|
-
"@arms/rum-core": "
|
|
111
|
+
"@arms/rum-core": "0.1.7",
|
|
111
112
|
"react": "*",
|
|
112
113
|
"react-native": ">=0.68.0"
|
|
113
114
|
},
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { NativeModules, TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 原生设备信息,对应存储模型中的公共属性:
|
|
6
|
+
* - device.* (id / type / brand / model / name)
|
|
7
|
+
* - os.* (type / version / container / container_version)
|
|
8
|
+
* - app.package
|
|
9
|
+
* - viewport.width / viewport.height
|
|
10
|
+
*/
|
|
11
|
+
export interface NativeDeviceInfo {
|
|
12
|
+
device_id?: string;
|
|
13
|
+
device_type?: string;
|
|
14
|
+
device_brand?: string;
|
|
15
|
+
device_model?: string;
|
|
16
|
+
device_name?: string;
|
|
17
|
+
os_type?: string;
|
|
18
|
+
os_version?: string;
|
|
19
|
+
app_package?: string;
|
|
20
|
+
app_version?: string;
|
|
21
|
+
viewport_width?: number;
|
|
22
|
+
viewport_height?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Spec extends TurboModule {
|
|
26
|
+
getItem(key: string): Promise<string | null>;
|
|
27
|
+
setItem(key: string, value: string): Promise<void>;
|
|
28
|
+
removeItem(key: string): Promise<void>;
|
|
29
|
+
clear(): Promise<void>;
|
|
30
|
+
getAllKeys(): Promise<string[]>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 采集原生平台设备信息,仅在初始化时调用一次。
|
|
34
|
+
*/
|
|
35
|
+
getDeviceInfo(): Promise<NativeDeviceInfo>;
|
|
36
|
+
|
|
37
|
+
// === 崩溃采集相关 ===
|
|
38
|
+
|
|
39
|
+
/** 获取待上报的崩溃报告列表(下次启动时调用) */
|
|
40
|
+
getPendingCrashes(): Promise<string>;
|
|
41
|
+
|
|
42
|
+
/** 清除已上报的崩溃文件 */
|
|
43
|
+
clearCrashReports(crashIds: string): Promise<void>;
|
|
44
|
+
|
|
45
|
+
/** 清除所有崩溃报告文件(用于清理无 crash_id 的旧版文件) */
|
|
46
|
+
clearAllCrashReports(): Promise<void>;
|
|
47
|
+
|
|
48
|
+
/** 清理过期和超限的崩溃文件(maxFiles 上限,maxAgeMs 过期时间) */
|
|
49
|
+
cleanupOldCrashes(maxFiles: number, maxAgeMs: number): Promise<void>;
|
|
50
|
+
|
|
51
|
+
/** 查询上次运行是否发生过崩溃 */
|
|
52
|
+
crashedLastRun(): Promise<boolean>;
|
|
53
|
+
|
|
54
|
+
/** 更新崩溃上下文快照(session/view 变更时调用) */
|
|
55
|
+
updateCrashContext(context: string): void;
|
|
56
|
+
|
|
57
|
+
/** 触发测试崩溃(仅用于开发调试,调用后 App 立即崩溃) */
|
|
58
|
+
triggerTestCrash(crashType: string): void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 获取原生模块。
|
|
63
|
+
*
|
|
64
|
+
* 优先使用 TurboModuleRegistry(RN 0.68+ TurboModule 架构),
|
|
65
|
+
* 若未找到则降级到 Legacy Bridge 的 NativeModules(RN 0.68-0.70 未开启 New Arch 时),
|
|
66
|
+
* 若均不可用则返回一组空实现兜底。
|
|
67
|
+
*
|
|
68
|
+
* 使用非强制的 `TurboModuleRegistry.get`(而非 `getEnforcing`),避免在原生
|
|
69
|
+
* 二进制未注册该模块时于「模块加载阶段」直接抛异常——那会连锁导致整个 JS
|
|
70
|
+
* bundle 评估失败(表现为所有路由丢失 default export、App 白屏)。
|
|
71
|
+
*
|
|
72
|
+
* 当原生模块缺失时(通常是新增原生代码后未重新编译原生 App,只重跑了 Metro),
|
|
73
|
+
* 返回一组空实现兜底:崩溃采集与原生设备信息降级为不可用,但 PV / 行为 / API /
|
|
74
|
+
* JS 异常等纯 JS 能力不受影响。需重新构建原生工程(如 `expo run:ios` /
|
|
75
|
+
* `pod install` + 重新编译)后崩溃采集才会真正生效。
|
|
76
|
+
*/
|
|
77
|
+
const nativeModule =
|
|
78
|
+
TurboModuleRegistry.get<Spec>('RumSdkReactnative') ??
|
|
79
|
+
(NativeModules.RumSdkReactnative as Spec | undefined);
|
|
80
|
+
|
|
81
|
+
if (!nativeModule) {
|
|
82
|
+
console.warn(
|
|
83
|
+
"[rum] Native module 'RumSdkReactnative' not found in the native binary. " +
|
|
84
|
+
'Crash reporting and native device info are disabled. ' +
|
|
85
|
+
'Rebuild the native app (e.g. `expo run:ios` / `expo run:android`, ' +
|
|
86
|
+
'or `pod install` + rebuild) so the module gets registered.'
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** 原生模块缺失时的空实现,保证调用方不会因缺方法而抛错。 */
|
|
91
|
+
const fallback: Spec = {
|
|
92
|
+
getItem: async () => null,
|
|
93
|
+
setItem: async () => {},
|
|
94
|
+
removeItem: async () => {},
|
|
95
|
+
clear: async () => {},
|
|
96
|
+
getAllKeys: async () => [],
|
|
97
|
+
getDeviceInfo: async () => ({}),
|
|
98
|
+
getPendingCrashes: async () => '[]',
|
|
99
|
+
clearCrashReports: async () => {},
|
|
100
|
+
clearAllCrashReports: async () => {},
|
|
101
|
+
cleanupOldCrashes: async () => {},
|
|
102
|
+
crashedLastRun: async () => false,
|
|
103
|
+
updateCrashContext: () => {},
|
|
104
|
+
triggerTestCrash: () => {},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default nativeModule ?? fallback;
|