Commit 9159d039 by chenwq

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

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