特色专区前端埋点

This commit is contained in:
qiukai 2024-11-27 08:43:17 +08:00
parent 347c7721d9
commit b62bc25370
11 changed files with 175 additions and 6 deletions

View File

@ -9,6 +9,8 @@ import RenderHtml from '../../../components/render-html';
import { Base64 } from 'js-base64';
import { getTocContent } from '../../../common/marked';
import TreeByWikiSidebar from '../../Wiki/components/treeByWikiSidebar';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
function ProjectSource(props) {
const [loading, setLoading] = useState(false);
@ -102,7 +104,17 @@ function ProjectSource(props) {
})
}, [wikiDetail])
useEffect(() =>{
//
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
//
const handleClick = (event) => {
let target = event.target;

View File

@ -1,4 +1,4 @@
import React,{ } from 'react';
import React,{ useEffect , useState } from 'react';
import Introduction from './component/introduction';
import News from './component/news';
import Project from './component/project';
@ -8,8 +8,21 @@ import Partner from './component/partner';
import SpecialProjects from './component/specialProjects';
import '../../indexZone1.scss'
import './index.scss'
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../../utils'
import {setZoneVisits} from '../../api'
function HeaderPageUos(props){
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
const { data } = props;
return(

View File

@ -13,6 +13,8 @@ import DefaultImg from '../Component/defaultImg';
import { getNewsAllList , getNewsHotList } from '../api';
import { tempConfig, tempEnum } from '../tempInfo';
import { httpUrl } from '../fetch';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
function Main(props){
@ -26,7 +28,16 @@ function Main(props){
const { deptId , cateId } = props.match.params;
const { id, temp, role, history, sectionCmsTitle } = props;
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
const menu = (
<Menu>
<Menu.Item>

View File

@ -12,6 +12,8 @@ import CommentList from '../Component/comments/list'
import { connect } from 'react-redux';
import { withRouter } from "react-router";
import { setZoneDetail, setNewsDetail } from '../../../redux/actions/server';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
function NewsDetail(props){
@ -28,6 +30,16 @@ function NewsDetail(props){
setMeta()
}
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
useEffect(()=>{
let initialContent = undefined;
//

View File

@ -8,7 +8,8 @@ import axios from 'axios';
import { getProjectsLists , getProjectsTypeLists } from '../api';
import nodata from '../img/nodata.png';
import { tempEnum } from '../tempInfo';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils'
import {setZoneVisits} from '../api'
const { Search } = Input;
function ProjectSource(props){
@ -23,6 +24,16 @@ function ProjectSource(props){
const [ value , setValue ] = useState(undefined);
const [ loading , setLoading ] = useState(false);
const { id, temp, sectionProjectTitle } = props;
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
useEffect(()=>{
if(id){

View File

@ -8,6 +8,8 @@ import Nodata from '../../Nodata';
import ImgGreen from '../img/green_nodata.png';
import '../indexZone1.scss';
import { FlexAJ } from '../../Component/layout';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
const { Search } = Input;
@ -25,6 +27,17 @@ function Source(props){
const limit = 21;
const { id , temp, history, role, sectionResourceTitle } = props;
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
useEffect(()=>{
id && getLists();
},[id,chooseTypeId,chooseZoneId,page,search])

View File

@ -7,6 +7,8 @@ import { httpUrl } from '../fetch';
import { AlignCenter, FlexAJ } from '../../Component/layout';
import SourceIcon from '../img/sourceIcon.png';
import { addMeta, setSeoMeta } from 'educoder';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
function SourceDetail(props){
@ -15,6 +17,17 @@ function SourceDetail(props){
const zonedetail = props.data;
const {temp} = props;
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
useEffect(()=>{
if(sourceid){
getDetails();

View File

@ -8,6 +8,8 @@ import MemberApply from '../Component/memberApply';
import { getVIPLists, getAuditStatus, applyJoin } from '../api';
import nodata from '../img/nodata.png';
import MemberList from '../Component/memberList';
import {getUniqueIdentifier,getUserName,getBrowserPlatform,getBrowserBrand} from '../utils';
import {setZoneVisits} from '../api'
import '../indexZone1.scss';
@ -25,6 +27,17 @@ function ZoneVIP(props){
const [ memberStatus , setMemberStatus] = useState(memberStatusEnum.notMember);
const { id, showNotification, checkIfLogin, showLoginDialog, temp, sectionMemberTitle } = props;
useEffect(()=>{
let uuid = getUniqueIdentifier()
let url = props.location.pathname
let platform = getBrowserPlatform()
let browser = getBrowserBrand()
let username = getUserName(props.current_user)
// if(!username) uuid = getUniqueIdentifier()
let remark = ` 操作系统:${platform};浏览器:${browser};`
setZoneVisits({url,username,uuid,remark})
},[])
useEffect(()=>{
if(id){
setIsSpin(true);

View File

@ -439,3 +439,11 @@ export function getRoleList(){
})
}
// 组织升级为企业
export function setZoneVisits(data) {
return fetch({
url: `/zone/open/zoneVisits`,
method: 'POST',
data
})
}

View File

@ -115,7 +115,6 @@ function Index(props){
const sourcedetail = pathname.indexOf(`/zone/${deptId}/newdetail/`)>-1 && isPhone();
const {current_user} = props;
console.log('deptId', deptId);
useEffect(()=>{
@ -149,8 +148,9 @@ function Index(props){
}
setData(data);
document.title= data && data.mainTitle;
setId(data.id);
if(data.id){
if(data && data.id){
setId(data.id);
getAdminUrl(data.id);
getRole(data.id)
}

View File

@ -0,0 +1,63 @@
export const generateUUID = () => { //生成uuid
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
export const getUniqueIdentifier = () => { //获取uuid
let uniqueId = localStorage.getItem('uniqueId');
if (!uniqueId) {
uniqueId = generateUUID();
localStorage.setItem('uniqueId', uniqueId);
}
return uniqueId;
}
export const getUserName = (user) => { //获取用户名
if(user && user.username) return user.username
return ''
}
export const getBrowserPlatform = () => {
const userAgent = navigator.userAgent;
let platform;
if (userAgent.indexOf("Win") !== -1) {
platform = "Windows";
} else if (userAgent.indexOf("Mac") !== -1) {
platform = "MacOS";
} else if (userAgent.indexOf("X11") !== -1 || userAgent.indexOf("Linux") !== -1) {
platform = "Linux";
} else if (userAgent.indexOf("Android") !== -1) {
platform = "Android";
} else if (userAgent.indexOf("like Mac") !== -1) {
platform = "iOS";
} else {
platform = "Unknown";
}
return platform;
}
export const getBrowserBrand = () => { //获取浏览器信息
const userAgent = navigator.userAgent;
let brand = "Unknown";
// 检测浏览器品牌
if (userAgent.includes("Chrome")) {
brand = "Chrome";
} else if (userAgent.includes("Firefox")) {
brand = "Firefox";
} else if (userAgent.includes("Safari") && !userAgent.includes("Chrome")) {
brand = "Safari";
} else if (userAgent.includes("MSIE") || userAgent.includes("Trident")) {
brand = "Internet Explorer";
} else if (userAgent.includes("Edge")) {
brand = "Edge";
} else if (userAgent.includes("Opera") || userAgent.includes("OPR")) {
brand = "Opera";
}
return brand;
}