Giter Site home page Giter Site logo

sensorsdata / sa-sdk-miniprogram Goto Github PK

View Code? Open in Web Editor NEW
234.0 29.0 223.0 1.47 MB

神策数据官方微信小程序埋点 SDK,是一款用于微信小程序端的数据采集埋点 SDK。使用代理的技术实现微信小程序端的全埋点。

Home Page: http://opensource.sensorsdata.cn

License: Apache License 2.0

JavaScript 100.00%

sa-sdk-miniprogram's Introduction

神策数据

License GitHub release

sa-sdk-miniprogram

神策简介

神策数据 (Sensors Data),隶属于神策网络科技(北京)有限公司,是一家专业的大数据分析服务公司,大数据分析行业开拓者,为客户提供深度用户行为分析平台、以及专业的咨询服务和行业解决方案,致力于帮助客户实现数据驱动。神策数据立足大数据及用户行为分析的技术与实践前沿,业务现已覆盖以互联网、金融、零售快消、高科技、制造等为代表的十多个主要行业、并可支持企业多个职能部门。公司总部在北京,并在上海、深圳、合肥、武汉等地拥有本地化的服务团队,覆盖东区及南区市场;公司拥有专业的服务团队,为客户提供一对一的客户服务。公司在大数据领域积累的核心关键技术,包括在海量数据采集、存储、清洗、分析挖掘、可视化、智能应用、安全与隐私保护等领域。 More

使用方法

使用方法请参考文档 https://manual.sensorsdata.cn/sa/latest/tech_sdk_client_mp_wx-1573892.html

注意 SDK 可能不完全向前兼容,请查看版本更新说明 CHANGELOG.md。如果有说明不兼容的话,需要升级神策分析对应的版本。 请根据需要前往 Releases 里下载对应的文件

版本更新记录

请参见 CHANGELOG.md

讨论

扫码加入神策数据开源社区 QQ 群
群号:785122381
扫码加入神策数据开源社区微信群
 QQ 讨论群  微信讨论群

公众号

扫码关注
神策数据开源社区
扫码关注
神策数据开源社区服务号
 微信订阅号  微信服务号

新书推荐

《ASM 全埋点开发实战》 《数据驱动:从方法到实践》 《Android 全埋点解决方案》 《iOS 全埋点解决方案》
《ASM 全埋点开发实战》 《数据驱动:从方法到实践》 《Android 全埋点解决方案》 《iOS 全埋点解决方案》

License

Copyright 2015-2022 Sensors Data Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

sa-sdk-miniprogram's People

Contributors

com-xubo avatar gc19923 avatar lixiang9 avatar riyue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sa-sdk-miniprogram's Issues

Taro-微信小程序,useShareAppMessage方法的title和imageUrl等参数会被全埋点修改,有什么办法保证不被修改参数

Taro-微信小程序,useShareAppMessage方法的title和imageUrl等参数会被全埋点修改,有什么办法保证不被修改参数。比如业务上需要动态拼接path、title、imageUrl,但是接入全埋点之后,分享参数全部变成sampshare={"i":"1713238586074-1933127-036993fb396169e-27817540","p":"compareProductModule/pages/compareInsurance/index","d":0,"m":"转发消息卡片"}这种情况

[bug] v1.14.1 App 的去除 mp_proxy 改造丢失了 autoTrackIsFirst 的规则

  1. 默认 autoTrackIsFirst 为 false, 神策的逻辑在生命周期之后执行
  2. 去除 mp_proxy, 改为 wx.onAppShow 之后,丢失了优先级策略

例:在默认情况下,如果想给 某个生命周期添加额外的参数

sa.para.autoTrack[hook] = { customField: 'bar' }

这样改造后导致,wx.onAppShow 的逻辑优先执行,才去执行 App 中的生命周期函数,造成次序不可控

track方法有回调吗?

我怎么知道调用成功还是失败了?

我要监听退出事件,所以一定要等埋点埋成功了再执行退出
所以track要告诉我它执行完毕了没有

现在貌似track方法什么返回值都没有,我都不知道执行完毕没有

sensorsdata_conf.js 没使用?

很早之前的版本 sensorsdata.min.js 中会导入 config 文件,现在的这在哪里使用这个文件的呢?

sensorsdata.min.js 中使用的是默认的,未发现导入 config:

var sa = {
    para: {
      name: 'sensors',
      server_url: '',
      send_timeout: 1e3,
      use_client_time: !1,
      show_log: !0,
      allow_amend_share_path: !0,
      max_string_length: 300,
      datasend_timeout: 3e3,
      source_channel: [],
      autoTrack: {
        appLaunch: !0,
        appShow: !0,
        appHide: !0,
        pageShow: !0,
        pageShare: !0
      },
      is_persistent_save: !1
    }
  };

麻烦重新把源码提供出来

不要只给一个压缩后的文件啊
那还放在GitHub上有啥意义呢。。。

还有最好切分一下文件啊,一千多行的源文件。。

mpvue中怎么获取函数名

在mpvue生成的wxml中,所有事件都被handleProxy的函数接管, 在点击拦截的处理函数中,只能获取到 handleProxy,要怎么获取调用的真正的函数名
image

小程序插件接入

请问目前神策sdk支持小程序插件吗?

目前尝试无脑接入,发现内部有调用wx.onAppShow, 微信小程序插件中没法使用wx.onAppShow

Trao 里面接入的时候无法从 getApp()里面获取到sensors

Trao 里面接入的时候无法从 getApp()里面获取到sensors

import Taro from '@tarojs/taro';

const env = Taro.getEnv();
if (env === 'WEAPP') {
  const sa = require('sa-sdk-miniprogram');
  const config = {
    name: 'sensors',
    server_url: {
      development: 'https://xxx.xxxx.net/salog/sa.gif?project=default',
      production: 'https://xxx.xxxxx.com/salog/sa.gif?project=production'
    }[process.env.NODE_ENV],
    // 全埋点控制开关
    autoTrack: {
      // appLaunch:true, // 默认为 true,false 则关闭 $MPLaunch 事件采集
      // appShow:true, // 默认为 true,false 则关闭 $MPShow 事件采集
      // appHide:true, // 默认为 true,false 则关闭 $MPHide 事件采集
      // pageShow:true, // 默认为 true,false 则关闭 $MPViewScreen 事件采集
      // pageShare:true, // 默认为 true,false 则关闭 $MPShare 事件采集
      // mpClick: false // 默认为 false,true 则开启 $MPClick 事件采集
    },
    // 自定义渠道追踪参数,如source_channel: ["custom_param"]
    // source_channel: [],
    // 是否允许控制台打印查看埋点数据(建议开启查看)
    show_log: process.env.NODE_ENV === 'development',
    // 是否允许修改 onShareAppMessage 里 return 的 path,用来增加(登录 ID,分享层级,当前的 path),在 app onShow 中自动获取这些参数来查看具体分享来源、层级等
    allow_amend_share_path: true
  }

  sa.setPara(config);
  sa.init();
  console.log('初始化神策');
}

小程序埋点超时

  1. 在taro小程序中,按照神策文档添加的前端埋点
  2. 线上环境,每天有几百条埋点的超时数据报警,神策sql查询有生产数据
  3. 神策sql查”进入页面“的数据 比 我们统计的在此页面产生"购买付费"行为的量少
  4. 小程序埋点是否有限制或者其他要求
  5. 神策服务地址是否有更稳定可靠的地址

烦请解答下疑问

批量上报参数似乎有问题

代码段 sa.para里给定了上报超时的预设值

datasend_timeout: 3000,

如果开启了批量上报开关(目前是默认开启了)
会额外执行这段代码,调高上报超时的预设值,这是符合逻辑的。但是这里似乎有一个问题:

if (para && para.datasend_timeout);  //因为这里永远不会是false
  else if (sa.para.batch_send) {
    sa.para.datasend_timeout = 10000;  // 所以这里设置的不会生效
  }

他的原理可能是,

if (sa.para.batch_send === true) {
    sa.para.batch_send = _.extend({}, batch_send_default);
  } else if (_.isObject(sa.para.batch_send)) {
    sa.para.batch_send = _.extend({}, batch_send_default, sa.para.batch_send);
  }`

`function extend(obj) {
  each(slice.call(arguments, 1), function(source) {
    for (var prop in source) {
      if (source[prop] !== void 0) {
        obj[prop] = source[prop];
      }
    }
  });
  return obj;
}
function extend2Lev(obj) {
  each(slice.call(arguments, 1), function(source) {
    for (var prop in source) {
      if (source[prop] !== void 0 && source[prop] !== null) {
        if (isObject(source[prop]) && isObject(obj[prop])) {
          extend(obj[prop], source[prop]);
        } else {
          obj[prop] = source[prop];
        }
      }
    }
  });
  return obj;
}

即先用预设的sa.para作为基础,再判断用户给的初始化值是否合法,合法就更新。这导致datasend_timeout这个值,是永远都有值的,根本不会因为开启了批量发送,就走到下面的方法上,去调高超时时间。
在测试环节中可以复现此现象,即手工指定超时时间为10,批量发送100%复现。不会因为有10000的批量发送修改,就改为10000。

为什么我 $is_login_id设置的false,到了神策里一查,它变成true了

这个参数到底有啥用啊
表示distinct_id是不是登录ID,我怎么知道这个ID是不是登录ID,我小程序里都没传这个值
$is_login_id
我传了false,它变成true
我传了true,有时候抓到的却是false

还有一些字段,我明明传的字符串“1”, 到了神策上却变成了浮点数类型:1.0
QA天天给我提BUG,是神策自动处理了我传的参数类型吗?为什么要处理啊

SDK在Taro框架中的优化

在taro框架中, 默认路由会注入 $taroTimestamp 参数,然后神策上报页面参数时也会上报$taroTimestamp 参数, 导致在神策后台查看带参数的页面统计数相关数据时,$taroTimestamp 干扰无法查看带参数页面的具体数据,因此希望SDK在上报时能过滤下$taroTimestamp 参数, 或者提供配置入口, 让用户可以指定不上报配置的参数。

相关issues: NervJS/taro#11713

有冲突

你们目前的实现方案与小程序使用插件的时候有冲突。
image

这段代码,arguments[0]为null,会直接报错

`function click_proxy(option, method) {
var oldFunc = option[method];

option[method] = function() {
var prop = {},
type = '';

if (typeof arguments[0] === 'object') {
  var target = arguments[0].currentTarget || {};
  var dataset = target.dataset || {};
  type = arguments[0]['type'];
  prop['$url_path'] = _.getCurrentPath();
  prop['$element_id'] = target.id;
  prop['$element_type'] = dataset['type'];
  prop['$element_content'] = dataset['content'];
  prop['$element_name'] = dataset['name'];
}
if (type && _.isClick(type)) {
  sa.track('$MPClick', prop);
}
return oldFunc && oldFunc.apply(this, arguments);

}
};
`

在QQ小程序生产环境中出现distinct_id丢失问题

image

问题描述:期望每个埋点的distinct_id都为login id。但生产环境刚进入小程序的几个埋点出现distinct_id丢失的情况,约20%用户会出现如上图的异常数据。

出现频率:偶现

备注:生产环境出现,开发环境没有复现。

代码片段:

      sa.login(my._id)
      sa.registerApp({
        platform: 'qq',
      })
      sa.init()

SDK中上报方法应设置默认contentType

SDK中请求参数
image
发送的请求
image
服务端会报错,数据类型有问题。

小程序默认content-type: application/json,sdk中需要设置为content-type: text/plain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.