Commit 9c8ab939 authored by 郝聪敏's avatar 郝聪敏

feature: 神策埋点添加自定义属性

parent 9ecf9bc1
......@@ -39,6 +39,7 @@ import { mapState, mapActions } from "vuex";
import protocol from "@/api/protocol";
import { authByxyqb } from "@/api/user";
import localStorage from "@/service/localStorage";
import { loginSa } from "@/service/utils";
export default {
name: "AuthFromXyqb",
......@@ -88,6 +89,7 @@ export default {
async confirm() {
const res = await authByxyqb({ xyqbToken: localStorage.get("xyqbToken") });
localStorage.set("mongoToken", res.token);
loginSa(res.userSecId);
this.setAuthXyqb(4);
},
showProtocol(idx) {
......
......@@ -53,6 +53,8 @@ import { loginByPhone, getCaptchaSms } from "@/api/user";
import protocol from "@/api/protocol";
import { isPhone, isWeixinBrower } from "@/service/validation";
import localStorage from "@/service/localStorage";
import { loginSa } from "@/service/utils";
export default {
name: "LoginModal",
components: {
......@@ -108,6 +110,7 @@ export default {
this.$notify({ type: "success", message: "登录成功" });
this.setIsShowLogin(false);
localStorage.set("mongoToken", res.token);
loginSa(res.userSecId);
// TODO 开发目前使用这个token
// localStorage.setItem("mongoToken", "6ae7da7dd4c543f1a36c702c6f419f12");
}
......
......@@ -7,5 +7,5 @@ export default {
// basicHost: "http://192.168.29.211:8964/",
wxAppId: "wx514de17b23d53a20",
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=default`, // 神策数据请求地址
test: false
test: true
};
......@@ -7,5 +7,5 @@ export default {
sharePath: "https://mangguo.qthbx.com/share.html#",
wxAppId: "wx514de17b23d53a20",
shenceUrl: `${protocol}//bn.xyqb.com/sa?project=production`, // 神策数据请求地址
test: false
test: true
};
......@@ -11,6 +11,7 @@ import Raven from "raven-js";
import RavenVue from "raven-js/plugins/vue";
import config from "@/config";
import { release } from "../.sentryclirc";
import { registerSa } from "./service/utils";
Vue.config.productionTip = false;
new Vue({
......@@ -40,8 +41,10 @@ sa.init({
},
show_log: config.test
});
// 添加公共属性
sa.registerPage({ platformType: "H5" });
registerSa();
router.afterEach(() => {
Vue.nextTick(() => {
sa.quick("autoTrackSinglePage");
......
import { isAndroid, isIOS } from "./validation";
import sa from "sa-sdk-javascript";
import uuidv1 from "uuid/v1";
import localStorage from "@/service/localStorage";
/**
* 替换邮箱字符
* @param {String} email 输入字符串
......@@ -317,3 +321,24 @@ export function onKeyboardStateChange(callback = () => {}, off = false) {
export function isValidDate(date) {
return date instanceof Date && !isNaN(date.getTime());
}
// 神策注册公共属性
export function registerSa() {
// 获取uuid表示设备唯一标识
let uuid_unloggin = localStorage.get("uuid_unloggin");
if (!uuid_unloggin) {
uuid_unloggin = uuidv1();
localStorage.set("uuid_unloggin", uuid_unloggin);
}
const saObj = { platformType: "H5", uuid_unloggin };
// 添加公共属性
sa.registerPage(saObj);
loginSa();
}
// 用户登录神策埋点
export function loginSa(uuid = localStorage.get("uuid")) {
if (!uuid) return;
localStorage.set("uuid", uuid);
sa.login(uuid);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment