@@ -21,14 +21,12 @@ import {
21
21
ODP_USER_KEY ,
22
22
REQUEST_TIMEOUT_ODP_SEGMENTS_MS ,
23
23
REQUEST_TIMEOUT_ODP_EVENTS_MS ,
24
- LOG_MESSAGES ,
25
24
} from '../../utils/enums' ;
26
- import { getLogger , LogHandler , LogLevel } from '../../modules/logging' ;
25
+ import { getLogger , LogHandler } from '../../modules/logging' ;
27
26
28
27
import { BrowserRequestHandler } from './../../utils/http_request_handler/browser_request_handler' ;
29
28
30
29
import BrowserAsyncStorageCache from '../key_value_cache/browserAsyncStorageCache' ;
31
- import PersistentKeyValueCache from '../key_value_cache/persistentKeyValueCache' ;
32
30
import { BrowserLRUCache } from '../../utils/lru_cache' ;
33
31
34
32
import { VuidManager } from './../vuid_manager/index' ;
@@ -53,8 +51,8 @@ interface BrowserOdpManagerConfig {
53
51
// Client-side Browser Plugin for ODP Manager
54
52
export class BrowserOdpManager extends OdpManager {
55
53
static cache = new BrowserAsyncStorageCache ( ) ;
56
- vuidManager ?: VuidManager ;
57
54
vuid ?: string ;
55
+ private static shouldUseVuid = false ;
58
56
59
57
constructor ( options : {
60
58
odpIntegrationConfig ?: OdpIntegrationConfig ;
@@ -73,13 +71,12 @@ export class BrowserOdpManager extends OdpManager {
73
71
clientEngine = clientEngine || JAVASCRIPT_CLIENT_ENGINE ;
74
72
clientVersion = clientVersion || CLIENT_VERSION ;
75
73
76
- let odpConfig : OdpConfig | undefined = undefined ;
74
+ let odpConfig : OdpConfig | undefined = undefined ;
77
75
if ( odpIntegrationConfig ?. integrated ) {
78
76
odpConfig = odpIntegrationConfig . odpConfig ;
79
77
}
80
78
81
79
let customSegmentRequestHandler ;
82
-
83
80
if ( odpOptions ?. segmentsRequestHandler ) {
84
81
customSegmentRequestHandler = odpOptions . segmentsRequestHandler ;
85
82
} else {
@@ -90,24 +87,22 @@ export class BrowserOdpManager extends OdpManager {
90
87
}
91
88
92
89
let segmentManager : IOdpSegmentManager ;
93
-
94
90
if ( odpOptions ?. segmentManager ) {
95
91
segmentManager = odpOptions . segmentManager ;
96
92
} else {
97
93
segmentManager = new OdpSegmentManager (
98
94
odpOptions ?. segmentsCache ||
99
- new BrowserLRUCache < string , string [ ] > ( {
100
- maxSize : odpOptions ?. segmentsCacheSize ,
101
- timeout : odpOptions ?. segmentsCacheTimeout ,
102
- } ) ,
95
+ new BrowserLRUCache < string , string [ ] > ( {
96
+ maxSize : odpOptions ?. segmentsCacheSize ,
97
+ timeout : odpOptions ?. segmentsCacheTimeout ,
98
+ } ) ,
103
99
new OdpSegmentApiManager ( customSegmentRequestHandler , logger ) ,
104
100
logger ,
105
101
odpConfig
106
102
) ;
107
103
}
108
104
109
105
let customEventRequestHandler ;
110
-
111
106
if ( odpOptions ?. eventRequestHandler ) {
112
107
customEventRequestHandler = odpOptions . eventRequestHandler ;
113
108
} else {
@@ -118,7 +113,6 @@ export class BrowserOdpManager extends OdpManager {
118
113
}
119
114
120
115
let eventManager : IOdpEventManager ;
121
-
122
116
if ( odpOptions ?. eventManager ) {
123
117
eventManager = odpOptions . eventManager ;
124
118
} else {
@@ -135,6 +129,8 @@ export class BrowserOdpManager extends OdpManager {
135
129
} ) ;
136
130
}
137
131
132
+ this . shouldUseVuid = odpOptions ?. enableVuid || false ;
133
+
138
134
return new BrowserOdpManager ( {
139
135
odpIntegrationConfig,
140
136
segmentManager,
@@ -149,6 +145,13 @@ export class BrowserOdpManager extends OdpManager {
149
145
*/
150
146
protected async initializeVuid ( ) : Promise < void > {
151
147
const vuidManager = await VuidManager . instance ( BrowserOdpManager . cache ) ;
148
+
149
+ if ( ! this . isVuidEnabled ( ) ) {
150
+ await vuidManager . remove ( BrowserOdpManager . cache ) ;
151
+ // assign default empty string VUID from VuidManager instead of
152
+ // early return here.
153
+ }
154
+
152
155
this . vuid = vuidManager . vuid ;
153
156
}
154
157
@@ -194,7 +197,7 @@ export class BrowserOdpManager extends OdpManager {
194
197
}
195
198
196
199
isVuidEnabled ( ) : boolean {
197
- return true ;
200
+ return BrowserOdpManager . shouldUseVuid ;
198
201
}
199
202
200
203
getVuid ( ) : string | undefined {
0 commit comments