tt.createLiveReportContext
收藏
我的收藏

该接口已停止维护,后续将逐步下线,不建议使用。​
基础库 2.29.0 开始支持本方法,这是一个同步方法。​
警告
此接口将逐步废弃,后续不再维护,请及时修改下线,避免影响小程序使用​
用于直播间小程序埋点上报。​

语法​

text
复制
tt.createLiveReportContext()

返回值​

返回 LiveReportContext 对象​

代码示例​

js
复制
// utils.js
const noop = () => {};
const defaultReporter = {
productSelect: noop,
productDetailsShow: noop,
productShareClick: noop,
shelfShow: noop,
orderConfirmPageShow: noop,
orderSubmit: noop,
};
export const liveReport = tt.canIUse("createLiveReportContext")
? tt.createLiveReportContext()
: defaultReporter;
js
复制
// page.js
const { liveReport } = require("utils.js");
Page({
onShow() {
liveReport.productDetailsShow({
productId: "商品id",
productName: "商品名称",
shopId: "商家id",
shopName: "商家名称",
success: () => {
console.log("上报成功");
},
fail: ({ errMsg }) => {
console.log("上报失败:", errMsg);
},
});
},
});

Bug & Tip​

    Tip: 开发者工具暂不支持此能力,请用真机扫码调试。​