Skip to content

Commit 4200ff8

Browse files
fix: PR requested changes
1 parent e970500 commit 4200ff8

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

lib/core/odp/odp_manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface IOdpManager {
4646

4747
sendEvent({ type, action, identifiers, data }: OdpEvent): void;
4848

49-
registerVuid(vuid: string | undefined): void;
49+
registerVuid(vuid: string): void;
5050
}
5151

5252
/**
@@ -139,7 +139,7 @@ export abstract class OdpManager implements IOdpManager {
139139
* Register a VUID with the ODP Manager in client side context
140140
* @param {string} vuid - Unique identifier of an anonymous vistor
141141
*/
142-
abstract registerVuid(vuid: string | undefined): void;
142+
abstract registerVuid(vuid: string): void;
143143

144144
/**
145145
* @returns {Status} The current status of the ODP Manager

lib/index.react_native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { OptimizelyDecideOption, Client, Config, VuidManagerOptions } from './sh
2828
import { createHttpPollingDatafileManager } from './plugins/datafile_manager/react_native_http_polling_datafile_manager';
2929
import { BrowserOdpManager } from './plugins/odp_manager/index.browser';
3030
import * as commonExports from './common_exports';
31-
import BrowserAsyncStorageCache from './plugins/key_value_cache/browserAsyncStorageCache';
3231
import { VuidManager } from './plugins/vuid_manager';
32+
import ReactNativeAsyncStorageCache from './plugins/key_value_cache/reactNativeAsyncStorageCache';
3333
import 'fast-text-encoding';
3434
import 'react-native-get-random-values';
3535

@@ -109,7 +109,7 @@ const createInstance = function (config: Config): Client | null {
109109

110110
const { clientEngine, clientVersion } = config;
111111

112-
const cache = new BrowserAsyncStorageCache();
112+
const cache = new ReactNativeAsyncStorageCache();
113113
const vuidManagerOptions: VuidManagerOptions = {
114114
enableVuid: config.vuidManagerOptions?.enableVuid || false,
115115
}

lib/optimizely/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,10 @@ export default class Optimizely implements Client {
14241424
resolveTimeoutPromise({
14251425
success: true,
14261426
});
1427-
this.odpManager?.registerVuid(this.vuidManager?.vuid)
1427+
const vuid = this.vuidManager?.vuid;
1428+
if (vuid) {
1429+
this.odpManager?.registerVuid(vuid);
1430+
}
14281431
});
14291432

14301433
return Promise.race([this.readyPromise, timeoutPromise]);

lib/plugins/odp_manager/index.browser.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class BrowserOdpManager extends OdpManager {
150150
super.identifyUser(fsUserId, vuid);
151151
}
152152

153-
registerVuid(vuid: string | undefined): void {
153+
registerVuid(vuid: string): void {
154154
if (!this.odpIntegrationConfig) {
155155
this.logger.log(LogLevel.ERROR, ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE);
156156
return;
@@ -161,11 +161,6 @@ export class BrowserOdpManager extends OdpManager {
161161
return;
162162
}
163163

164-
if (!vuid || !VuidManager.isVuid(vuid)) {
165-
this.logger.log(LogLevel.ERROR, `The provided VUID ${vuid} is invalid.`);
166-
return;
167-
}
168-
169164
try {
170165
this.eventManager.registerVuid(vuid);
171166
} catch (e) {

lib/plugins/odp_manager/index.node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class NodeOdpManager extends OdpManager {
134134
});
135135
}
136136

137-
registerVuid(vuid: string | undefined): void {
138-
this.logger.log(LogLevel.ERROR, `Unable to registerVuid ${vuid || ''} in a node server context`);
137+
registerVuid(vuid: string): void {
138+
this.logger.log(LogLevel.ERROR, `Unable to registerVuid ${vuid} in a node server context`);
139139
}
140140
}

0 commit comments

Comments
 (0)