npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bnq-gio-taro

v0.0.3

Published

微信小程序 gio 埋点Taro版本

Downloads

1

Readme

项目介绍

安装

yarn add bnq-gio-taro

npm install bnq-gio-taro

使用

页面组件使用

  • 可以做浏览,曝光,点击事件
  • pageInTrack 开启埋点
  • 会自动需计算曝光,无需特殊处理(如实现 componentDidHide,componentWillUnmount,componentDidShow)需要调用 super 对应方法
function gioConfig() {
  const env = 'test';
  const {accountId, projectId, appId} = hostConfig[env];
  const envStr = env == 'test' ? '测试环境':(env =='uat' ? 'UAT环境' : '生产环境');
  return {accountId, projectId, appId, scene: '商城', envStr};
}
// gio初始化
function gioInit() {
  const gioParam = gioConfig();
  Gio.init(gioParam, {
    host: "api-qa.bnq.com.cn",
    version: "1.0.0",
    scheme: 'https',
    debug: true,
  });
  const user = getUserInfo();
  const sysInfo = Taro.getSystemInfoSync();
  Gio.baseConfig({
    // uIp: '-', // 用户IP
    oneId: user.one_id || "-", // SDK获取,使用C端用户OneID或Gid、设备ID
    uId: user.userId || "-", // SDK获取,使用C端用户OneID或Gid、设备ID
    uName: user.nickName || "-", // 使用用户名称
    uType: "C端用户", // C端用户/B端用户
    // tId: '', // 默认三级渠道
    phoneBrand: sysInfo.brand, // 华为/小米/应用宝/OPPO/VIVO
    envType: gioParam.envStr, // 环境,生产环境/UAT环境/测试环境
    // url: '', // 具体网址
    version: sysInfo.SDKVersion, // 版本号
    device: sysInfo.model, // 设备标识符
  });

  Gio.setUserId(user.oneId || "-");

  Gio.config("shopCode", shopCode);
  Gio.config("oneId", oneId);
  Gio.config("uId", uId);
  Gio.config("uName", uName);
};

内置 类组件和函数式写法

import { Gio, GioComponent } from "bnq-gio-taro";

export default class Index extends GioComponent {
  componentDidMount() {
    super.pageInTrack();
  }

  componentDidShow() {
    super.componentDidShow();
  }

  componentDidHide() {
    super.componentDidHide();
  }

  onClick = () => {
    super.clickTrack(
      {
        pageClickArea_var: "点击区域",
        pageClickPosition_var: `点击位置`,
        pageClickName_var: "事件名称",
        To_RetentionPage_var: false,
      },
      "页面key"
    );

    super.clickTrack2("点击区域", `点击位置`, "事件名称", "是否留资 非必传");
  };

  render() {
    return <View>...</View>;
  }
}

函数式写法

import {useGioPage} from 'bnq-gio-taro';

function DemoPage() {

  const {pageConfig, trackEvent, pageInTrack, clickTrack, clickTrack2} = useGioPage({
    track?: boolean; // 是否默认开启埋点
    scene?: string; // 事件场景
    pageType_var?: string; // 页面类型
    pageName_var?: string; // 页面名称
    pageURL_var?: string; // 页面路径

    shareOneID_var?: string; // 分享id
    shareEmployeeID_var?: string; // 分享用户

    adContent_var?: string; // 广告内容
    adTerm_var: string; // 广告关键字

    channelThridID_var?: string; // 三方渠道id
    channelThridName_var?: string; // 三方渠道名称

    storeID_var?: string; // 门店id
    constructionSiteID_var?: string; // 工地id
    employeeID_var?: string; // 员工id
    contentID_var?: string; // 内容id
    activityID_var?: string; // 活动id
    prePageType_var?: string; // 上个页面类型
    prePageName_var: string; // 上个页面名称
    prePageURL_var?: string; // 上个页面路径
  });

  return (...);
}

Gio Api

相关 API


/**
   * 初始化
   * @param config 项目配置
   * @param option 配置项
   */
Gio.init(config: GioConfig, option: InitOption);
  /**
   * 基础参数配置
   * @param option 配置项
   */
  Gio.baseConfig(option: BaseConfig, thrid?: ThridShare): void;

  /**
   * 公共参数配置
   * @param option 配置项/或具体配置项的key
   * @param value 配置项值,只有option为字符串时传值
   */
  Gio.config(option: ParamOptionConfig | ThridShare | string, value?: string): void;

  /**
   * 获取参数
   * @param value 获取配置类型;不传全部配置,'param': 参数配置,'base': 基础配置,
   */
  Gio.getConfig(value?: string): {
    param: ParamOptionConfig;
    base: BaseConfig;
    thrid: ThridShare;
  };

  /**
   * 获取所有配置
   */
  Gio.getConfigAll(): ParamOptionConfig & BaseConfig & ThridShare;

  /**
   * 设置埋点事件和事件级变量
   * 发送一个埋点事件。在添加所需要发送的事件代码之前,需要在平台中配置事件以及事件属性。
   *
   * @param event 必填;事件名/标识符
   * @param params 选填;事件属性,即事件发生时所伴随的维度信息参数
   */
  Gio.track(event: string, params: any, item?: TrackItem): void;
  /**
   * 设置埋点事件 -浏览
   * @param params 配置参数
   */
  Gio.browse(params: BrowseParam, item?: TrackItem): void;

  /**
   * 设置埋点事件 -曝光
   * @param key 事件名
   * @param timeCount 计时
   * 例:event,
   */
  Gio.expose(key: string, timeCount?: number, item?: TrackItem): void;

  /**
   * 设置埋点事件 -点击
   * @param key 事件名
   * @param params 点击参数
   */
  Gio.click(key: string, params: ClickParam, item?: TrackItem): void;

  // 点击事件
  Gio.click2(area: string, position: string, name: string, retention?: boolean, item?: any): void;

  /**
   * 获取版本号
   */
  Gio.getVersion(): string;