Commit 9159d039 by chenwq

refactor: 积分会,移除不必要的 Sentry 上报,优化代码逻辑

1 parent e6de80f1
Pipeline #395 for 9159d039 failed in 0 seconds
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* · SHA1 不摊平 params → 内置签名策略 'rop-sha1'(与旧 getData 逐字节一致) * · SHA1 不摊平 params → 内置签名策略 'rop-sha1'(与旧 getData 逐字节一致)
* · 单一域名 / merchantId 头三级回退 → hosts、getMerchantId * · 单一域名 / merchantId 头三级回退 → hosts、getMerchantId
* · 业务失败 / 登录失效后 Promise 挂起 → loginReplay * · 业务失败 / 登录失效后 Promise 挂起 → loginReplay
* · sentry 上报 → events.error + onTransportError
*/ */
// 小程序走主入口具名导出(构建 npm 不保证解析 exports 子路径);web/Node 可用 @uj/api-core/Request。 // 小程序走主入口具名导出(构建 npm 不保证解析 exports 子路径);web/Node 可用 @uj/api-core/Request。
import { createClient } from '@uj/api-core' import { createClient } from '@uj/api-core'
...@@ -52,16 +51,7 @@ const client = createClient({ ...@@ -52,16 +51,7 @@ const client = createClient({
wx.p.storage.rm('userInfo') wx.p.storage.rm('userInfo')
wx.p.router.redirectTo('/pages/Login/Login') wx.p.router.redirectTo('/pages/Login/Login')
}, },
// 业务异常:toast 由门面负责,这里只补旧壳的 sentry 上报。 // 传输失败:改写提示文案(旧壳 fail 分支)。
events: {
error: (err) => {
const params = err?.config?.data
wx.p?.sentry?.reportError?.(`接口异常:${err?.message}`, {
code: err?.code, message: err?.message, params,
})
},
},
// 传输失败:改写提示文案 + sentry 上报(旧壳 fail 分支)。
onTransportError: (error) => { onTransportError: (error) => {
// 旧壳 fail 分支会先关掉 loading。 // 旧壳 fail 分支会先关掉 loading。
wx.hideLoading?.() wx.hideLoading?.()
...@@ -69,7 +59,6 @@ const client = createClient({ ...@@ -69,7 +59,6 @@ const client = createClient({
? error ? error
: (error && (error.errMsg || error.message)) || JSON.stringify(error) || '系统异常' : (error && (error.errMsg || error.message)) || JSON.stringify(error) || '系统异常'
console.error('[request fail]', error) console.error('[request fail]', error)
wx.p?.sentry?.reportError?.(`接口异常:${message}`, { error })
return { message } return { message }
}, },
}) })
......
...@@ -53,13 +53,6 @@ Component({ ...@@ -53,13 +53,6 @@ Component({
// 替换积分钱包名称 // 替换积分钱包名称
replaceNickName(data) { replaceNickName(data) {
let userInfo = wx.p.storage.get('userInfo') let userInfo = wx.p.storage.get('userInfo')
let { phone, scoreSource } = data
if (!phone || !scoreSource) {
wx.p.sentry.reportParamError(
'替换积分钱包姓名异常:phone, scoreSource',
data
)
}
commonApi.replaceWalletName({ commonApi.replaceWalletName({
nickName: data?.name, nickName: data?.name,
phone: data?.phone, phone: data?.phone,
......
...@@ -6,8 +6,5 @@ ...@@ -6,8 +6,5 @@
// 配置预发布的小程序aapId // 配置预发布的小程序aapId
export const preReleaseAppId = 'wx6e40cfb83ce4ffb1' export const preReleaseAppId = 'wx6e40cfb83ce4ffb1'
// sentry Dsn 地址
export const dsnUrl = 'https://70845376de464a7d9588639fd7c4b5f9@sentry.glsx.com.cn/46'
// cdn图片地址 // cdn图片地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/' export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/points-mall/'
...@@ -2,6 +2,5 @@ import sha1 from './sha1.js' ...@@ -2,6 +2,5 @@ import sha1 from './sha1.js'
import qs from './qs' import qs from './qs'
import wxqrcode from './wxqrcode.js' import wxqrcode from './wxqrcode.js'
import getUpdateManager from "./wxUpdateManager"; import getUpdateManager from "./wxUpdateManager";
import * as Sentry from './sentry-miniapp'
module.exports ={ sha1,qs,wxqrcode,getUpdateManager,Sentry }
\ No newline at end of file \ No newline at end of file
module.exports ={ sha1,qs,wxqrcode,getUpdateManager }
...@@ -536,17 +536,10 @@ compressImage(filePath, maxSize) { ...@@ -536,17 +536,10 @@ compressImage(filePath, maxSize) {
success: 'fail', success: 'fail',
dialogText: `原因:${message}` dialogText: `原因:${message}`
}) })
wx.p.sentry.reportError(`添加账户异常:${message}`, {
...formData,
message
});
// wx.$api.showToast(message) // wx.$api.showToast(message)
} }
} catch (err) { } catch {
wx.p.sentry.reportError(`添加账户异常:${err.message}`, { return undefined
...formData,
err
});
} }
} }
......
...@@ -98,19 +98,6 @@ Page({ ...@@ -98,19 +98,6 @@ Page({
merchantId: userInfo?.merchantId, merchantId: userInfo?.merchantId,
merchantName: userInfo?.merchantName, merchantName: userInfo?.merchantName,
} : {id: reviewId} } : {id: reviewId}
let { goodsId, customerMobile, merchantId } = params
if (e.type == 'add' && (!goodsId || !customerMobile || !merchantId)) {
wx.p.sentry.reportParamError(
'商品详情进入埋点异常:goodsId, customerMobile, merchantId',
params
)
}
if (e.type != 'add' && !reviewId) {
wx.p.sentry.reportParamError(
'商品详情离开埋点异常:id',
{id: reviewId}
)
}
commonApi[eventApi](params).then(res => { commonApi[eventApi](params).then(res => {
this.setData({reviewId: res?.data}) this.setData({reviewId: res?.data})
}) })
...@@ -201,12 +188,6 @@ Page({ ...@@ -201,12 +188,6 @@ Page({
}, },
// 获取详情 // 获取详情
getDetail(options) { getDetail(options) {
if (!options.id) {
wx.p.sentry.reportParamError(
'商品详情异常:id',
id
)
}
homeApi.getGoodsDetailInfo({id: options.id, businessType: 1}).then(res => { homeApi.getGoodsDetailInfo({id: options.id, businessType: 1}).then(res => {
if (res && res.specificationResponses?.length) { if (res && res.specificationResponses?.length) {
this.toGetSpecString(res, res.startQty) this.toGetSpecString(res, res.startQty)
...@@ -258,13 +239,6 @@ Page({ ...@@ -258,13 +239,6 @@ Page({
merchantId: userInfo?.merchantId merchantId: userInfo?.merchantId
} }
if (!detailInfo.goodsStock) return wx.p.wxApi.showToast('暂无库存') if (!detailInfo.goodsStock) return wx.p.wxApi.showToast('暂无库存')
let { goodsId, sellQty, goodsSource, scoreSource, merchantId, specificationData } = PARAMS
if (!goodsId || !sellQty || !goodsSource || !scoreSource || !merchantId || (goodsSource == 2 && !specificationData)) {
wx.p.sentry.reportParamError(
'加入购物车异常:goodsId, sellQty, goodsSource, scoreSource, merchantId, specificationData',
PARAMS
)
}
cartApi.addToCart(PARAMS).then(res => { cartApi.addToCart(PARAMS).then(res => {
wx.p.wxApi.showToast('加入购物车成功') wx.p.wxApi.showToast('加入购物车成功')
this.joinSuccess() this.joinSuccess()
......
...@@ -123,19 +123,10 @@ Page({ ...@@ -123,19 +123,10 @@ Page({
scoreSummary: res.data, scoreSummary: res.data,
staffBankFlag: !res.data.bankCardSize staffBankFlag: !res.data.bankCardSize
}) })
} else {
wx.p.sentry.reportError(`积分中心异常:${res.message}`, {
...params,
res
});
} }
}).catch((err) => { }).catch((err) => {
wx.p.wxApi.showToast(JSON.stringify(err)) wx.p.wxApi.showToast(JSON.stringify(err))
wx.p.sentry.reportError(`积分中心异常:${err}`, {
...params,
err
});
}) })
}, },
getScoreProfitListData(isFlag) { getScoreProfitListData(isFlag) {
......
...@@ -202,17 +202,9 @@ Page({ ...@@ -202,17 +202,9 @@ Page({
} else { } else {
wx.p.wxApi.showToast(res.message) wx.p.wxApi.showToast(res.message)
this.submit = false this.submit = false
wx.p.sentry.reportError(`积分提现异常:${res.message}`, {
...params,
res
});
} }
}).catch((err) => { }).catch((err) => {
this.submit = false this.submit = false
wx.p.sentry.reportError(`积分提现异常:${err.message}`, {
...params,
err
});
wx.p.wxApi.showToast(JSON.stringify(err)) wx.p.wxApi.showToast(JSON.stringify(err))
}).finally(() => { }).finally(() => {
......
...@@ -71,9 +71,7 @@ Page({ ...@@ -71,9 +71,7 @@ Page({
status, status,
button, button,
}); });
}).catch((err) => { }).catch(() => undefined)
wx.p.sentry.reportError(`售后详情异常:${err.message}`, {...this.data,err});
})
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
}); });
...@@ -125,13 +123,10 @@ Page({ ...@@ -125,13 +123,10 @@ Page({
tab: ORDER_STATUS[OrderStatusEnum.COMPLETED], tab: ORDER_STATUS[OrderStatusEnum.COMPLETED],
}); });
} }
}).catch((err) => { }).catch(() => undefined);
wx.p.sentry.reportError(`撤销售后:${err.message}`, {...this.data.orderInfo,err});
});
} }
}) })
.catch((err) => { .catch(() => {
wx.p.sentry.reportError(`撤销售后Modal:${err.message}`, {...this.data.orderInfo,err});
wx.p.wxApi.showToast("已取消"); wx.p.wxApi.showToast("已取消");
}) })
.finally(() => { .finally(() => {
......
...@@ -188,9 +188,6 @@ Component({ ...@@ -188,9 +188,6 @@ Component({
*/ */
processExpressInfo(expressInfo) { processExpressInfo(expressInfo) {
if (!expressInfo || typeof expressInfo !== "object") { if (!expressInfo || typeof expressInfo !== "object") {
wx.p.sentry.reportError(`快递信息异常:expressInfo参数无效`, {
expressInfo,
});
console.warn("Express组件: expressInfo参数无效"); console.warn("Express组件: expressInfo参数无效");
return; return;
} }
...@@ -204,9 +201,6 @@ Component({ ...@@ -204,9 +201,6 @@ Component({
// 验证必要字段 // 验证必要字段
if (typeof logisticsStatus !== "number") { if (typeof logisticsStatus !== "number") {
wx.p.sentry.reportError(`快递信息异常:logisticsStatus字段无效`, {
expressInfo,
});
console.warn("Express组件: logisticsStatus字段无效"); console.warn("Express组件: logisticsStatus字段无效");
return; return;
} }
......
...@@ -48,12 +48,7 @@ Page({ ...@@ -48,12 +48,7 @@ Page({
logisticsInfo: data, logisticsInfo: data,
}) })
} }
}).catch((err) => { }).catch(() => undefined);
wx.p.sentry.reportError(`查询物流异常:${err.message}`, {
subOrderCode,
err
});
});
}, },
getOrderDetail(subOrderCode) { getOrderDetail(subOrderCode) {
wx.p.wxApi.showLoading("加载中..."); wx.p.wxApi.showLoading("加载中...");
...@@ -89,12 +84,7 @@ Page({ ...@@ -89,12 +84,7 @@ Page({
} : {}) } : {})
}); });
}) })
.catch((err) => { .catch(() => undefined)
wx.p.sentry.reportError(`订单详情异常:${err.message}`, {
subOrderCode,
err
});
})
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
}); });
......
...@@ -139,14 +139,6 @@ Page({ ...@@ -139,14 +139,6 @@ Page({
} = this.data; } = this.data;
const userInfo = wx.p.storage.get("userInfo") || {}; const userInfo = wx.p.storage.get("userInfo") || {};
let { merchantId, channelSource, phone } = userInfo; let { merchantId, channelSource, phone } = userInfo;
//如果 merchantId, channelSource, phone 这三个参数有一个未获取到,给sentry上报异常,并且带上具体的值
if (!merchantId || !channelSource || !phone) {
// 设置自定义上下文信息
wx.p.sentry.reportParamError(
"订单列表异常:merchantId, channelSource, phone 参数异常",
userInfo
);
}
let obj = { let obj = {
requestType, requestType,
merchantId, merchantId,
...@@ -175,9 +167,7 @@ Page({ ...@@ -175,9 +167,7 @@ Page({
list, list,
listFlag: true, listFlag: true,
}); });
}).catch((err) => { }).catch(() => undefined)
wx.p.sentry.reportError(`订单列表异常:${err.message}`, {...obj,err});
})
.finally(() => { .finally(() => {
wx.hideLoading(); wx.hideLoading();
}); });
......
...@@ -52,8 +52,7 @@ Page({ ...@@ -52,8 +52,7 @@ Page({
async onLoad() { async onLoad() {
wx.p.wxApi.showLoading() wx.p.wxApi.showLoading()
const { const {
data, data
code
} = await wx.p.api.userApi.login() } = await wx.p.api.userApi.login()
// if (code == '0') this.customerLoginCallBack(data) // if (code == '0') this.customerLoginCallBack(data)
if (data) this.sessionId = data.sessionId if (data) this.sessionId = data.sessionId
...@@ -153,12 +152,6 @@ Page({ ...@@ -153,12 +152,6 @@ Page({
if (!captcha) throw '请输入验证码' if (!captcha) throw '请输入验证码'
if (!phoneRex.test(mobile)) throw '请输入正确的手机号' if (!phoneRex.test(mobile)) throw '请输入正确的手机号'
wx.p.wxApi.showLoading() wx.p.wxApi.showLoading()
if (!mobile || !captcha || !this.sessionId) {
wx.p.sentry.reportParamError(
'手机号验证码登录异常: mobile, captcha, sessionId',
{mobile, captcha, sessionId: this.sessionId}
)
}
const { const {
code, code,
data, data,
...@@ -193,13 +186,6 @@ Page({ ...@@ -193,13 +186,6 @@ Page({
iv: detail.iv, iv: detail.iv,
sessionId: this.sessionId sessionId: this.sessionId
} }
let { encryptedData, iv, sessionId } = obj
if (!encryptedData || !iv || !sessionId) {
wx.p.sentry.reportParamError(
'授权手机号登录异常: encryptedData, iv, sessionId',
obj
)
}
const { const {
code, code,
data, data,
...@@ -225,12 +211,6 @@ Page({ ...@@ -225,12 +211,6 @@ Page({
getSource() { getSource() {
let { loginData } = this.data let { loginData } = this.data
if (!loginData.phone) {
wx.p.sentry.reportParamError(
'获取积分渠道来源异常:staffPhone ',
loginData
)
}
commonApi.getPointsSourceList({ commonApi.getPointsSourceList({
staffPhone: loginData?.phone staffPhone: loginData?.phone
}).then(res => { }).then(res => {
...@@ -256,12 +236,6 @@ Page({ ...@@ -256,12 +236,6 @@ Page({
this.getMerchantList(source, loginData) this.getMerchantList(source, loginData)
}, },
getMerchantList(source, loginData) { getMerchantList(source, loginData) {
if (!loginData.phone || !source) {
wx.p.sentry.reportParamError(
'获取门店列表异常:staffPhone, channelSource',
{staffPhone: loginData.phone, channelSource: source}
)
}
commonApi.getMerchantData({staffPhone: loginData?.phone, channelSource: source}).then(res => { commonApi.getMerchantData({staffPhone: loginData?.phone, channelSource: source}).then(res => {
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
...@@ -272,12 +246,6 @@ Page({ ...@@ -272,12 +246,6 @@ Page({
if (data?.length == 1) { // 仅有一个门店时跳过选择门店页面 直接登录成功 if (data?.length == 1) { // 仅有一个门店时跳过选择门店页面 直接登录成功
const { merchantId, merchantName } = data[0] || {} const { merchantId, merchantName } = data[0] || {}
wx.p.isLogin = true; wx.p.isLogin = true;
if (!source || !merchantId || !loginData.phone) {
wx.p.sentry.reportParamError(
'门店选择异常:staffPhone, channelSource',
{channelSource: source, merchantId, merchantName}
)
}
wx.p.storage.set('userInfo', { wx.p.storage.set('userInfo', {
...loginData, ...loginData,
channelSource: source, channelSource: source,
......
// pages/chooseMerchant/index.js // pages/chooseMerchant/index.js
import commonApi from '~/api/module/common.js'
import { import {
systemApi systemApi
} from '~/api/index' } from '~/api/index'
...@@ -49,12 +48,6 @@ Page({ ...@@ -49,12 +48,6 @@ Page({
return return
} }
wx.p.isLogin = true wx.p.isLogin = true
if (!paramsData.loginData?.phone || !paramsData.loginData?.channelSource) {
wx.p.sentry.reportParamError(
'门店选择异常:phone, channelSource',
{phone: paramsData.loginData?.phone, channelSource: paramsData.loginData?.channelSource}
)
}
wx.p.storage.set('userInfo', { ...paramsData.loginData, merchantId: obj?.merchantId, merchantName: obj?.merchantName }) wx.p.storage.set('userInfo', { ...paramsData.loginData, merchantId: obj?.merchantId, merchantName: obj?.merchantName })
wx.p.router.reLaunch('/pages/tab/index/index', {loginPageFlag: paramsData?.loginPageFlag}) wx.p.router.reLaunch('/pages/tab/index/index', {loginPageFlag: paramsData?.loginPageFlag})
}, },
......
...@@ -59,9 +59,9 @@ ...@@ -59,9 +59,9 @@
</view> </view>
</view> </view>
<!-- 我的订单 --> <!-- 我的订单 -->
<myOrder/> <!-- <myOrder/> -->
<!-- 常用工具 --> <!-- 常用工具 -->
<view class="tool-box box"> <!-- <view class="tool-box box">
<view class="title">常用工具</view> <view class="title">常用工具</view>
<view class="btnBox"> <view class="btnBox">
<block wx:for="{{toolList}}" wx:key="index"> <block wx:for="{{toolList}}" wx:key="index">
...@@ -73,6 +73,6 @@ ...@@ -73,6 +73,6 @@
</view> </view>
</block> </block>
</view> </view>
</view> </view> -->
</view> </view>
</block> </block>
\ No newline at end of file \ No newline at end of file
...@@ -10,5 +10,4 @@ import routerApi from './routerApi' ...@@ -10,5 +10,4 @@ import routerApi from './routerApi'
import WxValidate from './WxValidate' import WxValidate from './WxValidate'
import cache from './cache/index' import cache from './cache/index'
import GlMap from './mapapi/mapapi' import GlMap from './mapapi/mapapi'
import sentry from './sentry' module.exports ={util,wxApi,constants,draw,emoji,eventbus,format,network,routerApi,WxValidate,cache,GlMap}
module.exports ={util,wxApi,constants,draw,emoji,eventbus,format,network,routerApi,WxValidate,cache,GlMap,sentry}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!