Skip to content

Commit

Permalink
[Java] Implement new user module (#171)
Browse files Browse the repository at this point in the history
* feat: new user module

* fix: checkup a little comments

* fix: revert picture byte array changes

* fix: rework with images

* feat: tests for the new calls
  • Loading branch information
arifBurakDemiray authored Nov 21, 2023
1 parent 691233a commit 7a05f5f
Show file tree
Hide file tree
Showing 12 changed files with 1,048 additions and 430 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
## XX.XX.XX

* !! Major breaking change !! The following method and its functionality is deprecated from the "UserEditor" interface and will not function anymore:
* "setLocale(String)"

* Added the user profiles feature interface, and it is accessible through "Countly::instance()::userProfile()" call.

* Fixed a bug where setting custom user properties would not work.
* Fixed a bug where setting organization of the user would not work.

* Deprecated "Countly::backendMode()" call, use "Countly::backendM" instead via "instance()" call.
* The following methods are deprecated from the "UserEditor" interface:
* "commit()" instead use "Countly::userProfile::save" via "instance()" call
* "pushUnique(String, Object)" instead use "Countly::userProfile::pushUnique" via "instance()" call
* "pull(String, Object)" instead use "Countly::userProfile::pull" via "instance()" call
* "push(String, Object)" instead use "Countly::userProfile::push" via "instance()" call
* "setOnce(String, Object)" instead use "Countly::userProfile::setOnce" via "instance()" call
* "max(String, double)" instead use "Countly::userProfile::saveMax" via "instance()" call
* "min(String, double)" instead use "Countly::userProfile::saveMin" via "instance()" call
* "mul(String, double)" instead use "Countly::userProfile::multiply" via "instance()" call
* "inc(String, int)" instead use "Countly::userProfile::incrementBy" via "instance()" call
* "optOutFromLocationServices()" todo add replacement func when location module added
* "setLocation(double, double)" todo add replacement func when location module added
* "setLocation(String)" todo add replacement func when location module added
* "setCountry(String)" todo add replacement func when location module added
* "setCity(String)" todo add replacement func when location module added
* "setGender(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setBirthyear(int)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setBirthyear(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setEmail(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setName(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setUsername(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setPhone(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setPicturePath(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setOrg(String)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "setCustom(String, Object)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "set(String, Object)" instead use "Countly::userProfile::setProperty" via "instance()" call
* "picture(byte[])" instead use "Countly::userProfile::setProperty" via "instance()" call

## 23.10.1

Expand Down
16 changes: 16 additions & 0 deletions sdk-java/src/main/java/ly/count/sdk/java/Countly.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ly.count.sdk.java.internal.ModuleEvents;
import ly.count.sdk.java.internal.ModuleFeedback;
import ly.count.sdk.java.internal.ModuleRemoteConfig;
import ly.count.sdk.java.internal.ModuleUserProfile;
import ly.count.sdk.java.internal.SDKCore;

/**
Expand Down Expand Up @@ -463,6 +464,21 @@ public Event timedEvent(String key) {
return ((Session) sdk.session(null)).timedEvent(key);
}

/**
* <code>UserProfile</code> interface to use user profile feature.
*
* @return {@link ModuleUserProfile.UserProfile} instance.
*/
public ModuleUserProfile.UserProfile userProfile() {
if (!isInitialized()) {
if (L != null) {
L.e("[Countly] userProfile, SDK is not initialized yet.");
}
return null;
}
return sdk.userProfile();
}

/**
* Get current User Profile object.
*
Expand Down
24 changes: 13 additions & 11 deletions sdk-java/src/main/java/ly/count/sdk/java/Event.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package ly.count.sdk.java;

import ly.count.sdk.java.internal.ModuleEvents;
import javax.annotation.Nonnull;
import java.util.Map;
import javax.annotation.Nonnull;
import ly.count.sdk.java.internal.ModuleEvents;

/**
* Event interface. By default event is created with count=1 and all other fields empty or 0.
* Event interface. By default, event is created with count=1 and all other fields empty or 0.
*
* @deprecated this class is deprecated, use {@link ModuleEvents.Events} instead
*/

public interface Event {
/**
* Add event to the buffer, send it to the server in case number of events in the session
* is equal or bigger than {@link Config#eventQueueThreshold} or wait until next {@link Session#update()}.
*
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
void record();

Expand All @@ -23,7 +25,7 @@ public interface Event {
* send it to the server in case number of events in the session is equal or bigger
* than {@link Config#eventQueueThreshold} or wait until next {@link Session#update()}.
*
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#endEvent(String, Map, int, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#endEvent(String, Map, int, Double)} instead
*/
void endAndRecord();

Expand All @@ -33,7 +35,7 @@ public interface Event {
* @param key key of segment, must not be null or empty
* @param value value of segment, must not be null or empty
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event addSegment(@Nonnull String key, @Nonnull String value);

Expand All @@ -44,7 +46,7 @@ public interface Event {
* segmentation from; cannot contain nulls or empty strings; must have
* even length
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event addSegments(@Nonnull String... segmentation);

Expand All @@ -53,7 +55,7 @@ public interface Event {
*
* @param segmentation map of segment pairs ({key1: value1, key2: value2}
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event setSegmentation(@Nonnull Map<String, String> segmentation);

Expand All @@ -62,7 +64,7 @@ public interface Event {
*
* @param count event count, cannot be 0
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event setCount(int count);

Expand All @@ -71,7 +73,7 @@ public interface Event {
*
* @param sum event sum
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event setSum(double sum);

Expand All @@ -80,7 +82,7 @@ public interface Event {
*
* @param duration event duration
* @return this instance for method chaining
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, int, double, Map, double)} instead
* @deprecated this function is deprecated, use {@link ModuleEvents.Events#recordEvent(String, Map, int, Double, Double)} instead
*/
Event setDuration(double duration);

Expand Down
Loading

0 comments on commit 7a05f5f

Please sign in to comment.