
Product
PHP and Composer Support Is Now in Beta
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.
@umengfe/babel-plugin-uapm-trycatch
Advanced tools
Babel plugin 可自动对文件中存在的Catch表达式插入友盟WEB/小程序的异常上报的脚本
Install:
npm install --save-dev @alife/babel-plugin-uapm-trycatch
| 支持平台 | 是否支持 |
|---|---|
| WEB/H5 | - [x] |
| 微信小程序 | - [x] |
| 支付宝小程序 | - [x] |
| 配置参数 | 是否必选 | 参数说明 | 参数类型 | 示例 |
|---|---|---|---|---|
| include | 否 | 包含的文件及路径规则 | string[] | include: ['/*.tsx', '/*.ts'] |
| exclude | 否 | 排除的文件及路径规则 | string[] | exclude: ['**/node_modules'] |
| platform | 否 | 目标构建平台,支持(wechat、web、alipay) | string | platform: 'web' |
目标构建平台也可配合构建命令 通过约定的环境变量(
UAPM_PLATFORM)在package.json的构建命令中进行指定,同时配置取值优先级options高于全局变量
// package.json
{
"name": "",
"version": "0.1.0",
"scripts": {
"build:h5": "cross-env UAPM_PLATFORM=web npm run build"
}
}
before:
const fn = () => {
try {
console.log(test);
} catch (error) {}
};
after:
const fn = () => {
try {
console.log(test);
} catch (error) {
// WEB
+ try { window && window._apm && window._apm.captureException && window._apm.captureException(error); } catch(e){}
// 小程序
+ try { wx && wx.umapm && wx.$umapm.captureException && wx.$umapm.captureException(error); } catch(e){}
// 支付宝
+ try { my && my.$umapm && my.$umapm.captureException && my.$umapm.captureException(error); } catch(e){}
}
};
.babelrc
{
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-transform-runtime',
+ [
+ @alife/babel-plugin-uapm-trycatch,
+ {
+ include: ['**/*.tsx', '**/*.ts'],
+ platform: 'web'
+ }
+ ]
],
};
uniapp babel.config.js
```diff
+ if (process.env.UNI_PLATFORM === 'h5' || process.env.UNI_PLATFORM === 'alipay' || process.env.UNI_PLATFORM === 'wexin') {
+ plugins.push([
+ @alife/babel-plugin-uapm-trycatch,
+ {
+ exclude: ['**/node_modules'],
+ platform: process.env.UAPM_PLATFORM
+ }
+ ])
+ }
module.exports = {
presets: [
[
'@vue/app',
{
modules: 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
]
],
plugins
}
FAQs
> Babel plugin 可自动对文件中存在的Catch表达式插入友盟WEB/小程序的异常上报的脚本
The npm package @umengfe/babel-plugin-uapm-trycatch receives a total of 0 weekly downloads. As such, @umengfe/babel-plugin-uapm-trycatch popularity was classified as not popular.
We found that @umengfe/babel-plugin-uapm-trycatch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.

Product
Socket’s PHP and Composer support is now in Beta for all customers, with PHP reachability analysis generally available.

Product
Socket is bringing experimental protection to Firefox, scanning 97,000+ extensions in Mozilla's official directory for malware and risky updates.

Research
/Security News
Three compromised Rust crates pulled in a malicious dependency that downloaded and executed cross-platform malware during Cargo builds.