🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

hm-wkapi-taro

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

hm-wkapi-taro

惟客宝埋点 Taro 3.0 版本

latest
npmnpm
Version
2.0.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

惟客宝埋点 SDK Taro 3.x 适配版本

安装

$ yarn add wkapi-taro


初始化

import wkApi from 'wkapi-taro';
import React from 'react';

class App extends React.Component {
  componentDidMount() {
    const ext = getExtConfig();
    wxApi.config({
      appId: ext.appId,
      appKey: ext.maAppId,
    });
  }
}

注意: 不需要调用 initLaunch、setContext。App、页面生命周期会自动监听



配置页面业务参数

@connect(mapStateToProps, mapDispatchToProps, undefined, { forwardRef: true })
@hoc
class GoodsDetail extends WaitComponent {
  // ...
  constructor(props) {
    super(props);
    // 埋点:页面标识
    // 取代旧的 ftBuryPageKey
    wkApi.setBuryPageKey(buryConfig.ITEM_DETAIL.key);

    // 埋点: 页面业务参数,供埋点sdk调用 **不能删除**
    // 取代旧的 ftBuryLoadArgument
    wkApi.setBuryPageLoadArgument(() => {
      const { itemNo, activityType, activityId, distributorId, source } = this.state;

      if (itemNo || activityId) {
        return {
          itemNo,
          activityType,
          activityId,
          distributorId,
          source,
        };
      }
      return null;
    });
  }

  // ...
}

Hooks 版本

function Foo() {
  useSetBuryPageKey(buryConfig.ITEM_DETAIL.key);
  useSetBuryPageLoadArgument(() => {
    /*...*/
  });
}


向下兼容

其余内容和旧版本保持一致

FAQs

Package last updated on 03 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts