smart_web_data_sdk icon indicating copy to clipboard operation
smart_web_data_sdk copied to clipboard

老哥 这个在vue项目中怎么引入啊

Open xdyz opened this issue 5 years ago • 12 comments

xdyz avatar Sep 17 '19 09:09 xdyz

一个直接在html页面里引入build下的文件(打包好的),还有就是参考loader里的文件引入方式。

534591395 avatar Sep 17 '19 09:09 534591395

用的脚手架3 没有html

xdyz avatar Sep 17 '19 09:09 xdyz

一个直接在html页面里引入build下的文件(打包好的),还有就是参考loader里的文件引入方式。

就是说 我reruire 进去 然后在插件里面new就可以了吗?

xdyz avatar Sep 17 '19 10:09 xdyz

一个直接在html页面里引入build下的文件(打包好的),还有就是参考loader里的文件引入方式。

老哥 这个具体的引入 是怎么样的啊 还是搞不懂

xdyz avatar Sep 18 '19 01:09 xdyz

import SMARTLib from '../src/main'

class LoaderSync { constructor() { window['smart'] = this; } init(token, config) { if (this['__loaded']) { return ; } this.instance = new SMARTLib(token, config); this.instance.init = this['init']; window['smart'] = this.instance; } }

new LoaderSync();

类似这样

534591395 avatar Sep 18 '19 01:09 534591395

import SMARTLib from '../src/main'

class LoaderSync { constructor() { window['smart'] = this; } init(token, config) { if (this['__loaded']) { return ; } this.instance = new SMARTLib(token, config); this.instance.init = this['init']; window['smart'] = this.instance; } }

new LoaderSync();

类似这样

我在我的vue 的index.html文件中引入了这个 也初始化了 但是好像跳转 按钮点击都没有发送请求啊 浏览器的回退前进可以 我用的vuerouter 配合elementui导航 的跳转就不起作用了 这个怎么回事

xdyz avatar Sep 18 '19 03:09 xdyz

开启了PV单页面监听了不?点击按钮加了埋点没? 不行的话,你调试下源码看看?源码很简单的,都加了注释。

534591395 avatar Sep 18 '19 03:09 534591395

开启了PV单页面监听了不?点击按钮加了埋点没? 不行的话,你调试下源码看看?源码很简单的,都加了注释。

老哥 那就是说对于所有的按钮点击事件 我都需要去 加入
document.getElementsByTagName('h1')[0].onclick = function(e) { smart.login(document.getElementById('userId').value); } 类似于这种方式 对吧

xdyz avatar Sep 18 '19 03:09 xdyz

是的。无埋点模块我没上传的,这个很简单,你可以自己实现下。这方面你也可以看下我另一个采集器的实现。 这个采集器主要还是代码埋点为主。

534591395 avatar Sep 18 '19 03:09 534591395

明白了 我得对所有的点击事件进行smart.xxx({})进行 埋点 对吧

xdyz avatar Sep 18 '19 03:09 xdyz

是的。无埋点模块我没上传的,这个很简单,你可以自己实现下。这方面你也可以看下我另一个采集器的实现。 这个采集器主要还是代码埋点为主。

老哥 怎么结合你这个代码 实现一个无埋点的方式啊 我不知道怎么去修改你这个代码

xdyz avatar Sep 19 '19 06:09 xdyz

其实很简单的,比如全局监听click事件,然后拿到元素的信息,元素事先加些要采集的内容,再调用下track方法就好了。

534591395 avatar Sep 19 '19 07:09 534591395