File tree Expand file tree Collapse file tree 4 files changed +96
-1
lines changed Expand file tree Collapse file tree 4 files changed +96
-1
lines changed Original file line number Diff line number Diff line change 1+ # 插件的开发方式
2+
3+ ## 插件开发注意点
4+ 1 . 插件目录是 pluginXX,默认文件名为 ` index.esm.js `
5+ 2 . 末尾建议是 ` export default pluginXX `
6+ 3 . pluginXX 必须是 ` object `
7+ 4 . pluginXX 必须包含 ` name ` ,` name ` 必须是首字母大写的字符串,命名是大驼峰
8+ 5 . pluginXX 必须提供 ` init ` 方法
9+
10+ ## 示例代码
11+ 下面我们实现一个插件,当小程序进入后台后,自动发送一个 ` hide ` 事件并包含传入的自定义属性
12+
13+ ``` javascript
14+ // index.js
15+ var TrackHide = {
16+ name: ' TrackHide' ,
17+ init : function (sensors , config ){
18+ wx .onAppHide (function (){
19+ sensors .track (' hide' ,config);
20+ });
21+ }
22+ };
23+ export default TrackHide ;
24+ ```
25+
26+ 以上一个插件就编写好了,下面是使用方式
27+
28+ ``` javascript
29+ import sensors from ' /dist/wechat/sensorsdata.ems' ;
30+ import trackHide from ' /dist/wechat/plugin/track-hide/index.esm' ;
31+ sensors .setPara ({... });
32+ sensors .use (trackHide,{platform: ' wechat' });
33+ sensors .init ();
34+ ```
35+
36+ 这样,当小程序隐藏的时候,会自动发送 ` hide ` 事件。
Original file line number Diff line number Diff line change 1+ # 插件规范
2+ 为了满足多变的需求,提供可无限扩展的能力。神策的 Web/小程序 SDK 将逐步演化为插件式架构。
3+ SDK 会越来越轻量化,在不久的将来 SDK = CORE + 插件。
4+ 一切需求都是插件,业务都是通过插件来实现。
5+
6+ ## SDK 和插件下载
7+ ```
8+ dist
9+ ├── web
10+ ├── plugin
11+ │ ├── plugin-xx
12+ │ │ ├── index.esm.js
13+ │ │ ├── index.cmd.js
14+ |── sensorsdata.esm.js
15+ |── sensorsdata.cjs.js
16+ ```
17+ * SDK 位置: ` /dist/wechat/sensorsdata.esm.js `
18+ * 插件位置: ` /dist/wechat/plugin/ `
19+
20+ 注意: 弹窗、abtesting 也都在 ` /dist/wechat/plugin ` 目录下
21+
22+ ## 使用示例
23+ ``` javascript
24+ import sensors from ' /dist/wechat/sensorsdata.esm.js' ;
25+ import pluginXX from ' /dist/wechat/plugin/xx/index.esm.js' ;
26+ sensors .usePlugin (pluginXX, option);
27+ sensors .setPara ();
28+ sensors .init ();
29+ ```
30+ 注意:所有插件都是按照这种方式引入,各插件文档中不会再次介绍,如果 ` option ` 有参数时候,才会单独介绍参数的用法
31+
32+ ## 插件使用注意
33+ 1 . 按顺序引入插件 ! 先 ` import ` 主 SDK,后 ` import plugin ` 。先调用 ` use ` ,后调用 ` init ` 。
34+ 2 . 版本必须一致 ! 如果单独升级了插件,必须同时单独更新主 SDK。建议插件和 SDK 都引用 ` /dist/wechat/ ` 下的目录文件,这样就会一起更新,就不会出现版本不一致!
Original file line number Diff line number Diff line change 1+ [ ![ 神策数据] ( https://opensource.sensorsdata.cn/wp-content/uploads/logo.png ' 神策数据 ')] ( https://www.sensorsdata.cn/ )
2+ <br ><br >
3+
4+ # sf-sdk-miniprogram
5+
6+ ## 神策简介
7+
8+ [ ** 神策数据** ] ( https://www.sensorsdata.cn/ )
9+ (Sensors Data),隶属于神策网络科技(北京)有限公司,是一家专业的大数据分析服务公司,大数据分析行业开拓者,为客户提供深度用户行为分析平台、以及专业的咨询服务和行业解决方案,致力于帮助客户实现数据驱动。神策数据立足大数据及用户行为分析的技术与实践前沿,业务现已覆盖以互联网、金融、零售快消、高科技、制造等为代表的十多个主要行业、并可支持企业多个职能部门。公司总部在北京,并在上海、深圳、合肥、武汉等地拥有本地化的服务团队,覆盖东区及南区市场;公司拥有专业的服务团队,为客户提供一对一的客户服务。公司在大数据领域积累的核心关键技术,包括在海量数据采集、存储、清洗、分析挖掘、可视化、智能应用、安全与隐私保护等领域。 [ ** More** ] ( https://www.sensorsdata.cn/about/aboutus.html )
10+
11+ ## 更新日志
12+
13+ 请参见 [ CHANGELOG.md] ( CHANGELOG.md )
14+
15+ ## 讨论
16+
17+ | 扫码加入神策数据开源社区 QQ 群<br >群号:785122381 | 扫码加入神策数据开源社区微信群 |
18+ | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
19+ | ![ QQ 讨论群] ( https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_1.png ) | ![ 微信讨论群 ] ( https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_2.png ) |
20+
21+ ## 公众号
22+
23+ | 扫码关注<br >神策数据开源社区 | 扫码关注<br >神策数据开源社区服务号 |
24+ | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
25+ | ![ 微信订阅号 ] ( https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_3.png ) | ![ 微信服务号 ] ( https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_4.png ) |
You can’t perform that action at this time.
0 commit comments