diff --git a/public/config.yaml b/public/config.yaml index e46925f..9265335 100644 --- a/public/config.yaml +++ b/public/config.yaml @@ -16,6 +16,7 @@ URLS: #data: /assets/data # DATA_URL: ${DATA_PATH}/dist/info.json data: /getdata + trackit: /trackit send: /info htmlAttrs: bold: #itm-title diff --git a/src/hooks/tracking.ts b/src/hooks/tracking.ts index f31d113..b9f0432 100644 --- a/src/hooks/tracking.ts +++ b/src/hooks/tracking.ts @@ -2,16 +2,19 @@ import useState from '~/hooks/useState' import { MessageType, TrackActionType } from '~/typs' import { show_message,send_data} from '~/hooks/utils' -export const track_action = async(e: any, src?: {ref: string,text?: string}, act = 'click') => { - const url = useState().CONFURLS.value.tracking || '' +export const track_action = async(e: any, src?: {ref: string,text?: string,lng?: string}, routeKy?: string, act = 'click') => { + const url = useState().CONFURLS.value.trackit || '' if (url.length == 0) { return } + const routeKey = routeKy.length > 0 ? routeKy : 'public' let href='' let text='' + let lang='' if (src && src.ref && src.ref.length > 0 ) { href=src.ref text=src.text ? src.text : src.ref + lang=src.lng ? src.lng : navigator.language } else if (e && e.target) { switch(e.target.tagName) { case 'IMG': @@ -32,12 +35,12 @@ export const track_action = async(e: any, src?: {ref: string,text?: string}, act } const trackAction: TrackActionType = { when: Date.now().toString(), - where: `${useState().APPNAME.value}>${text}: ${href}`, + where: `app=${useState().APPNAME.value}|ref=${href}|target=${text}`, what: act, - context: navigator.userAgent, - data: useState().userID.value, + context: `lng=${lang}|nvlng=${navigator.language}|ag=${navigator.userAgent}`, + data: useState().userID.value.length > 0 ? useState().userID.value.length : routeKey, } - const [_res,err] = await send_data(url, trackAction, true, true) + const [_res,err] = await send_data(url, trackAction, false, true) if (err && err.length > 0 ) { show_message(MessageType.Error, `Error: ${err}`,2000) }