com.hina.sdk.event.EventReq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of HinaCloudSDK Show documentation
Show all versions of HinaCloudSDK Show documentation
The official Java SDK of Hina Analytics
The newest version!
package com.hina.sdk.event;
import java.util.HashMap;
import java.util.Map;
import com.hina.sdk.HinaSdk;
/**
* 事件请求model
*/
public class EventReq {
private String userUid; //用户ID
private String eventName; //事件名称
private Map data; //发送数据
private boolean isLogin; //是否登录
private Map superProperties; //公共属性
private String type; //请求类型
private Long time; //事件的时间,13位,单位毫秒
public EventReq(){}
public EventReq(String userUid, String eventName, Map data, Long time, Boolean isLogin, String type, Map superProperties) {
this.userUid = userUid;
this.eventName = eventName;
this.time = time;
this.data = handlerMapMacLength(data);
this.superProperties = handlerMapMacLength(superProperties);
this.isLogin=isLogin;
this.type=type;
}
/**
* 处理map中key的长度超过设定值的情况
* @param map
* @return
*/
public Map handlerMapMacLength(Map map){
Map newmap=new HashMap<>();
if(map==null)return newmap;
int maxlength=HinaSdk.getAttributeValueMaxLength();
map.forEach((k,v)->{
if(v instanceof String){
String strValue = (String) v;
if (strValue.length() > maxlength) {
newmap.put(k, strValue.substring(0, maxlength));
}else{
newmap.put(k,v);
}
}else{
newmap.put(k,v);
}
});
return newmap;
}
public Long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public Map getSuperProperties() {
return superProperties;
}
public void setSuperProperties(Map superProperties) {
this.superProperties = superProperties;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUserUid() {
return userUid;
}
public void setUserUid(String userUid) {
this.userUid = userUid;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public Map getData() {
return data;
}
public void setData(Map data) {
this.data = data;
}
public boolean isLogin() {
return isLogin;
}
public void setLogin(boolean login) {
isLogin = login;
}
}