@hackler/react-sdk 11.9.1 → 11.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/Context.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  /// <reference types="react" />
2
- import { User } from "@hackler/javascript-sdk";
3
2
  import { HackleReactSDKClient } from "./client";
4
- interface HackleContext {
3
+ export interface HackleContext {
5
4
  hackle: HackleReactSDKClient | undefined;
6
- user?: User;
5
+ userVersion: number;
7
6
  initialized: boolean;
8
7
  }
9
8
  export declare const HackleContext: import("react").Context<HackleContext>;
10
9
  export declare const HackleContextConsumer: import("react").Consumer<HackleContext>;
11
10
  export declare const HackleContextProvider: import("react").Provider<HackleContext>;
12
- export {};
13
11
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../src/Context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,UAAU,aAAa;IACrB,MAAM,EAAE,oBAAoB,GAAG,SAAS,CAAA;IACxC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,eAAO,MAAM,aAAa,wCAIxB,CAAA;AAEF,eAAO,MAAM,qBAAqB,yCAAyB,CAAA;AAC3D,eAAO,MAAM,qBAAqB,yCAAyB,CAAA"}
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../src/Context.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,oBAAoB,GAAG,SAAS,CAAA;IACxC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,eAAO,MAAM,aAAa,wCAIxB,CAAA;AAEF,eAAO,MAAM,qBAAqB,yCAAyB,CAAA;AAC3D,eAAO,MAAM,qBAAqB,yCAAyB,CAAA"}
package/lib/Provider.d.ts CHANGED
@@ -3,11 +3,11 @@ import { User } from "@hackler/javascript-sdk";
3
3
  import { HackleReactSDKClient } from "./client";
4
4
  interface ProviderProps {
5
5
  hackleClient: HackleReactSDKClient;
6
- user?: User;
6
+ user?: User | null;
7
7
  timeout?: number;
8
8
  supportSSR?: boolean;
9
9
  children?: ReactNode;
10
10
  }
11
- export declare function HackleProvider({ hackleClient, user, timeout, supportSSR, children }: ProviderProps): JSX.Element | null;
11
+ export declare function HackleProvider({ hackleClient, user: initialUser, timeout, supportSSR, children }: ProviderProps): JSX.Element | null;
12
12
  export {};
13
13
  //# sourceMappingURL=Provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,UAAU,aAAa;IACrB,YAAY,EAAE,oBAAoB,CAAA;IAClC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,wBAAgB,cAAc,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,OAAc,EAAE,UAAkB,EAAE,QAAQ,EAAE,EAAE,aAAa,sBAiDjH"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE/C,UAAU,aAAa;IACrB,YAAY,EAAE,oBAAoB,CAAA;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAED,wBAAgB,cAAc,CAAC,EACE,YAAY,EACZ,IAAI,EAAE,WAAW,EACjB,OAAc,EACd,UAAkB,EAClB,QAAQ,EACT,EAAE,aAAa,sBA6D9C"}
package/lib/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Decision, FeatureFlagDecision, HackleEvent, HackleRemoteConfig, PageView, User } from "@hackler/javascript-sdk";
2
+ import { Emitter } from "./emitter";
2
3
  interface Config {
3
4
  debug?: boolean;
4
5
  auto_track_page_view?: boolean;
@@ -6,22 +7,33 @@ interface Config {
6
7
  exposureEventDedupIntervalMillis?: number;
7
8
  sessionTimeoutMillis?: number;
8
9
  }
9
- export declare class HackleReactSDKClient {
10
+ interface HackleReactSDKClientEventMap {
11
+ "user-updated": User | null;
12
+ }
13
+ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEventMap> {
10
14
  private client;
15
+ private _currentUser;
11
16
  constructor(sdkKey: string, config?: Config);
12
- variation(experimentKey: number, user?: User, defaultVariation?: string): string;
13
- variationDetail(experimentKey: number, user?: User, defaultVariation?: string): Decision;
14
- isFeatureOn(featureKey: number, user?: User): boolean;
15
- featureFlagDetail(featureKey: number, user?: User): FeatureFlagDecision;
16
- track(event: string | HackleEvent, user?: User): void;
17
+ getUser(): User;
18
+ setUser(user: User): void;
19
+ setUserId(userId: string | undefined): void;
20
+ setDeviceId(deviceId: string): void;
21
+ setUserProperty(key: string, value: any): void;
22
+ resetUser(): void;
23
+ variation(experimentKey: number, user?: User | null, defaultVariation?: string): string;
24
+ variationDetail(experimentKey: number, user?: User | null, defaultVariation?: string): Decision;
25
+ isFeatureOn(featureKey: number, user?: User | null): boolean;
26
+ featureFlagDetail(featureKey: number, user?: User | null): FeatureFlagDecision;
27
+ track(event: string | HackleEvent, user?: User | null): void;
17
28
  trackPageView(option?: PageView): void;
18
- remoteConfig(user?: User): HackleRemoteConfig;
29
+ remoteConfig(user?: User | null): HackleRemoteConfig;
19
30
  onReady(cb: any, timeout?: number): void;
20
31
  onInitialized(config?: {
21
32
  timeout: number;
22
33
  }): Promise<{
23
34
  success: boolean;
24
35
  }>;
36
+ private emitUpdatedUser;
25
37
  }
26
38
  export declare function createInstance(sdkKey: string, config?: Config): HackleReactSDKClient;
27
39
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,mBAAmB,EAEnB,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,IAAI,EACL,MAAM,yBAAyB,CAAA;AAGhC,UAAU,MAAM;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,gCAAgC,CAAC,EAAE,MAAM,CAAA;IACzC,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAc;gBAEhB,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAQ3C,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;IAIhF,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIxF,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,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CAAC,EAAE,MAAM,GAAG,oBAAoB,CAEpF"}
package/lib/config.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const SDK_NAME_HEADER = "react-sdk";
2
- export declare const SDK_VERSION_HEADER = "11.9.1";
2
+ export declare const SDK_VERSION_HEADER = "11.10.0";
3
3
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAAc,CAAA;AAC1C,eAAO,MAAM,kBAAkB,WAAW,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAAc,CAAA;AAC1C,eAAO,MAAM,kBAAkB,YAAY,CAAA"}
@@ -0,0 +1,11 @@
1
+ declare type EventMap = Record<string, any>;
2
+ declare type EventKey<T extends EventMap> = string & keyof T;
3
+ declare type EventReceiver<T> = (params: T) => void;
4
+ export declare class Emitter<T extends EventMap> {
5
+ private listeners;
6
+ on<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
7
+ off<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
8
+ emit<K extends EventKey<T>>(eventName: K, params: T[K]): void;
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,aAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AACnC,aAAK,QAAQ,CAAC,CAAC,SAAS,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,CAAA;AACpD,aAAK,aAAa,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAA;AAE3C,qBAAa,OAAO,CAAC,CAAC,SAAS,QAAQ;IACrC,OAAO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Q;IAClD,YAAY,EAAE,kBAAkB,CAAA;CACjC;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,SAAM,GAAG,MAAM,CA+BlF;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,SAAM,GAAG,QAAQ,CA8B1F;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,SAAM,GAAG,eAAe,CAOnG;AAED,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,gBAAgB,SAAM,GAAG,qBAAqB,CAmC/G;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA8BtD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CA8B5E;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAOxE;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,CAkCpF;AAED,wBAAgB,eAAe,IAAI,kBAAkB,CA0BpD;AAED,wBAAgB,uBAAuB,IAAI,kBAAkB,CAgC5D;AAED,UAAU,KAAK;IACb,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;CAC3B;AACD,wBAAgB,QAAQ,IAAI,KAAK,CAShC"}
package/lib/index.es.js CHANGED
@@ -18,6 +18,22 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
19
  PERFORMANCE OF THIS SOFTWARE.
20
20
  ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+
23
+ var extendStatics = function(d, b) {
24
+ extendStatics = Object.setPrototypeOf ||
25
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
27
+ return extendStatics(d, b);
28
+ };
29
+
30
+ function __extends(d, b) {
31
+ if (typeof b !== "function" && b !== null)
32
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
+ extendStatics(d, b);
34
+ function __() { this.constructor = d; }
35
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
+ }
21
37
 
22
38
  var __assign = function() {
23
39
  __assign = Object.assign || function __assign(t) {
@@ -48,32 +64,114 @@ function __read(o, n) {
48
64
  }
49
65
 
50
66
  var SDK_NAME_HEADER = "react-sdk";
51
- var SDK_VERSION_HEADER = "11.9.1";
67
+ var SDK_VERSION_HEADER = "11.10.0";
68
+
69
+ var Emitter = /** @class */ (function () {
70
+ function Emitter() {
71
+ this.listeners = {};
72
+ }
73
+ Emitter.prototype.on = function (eventName, fn) {
74
+ this.listeners[eventName] = (this.listeners[eventName] || []).concat(fn);
75
+ };
76
+ Emitter.prototype.off = function (eventName, fn) {
77
+ this.listeners[eventName] = (this.listeners[eventName] || []).filter(function (f) { return f !== fn; });
78
+ };
79
+ Emitter.prototype.emit = function (eventName, params) {
80
+ (this.listeners[eventName] || []).forEach(function (fn) {
81
+ fn(params);
82
+ });
83
+ };
84
+ return Emitter;
85
+ }());
52
86
 
53
- var HackleReactSDKClient = /** @class */ (function () {
87
+ var ObjectUtil = /** @class */ (function () {
88
+ function ObjectUtil() {
89
+ }
90
+ ObjectUtil.arePropertiesEqual = function (prevProps, currentProps) {
91
+ var prev = ObjectUtil.coerceUnknownToProperties(prevProps);
92
+ var current = ObjectUtil.coerceUnknownToProperties(currentProps);
93
+ var prevKeys = Object.keys(prev);
94
+ var currentKeys = Object.keys(current);
95
+ if (prevKeys.length !== currentKeys.length) {
96
+ return false;
97
+ }
98
+ return prevKeys.every(function (it) {
99
+ // @ts-ignore
100
+ return it in current && prev[it] === current[it];
101
+ });
102
+ };
103
+ ObjectUtil.coerceUnknownToProperties = function (props) {
104
+ if (typeof props === "object" && props !== null) {
105
+ return props;
106
+ }
107
+ return {};
108
+ };
109
+ return ObjectUtil;
110
+ }());
111
+ var UserUtil = /** @class */ (function () {
112
+ function UserUtil() {
113
+ }
114
+ UserUtil.isUserEqual = function (prevUser, currentUser) {
115
+ return ((prevUser === null || prevUser === void 0 ? void 0 : prevUser.id) === (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) &&
116
+ (prevUser === null || prevUser === void 0 ? void 0 : prevUser.deviceId) === (currentUser === null || currentUser === void 0 ? void 0 : currentUser.deviceId) &&
117
+ (prevUser === null || prevUser === void 0 ? void 0 : prevUser.userId) === (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId) &&
118
+ ObjectUtil.arePropertiesEqual(prevUser === null || prevUser === void 0 ? void 0 : prevUser.properties, currentUser === null || currentUser === void 0 ? void 0 : currentUser.properties) &&
119
+ ObjectUtil.arePropertiesEqual(prevUser === null || prevUser === void 0 ? void 0 : prevUser.identifiers, currentUser === null || currentUser === void 0 ? void 0 : currentUser.identifiers));
120
+ };
121
+ return UserUtil;
122
+ }());
123
+
124
+ var HackleReactSDKClient = /** @class */ (function (_super) {
125
+ __extends(HackleReactSDKClient, _super);
54
126
  function HackleReactSDKClient(sdkKey, config) {
55
- this.client = Hackle.createInstance(sdkKey, __assign(__assign({}, config), { SDK_NAME_HEADER: SDK_NAME_HEADER, SDK_VERSION_HEADER: SDK_VERSION_HEADER }));
127
+ var _this = _super.call(this) || this;
128
+ _this._currentUser = null;
129
+ _this.client = Hackle.createInstance(sdkKey, __assign(__assign({}, config), { SDK_NAME_HEADER: SDK_NAME_HEADER, SDK_VERSION_HEADER: SDK_VERSION_HEADER }));
130
+ return _this;
56
131
  }
132
+ HackleReactSDKClient.prototype.getUser = function () {
133
+ return this.client.getUser();
134
+ };
135
+ HackleReactSDKClient.prototype.setUser = function (user) {
136
+ this.client.setUser(user);
137
+ this.emitUpdatedUser(this.getUser());
138
+ };
139
+ HackleReactSDKClient.prototype.setUserId = function (userId) {
140
+ this.client.setUserId(userId);
141
+ this.emitUpdatedUser(this.getUser());
142
+ };
143
+ HackleReactSDKClient.prototype.setDeviceId = function (deviceId) {
144
+ this.client.setDeviceId(deviceId);
145
+ this.emitUpdatedUser(this.getUser());
146
+ };
147
+ HackleReactSDKClient.prototype.setUserProperty = function (key, value) {
148
+ this.client.setUserProperty(key, value);
149
+ this.emitUpdatedUser(this.getUser());
150
+ };
151
+ HackleReactSDKClient.prototype.resetUser = function () {
152
+ this.client.resetUser();
153
+ this.emitUpdatedUser(this.getUser());
154
+ };
57
155
  HackleReactSDKClient.prototype.variation = function (experimentKey, user, defaultVariation) {
58
- return this.client.variation(experimentKey, user, defaultVariation);
156
+ return this.client.variation(experimentKey, user || undefined, defaultVariation);
59
157
  };
60
158
  HackleReactSDKClient.prototype.variationDetail = function (experimentKey, user, defaultVariation) {
61
- return this.client.variationDetail(experimentKey, user, defaultVariation);
159
+ return this.client.variationDetail(experimentKey, user || undefined, defaultVariation);
62
160
  };
63
161
  HackleReactSDKClient.prototype.isFeatureOn = function (featureKey, user) {
64
- return this.client.isFeatureOn(featureKey, user);
162
+ return this.client.isFeatureOn(featureKey, user || undefined);
65
163
  };
66
164
  HackleReactSDKClient.prototype.featureFlagDetail = function (featureKey, user) {
67
- return this.client.featureFlagDetail(featureKey, user);
165
+ return this.client.featureFlagDetail(featureKey, user || undefined);
68
166
  };
69
167
  HackleReactSDKClient.prototype.track = function (event, user) {
70
- this.client.track(event, user);
168
+ this.client.track(event, user || undefined);
71
169
  };
72
170
  HackleReactSDKClient.prototype.trackPageView = function (option) {
73
- this.client.trackPageView(option);
171
+ this.client.trackPageView(__assign(__assign({}, option), { user: (option === null || option === void 0 ? void 0 : option.user) || undefined }));
74
172
  };
75
173
  HackleReactSDKClient.prototype.remoteConfig = function (user) {
76
- return this.client.remoteConfig(user);
174
+ return this.client.remoteConfig(user || undefined);
77
175
  };
78
176
  HackleReactSDKClient.prototype.onReady = function (cb, timeout) {
79
177
  this.client.onReady(cb, timeout);
@@ -81,35 +179,50 @@ var HackleReactSDKClient = /** @class */ (function () {
81
179
  HackleReactSDKClient.prototype.onInitialized = function (config) {
82
180
  return this.client.onInitialized(config);
83
181
  };
182
+ HackleReactSDKClient.prototype.emitUpdatedUser = function (user) {
183
+ if (!UserUtil.isUserEqual(this._currentUser, user)) {
184
+ this.emit("user-updated", user);
185
+ }
186
+ this._currentUser = user;
187
+ };
84
188
  return HackleReactSDKClient;
85
- }());
189
+ }(Emitter));
86
190
  function createInstance(sdkKey, config) {
87
191
  return new HackleReactSDKClient(sdkKey, config);
88
192
  }
89
193
 
90
194
  var HackleContext = createContext({
91
195
  hackle: undefined,
92
- user: undefined,
93
- initialized: false,
196
+ userVersion: 0,
197
+ initialized: false
94
198
  });
95
199
  var HackleContextConsumer = HackleContext.Consumer;
96
200
  var HackleContextProvider = HackleContext.Provider;
97
201
 
98
202
  function HackleProvider(_a) {
99
- var hackleClient = _a.hackleClient, user = _a.user, _b = _a.timeout, timeout = _b === void 0 ? 3000 : _b, _c = _a.supportSSR, supportSSR = _c === void 0 ? false : _c, children = _a.children;
100
- var state = {
203
+ var hackleClient = _a.hackleClient, initialUser = _a.user, _b = _a.timeout, timeout = _b === void 0 ? 3000 : _b, _c = _a.supportSSR, supportSSR = _c === void 0 ? false : _c, children = _a.children;
204
+ var _d = __read(useState({
101
205
  hackle: hackleClient,
102
- user: user,
103
- initialized: false
104
- };
105
- var _d = __read(useState(state), 2), value = _d[0], setValue = _d[1];
206
+ initialized: false,
207
+ userVersion: 0
208
+ }), 2), value = _d[0], setValue = _d[1];
106
209
  useEffect(function () {
107
- setValue(function (prevState) {
108
- return __assign(__assign({}, prevState), { user: user });
109
- });
110
- }, [user]);
210
+ if (typeof initialUser !== "undefined" && initialUser !== null) {
211
+ hackleClient.setUser(initialUser);
212
+ }
213
+ }, [initialUser]);
214
+ useEffect(function () {
215
+ var onUserUpdated = function () {
216
+ setValue(function (prevState) { return (__assign(__assign({}, prevState), { userVersion: prevState.userVersion + 1 })); });
217
+ };
218
+ hackleClient.on("user-updated", onUserUpdated);
219
+ return function () {
220
+ hackleClient.off("user-updated", onUserUpdated);
221
+ };
222
+ }, [hackleClient]);
111
223
  useEffect(function () {
112
- hackleClient.onInitialized({ timeout: timeout })
224
+ hackleClient
225
+ .onInitialized({ timeout: timeout })
113
226
  .then(function () {
114
227
  setValue(function (prevState) {
115
228
  return __assign(__assign({}, prevState), { initialized: true });
@@ -118,7 +231,8 @@ function HackleProvider(_a) {
118
231
  setValue(function (prevState) {
119
232
  return __assign(__assign({}, prevState), { initialized: true });
120
233
  });
121
- }).catch(function () {
234
+ })
235
+ .catch(function () {
122
236
  setValue(function (prevState) {
123
237
  return __assign(__assign({}, prevState), { initialized: true });
124
238
  });
@@ -133,10 +247,10 @@ function HackleProvider(_a) {
133
247
  var log = Logger.log;
134
248
  function useVariation(experimentKey, defaultVariation) {
135
249
  if (defaultVariation === void 0) { defaultVariation = "A"; }
136
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
250
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
137
251
  var getVariation = useCallback(function () {
138
- return (initialized && (hackle === null || hackle === void 0 ? void 0 : hackle.variation(experimentKey, user))) || defaultVariation;
139
- }, [defaultVariation, experimentKey, user, hackle, initialized]);
252
+ return (initialized && (hackle === null || hackle === void 0 ? void 0 : hackle.variation(experimentKey))) || defaultVariation;
253
+ }, [defaultVariation, experimentKey, hackle, initialized]);
140
254
  var _b = __read(useState(function () {
141
255
  if (notExistClient(hackle)) {
142
256
  if (typeof window !== "undefined") {
@@ -148,7 +262,7 @@ function useVariation(experimentKey, defaultVariation) {
148
262
  }), 2), variation = _b[0], setVariation = _b[1];
149
263
  var currentInput = {
150
264
  key: experimentKey,
151
- user: user,
265
+ userVersion: userVersion,
152
266
  initialized: initialized
153
267
  };
154
268
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -160,10 +274,10 @@ function useVariation(experimentKey, defaultVariation) {
160
274
  }
161
275
  function useVariationDetail(experimentKey, defaultVariation) {
162
276
  if (defaultVariation === void 0) { defaultVariation = "A"; }
163
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
277
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
164
278
  var getVariationDetail = useCallback(function () {
165
- return (hackle === null || hackle === void 0 ? void 0 : hackle.variationDetail(experimentKey, user)) || Decision.of(defaultVariation, DecisionReason.EXCEPTION);
166
- }, [defaultVariation, experimentKey, user, hackle, initialized]);
279
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.variationDetail(experimentKey)) || Decision.of(defaultVariation, DecisionReason.EXCEPTION);
280
+ }, [defaultVariation, experimentKey, hackle, initialized]);
167
281
  var _b = __read(useState(function () {
168
282
  if (notExistClient(hackle)) {
169
283
  if (typeof window !== "undefined") {
@@ -175,7 +289,7 @@ function useVariationDetail(experimentKey, defaultVariation) {
175
289
  }), 2), variationDetail = _b[0], setVariationDetail = _b[1];
176
290
  var currentInput = {
177
291
  key: experimentKey,
178
- user: user,
292
+ userVersion: userVersion,
179
293
  initialized: initialized
180
294
  };
181
295
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -195,13 +309,13 @@ function useLoadableVariation(experimentKey, defaultVariation) {
195
309
  }
196
310
  function useLoadableVariationDetail(experimentKey, defaultVariation) {
197
311
  if (defaultVariation === void 0) { defaultVariation = "A"; }
198
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
312
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
199
313
  var getVariationDetail = useCallback(function () {
200
314
  if (!initialized) {
201
315
  return Decision.of(defaultVariation, DecisionReason.SDK_NOT_READY);
202
316
  }
203
- return (hackle === null || hackle === void 0 ? void 0 : hackle.variationDetail(experimentKey, user)) || Decision.of(defaultVariation, DecisionReason.EXCEPTION);
204
- }, [defaultVariation, experimentKey, user, hackle, initialized]);
317
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.variationDetail(experimentKey)) || Decision.of(defaultVariation, DecisionReason.EXCEPTION);
318
+ }, [defaultVariation, experimentKey, hackle, initialized]);
205
319
  var _b = __read(useState(function () {
206
320
  if (notExistClient(hackle)) {
207
321
  log.error("HackleClient is not existed");
@@ -211,7 +325,7 @@ function useLoadableVariationDetail(experimentKey, defaultVariation) {
211
325
  }), 2), variationDetail = _b[0], setVariationDetail = _b[1];
212
326
  var currentInput = {
213
327
  key: experimentKey,
214
- user: user,
328
+ userVersion: userVersion,
215
329
  initialized: initialized
216
330
  };
217
331
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -225,10 +339,10 @@ function useLoadableVariationDetail(experimentKey, defaultVariation) {
225
339
  };
226
340
  }
227
341
  function useFeature(featureKey) {
228
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
342
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
229
343
  var getIsOn = useCallback(function () {
230
- return (hackle === null || hackle === void 0 ? void 0 : hackle.isFeatureOn(featureKey, user)) || false;
231
- }, [featureKey, user, hackle, initialized]);
344
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.isFeatureOn(featureKey)) || false;
345
+ }, [featureKey, hackle, initialized]);
232
346
  var _b = __read(useState(function () {
233
347
  if (notExistClient(hackle)) {
234
348
  if (typeof window !== "undefined") {
@@ -240,7 +354,7 @@ function useFeature(featureKey) {
240
354
  }), 2), isOn = _b[0], setIsOn = _b[1];
241
355
  var currentInput = {
242
356
  key: featureKey,
243
- user: user,
357
+ userVersion: userVersion,
244
358
  initialized: initialized
245
359
  };
246
360
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -251,10 +365,10 @@ function useFeature(featureKey) {
251
365
  return isOn;
252
366
  }
253
367
  function useFeatureFlagDetail(featureKey) {
254
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
368
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
255
369
  var getFeatureDetail = useCallback(function () {
256
- return (hackle === null || hackle === void 0 ? void 0 : hackle.featureFlagDetail(featureKey, user)) || FeatureFlagDecision.off(DecisionReason.EXCEPTION);
257
- }, [featureKey, user, hackle, initialized]);
370
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.featureFlagDetail(featureKey)) || FeatureFlagDecision.off(DecisionReason.EXCEPTION);
371
+ }, [featureKey, hackle, initialized]);
258
372
  var _b = __read(useState(function () {
259
373
  if (notExistClient(hackle)) {
260
374
  if (typeof window !== "undefined") {
@@ -266,7 +380,7 @@ function useFeatureFlagDetail(featureKey) {
266
380
  }), 2), featureDetail = _b[0], setFeatureDetail = _b[1];
267
381
  var currentInput = {
268
382
  key: featureKey,
269
- user: user,
383
+ userVersion: userVersion,
270
384
  initialized: initialized
271
385
  };
272
386
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -284,13 +398,13 @@ function useLoadableFeature(featureKey) {
284
398
  };
285
399
  }
286
400
  function useLoadableFeatureDetail(featureKey) {
287
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
401
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
288
402
  var getFeatureDetail = useCallback(function () {
289
403
  if (!initialized) {
290
404
  return FeatureFlagDecision.off(DecisionReason.SDK_NOT_READY);
291
405
  }
292
- return (hackle === null || hackle === void 0 ? void 0 : hackle.featureFlagDetail(featureKey, user)) || FeatureFlagDecision.off(DecisionReason.EXCEPTION);
293
- }, [featureKey, user, hackle, initialized]);
406
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.featureFlagDetail(featureKey)) || FeatureFlagDecision.off(DecisionReason.EXCEPTION);
407
+ }, [featureKey, hackle, initialized]);
294
408
  var _b = __read(useState(function () {
295
409
  if (notExistClient(hackle)) {
296
410
  log.error("HackleClient is not existed");
@@ -300,7 +414,7 @@ function useLoadableFeatureDetail(featureKey) {
300
414
  }), 2), featureDetail = _b[0], setFeatureDetail = _b[1];
301
415
  var currentInput = {
302
416
  key: featureKey,
303
- user: user,
417
+ userVersion: userVersion,
304
418
  initialized: initialized
305
419
  };
306
420
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -314,10 +428,10 @@ function useLoadableFeatureDetail(featureKey) {
314
428
  };
315
429
  }
316
430
  function useRemoteConfig() {
317
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
431
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
318
432
  var getRemoteConfig = useCallback(function () {
319
- return (hackle === null || hackle === void 0 ? void 0 : hackle.remoteConfig(user)) || new EmptyHackleRemoteConfig();
320
- }, [user, hackle, initialized]);
433
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.remoteConfig()) || new EmptyHackleRemoteConfig();
434
+ }, [hackle, initialized]);
321
435
  var _b = __read(useState(function () {
322
436
  if (notExistClient(hackle)) {
323
437
  log.error("HackleClient is not existed");
@@ -325,7 +439,7 @@ function useRemoteConfig() {
325
439
  return getRemoteConfig();
326
440
  }), 2), remoteConfig = _b[0], setRemoteConfig = _b[1];
327
441
  var currentInput = {
328
- user: user,
442
+ userVersion: userVersion,
329
443
  initialized: initialized
330
444
  };
331
445
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -336,13 +450,13 @@ function useRemoteConfig() {
336
450
  return remoteConfig;
337
451
  }
338
452
  function useLoadableRemoteConfig() {
339
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user, initialized = _a.initialized;
453
+ var _a = useContext(HackleContext), hackle = _a.hackle, userVersion = _a.userVersion, initialized = _a.initialized;
340
454
  var getRemoteConfig = useCallback(function () {
341
455
  if (!initialized) {
342
456
  return new EmptyHackleRemoteConfig();
343
457
  }
344
- return (hackle === null || hackle === void 0 ? void 0 : hackle.remoteConfig(user)) || new EmptyHackleRemoteConfig();
345
- }, [user, hackle, initialized]);
458
+ return (hackle === null || hackle === void 0 ? void 0 : hackle.remoteConfig()) || new EmptyHackleRemoteConfig();
459
+ }, [hackle, initialized]);
346
460
  var _b = __read(useState(function () {
347
461
  if (notExistClient(hackle)) {
348
462
  log.error("HackleClient is not existed");
@@ -350,7 +464,7 @@ function useLoadableRemoteConfig() {
350
464
  return getRemoteConfig();
351
465
  }), 2), remoteConfig = _b[0], setRemoteConfig = _b[1];
352
466
  var currentInput = {
353
- user: user,
467
+ userVersion: userVersion,
354
468
  initialized: initialized
355
469
  };
356
470
  var _c = __read(useState(currentInput), 2), prevInput = _c[0], setPrevInput = _c[1];
@@ -364,40 +478,18 @@ function useLoadableRemoteConfig() {
364
478
  };
365
479
  }
366
480
  function useTrack() {
367
- var _a = useContext(HackleContext), hackle = _a.hackle, user = _a.user;
481
+ var hackle = useContext(HackleContext).hackle;
368
482
  if (notExistClient(hackle)) {
369
483
  log.error("HackleClient is not existed");
370
484
  return function () { };
371
485
  }
372
- return function (event) { return hackle === null || hackle === void 0 ? void 0 : hackle.track(event, user); };
486
+ return function (event) { return hackle === null || hackle === void 0 ? void 0 : hackle.track(event); };
373
487
  }
374
488
  function notExistClient(hackle) {
375
489
  return !hackle;
376
490
  }
377
491
  function isInputEqual(prev, current) {
378
- var _a, _b, _c, _d;
379
- return (prev.initialized === current.initialized &&
380
- prev.key === current.key &&
381
- ((_a = prev.user) === null || _a === void 0 ? void 0 : _a.id) === ((_b = current.user) === null || _b === void 0 ? void 0 : _b.id) &&
382
- arePropertiesEqual((_c = prev.user) === null || _c === void 0 ? void 0 : _c.properties, (_d = current.user) === null || _d === void 0 ? void 0 : _d.properties));
383
- }
384
- function arePropertiesEqual(prevProps, currentProps) {
385
- var prev = coerceUnknownToProperties(prevProps);
386
- var current = coerceUnknownToProperties(currentProps);
387
- var prevKeys = Object.keys(prev);
388
- var currentKeys = Object.keys(current);
389
- if (prevKeys.length !== currentKeys.length) {
390
- return false;
391
- }
392
- return prevKeys.every(function (it) {
393
- return it in current && prev[it] === current[it];
394
- });
395
- }
396
- function coerceUnknownToProperties(props) {
397
- if (typeof props === "object" && props !== null) {
398
- return props;
399
- }
400
- return {};
492
+ return (prev.initialized === current.initialized && prev.key === current.key && prev.userVersion === current.userVersion);
401
493
  }
402
494
 
403
495
  function Experiment(_a) {