Authored by 郁健超

有货推手首页资源位添加埋点&&曝光 reviewed by hy

... ... @@ -42,7 +42,7 @@ export default class EditorTalk extends Component {
}
}
_handleParamsJumpWithUrl(id, name, url) {
_handleParamsJumpWithUrl(id, name, url, clickData) {
// 为埋点提供参数组装
// 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件
// 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行
... ... @@ -51,6 +51,12 @@ export default class EditorTalk extends Component {
F_NAME: name,
F_URL: url
};
if (clickData) {
params = {
...clickData,
F_URL:url,
};
}
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'talk', params);
}
... ... @@ -68,6 +74,7 @@ export default class EditorTalk extends Component {
let { mainTitlelist, subTitlelist, contextlist, url } = this._handleData();
let image = this.props.image;
let {resource} = this.props;
let resourceData = resource.toJS();
if (!resource || resource.size === 0) {
return null;
... ... @@ -76,8 +83,9 @@ export default class EditorTalk extends Component {
<TouchableOpacity
activeOpacity={1}
style={{width: width, height: sliderHeight}}
yh_exposureData={resourceData.yh_exposureData}
onPress={() => {
this._handleParamsJumpWithUrl(resource.get('template_id'), resource.get('template_name'), url);
this._handleParamsJumpWithUrl(resourceData.template_id, resourceData.template_name, url, resourceData.yh_clickData);
}}
>
<Image
... ...
... ... @@ -26,13 +26,16 @@ export default class ImageFour extends React.Component {
}
}
_handleParamsJumpWithUrl(id, url) {
_handleParamsJumpWithUrl(id, url, clickData) {
// 为埋点提供参数组装
// 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件
// 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行
let params = {
ID: id
};
if (clickData) {
params = clickData;
}
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'icon', params);
}
... ... @@ -61,7 +64,7 @@ export default class ImageFour extends React.Component {
yh_exposureData={item.yh_exposureData}
style={{ width: sliderWidth, height: sliderHeight }}
onPress={() => {
this._handleParamsJumpWithUrl(i + 1, item.url);
this._handleParamsJumpWithUrl(i + 1, item.url, item.yh_clickData);
}}
>
<YH_Image
... ...
... ... @@ -25,7 +25,7 @@ export default class ImageSingle extends React.Component {
}
}
_handleParamsJumpWithUrl(id, name, url) {
_handleParamsJumpWithUrl(id, name, url, clickData) {
// 为埋点提供参数组装
// 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件
// 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行
... ... @@ -39,6 +39,9 @@ export default class ImageSingle extends React.Component {
ID: id,
};
}
if (clickData) {
params = clickData;
}
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'one', params);
}
... ... @@ -64,7 +67,7 @@ export default class ImageSingle extends React.Component {
yh_exposureData={list[0].yh_exposureData}
style={[{width: sliderWidth, height: sliderHeight},this.props.style]}
onPress={() => {
this._handleParamsJumpWithUrl(resource.get('template_id'), resource.get('template_name'), list[0].url);
this._handleParamsJumpWithUrl(resource.get('template_id'), resource.get('template_name'), list[0].url, list[0].yh_clickData);
}}
>
<YH_Image
... ...
... ... @@ -32,14 +32,18 @@ export default class ImageSlider extends React.Component {
}
}
_handleParamsJumpWithUrl(index, url) {
_handleParamsJumpWithUrl(index, url, clickData) {
// 为埋点提供参数组装
// 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件
// 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行
let params = {
I_INDEX: index,
F_URL: url
};
if (clickData) {
params = clickData;
}
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'banner', params);
}
... ... @@ -59,7 +63,7 @@ export default class ImageSlider extends React.Component {
yh_exposureData={data[0].yh_exposureData}
style={{width: sliderWidth, height: sliderHeight}}
onPress={() => {
this._handleParamsJumpWithUrl(1, data[0].url)
this._handleParamsJumpWithUrl(1, data[0].url, data[0].yh_clickData)
}}
>
<YH_Image
... ... @@ -95,7 +99,7 @@ export default class ImageSlider extends React.Component {
activeOpacity={1}
yh_exposureData={item.yh_exposureData}
onPress={() => {
this._handleParamsJumpWithUrl(i + 1, item.url);
this._handleParamsJumpWithUrl(i + 1, item.url, item.yh_clickData);
}}
>
<YH_Image
... ...
... ... @@ -26,7 +26,7 @@ export default class ImageTwo extends React.Component {
}
}
_handleParamsJumpWithUrl(id, name, url, i_index) {
_handleParamsJumpWithUrl(id, name, url, i_index, clickData) {
// 为埋点提供参数组装
// 后期请将所有的点击事件由 resourceJumpWithUrl 修改为自己独有的事件
// 由于多数组件都使用的 resourceJumpWithUrl ,埋点传参无法正常进行
... ... @@ -36,6 +36,9 @@ export default class ImageTwo extends React.Component {
F_URL: url,
I_INDEX: i_index
};
if (clickData) {
params = clickData;
}
this.props.resourceJumpWithUrl && this.props.resourceJumpWithUrl(url, 'two', params);
}
... ... @@ -66,7 +69,7 @@ export default class ImageTwo extends React.Component {
yh_exposureData={item.yh_exposureData}
style={{width: sliderWidth, height: sliderHeight, marginRight:10}}
onPress={() => {
this._handleParamsJumpWithUrl(resource.get('template_id'), resource.get('template_name'), item.url, i + 1);
this._handleParamsJumpWithUrl(resource.get('template_id'), resource.get('template_name'), item.url, i + 1, item.yh_clickData);
}}
>
<YH_Image
... ...
... ... @@ -114,13 +114,7 @@ class HomeContainer extends Component {
if (!url) {
return;
}
if (type === 'icon' && params) {
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_ICON_C', params);
} else if (type === 'banner' && params) {
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_BANNER_C', params);
} else if (type && params) {
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_ACTIVITY_C', params);
}
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_CPS_MAIN_EVENT', params);
ReactNative.NativeModules.YH_CommonHelper.jumpWithUrl(url);
}
... ...
... ... @@ -922,17 +922,7 @@ export function getResourceInfo(callback) {
dispatch(getResourceRequest());
return new AllianceService(app.host).fetchResourceInfo(CODE_ALLIANCE_BANNER_RESOURCE_CODE)
.then(json => {
let bannerList = json.length > 0 && json[0].data ? json[0].data : [];
bannerList.forEach(function (item, index) {
item.yh_exposureData = {
P_NAME: Platform.OS === 'ios' ? 'iFP_Alliance' : 'aFP_Alliance',
P_PARAM: CODE_ALLIANCE_BANNER_RESOURCE_CODE,
F_URL: item.url,
I_INDEX: index + 1,
exposureEnd: 1
};
return item
})
json = exposeHomeResource(json);
dispatch(getResourceSuccess(json));
callback && typeof callback === 'function' && callback(json)
... ... @@ -951,6 +941,66 @@ export function getResourceInfo(callback) {
};
}
function exposeHomeResource(json) {
if (!json) return json;
let pageName = 'iFP_Alliance';
if (Platform.OS === 'android') {
pageName = 'aFP_Alliance';
}
for (let i = 0; i < json.length; i++) {
let item = json[i]
let floorname = item.template_name;
let floorid = item.template_id;
let list = item.data;
if (floorname === 'image_list' || floorname === 'newSingleImage' || floorname === 'twoPicture') {
list = list && list.list;
}
if (list instanceof Array) {
for (let j = 0; j < list.length; j++) {
let subItem = list[j];
let url = subItem.url;
subItem.yh_exposureData = {
P_NAME: pageName,
P_PARAM: CODE_ALLIANCE_BANNER_RESOURCE_CODE,
F_ID: floorid,
F_NAME: floorname,
F_INDEX: +i + 1,
I_INDEX: parseInt(j) + 1 + "",
F_URL: url,
exposureEnd: 1,
}
subItem.yh_clickData = {
P_NAME: pageName,
P_PARAM: CODE_ALLIANCE_BANNER_RESOURCE_CODE,
F_ID: floorid,
F_NAME: floorname,
F_INDEX: +i + 1,
I_INDEX: parseInt(j) + 1 + "",
F_URL: url,
}
}
}else {
item.yh_exposureData = {
P_NAME: pageName,
P_PARAM: CODE_ALLIANCE_BANNER_RESOURCE_CODE,
F_ID: floorid,
F_NAME: floorname,
F_INDEX: +i + 1,
exposureEnd: 1,
}
item.yh_clickData = {
P_NAME: pageName,
P_PARAM: CODE_ALLIANCE_BANNER_RESOURCE_CODE,
F_ID: floorid,
F_NAME: floorname,
F_INDEX: +i + 1,
}
}
}
return json
}
export function getMessageResourceInfo() {
return (dispatch, getState) => {
let {app, alliance} = getState();
... ...