Browse Source

feat: 新增用户code埋点

huangzhichao 1 year ago
parent
commit
6ad40fd286

+ 1 - 0
src/http/api/index.ts

@@ -4,6 +4,7 @@ import { BASE_DOMAIN, INVITE_API_DOMAIN, BASE_COMMON_DOMAIN } from './base'
 function env(BASE_DOMAIN) {
 function env(BASE_DOMAIN) {
   // const envApi = Taro.getStorageSync('env')
   // const envApi = Taro.getStorageSync('env')
   return BASE_DOMAIN['staging']
   return BASE_DOMAIN['staging']
+  // return BASE_DOMAIN['development']
 }
 }
 
 
 export const adSelfPredict =  `${env(INVITE_API_DOMAIN)}/ad/alliance/self/predict`
 export const adSelfPredict =  `${env(INVITE_API_DOMAIN)}/ad/alliance/self/predict`

+ 2 - 1
src/pages/index/index.tsx

@@ -16,7 +16,8 @@ const Index: React.FC = () => {
       envVersion: 'trial'
       envVersion: 'trial'
     })
     })
   }
   }
-
+  // 测试 ADY_17097254415021673
+  // 正式 ADY_17103126327291030
   return (
   return (
     <View className='index'>
     <View className='index'>
       <custom props={{ onEmitOpenMiniProgram, adpId: 'ADY_17103126327291030', width:250 }}/>
       <custom props={{ onEmitOpenMiniProgram, adpId: 'ADY_17103126327291030', width:250 }}/>

+ 4 - 3
src/plugin/components/custom/index.tsx

@@ -28,7 +28,6 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   const [adData, setAdData] = useState<any>({})
   const [adData, setAdData] = useState<any>({})
 
 
   useReady(() => {
   useReady(() => {
-    console.log('YLQCustom init', Taro.$global)
     init()
     init()
     pqtId = generateUUID()
     pqtId = generateUUID()
     getAdConfig()
     getAdConfig()
@@ -110,7 +109,6 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
       'wx5ef216d1caf4a0ea',
       'wx5ef216d1caf4a0ea',
       `/pages/ad-launch-page/index?q=${path}`
       `/pages/ad-launch-page/index?q=${path}`
     )
     )
-
     console.log(`/pages/ad-launch-page/index?q=${path}`)
     console.log(`/pages/ad-launch-page/index?q=${path}`)
   }
   }
 
 
@@ -170,6 +168,8 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
       adType: ownAdSystemType
       adType: ownAdSystemType
     } = adData
     } = adData
 
 
+    const userCode = Taro.$global.userCode || Taro.getStorageSync('userCode') || ''
+
     return {
     return {
       adpCode: trafficCode,
       adpCode: trafficCode,
       advertiserCode,
       advertiserCode,
@@ -186,7 +186,8 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
       bidCreativeParam: JSON.stringify(bidCreativeParam || {}), // {}
       bidCreativeParam: JSON.stringify(bidCreativeParam || {}), // {}
       adpId,
       adpId,
       pqtId,
       pqtId,
-      ownAdSystemType
+      ownAdSystemType,
+      userCode
     }
     }
   }
   }
 
 

+ 8 - 1
src/plugin/index.ts

@@ -2,8 +2,15 @@ import Taro from '@tarojs/taro'
 
 
 function loadPlugin() {
 function loadPlugin() {
   Taro.$global = createTaroGlobal()
   Taro.$global = createTaroGlobal()
-  console.log('main', Taro.$global)
   listenNetwork()
   listenNetwork()
+
+  Taro.pluginLogin({
+    success(res) {
+      const { code } = res || {}
+      Taro.$global.userCode = code
+      Taro.setStorageSync('userCode', code)
+    }
+  })
 }
 }
 
 
 function createTaroGlobal() {
 function createTaroGlobal() {