11package com .sensorsdata .analytics .javasdk ;
22
3- import com .sensorsdata .analytics .javasdk .bean .EventRecord ;
4- import com .sensorsdata .analytics .javasdk .bean .ItemRecord ;
5- import com .sensorsdata .analytics .javasdk .bean .SuperPropertiesRecord ;
6- import com .sensorsdata .analytics .javasdk .bean .UserRecord ;
3+ import com .sensorsdata .analytics .javasdk .bean .*;
74import com .sensorsdata .analytics .javasdk .consumer .ConcurrentLoggingConsumer ;
85
9- import java .util .ArrayList ;
10- import java .util .Calendar ;
11- import java .util .List ;
6+ import java .util .*;
127
138/**
149 * @author fz
@@ -32,7 +27,6 @@ public static void main(final String[] args) throws Exception {
3227
3328 // 1. 用户匿名访问网站,cookieId 默认神策生成分配
3429 String cookieId = "ABCDEF123456789" ;
35-
3630 // 1.1 访问首页
3731 // 前面有$开头的property字段,是SA提供给用户的预置字段
3832 // 对于预置字段,已经确定好了字段类型和字段的显示名
@@ -126,13 +120,36 @@ public static void main(final String[] args) throws Exception {
126120 //物品纬度表上报
127121 String itemId = "product001" , itemType = "mobile" ;
128122 ItemRecord addRecord = ItemRecord .builder ().setItemId (itemId ).setItemType (itemType )
129- .addProperty ("color" , "white" )
130- .build ();
123+ .addProperty ("color" , "white" )
124+ .build ();
131125 sa .itemSet (addRecord );
132126
133127 //删除物品纬度信息
134128 ItemRecord deleteRecord = ItemRecord .builder ().setItemId (itemId ).setItemType (itemType )
135- .build ();
129+ .build ();
136130 sa .itemDelete (deleteRecord );
131+
132+ //Id-mapping
133+ SensorsAnalyticsIdentity identity = SensorsAnalyticsIdentity .builder ()
134+ .
addIdentityProperty (
"email" ,
"[email protected] " )
135+ .build ();
136+ Map <String , Object > properties = new HashMap <String , Object >();
137+ properties .put ("Channel" , "baidu" );
138+ sa .trackById (identity , "test" , properties );
139+ SensorsAnalyticsIdentity identity1 = SensorsAnalyticsIdentity .builder ()
140+ .addIdentityProperty ("login_id" , "fz123" )
141+ .build ();
142+ sa .bind (identity , identity1 );
143+ sa .profileSetById (identity , "age" , 15 );
144+ List <String > sports = new ArrayList <String >();
145+ sports .add ("swim" );
146+ sports .add ("run" );
147+ Map <String , Object > hh = new HashMap <String , Object >();
148+ hh .put ("sport" , sports );
149+ sa .profileSetById (identity , hh );
150+ sa .profileIncrementById (identity , "age" , 1 );
151+ sa .profileAppendById (identity , "sport" , "ball" );
152+ sa .profileUnsetById (identity ,"sport" );
153+ sa .profileDeleteById (identity );
137154 }
138155}
0 commit comments