Merge branch 'feature/20250910-all' into feature/20251001-gil
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import * as amplitude from '@amplitude/analytics-browser'
|
||||
import type { AnalyticsDetailType, AnalyticsLogDataTracking } from '../types/AnalyticsType'
|
||||
import type {
|
||||
AnalyticsDetailType,
|
||||
AnalyticsLogDataTracking,
|
||||
} from '../types/AnalyticsType'
|
||||
import type { PageDataResourceGroup } from '#layers/types/api/pageData'
|
||||
import type { IdentityInfo, ActionInfo, MarketingInfo } from '../types/Stove81Plug'
|
||||
import type { IdentityInfo, ActionInfo, MarketingInfo } from '../types/Stove'
|
||||
|
||||
declare const svcLog: any
|
||||
declare const twq: any
|
||||
@@ -24,26 +27,31 @@ export const useAnalyticsLogData = (
|
||||
return ref({} as AnalyticsDetailType)
|
||||
}
|
||||
|
||||
const pageDataTrack = (typeof resourcesData.tracking === 'object' ? resourcesData.tracking : {}) as AnalyticsLogDataTracking
|
||||
const pageDataTrack = (
|
||||
typeof resourcesData.tracking === 'object' ? resourcesData.tracking : {}
|
||||
) as AnalyticsLogDataTracking
|
||||
console.log('🚀 ~ useAnalyticsLogData ~ pageDataTrack:', pageData)
|
||||
|
||||
const logData = ref({
|
||||
actionType: pageDataTrack?.action_type,
|
||||
// logSourceType:pageDataTrack.logSourceType,
|
||||
// viewArea:pageDataTrack.viewArea,
|
||||
// viewType:pageDataTrack.viewType,
|
||||
clickArea:pageData.page_name_en,
|
||||
clickArea: pageData.page_name_en,
|
||||
clickSarea: pageData.templates[pageVerTmplSeq].page_ver_tmpl_name_en,
|
||||
clickItem: `${pageData.templates[pageVerTmplSeq].page_ver_tmpl_name}_${pageDataTrack?.click_item}`,
|
||||
event: pageData.page_name,
|
||||
eventCategory: `${pageData.page_name}_${pageDataTrack?.click_item}`,
|
||||
template_code: pageData.templates[pageVerTmplSeq].template_code,
|
||||
page_ver_tmpl_name: pageData.templates[pageVerTmplSeq].page_ver_tmpl_name,
|
||||
page_ver_tmpl_name_en: pageData.templates[pageVerTmplSeq].page_ver_tmpl_name_en,
|
||||
page_ver_tmpl_name_en:
|
||||
pageData.templates[pageVerTmplSeq].page_ver_tmpl_name_en,
|
||||
} as unknown as AnalyticsDetailType)
|
||||
|
||||
return logData
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
* 페이지 데이터와 템플릿 정보를 기반으로 분석용 로그 데이터를 생성하는 composable (직접 객체 반환)
|
||||
* @param resourcesData 페이지 리소스 데이터
|
||||
@@ -82,10 +90,15 @@ export const useAnalyticsLogDataDirect = (
|
||||
}
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> feature/20250910-all
|
||||
// target에 {XX1, XX2}와 같은 형태가 포함되어 있을 경우 options.clickItem으로부터 값 추출하여 세팅
|
||||
const findValueFromOption = (target: string, { options = {} }: any) => {
|
||||
if (target.includes('{') && target.includes('}')) {
|
||||
const strTargetClickItem = target.substring(target.indexOf('{') + 1, target.indexOf('}'))
|
||||
const strTargetClickItem = target.substring(
|
||||
target.indexOf('{') + 1,
|
||||
target.indexOf('}')
|
||||
)
|
||||
|
||||
const arrTargetClickItem = strTargetClickItem.split(',')
|
||||
const arrTargetClickItemValue = []
|
||||
@@ -94,7 +107,10 @@ const findValueFromOption = (target: string, { options = {} }: any) => {
|
||||
targetClickItem = targetClickItem.trim()
|
||||
arrTargetClickItemValue.push(options.clickItem[targetClickItem])
|
||||
}
|
||||
target = target.replaceAll(`{${strTargetClickItem}}`, arrTargetClickItemValue.join(','))
|
||||
target = target.replaceAll(
|
||||
`{${strTargetClickItem}}`,
|
||||
arrTargetClickItemValue.join(',')
|
||||
)
|
||||
}
|
||||
return target
|
||||
}
|
||||
@@ -106,6 +122,10 @@ const findValueFromOption = (target: string, { options = {} }: any) => {
|
||||
* @param {object} options
|
||||
*/
|
||||
const sendGA = (analytics: AnalyticsDetailType, { options = {} }: any) => {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
console.log('🚀 ~ 1111 sendGA ~ analytics:', analytics)
|
||||
>>>>>>> feature/20250910-all
|
||||
try {
|
||||
const { gtag } = useGtag()
|
||||
|
||||
@@ -119,7 +139,7 @@ const sendGA = (analytics: AnalyticsDetailType, { options = {} }: any) => {
|
||||
gtag('set', 'cookie_domain', `${window?.location?.hostname || ''}`) // env 값으로 설정 시 쿠키 생성 안 돼서 window.location.hostname으로 설정
|
||||
gtag('set', 'cookie_expires', '0') // 0으로 설정 시 쿠키가 Session 기반 쿠키로 전환
|
||||
gtag('event', `${eventName}`, {
|
||||
event_category: eventLabel
|
||||
event_category: eventLabel,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('[Exception] useAnalytics.sendGA: ', e)
|
||||
@@ -133,8 +153,15 @@ const sendGA = (analytics: AnalyticsDetailType, { options = {} }: any) => {
|
||||
* @param {string} mcode
|
||||
* @param {object} options
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options = {} }: any) => {
|
||||
console.log("🚀 ~44444 sendSA ~ analytics:", analytics)
|
||||
=======
|
||||
const sendSA = (
|
||||
analytics: AnalyticsDetailType,
|
||||
{ mcode = '', options = {} }: any
|
||||
) => {
|
||||
>>>>>>> feature/20250910-all
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameData } = storeToRefs(gameDataStore)
|
||||
|
||||
@@ -152,7 +179,13 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
const viewArea = analytics.viewArea || ''
|
||||
const viewType = analytics.viewType || ''
|
||||
const clickArea = analytics.clickArea || ''
|
||||
<<<<<<< HEAD
|
||||
const clickSarea = findValueFromOption(analytics.clickSarea || '', { _options })
|
||||
=======
|
||||
const clickSarea = findValueFromOption(analytics.clickSarea || '', {
|
||||
options,
|
||||
})
|
||||
>>>>>>> feature/20250910-all
|
||||
const eventLocale = analytics.eventLocale || ''
|
||||
|
||||
const identityInfo: IdentityInfo = {
|
||||
@@ -162,14 +195,14 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
locale: eventLocale,
|
||||
lang_cd: eventLocale,
|
||||
member_no: memberNo,
|
||||
channeling_cd: 'SO'
|
||||
channeling_cd: 'SO',
|
||||
}
|
||||
|
||||
const marketingInfo: MarketingInfo = {
|
||||
marketing_code: mcode || '',
|
||||
device_type: deviceType,
|
||||
media_type: '',
|
||||
media_page: ''
|
||||
media_page: '',
|
||||
}
|
||||
|
||||
let actionParam = {}
|
||||
@@ -181,8 +214,13 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
view_info: {
|
||||
game_no: gameNo,
|
||||
lang_cd: eventLocale,
|
||||
<<<<<<< HEAD
|
||||
..._options?.viewInfo
|
||||
}
|
||||
=======
|
||||
...options?.viewInfo,
|
||||
},
|
||||
>>>>>>> feature/20250910-all
|
||||
}
|
||||
} else if (actionType === 'click') {
|
||||
actionParam = {
|
||||
@@ -192,21 +230,26 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
click_item: analytics.clickItem,
|
||||
game_no: gameNo,
|
||||
lang_cd: eventLocale,
|
||||
<<<<<<< HEAD
|
||||
..._options?.clickItem
|
||||
}
|
||||
=======
|
||||
...options?.clickItem,
|
||||
},
|
||||
>>>>>>> feature/20250910-all
|
||||
}
|
||||
}
|
||||
|
||||
const actionInfo: ActionInfo = {
|
||||
action_type: actionType,
|
||||
action_param: actionParam,
|
||||
marketing_info: marketingInfo
|
||||
marketing_info: marketingInfo,
|
||||
}
|
||||
|
||||
const amplitudeActionInfo = {
|
||||
...actionInfo,
|
||||
url: `${location?.href || ''}`,
|
||||
agent: `${navigator?.userAgent || ''}`
|
||||
agent: `${navigator?.userAgent || ''}`,
|
||||
}
|
||||
|
||||
const amplitudeActionParams: {
|
||||
@@ -214,7 +257,7 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
event_properties: ActionInfo & { url: string; agent: string }
|
||||
} = {
|
||||
event_type: actionType,
|
||||
event_properties: amplitudeActionInfo
|
||||
event_properties: amplitudeActionInfo,
|
||||
}
|
||||
|
||||
svcLog.identity(identityInfo)
|
||||
@@ -232,9 +275,12 @@ const sendSA = (analytics: AnalyticsDetailType, { mcode = '', options: _options
|
||||
* @param {AnalyticsDetailType} analytics
|
||||
*/
|
||||
const sendLog = (locale: string, analytics: AnalyticsDetailType) => {
|
||||
<<<<<<< HEAD
|
||||
console.log("🚀 ~33333 sendLog ~ analytics:", analytics)
|
||||
=======
|
||||
console.log('🚀 ~ sendLog ~ analytics:', analytics)
|
||||
>>>>>>> feature/20250910-all
|
||||
|
||||
|
||||
// 언어 코드 대문자 변환
|
||||
analytics.eventLocale = locale.toUpperCase()
|
||||
|
||||
@@ -243,7 +289,7 @@ console.log("🚀 ~33333 sendLog ~ analytics:", analytics)
|
||||
sendGA(analytics, { options: analytics.options })
|
||||
// SA 전송 : actionType, logSourceType 유무로 판별
|
||||
if (
|
||||
analytics.actionType &&
|
||||
analytics.actionType &&
|
||||
analytics.actionType !== ''
|
||||
// analytics.logSourceType &&
|
||||
// analytics.logSourceType !== ''
|
||||
@@ -327,7 +373,7 @@ const sendMarketingScript = ({
|
||||
gaEventName,
|
||||
fbEventName,
|
||||
twEventName,
|
||||
ttEventName
|
||||
ttEventName,
|
||||
}: {
|
||||
gaEventName?: string
|
||||
fbEventName?: string
|
||||
|
||||
Reference in New Issue
Block a user