Ackee 调整

This commit is contained in:
tangly1024.com
2023-08-01 15:58:31 +08:00
parent e44a35fd3a
commit 4b7564e018
3 changed files with 27 additions and 8 deletions

View File

@@ -4,10 +4,11 @@ import { useEffect } from 'react'
import BLOG from '@/blog.config'
import { loadExternalResource } from '@/lib/utils'
import { useRouter } from 'next/router'
const Ackee = () => {
const router = useRouter()
useEffect(() => {
// handleAckee 函数
const handleAckeeCallback = () => {
handleAckee(
router.asPath,
{
@@ -15,10 +16,28 @@ const Ackee = () => {
domainId: BLOG.ANALYTICS_ACKEE_DOMAIN_ID
},
{
detailed: false,
ignoreLocalhost: false
/*
* Enable or disable tracking of personal data.
* We recommend to ask the user for permission before turning this option on.
*/
detailed: true,
/*
* Enable or disable tracking when on localhost.
*/
ignoreLocalhost: false,
/*
* Enable or disable the tracking of your own visits.
* This is enabled by default, but should be turned off when using a wildcard Access-Control-Allow-Origin header.
* Some browsers strictly block third-party cookies. The option won't have an impact when this is the case.
*/
ignoreOwnVisits: false
}
)
}
// 或者使用其他依赖数组,根据需要执行 handleAckee
useEffect(() => {
handleAckeeCallback()
}, [router])
return null

View File

@@ -56,12 +56,12 @@ const CommonScript = () => {
{/* 代码统计 */}
{/* ackee统计脚本 */}
{BLOG.ANALYTICS_ACKEE_TRACKER && (
{/* {BLOG.ANALYTICS_ACKEE_TRACKER && (
<script async src={BLOG.ANALYTICS_ACKEE_TRACKER}
data-ackee-server={BLOG.ANALYTICS_ACKEE_DATA_SERVER}
data-ackee-domain-id={BLOG.ANALYTICS_ACKEE_DOMAIN_ID}
/>
)}
)} */}
{/* 百度统计 */}
{BLOG.ANALYTICS_BAIDU_ID && (

View File

@@ -46,11 +46,11 @@ export function loadExternalResource(url, type) {
}
if (tag) {
tag.onload = () => {
console.log(url, '加载成功')
console.log('Load Success', url)
resolve(url)
}
tag.onerror = () => {
console.log(url, '加载失败')
console.log('Load Error', url)
reject(url)
}
document.head.appendChild(tag)