@@ -1054,104 +1054,83 @@ Countly.Bulk = Bulk;
10541054 * @param {string|number } value - value to store under provided property
10551055 * */
10561056 set_once ( key , value ) {
1057- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "set_once" , Countly . debug ) ;
1058- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "set_once" , Countly . debug ) ;
1059- change_custom_property ( key , value , "$setOnce" ) ;
1057+ Countly . userProfile . set_once ( key , value ) ;
10601058 } ,
10611059 /**
10621060 * Unset's/delete's user's custom property
10631061 * @param {string } key - name of the property to delete
10641062 * */
10651063 unset ( key ) {
1066- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "unset" , Countly . debug ) ;
1067- customData [ key ] = "" ;
1064+ Countly . userProfile . unset ( key ) ;
10681065 } ,
10691066 /**
10701067 * Increment value under the key of this user's custom properties by one
10711068 * @param {string } key - name of the property to attach to user
10721069 * */
10731070 increment ( key ) {
1074- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "increment" , Countly . debug ) ;
1075- change_custom_property ( key , 1 , "$inc" ) ;
1071+ Countly . userProfile . increment ( key ) ;
10761072 } ,
10771073 /**
10781074 * Increment value under the key of this user's custom properties by provided value
10791075 * @param {string } key - name of the property to attach to user
10801076 * @param {number } value - value by which to increment server value
10811077 * */
10821078 increment_by ( key , value ) {
1083- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "increment_by" , Countly . debug ) ;
1084- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "increment_by" , Countly . debug ) ;
1085- change_custom_property ( key , value , "$inc" ) ;
1079+ Countly . userProfile . increment_by ( key , value ) ;
10861080 } ,
10871081 /**
10881082 * Multiply value under the key of this user's custom properties by provided value
10891083 * @param {string } key - name of the property to attach to user
10901084 * @param {number } value - value by which to multiply server value
10911085 * */
10921086 multiply ( key , value ) {
1093- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "multiply" , Countly . debug ) ;
1094- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "multiply" , Countly . debug ) ;
1095- change_custom_property ( key , value , "$mul" ) ;
1087+ Countly . userProfile . multiply ( key , value ) ;
10961088 } ,
10971089 /**
10981090 * Save maximal value under the key of this user's custom properties
10991091 * @param {string } key - name of the property to attach to user
11001092 * @param {number } value - value which to compare to server's value and store maximal value of both provided
11011093 * */
11021094 max ( key , value ) {
1103- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "max" , Countly . debug ) ;
1104- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "max" , Countly . debug ) ;
1105- change_custom_property ( key , value , "$max" ) ;
1095+ Countly . userProfile . max ( key , value ) ;
11061096 } ,
11071097 /**
11081098 * Save minimal value under the key of this user's custom properties
11091099 * @param {string } key - name of the property to attach to user
11101100 * @param {number } value - value which to compare to server's value and store minimal value of both provided
11111101 * */
11121102 min ( key , value ) {
1113- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "min" , Countly . debug ) ;
1114- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "min" , Countly . debug ) ;
1115- change_custom_property ( key , value , "$min" ) ;
1103+ Countly . userProfile . min ( key , value ) ;
11161104 } ,
11171105 /**
11181106 * Add value to array under the key of this user's custom properties. If property is not an array, it will be converted to array
11191107 * @param {string } key - name of the property to attach to user
11201108 * @param {string|number } value - value which to add to array
11211109 * */
11221110 push ( key , value ) {
1123- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "push" , Countly . debug ) ;
1124- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "push" , Countly . debug ) ;
1125- change_custom_property ( key , value , "$push" ) ;
1111+ Countly . userProfile . push ( key , value ) ;
11261112 } ,
11271113 /**
11281114 * Add value to array under the key of this user's custom properties, storing only unique values. If property is not an array, it will be converted to array
11291115 * @param {string } key - name of the property to attach to user
11301116 * @param {string|number } value - value which to add to array
11311117 * */
11321118 push_unique ( key , value ) {
1133- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "push_unique" , Countly . debug ) ;
1134- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "push_unique" , Countly . debug ) ;
1135- change_custom_property ( key , value , "$addToSet" ) ;
1119+ Countly . userProfile . push_unique ( key , value ) ;
11361120 } ,
11371121 /**
11381122 * Remove value from array under the key of this user's custom properties
11391123 * @param {string } key - name of the property
11401124 * @param {string|number } value - value which to remove from array
11411125 * */
11421126 pull ( key , value ) {
1143- key = cc . truncateSingleValue ( key , Countly . maxKeyLength , "pull" , Countly . debug ) ;
1144- value = cc . truncateSingleValue ( value , Countly . maxValueSize , "pull" , Countly . debug ) ;
1145- change_custom_property ( key , value , "$pull" ) ;
1127+ Countly . userProfile . pull ( key , value ) ;
11461128 } ,
11471129 /**
11481130 * Save changes made to user's custom properties object and send them to server
11491131 * */
11501132 save ( ) {
1151- if ( Countly . check_consent ( "users" ) ) {
1152- toRequestQueue ( { user_details : JSON . stringify ( { custom : customData } ) } ) ;
1153- }
1154- customData = { } ;
1133+ Countly . userProfile . save ( ) ;
11551134 } ,
11561135 } ;
11571136
0 commit comments