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

User Profile Rework #423

Open
wants to merge 13 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
* `enterContentZone`, to start Content checks (Experimental!)
* `exitContentZone`, to stop Content checks (Experimental!)
* Added `Countly.deviceId.setID` method for changing device ID based on the device ID type
* Deprecated `Countly.setUserData` and replaced with `Countly.userProfile.setProperties`
* Deprecated `Countly.userData` and replaced with `Countly.userProfile`, also following calls are deprecated and replaced:
* `Countly.userData.setProperty` (replaced with: `Countly.userProfile.setProperty`)
* `Countly.userData.increment` (replaced with: `Countly.userProfile.increment`)
* `Countly.userData.incrementBy` (replaced with: `Countly.userProfile.incrementBy`)
* `Countly.userData.multiply` (replaced with: `Countly.userProfile.multiply`)
* `Countly.userData.saveMax` (replaced with: `Countly.userProfile.saveMax`)
* `Countly.userData.saveMin` (replaced with: `Countly.userProfile.saveMin`)
* `Countly.userData.setOnce` (replaced with: `Countly.userProfile.setOnce`)
* `Countly.userData.pushUniqueValue` (replaced with: `Countly.userProfile.pushUnique`)
* `Countly.userData.pushValue` (replaced with: `Countly.userProfile.push`)
* `Countly.userData.pullValue` (replaced with: `Countly.userProfile.pull`)
* Mitigated an issue where a session could have started while the app was in the background when the device ID was changed (non-merge).
* Deprecated following SDK calls:
* `Countly.getCurrentDeviceId` (replaced with: `Countly.deviceId.getID`)
Expand Down
134 changes: 124 additions & 10 deletions Countly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,130 @@ declare module "countly-sdk-react-native-bridge" {

/**
*
* @deprecated 'setUserData' is deprecated use 'Countly.userProfile.setProperties' instead.
* Used to send user data
*
* @param {object} userData user data
* @return {string | void} error message or void
*/
export function setUserData(userData: CountlyUserData): string | Promise<void>;

namespace userProfile {
/**
*
* Set custom key and value pair for the current user
*
* @param {string} keyName - user property key
* @param {object} keyValue - user property value
* @returns {void}
*/
export function setProperty(keyName: string, keyValue: any): Promise<void>;

/**
*
* Set predefined and/or custom key and value pairs for the current user
*
* @param {object} userData - custom key value pairs
* @returns {void}
*/
export function setProperties(userData: CountlyUserData): Promise<void>;

/**
*
* Increment custom user data by 1
*
* @param {string} keyName - user property key
* @returns {void}
*/
export function increment(keyName: string): Promise<void>;

/**
*
* Increment custom user data by a specified value
*
* @param {string} keyName - user property key
* @param {number} keyValue - value to increment user property by
* @returns {void}
*/
export function incrementBy(keyName: string, keyValue: any): Promise<void>;

/**
*
* Multiply custom user data by a specified value
*
* @param {string} keyName - user property key
* @param {number} keyValue - value to multiply user property by
* @returns {void}
*/
export function multiply(keyName: string, keyValue: any): Promise<void>;

/**
*
* Save the max value between current and provided value
*
* @param {string} keyName - user property key
* @param {number} keyValue - user property value
* @returns {void}
*/
export function saveMax(keyName: string, keyValue: any): Promise<void>;

/**
*
* Save the min value between current and provided value
*
* @param {string} keyName - user property key
* @param {number} keyValue - user property value
* @returns {void}
*/
export function saveMin(keyName: string, keyValue: any): Promise<void>;

/**
*
* Set the property value if it does not exist
*
* @param {string} keyName - user property key
* @param {string} keyValue - user property value
* @returns {void}
*/
export function setOnce(keyName: string, keyValue: any): Promise<void>;

/**
*
* Add value to custom property (array) if value does not exist within
*
* @param {string} keyName user property key
* @param {string} keyValue user property value
* @returns {void}
*/
export function pushUnique(keyName: string, keyValue: any): Promise<void>;

/**
*
* Add value to custom property (array)
*
* @param {string} keyName user property key
* @param {string} keyValue user property value
* @returns {void}
*/
export function push(keyName: string, keyValue: any): Promise<void>;

/**
*
* Remove value from custom property (array)
*
* @param {string} keyName user property key
* @param {string} keyValue user property value
* @returns {void}
*/
export function pull(keyName: string, keyValue: any): Promise<void>;
}

/**
* @deprecated Countly.userData is deprecated, use Countly.userProfile instead
*/
namespace userData {
/**
*
* @deprecated 'Countly.userData.setProperty' is deprecated, use 'Countly.userProfile.setProperty' instead.
* Set custom key and value pair for the current user.
*
* @param {string} keyName user property key
Expand All @@ -591,7 +705,7 @@ declare module "countly-sdk-react-native-bridge" {
export function setProperty(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.increment' is deprecated, use 'Countly.userProfile.increment' instead.
* Increment custom user data by 1
*
* @param {string} keyName user property key
Expand All @@ -600,7 +714,7 @@ declare module "countly-sdk-react-native-bridge" {
export function increment(keyName: string): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.incrementBy' is deprecated, use 'Countly.userProfile.incrementBy' instead.
* Increment custom user data by a specified value
*
* @param {string} keyName user property key
Expand All @@ -610,7 +724,7 @@ declare module "countly-sdk-react-native-bridge" {
export function incrementBy(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.multiply' is deprecated, use 'Countly.userProfile.multiply' instead.
* Multiply custom user data by a specified value
*
* @param {string} keyName user property key
Expand All @@ -620,7 +734,7 @@ declare module "countly-sdk-react-native-bridge" {
export function multiply(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.saveMax' is deprecated, use 'Countly.userProfile.saveMax' instead.
* Save the max value between current and provided value.
*
* @param {string} keyName user property key
Expand All @@ -630,7 +744,7 @@ declare module "countly-sdk-react-native-bridge" {
export function saveMax(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.saveMin' is deprecated, use 'Countly.userProfile.saveMin' instead.
* Save the min value between current and provided value.
*
* @param {string} keyName user property key
Expand All @@ -640,7 +754,7 @@ declare module "countly-sdk-react-native-bridge" {
export function saveMin(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.setOnce' is deprecated, use 'Countly.userProfile.setOnce' instead.
* Set the property value if it does not exist.
*
* @param {string} keyName user property key
Expand All @@ -650,7 +764,7 @@ declare module "countly-sdk-react-native-bridge" {
export function setOnce(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.pushUniqueValue' is deprecated, use 'Countly.userProfile.pushUnique' instead.
* Add value to custom property (array) if value does not exist within.
*
* @param {string} keyName user property key
Expand All @@ -660,7 +774,7 @@ declare module "countly-sdk-react-native-bridge" {
export function pushUniqueValue(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.pushValue' is deprecated, use 'Countly.userProfile.push' instead.
* Add value to custom property (array).
*
* @param {string} keyName user property key
Expand All @@ -670,7 +784,7 @@ declare module "countly-sdk-react-native-bridge" {
export function pushValue(keyName: string, keyValue: any): Promise<void> | string;

/**
*
* @deprecated 'Countly.userData.pullValue' is deprecated, use 'Countly.userProfile.pull' instead.
* Remove value to custom property (array).
*
* @param {string} keyName user property key
Expand Down
25 changes: 15 additions & 10 deletions Countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CountlyState from "./CountlyState.js";
import Feedback from "./Feedback.js";
import Event from "./Event.js";
import DeviceId from "./DeviceId.js";
import UserProfile from "./UserProfile.js";
import * as L from "./Logger.js";
import * as Utils from "./Utils.js";
import * as Validate from "./Validators.js";
Expand All @@ -28,9 +29,13 @@ CountlyState.eventEmitter = eventEmitter;
Countly.feedback = new Feedback(CountlyState);
Countly.events = new Event(CountlyState);
Countly.deviceId = new DeviceId(CountlyState);
Countly.userProfile = new UserProfile(CountlyState);

let _isCrashReportingEnabled = false;

/**
* @deprecated Countly.userData is deprecated, use Countly.userProfile instead
*/
Countly.userData = {}; // userData interface
Countly.userDataBulk = {}; // userDataBulk interface

Expand Down Expand Up @@ -835,7 +840,7 @@ Countly.setUserData = async function (userData) {
};

/**
*
* @deprecated 'Countly.userData.setProperty' is deprecated, use 'Countly.userProfile.setProperty' instead.
* Set custom key and value pair for the current user.
*
* @param {string} keyName user property key
Expand Down Expand Up @@ -866,7 +871,7 @@ Countly.userData.setProperty = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.increment' is deprecated, use 'Countly.userProfile.increment' instead.
* Increment custom user data by 1
*
* @param {string} keyName user property key
Expand All @@ -890,7 +895,7 @@ Countly.userData.increment = async function (keyName) {
};

/**
*
* @deprecated 'Countly.userData.incrementBy' is deprecated, use 'Countly.userProfile.incrementBy' instead.
* Increment custom user data by a specified value
*
* @param {string} keyName user property key
Expand All @@ -917,7 +922,7 @@ Countly.userData.incrementBy = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.multiply' is deprecated, use 'Countly.userProfile.multiply' instead.
* Multiply custom user data by a specified value
*
* @param {string} keyName user property key
Expand All @@ -944,7 +949,7 @@ Countly.userData.multiply = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.saveMax' is deprecated, use 'Countly.userProfile.saveMax' instead.
* Save the max value between current and provided value.
*
* @param {string} keyName user property key
Expand All @@ -971,7 +976,7 @@ Countly.userData.saveMax = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.saveMin' is deprecated, use 'Countly.userProfile.saveMin' instead.
* Save the min value between current and provided value.
*
* @param {string} keyName user property key
Expand All @@ -998,7 +1003,7 @@ Countly.userData.saveMin = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.setOnce' is deprecated, use 'Countly.userProfile.setOnce' instead.
* Set the property value if it does not exist.
*
* @param {string} keyName user property key
Expand Down Expand Up @@ -1027,7 +1032,7 @@ Countly.userData.setOnce = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.pushUniqueValue' is deprecated, use 'Countly.userProfile.pushUnique' instead.
* Add value to custom property (array) if value does not exist within.
*
* @param {string} keyName user property key
Expand Down Expand Up @@ -1056,7 +1061,7 @@ Countly.userData.pushUniqueValue = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.pushValue' is deprecated, use 'Countly.userProfile.push' instead.
* Add value to custom property (array).
*
* @param {string} keyName user property key
Expand Down Expand Up @@ -1085,7 +1090,7 @@ Countly.userData.pushValue = async function (keyName, keyValue) {
};

/**
*
* @deprecated 'Countly.userData.pullValue' is deprecated, use 'Countly.userProfile.pull' instead.
* Remove value to custom property (array).
*
* @param {string} keyName user property key
Expand Down
Loading