@arms/rum-reactnative 0.1.3-beta.5 → 0.1.4-beta.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 +6 -0
- package/android/src/main/java/com/rumsdkreactnative/RumSdkReactnativeModule.kt +31 -0
- package/docs/ReactNative SDK/351/205/215/347/275/256/345/217/202/350/200/203.md" +25 -0
- package/docs/SDK /347/211/210/346/234/254/350/257/264/346/230/216.md" +14 -0
- package/ios/RumAppStateRecorder.h +69 -0
- package/ios/RumAppStateRecorder.mm +547 -0
- package/ios/RumCrashReporter.h +32 -0
- package/ios/RumCrashReporter.mm +97 -11
- package/ios/RumSdkReactnative.mm +81 -1
- package/lib/commonjs/NativeRumSdkReactnative.js +1 -54
- package/lib/commonjs/collector/action/index.js +1 -108
- package/lib/commonjs/collector/exception/crash.js +1 -148
- package/lib/commonjs/collector/exception/index.js +1 -238
- package/lib/commonjs/collector/exception/oom.js +1 -0
- package/lib/commonjs/collector/index.js +1 -42
- package/lib/commonjs/collector/resource/api.js +1 -292
- package/lib/commonjs/collector/view/perf.js +1 -79
- package/lib/commonjs/collector/view/pv.js +1 -88
- package/lib/commonjs/expoConfigPlugin.js +1 -37
- package/lib/commonjs/index.js +1 -29
- package/lib/commonjs/plugin.js +1 -47
- package/lib/commonjs/processor/default-processor.js +1 -27
- package/lib/commonjs/processor/session-processor.js +1 -47
- package/lib/commonjs/reporter/index.js +1 -148
- package/lib/commonjs/reporter/monitor-reporter.js +1 -43
- package/lib/commonjs/shell.js +1 -91
- package/lib/commonjs/types/client.js +1 -6
- package/lib/commonjs/types/crash.js +1 -37
- package/lib/commonjs/types/index.js +1 -2
- package/lib/commonjs/types/oom.js +1 -0
- package/lib/commonjs/utils/action.js +1 -305
- package/lib/commonjs/utils/api.js +1 -84
- package/lib/commonjs/utils/base.js +1 -95
- package/lib/commonjs/utils/crash.js +1 -149
- package/lib/commonjs/utils/platform.js +1 -162
- package/lib/commonjs/utils/session.js +1 -158
- package/lib/commonjs/utils/url.js +1 -59
- package/lib/commonjs/utils/view.js +1 -93
- package/lib/module/NativeRumSdkReactnative.js +1 -51
- package/lib/module/collector/action/index.js +1 -103
- package/lib/module/collector/exception/crash.js +1 -143
- package/lib/module/collector/exception/index.js +1 -233
- package/lib/module/collector/exception/oom.js +1 -0
- package/lib/module/collector/index.js +1 -8
- package/lib/module/collector/resource/api.js +1 -287
- package/lib/module/collector/view/perf.js +1 -79
- package/lib/module/collector/view/pv.js +1 -83
- package/lib/module/expoConfigPlugin.js +1 -33
- package/lib/module/index.js +1 -7
- package/lib/module/plugin.js +1 -42
- package/lib/module/processor/default-processor.js +1 -22
- package/lib/module/processor/session-processor.js +1 -42
- package/lib/module/reporter/index.js +1 -144
- package/lib/module/reporter/monitor-reporter.js +1 -38
- package/lib/module/shell.js +1 -84
- package/lib/module/types/client.js +1 -4
- package/lib/module/types/crash.js +1 -33
- package/lib/module/types/index.js +1 -2
- package/lib/module/types/oom.js +1 -0
- package/lib/module/utils/action.js +1 -299
- package/lib/module/utils/api.js +1 -76
- package/lib/module/utils/base.js +1 -90
- package/lib/module/utils/crash.js +1 -144
- package/lib/module/utils/platform.js +1 -150
- package/lib/module/utils/session.js +1 -154
- package/lib/module/utils/url.js +1 -54
- package/lib/module/utils/view.js +1 -88
- package/lib/typescript/commonjs/src/NativeRumSdkReactnative.d.ts +10 -0
- package/lib/typescript/commonjs/src/collector/exception/oom.d.ts +34 -0
- package/lib/typescript/commonjs/src/collector/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/shell.d.ts +1 -1
- package/lib/typescript/commonjs/src/types/client.d.ts +27 -0
- package/lib/typescript/commonjs/src/types/oom.d.ts +58 -0
- package/lib/typescript/commonjs/src/utils/crash.d.ts +13 -0
- package/lib/typescript/module/src/NativeRumSdkReactnative.d.ts +10 -0
- package/lib/typescript/module/src/collector/exception/oom.d.ts +34 -0
- package/lib/typescript/module/src/collector/index.d.ts +1 -0
- package/lib/typescript/module/src/shell.d.ts +1 -1
- package/lib/typescript/module/src/types/client.d.ts +27 -0
- package/lib/typescript/module/src/types/oom.d.ts +58 -0
- package/lib/typescript/module/src/utils/crash.d.ts +13 -0
- package/package.json +1 -2
- package/src/NativeRumSdkReactnative.ts +18 -0
package/lib/module/utils/view.js
CHANGED
|
@@ -1,88 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { isFunction
|
|
4
|
-
// IRumSession,
|
|
5
|
-
// IViewData
|
|
6
|
-
} from '@arms/rum-core';
|
|
7
|
-
// import { IPage } from "../types/client";
|
|
8
|
-
|
|
9
|
-
// export const PAGE_ID = '__rum_view_id';
|
|
10
|
-
//
|
|
11
|
-
// /**
|
|
12
|
-
// * 获取 RUM 内置的view_id标识
|
|
13
|
-
// * @param page
|
|
14
|
-
// * @param session
|
|
15
|
-
// * @returns
|
|
16
|
-
// */
|
|
17
|
-
// export async function getRumViewId(page: IPage, session?: IRumSession): Promise<string> {
|
|
18
|
-
// if (!page) return;
|
|
19
|
-
// if (page.id) {
|
|
20
|
-
// return page.id;
|
|
21
|
-
// }
|
|
22
|
-
// if (!session) return;
|
|
23
|
-
// return page.id = session.getViewId();
|
|
24
|
-
// }
|
|
25
|
-
//
|
|
26
|
-
// /**
|
|
27
|
-
// * 获取当前 view
|
|
28
|
-
// * @param viewId
|
|
29
|
-
// * @param ctx
|
|
30
|
-
// * @returns
|
|
31
|
-
// */
|
|
32
|
-
// export function getViewById(viewId: string, ctx: IContext): IViewData {
|
|
33
|
-
// if (!viewId || !ctx) return;
|
|
34
|
-
// return ctx.getViews().find(view => view.id === viewId);
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 获取当前 view
|
|
39
|
-
* @param ctx
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
export function getCurView(ctx) {
|
|
43
|
-
if (!ctx) return;
|
|
44
|
-
const views = ctx.getViews();
|
|
45
|
-
if (views && views.length) {
|
|
46
|
-
return views[views.length - 1];
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
let currentNavigationRef;
|
|
51
|
-
const navigateListeners = [];
|
|
52
|
-
export function addNavigateListener(listener) {
|
|
53
|
-
if (isFunction(listener)) {
|
|
54
|
-
navigateListeners.push(listener);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export function removeNavigateListener(listener) {
|
|
58
|
-
navigateListeners.splice(navigateListeners.indexOf(listener), 1);
|
|
59
|
-
}
|
|
60
|
-
function triggerNavigateChange(event) {
|
|
61
|
-
if (!currentNavigationRef) return;
|
|
62
|
-
let route = event;
|
|
63
|
-
if (isFunction(currentNavigationRef.getCurrentRoute)) {
|
|
64
|
-
route = currentNavigationRef.getCurrentRoute();
|
|
65
|
-
}
|
|
66
|
-
if (!route) return;
|
|
67
|
-
navigateListeners.forEach(listener => {
|
|
68
|
-
listener(route);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
export function startTrackingViews(nav) {
|
|
72
|
-
if (!nav || currentNavigationRef) return;
|
|
73
|
-
currentNavigationRef = nav;
|
|
74
|
-
if (isFunction(nav.events)) {
|
|
75
|
-
// react-native-navigation
|
|
76
|
-
nav.events().registerComponentDidAppearListener(triggerNavigateChange);
|
|
77
|
-
} else {
|
|
78
|
-
// @react-native/navigation
|
|
79
|
-
nav.addListener('state', triggerNavigateChange);
|
|
80
|
-
}
|
|
81
|
-
triggerNavigateChange({});
|
|
82
|
-
}
|
|
83
|
-
export function stopTrackingViews() {
|
|
84
|
-
if (!currentNavigationRef) return;
|
|
85
|
-
currentNavigationRef.removeListener('state', triggerNavigateChange);
|
|
86
|
-
currentNavigationRef = undefined;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=view.js.map
|
|
1
|
+
"use strict";import{isFunction}from"@arms/rum-core";export function getCurView(e){if(!e)return;const t=e.getViews();return t&&t.length?t[t.length-1]:null}let currentNavigationRef;const navigateListeners=[];export function addNavigateListener(e){isFunction(e)&&navigateListeners.push(e)}export function removeNavigateListener(e){navigateListeners.splice(navigateListeners.indexOf(e),1)}function triggerNavigateChange(e){if(!currentNavigationRef)return;let t=e;isFunction(currentNavigationRef.getCurrentRoute)&&(t=currentNavigationRef.getCurrentRoute()),t&&navigateListeners.forEach(e=>{e(t)})}export function startTrackingViews(e){e&&!currentNavigationRef&&(currentNavigationRef=e,isFunction(e.events)?e.events().registerComponentDidAppearListener(triggerNavigateChange):e.addListener("state",triggerNavigateChange),triggerNavigateChange({}))}export function stopTrackingViews(){currentNavigationRef&&(currentNavigationRef.removeListener("state",triggerNavigateChange),currentNavigationRef=void 0)}
|
|
@@ -43,6 +43,16 @@ export interface Spec extends TurboModule {
|
|
|
43
43
|
updateCrashContext(context: string): void;
|
|
44
44
|
/** 触发测试崩溃(仅用于开发调试,调用后 App 立即崩溃) */
|
|
45
45
|
triggerTestCrash(crashType: string): void;
|
|
46
|
+
/** 获取待上报的 OOM 报告列表(下次启动时调用),JSON 字符串 */
|
|
47
|
+
getPendingOomReports(): Promise<string>;
|
|
48
|
+
/** 清除已上报的 OOM 报告文件 */
|
|
49
|
+
clearOomReports(oomIds: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* 同步 JS 侧采集器配置到原生(SDK init 时调用),config 为 JSON 字符串。
|
|
52
|
+
* 当前支持的键:`oom`(boolean,是否开启 OOM 采集,false/缺省不启用)。
|
|
53
|
+
* 原生侧据此安装状态记录器并执行上次启动的看门狗终止判定。
|
|
54
|
+
*/
|
|
55
|
+
updateCollectorsConfig(config: string): void;
|
|
46
56
|
}
|
|
47
57
|
declare const _default: Spec;
|
|
48
58
|
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ICollector, IContext, SendEventFn } from '@arms/rum-core';
|
|
2
|
+
/**
|
|
3
|
+
* OOM(iOS 看门狗终止推断)采集器(Exception 的子类型):
|
|
4
|
+
* 1. 初始化时将 oom 开关同步到原生(原生侧据此安装状态记录器并执行
|
|
5
|
+
* 上次启动的看门狗终止判定);
|
|
6
|
+
* 2. 读取上次运行写入的原生 OOM 事件文件,转换为 RumEvent(type='crash' +
|
|
7
|
+
* subtype='oom')通过标准管线上报(每次启动最多 1 条,直接 immediate);
|
|
8
|
+
* 3. 复用崩溃 Ack 管线:上报成功后回 ack 删除对应文件,失败保留重试。
|
|
9
|
+
*
|
|
10
|
+
* 与 CrashCollector 的关系(D7,采集器配置相互独立、不级联):
|
|
11
|
+
* - 本采集器不检查 collectors.crash,crash 关闭时 OOM 仍独立工作;
|
|
12
|
+
* - 双报防护由原生判定层互斥承担(存在待处理崩溃证据则不产生 OOM 文件);
|
|
13
|
+
* - context 同步与 CrashCollector 各自订阅同一事件,原生侧幂等写入无副作用
|
|
14
|
+
* (crash 单独关闭而 OOM 开启时 context 同步仍可用)。
|
|
15
|
+
*/
|
|
16
|
+
export default class OomCollector implements ICollector {
|
|
17
|
+
name: string;
|
|
18
|
+
private ctx?;
|
|
19
|
+
private sendEvent?;
|
|
20
|
+
private initialized;
|
|
21
|
+
/** 已上报待确认(ack)的 oom_id,成功后才删文件 */
|
|
22
|
+
private pendingAckIds;
|
|
23
|
+
setup(ctx: IContext, sendEvent: SendEventFn): void;
|
|
24
|
+
private processPendingOomReports;
|
|
25
|
+
private onCrashContextChange;
|
|
26
|
+
/**
|
|
27
|
+
* reporter 上报确认回调(复用崩溃 Ack 事件,按 oom_id 归属):
|
|
28
|
+
* - 成功:删除对应 oom_id 的 OOM 文件(确保上报成功后才删,不丢数据);
|
|
29
|
+
* - 失败:保留文件,下次启动重试,仅从内存待确认集合中移除。
|
|
30
|
+
*/
|
|
31
|
+
private onCrashReportAck;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=oom.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as PvCollector } from './view/pv';
|
|
2
2
|
export { default as ExceptionCollector } from './exception/index';
|
|
3
3
|
export { default as CrashCollector } from './exception/crash';
|
|
4
|
+
export { default as OomCollector } from './exception/oom';
|
|
4
5
|
export { default as ApiCollector } from './resource/api';
|
|
5
6
|
export { default as ActionCollector } from './action/index';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { Shell } from '@arms/rum-core';
|
|
|
2
2
|
import * as collectors from './collector';
|
|
3
3
|
import { IRNConfig } from './types/client';
|
|
4
4
|
import { NavigationContainerRef } from './types';
|
|
5
|
-
declare const builtInCollectors: readonly (typeof collectors.PvCollector | typeof collectors.ExceptionCollector | typeof collectors.CrashCollector | typeof collectors.ApiCollector | typeof collectors.ActionCollector)[];
|
|
5
|
+
declare const builtInCollectors: readonly (typeof collectors.PvCollector | typeof collectors.ExceptionCollector | typeof collectors.CrashCollector | typeof collectors.OomCollector | typeof collectors.ApiCollector | typeof collectors.ActionCollector)[];
|
|
6
6
|
type CollectorName = (typeof builtInCollectors)[number]['prototype']['name'];
|
|
7
7
|
type CollectorMap = {
|
|
8
8
|
[K in CollectorName]: InstanceType<Extract<(typeof builtInCollectors)[number], {
|
|
@@ -23,5 +23,32 @@ export interface IRNConfig extends IConfiguration {
|
|
|
23
23
|
* request 自定义解析;
|
|
24
24
|
*/
|
|
25
25
|
evaluateApi?(request: any, response: any, error?: Error, xhr?: XMLHttpRequest): Promise<IApiBaseAttr>;
|
|
26
|
+
/**
|
|
27
|
+
* 采集器配置。
|
|
28
|
+
*
|
|
29
|
+
* 以交叉类型扩展父类型的 index signature,补充各采集器开关的 JSDoc
|
|
30
|
+
* 默认值说明(对齐 rum-electron 配置类型风格,与配置参考文档双保险
|
|
31
|
+
* 防默认值漂移)。
|
|
32
|
+
*/
|
|
33
|
+
collectors?: IConfiguration['collectors'] & {
|
|
34
|
+
/**
|
|
35
|
+
* OOM(iOS 看门狗终止推断)采集开关。
|
|
36
|
+
*
|
|
37
|
+
* 默认 false,需显式开启(`oom: true`),缺省或 false 均不启用;
|
|
38
|
+
* 开关方向与 crash 采集器相反(crash 默认开启,`crash === false` 才关闭)。
|
|
39
|
+
*
|
|
40
|
+
* 能力范围:仅 iOS 前台看门狗终止的事后推断(无堆栈,timestamp 为
|
|
41
|
+
* 估算值,`snapshots.estimated: true` 标记推断性质);Android 无此
|
|
42
|
+
* 能力(Java OutOfMemoryError 已由崩溃链路捕获)。
|
|
43
|
+
*
|
|
44
|
+
* 建议与 `crash` 同时开启;crash 关闭时 KSCrash 崩溃报告只写不删,
|
|
45
|
+
* 残留报告会使 OOM 判定倾向被抑制(漏判方向保守),而非误报增多。
|
|
46
|
+
*
|
|
47
|
+
* 未来若出现子开关需求(内存警告、前后台区分等),本字段计划演进为
|
|
48
|
+
* `boolean | object` 双形态(参照 rum-electron checkEnable 四态归一),
|
|
49
|
+
* 本期维持单一 boolean。
|
|
50
|
+
*/
|
|
51
|
+
oom?: boolean;
|
|
52
|
+
};
|
|
26
53
|
}
|
|
27
54
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOM(iOS 看门狗终止推断)相关类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 对应 iOS 原生侧落盘的 oom_{timestamp}_{uuid}.json 事件文件结构
|
|
5
|
+
* (getPendingOomReports 返回数组的元素),见
|
|
6
|
+
* dev-docs/OOM采集调研与实施方案.md 4.2.3 节。
|
|
7
|
+
*/
|
|
8
|
+
/** OOM 事件的上次会话上下文(原生从 context.json 恢复) */
|
|
9
|
+
export interface OomContext {
|
|
10
|
+
session_id?: string;
|
|
11
|
+
view_id?: string;
|
|
12
|
+
view_name?: string;
|
|
13
|
+
user_id?: string;
|
|
14
|
+
}
|
|
15
|
+
/** 上次会话的 App 状态快照(原生 RumAppStateRecorder 状态变更时写入) */
|
|
16
|
+
export interface OomAppState {
|
|
17
|
+
appVersion?: string;
|
|
18
|
+
osVersion?: string;
|
|
19
|
+
/** 系统启动时刻(ISO8601),用于排除设备重启 */
|
|
20
|
+
systemBootTime?: string;
|
|
21
|
+
vendorId?: string;
|
|
22
|
+
/** 上次进程是否前台激活(仅前台被杀才判定,D5) */
|
|
23
|
+
isActive?: boolean;
|
|
24
|
+
/** 是否收到正常终止回调(用户强杀排除) */
|
|
25
|
+
wasTerminated?: boolean;
|
|
26
|
+
/** 上次是否处于调试态(调试期被杀排除) */
|
|
27
|
+
isDebugging?: boolean;
|
|
28
|
+
/** 状态快照写入时刻(ms),供 context 新鲜度评估 */
|
|
29
|
+
updatedAt?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 原生 OOM 数据结构(与 iOS 原生侧落盘的 JSON 对齐)。
|
|
33
|
+
* 仅声明 JS 层会用到的字段。
|
|
34
|
+
*/
|
|
35
|
+
export interface NativeOomData {
|
|
36
|
+
/**
|
|
37
|
+
* OOM 事件唯一标识(UUID),承担与 crash_id 等价的 Ack 标识角色。
|
|
38
|
+
* 防御性声明为可选:缺失时事件仍可上报,仅无法走 ack 删文件链路。
|
|
39
|
+
*/
|
|
40
|
+
oom_id?: string;
|
|
41
|
+
/** 估算的案发时刻(ms,取上次会话最后写入的持久化文件 mtime) */
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
platform?: string;
|
|
44
|
+
subtype?: string;
|
|
45
|
+
/** 事件名,PascalCase(如 WatchdogTermination) */
|
|
46
|
+
name?: string;
|
|
47
|
+
/** 英文证据式表述(D8),推断性质由 snapshots.estimated 承载 */
|
|
48
|
+
message?: string;
|
|
49
|
+
/** 崩溃机制信息(如 { type: 'watchdog_termination', handled: false }) */
|
|
50
|
+
mechanism?: Record<string, unknown>;
|
|
51
|
+
/** 上次会话的 App 状态快照 */
|
|
52
|
+
app_state?: OomAppState;
|
|
53
|
+
/** 上次会话上下文(session/view/user 关联依据) */
|
|
54
|
+
context?: OomContext;
|
|
55
|
+
app?: Record<string, unknown>;
|
|
56
|
+
device?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=oom.d.ts.map
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { type RumEvent } from '@arms/rum-core';
|
|
2
2
|
import type { NativeCrashData } from '../types/crash';
|
|
3
|
+
import type { NativeOomData } from '../types/oom';
|
|
3
4
|
/**
|
|
4
5
|
* 将原生崩溃数据转换为 RumEvent 异常事件,对齐存储模型 Exception 表的
|
|
5
6
|
* Attributes(session/view/exception 基础信息)+ Metadata(堆栈、快照等)字段。
|
|
6
7
|
*/
|
|
7
8
|
export declare function convertCrashToRumEvent(crashData: NativeCrashData): RumEvent;
|
|
9
|
+
/**
|
|
10
|
+
* 将原生 OOM(看门狗终止推断)数据转换为 RumEvent 异常事件,
|
|
11
|
+
* 对齐存储模型 Exception 表。
|
|
12
|
+
*
|
|
13
|
+
* 与崩溃事件的差异:
|
|
14
|
+
* - type='crash' + subtype='oom' 复用现有 exception 链路,不新增 type 枚举(D4);
|
|
15
|
+
* - 无堆栈(watchdog 终止无信号可捕获,无现场数据);
|
|
16
|
+
* - timestamp 为估算值(snapshots.estimated: true 结构化标记推断性质,D8);
|
|
17
|
+
* - session/view 取自上次会话的持久化 context,由 rum-core dispatchEvents
|
|
18
|
+
* 按 session_id 分组上报,不会因旧 session 被丢弃。
|
|
19
|
+
*/
|
|
20
|
+
export declare function convertOomToRumEvent(oomData: NativeOomData): RumEvent;
|
|
8
21
|
/**
|
|
9
22
|
* 安全调用原生桥方法,异常时静默降级。
|
|
10
23
|
*/
|
|
@@ -43,6 +43,16 @@ export interface Spec extends TurboModule {
|
|
|
43
43
|
updateCrashContext(context: string): void;
|
|
44
44
|
/** 触发测试崩溃(仅用于开发调试,调用后 App 立即崩溃) */
|
|
45
45
|
triggerTestCrash(crashType: string): void;
|
|
46
|
+
/** 获取待上报的 OOM 报告列表(下次启动时调用),JSON 字符串 */
|
|
47
|
+
getPendingOomReports(): Promise<string>;
|
|
48
|
+
/** 清除已上报的 OOM 报告文件 */
|
|
49
|
+
clearOomReports(oomIds: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* 同步 JS 侧采集器配置到原生(SDK init 时调用),config 为 JSON 字符串。
|
|
52
|
+
* 当前支持的键:`oom`(boolean,是否开启 OOM 采集,false/缺省不启用)。
|
|
53
|
+
* 原生侧据此安装状态记录器并执行上次启动的看门狗终止判定。
|
|
54
|
+
*/
|
|
55
|
+
updateCollectorsConfig(config: string): void;
|
|
46
56
|
}
|
|
47
57
|
declare const _default: Spec;
|
|
48
58
|
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ICollector, IContext, SendEventFn } from '@arms/rum-core';
|
|
2
|
+
/**
|
|
3
|
+
* OOM(iOS 看门狗终止推断)采集器(Exception 的子类型):
|
|
4
|
+
* 1. 初始化时将 oom 开关同步到原生(原生侧据此安装状态记录器并执行
|
|
5
|
+
* 上次启动的看门狗终止判定);
|
|
6
|
+
* 2. 读取上次运行写入的原生 OOM 事件文件,转换为 RumEvent(type='crash' +
|
|
7
|
+
* subtype='oom')通过标准管线上报(每次启动最多 1 条,直接 immediate);
|
|
8
|
+
* 3. 复用崩溃 Ack 管线:上报成功后回 ack 删除对应文件,失败保留重试。
|
|
9
|
+
*
|
|
10
|
+
* 与 CrashCollector 的关系(D7,采集器配置相互独立、不级联):
|
|
11
|
+
* - 本采集器不检查 collectors.crash,crash 关闭时 OOM 仍独立工作;
|
|
12
|
+
* - 双报防护由原生判定层互斥承担(存在待处理崩溃证据则不产生 OOM 文件);
|
|
13
|
+
* - context 同步与 CrashCollector 各自订阅同一事件,原生侧幂等写入无副作用
|
|
14
|
+
* (crash 单独关闭而 OOM 开启时 context 同步仍可用)。
|
|
15
|
+
*/
|
|
16
|
+
export default class OomCollector implements ICollector {
|
|
17
|
+
name: string;
|
|
18
|
+
private ctx?;
|
|
19
|
+
private sendEvent?;
|
|
20
|
+
private initialized;
|
|
21
|
+
/** 已上报待确认(ack)的 oom_id,成功后才删文件 */
|
|
22
|
+
private pendingAckIds;
|
|
23
|
+
setup(ctx: IContext, sendEvent: SendEventFn): void;
|
|
24
|
+
private processPendingOomReports;
|
|
25
|
+
private onCrashContextChange;
|
|
26
|
+
/**
|
|
27
|
+
* reporter 上报确认回调(复用崩溃 Ack 事件,按 oom_id 归属):
|
|
28
|
+
* - 成功:删除对应 oom_id 的 OOM 文件(确保上报成功后才删,不丢数据);
|
|
29
|
+
* - 失败:保留文件,下次启动重试,仅从内存待确认集合中移除。
|
|
30
|
+
*/
|
|
31
|
+
private onCrashReportAck;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=oom.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as PvCollector } from './view/pv';
|
|
2
2
|
export { default as ExceptionCollector } from './exception/index';
|
|
3
3
|
export { default as CrashCollector } from './exception/crash';
|
|
4
|
+
export { default as OomCollector } from './exception/oom';
|
|
4
5
|
export { default as ApiCollector } from './resource/api';
|
|
5
6
|
export { default as ActionCollector } from './action/index';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { Shell } from '@arms/rum-core';
|
|
|
2
2
|
import * as collectors from './collector';
|
|
3
3
|
import { IRNConfig } from './types/client';
|
|
4
4
|
import { NavigationContainerRef } from './types';
|
|
5
|
-
declare const builtInCollectors: readonly (typeof collectors.PvCollector | typeof collectors.ExceptionCollector | typeof collectors.CrashCollector | typeof collectors.ApiCollector | typeof collectors.ActionCollector)[];
|
|
5
|
+
declare const builtInCollectors: readonly (typeof collectors.PvCollector | typeof collectors.ExceptionCollector | typeof collectors.CrashCollector | typeof collectors.OomCollector | typeof collectors.ApiCollector | typeof collectors.ActionCollector)[];
|
|
6
6
|
type CollectorName = (typeof builtInCollectors)[number]['prototype']['name'];
|
|
7
7
|
type CollectorMap = {
|
|
8
8
|
[K in CollectorName]: InstanceType<Extract<(typeof builtInCollectors)[number], {
|
|
@@ -23,5 +23,32 @@ export interface IRNConfig extends IConfiguration {
|
|
|
23
23
|
* request 自定义解析;
|
|
24
24
|
*/
|
|
25
25
|
evaluateApi?(request: any, response: any, error?: Error, xhr?: XMLHttpRequest): Promise<IApiBaseAttr>;
|
|
26
|
+
/**
|
|
27
|
+
* 采集器配置。
|
|
28
|
+
*
|
|
29
|
+
* 以交叉类型扩展父类型的 index signature,补充各采集器开关的 JSDoc
|
|
30
|
+
* 默认值说明(对齐 rum-electron 配置类型风格,与配置参考文档双保险
|
|
31
|
+
* 防默认值漂移)。
|
|
32
|
+
*/
|
|
33
|
+
collectors?: IConfiguration['collectors'] & {
|
|
34
|
+
/**
|
|
35
|
+
* OOM(iOS 看门狗终止推断)采集开关。
|
|
36
|
+
*
|
|
37
|
+
* 默认 false,需显式开启(`oom: true`),缺省或 false 均不启用;
|
|
38
|
+
* 开关方向与 crash 采集器相反(crash 默认开启,`crash === false` 才关闭)。
|
|
39
|
+
*
|
|
40
|
+
* 能力范围:仅 iOS 前台看门狗终止的事后推断(无堆栈,timestamp 为
|
|
41
|
+
* 估算值,`snapshots.estimated: true` 标记推断性质);Android 无此
|
|
42
|
+
* 能力(Java OutOfMemoryError 已由崩溃链路捕获)。
|
|
43
|
+
*
|
|
44
|
+
* 建议与 `crash` 同时开启;crash 关闭时 KSCrash 崩溃报告只写不删,
|
|
45
|
+
* 残留报告会使 OOM 判定倾向被抑制(漏判方向保守),而非误报增多。
|
|
46
|
+
*
|
|
47
|
+
* 未来若出现子开关需求(内存警告、前后台区分等),本字段计划演进为
|
|
48
|
+
* `boolean | object` 双形态(参照 rum-electron checkEnable 四态归一),
|
|
49
|
+
* 本期维持单一 boolean。
|
|
50
|
+
*/
|
|
51
|
+
oom?: boolean;
|
|
52
|
+
};
|
|
26
53
|
}
|
|
27
54
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOM(iOS 看门狗终止推断)相关类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 对应 iOS 原生侧落盘的 oom_{timestamp}_{uuid}.json 事件文件结构
|
|
5
|
+
* (getPendingOomReports 返回数组的元素),见
|
|
6
|
+
* dev-docs/OOM采集调研与实施方案.md 4.2.3 节。
|
|
7
|
+
*/
|
|
8
|
+
/** OOM 事件的上次会话上下文(原生从 context.json 恢复) */
|
|
9
|
+
export interface OomContext {
|
|
10
|
+
session_id?: string;
|
|
11
|
+
view_id?: string;
|
|
12
|
+
view_name?: string;
|
|
13
|
+
user_id?: string;
|
|
14
|
+
}
|
|
15
|
+
/** 上次会话的 App 状态快照(原生 RumAppStateRecorder 状态变更时写入) */
|
|
16
|
+
export interface OomAppState {
|
|
17
|
+
appVersion?: string;
|
|
18
|
+
osVersion?: string;
|
|
19
|
+
/** 系统启动时刻(ISO8601),用于排除设备重启 */
|
|
20
|
+
systemBootTime?: string;
|
|
21
|
+
vendorId?: string;
|
|
22
|
+
/** 上次进程是否前台激活(仅前台被杀才判定,D5) */
|
|
23
|
+
isActive?: boolean;
|
|
24
|
+
/** 是否收到正常终止回调(用户强杀排除) */
|
|
25
|
+
wasTerminated?: boolean;
|
|
26
|
+
/** 上次是否处于调试态(调试期被杀排除) */
|
|
27
|
+
isDebugging?: boolean;
|
|
28
|
+
/** 状态快照写入时刻(ms),供 context 新鲜度评估 */
|
|
29
|
+
updatedAt?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 原生 OOM 数据结构(与 iOS 原生侧落盘的 JSON 对齐)。
|
|
33
|
+
* 仅声明 JS 层会用到的字段。
|
|
34
|
+
*/
|
|
35
|
+
export interface NativeOomData {
|
|
36
|
+
/**
|
|
37
|
+
* OOM 事件唯一标识(UUID),承担与 crash_id 等价的 Ack 标识角色。
|
|
38
|
+
* 防御性声明为可选:缺失时事件仍可上报,仅无法走 ack 删文件链路。
|
|
39
|
+
*/
|
|
40
|
+
oom_id?: string;
|
|
41
|
+
/** 估算的案发时刻(ms,取上次会话最后写入的持久化文件 mtime) */
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
platform?: string;
|
|
44
|
+
subtype?: string;
|
|
45
|
+
/** 事件名,PascalCase(如 WatchdogTermination) */
|
|
46
|
+
name?: string;
|
|
47
|
+
/** 英文证据式表述(D8),推断性质由 snapshots.estimated 承载 */
|
|
48
|
+
message?: string;
|
|
49
|
+
/** 崩溃机制信息(如 { type: 'watchdog_termination', handled: false }) */
|
|
50
|
+
mechanism?: Record<string, unknown>;
|
|
51
|
+
/** 上次会话的 App 状态快照 */
|
|
52
|
+
app_state?: OomAppState;
|
|
53
|
+
/** 上次会话上下文(session/view/user 关联依据) */
|
|
54
|
+
context?: OomContext;
|
|
55
|
+
app?: Record<string, unknown>;
|
|
56
|
+
device?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=oom.d.ts.map
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { type RumEvent } from '@arms/rum-core';
|
|
2
2
|
import type { NativeCrashData } from '../types/crash';
|
|
3
|
+
import type { NativeOomData } from '../types/oom';
|
|
3
4
|
/**
|
|
4
5
|
* 将原生崩溃数据转换为 RumEvent 异常事件,对齐存储模型 Exception 表的
|
|
5
6
|
* Attributes(session/view/exception 基础信息)+ Metadata(堆栈、快照等)字段。
|
|
6
7
|
*/
|
|
7
8
|
export declare function convertCrashToRumEvent(crashData: NativeCrashData): RumEvent;
|
|
9
|
+
/**
|
|
10
|
+
* 将原生 OOM(看门狗终止推断)数据转换为 RumEvent 异常事件,
|
|
11
|
+
* 对齐存储模型 Exception 表。
|
|
12
|
+
*
|
|
13
|
+
* 与崩溃事件的差异:
|
|
14
|
+
* - type='crash' + subtype='oom' 复用现有 exception 链路,不新增 type 枚举(D4);
|
|
15
|
+
* - 无堆栈(watchdog 终止无信号可捕获,无现场数据);
|
|
16
|
+
* - timestamp 为估算值(snapshots.estimated: true 结构化标记推断性质,D8);
|
|
17
|
+
* - session/view 取自上次会话的持久化 context,由 rum-core dispatchEvents
|
|
18
|
+
* 按 session_id 分组上报,不会因旧 session 被丢弃。
|
|
19
|
+
*/
|
|
20
|
+
export declare function convertOomToRumEvent(oomData: NativeOomData): RumEvent;
|
|
8
21
|
/**
|
|
9
22
|
* 安全调用原生桥方法,异常时静默降级。
|
|
10
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arms/rum-reactnative",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4-beta.1",
|
|
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",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"clean": "del-cli android/build example/ios example/android lib",
|
|
65
65
|
"build": "bob build && node scripts/inject-version.js",
|
|
66
66
|
"build:prod": "bob build && node scripts/minify-prod.js",
|
|
67
|
-
"prepare": "bob build && node scripts/inject-version.js",
|
|
68
67
|
"prepack": "yarn build:prod",
|
|
69
68
|
"release": "release-it --only-version"
|
|
70
69
|
},
|
|
@@ -56,6 +56,21 @@ export interface Spec extends TurboModule {
|
|
|
56
56
|
|
|
57
57
|
/** 触发测试崩溃(仅用于开发调试,调用后 App 立即崩溃) */
|
|
58
58
|
triggerTestCrash(crashType: string): void;
|
|
59
|
+
|
|
60
|
+
// === OOM(看门狗终止)采集相关 ===
|
|
61
|
+
|
|
62
|
+
/** 获取待上报的 OOM 报告列表(下次启动时调用),JSON 字符串 */
|
|
63
|
+
getPendingOomReports(): Promise<string>;
|
|
64
|
+
|
|
65
|
+
/** 清除已上报的 OOM 报告文件 */
|
|
66
|
+
clearOomReports(oomIds: string): Promise<void>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 同步 JS 侧采集器配置到原生(SDK init 时调用),config 为 JSON 字符串。
|
|
70
|
+
* 当前支持的键:`oom`(boolean,是否开启 OOM 采集,false/缺省不启用)。
|
|
71
|
+
* 原生侧据此安装状态记录器并执行上次启动的看门狗终止判定。
|
|
72
|
+
*/
|
|
73
|
+
updateCollectorsConfig(config: string): void;
|
|
59
74
|
}
|
|
60
75
|
|
|
61
76
|
/**
|
|
@@ -102,6 +117,9 @@ const fallback: Spec = {
|
|
|
102
117
|
crashedLastRun: async () => false,
|
|
103
118
|
updateCrashContext: () => {},
|
|
104
119
|
triggerTestCrash: () => {},
|
|
120
|
+
getPendingOomReports: async () => '[]',
|
|
121
|
+
clearOomReports: async () => {},
|
|
122
|
+
updateCollectorsConfig: () => {},
|
|
105
123
|
};
|
|
106
124
|
|
|
107
125
|
export default nativeModule ?? fallback;
|