Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Implement new user module #171

Merged
merged 6 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading