@@ -9,30 +9,83 @@ import { OdpSegmentManager } from '@optimizely/optimizely-sdk/lib/core/odp/odp_s
9
9
// });
10
10
11
11
export const FetchQualifiedSegments : React . FC = ( ) => {
12
- // const optimizelyClient = createInstance({
13
- // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
14
- // });
15
12
const [ featureKey , setFeatureKey ] = useState < string > ( 'some_key' ) ;
16
13
const [ isSegmentsFetched , setIsSegmentsFetched ] = useState < boolean | null > ( null ) ;
17
14
const [ readyResult , setReadyResult ] = useState < OptimizelyReturnType > ( ) ;
18
15
19
16
const [ enableDecision , setEnableDecision ] = useState < boolean > ( false ) ;
20
17
// 1. console should show two qualified segments and a viud
21
- // const [userId] = useState<string>('matjaz-user-1');
18
+ const optimizelyClient = createInstance ( {
19
+ sdkKey : 'KZbunNn9bVfBWLpZPq2XC4' ,
20
+ } ) ;
21
+ const [ userId ] = useState < string > ( 'matjaz-user-1' ) ;
22
+ const prepareClient = ( ) => {
23
+ optimizelyClient . onReady ( ) . then ( async ( res : any ) => {
24
+ setReadyResult ( res ) ;
25
+ setIsSegmentsFetched ( true ) ;
26
+ } ) ;
27
+ } ;
22
28
23
29
// 2. console should show three qualified segments and the same viud
30
+ // const optimizelyClient = createInstance({
31
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
32
+ // });
24
33
// const [userId] = useState<string>('matjaz-user-2');
34
+ // const prepareClient = () => {
35
+ // optimizelyClient.onReady().then(async (res: any) => {
36
+ // setReadyResult(res);
37
+ // setIsSegmentsFetched(true);
38
+ // });
39
+ // };
25
40
26
41
// 3. console should show no qualified segments and the same viud
42
+ // const optimizelyClient = createInstance({
43
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
44
+ // });
27
45
// const [userId] = useState<string>('matjaz-user-3');
46
+ // const prepareClient = () => {
47
+ // optimizelyClient.onReady().then(async (res: any) => {
48
+ // setReadyResult(res);
49
+ // setIsSegmentsFetched(true);
50
+ // });
51
+ // };
28
52
29
53
// 4. console should show no qualified segments and the same viud
30
54
// const [userId] = useState<null>(null);
55
+ // const optimizelyClient = createInstance({
56
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
57
+ // });
58
+ // const prepareClient = () => {
59
+ // optimizelyClient.onReady().then(async (res: any) => {
60
+ // setReadyResult(res);
61
+ // setIsSegmentsFetched(true);
62
+ // });
63
+ // };
31
64
32
65
// 5. the network tab zaious call should be sending the vuid_xxxxx as the vuid and there shouldnt be a fs_userid sent
33
66
// const [userId] = useState<string>('vuid_overridden');
67
+ // const optimizelyClient = createInstance({
68
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
69
+ // });
70
+ // const prepareClient = () => {
71
+ // optimizelyClient.onReady().then(async (res: any) => {
72
+ // setReadyResult(res);
73
+ // setIsSegmentsFetched(true);
74
+ // });
75
+ // };
34
76
35
77
// 6. the network tab should show 2 graphql calls
78
+ // const [userId] = useState<string>('matjaz-user-3');
79
+ // const optimizelyClient = createInstance({
80
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
81
+ // });
82
+ // const prepareClient = () => {
83
+ // optimizelyClient.onReady().then(async (res: any) => {
84
+ // setReadyResult(res);
85
+ // setIsSegmentsFetched(true);
86
+ // });
87
+ // };
88
+
36
89
// useEffect(() => {
37
90
// const callSegments = async () => {
38
91
// if (readyResult?.success) {
@@ -44,6 +97,17 @@ export const FetchQualifiedSegments: React.FC = () => {
44
97
// }, [readyResult?.success]);
45
98
46
99
// 7. the network tab should show 2 graphql calls
100
+ // const [userId] = useState<string>('matjaz-user-3');
101
+ // const optimizelyClient = createInstance({
102
+ // sdkKey: 'KZbunNn9bVfBWLpZPq2XC4',
103
+ // });
104
+ // const prepareClient = () => {
105
+ // optimizelyClient.onReady().then(async (res: any) => {
106
+ // setReadyResult(res);
107
+ // setIsSegmentsFetched(true);
108
+ // });
109
+ // };
110
+
47
111
// useEffect(() => {
48
112
// const callSegments = async () => {
49
113
// if (readyResult?.success) {
@@ -224,19 +288,19 @@ export const FetchQualifiedSegments: React.FC = () => {
224
288
// };
225
289
226
290
// 18. test identifier should return bad request 400
227
- const optimizelyClient = createInstance ( {
228
- sdkKey : 'TbrfRLeKvLyWGusqANoeR' ,
229
- } ) ;
291
+ // const optimizelyClient = createInstance({
292
+ // sdkKey: 'TbrfRLeKvLyWGusqANoeR',
293
+ // });
230
294
231
- const [ userId ] = useState < string > ( 'matjaz -user-2' ) ;
295
+ // const [userId] = useState<string>('-user-2');
232
296
233
- const prepareClient = ( ) => {
234
- optimizelyClient . onReady ( ) . then ( async ( res : any ) => {
235
- setReadyResult ( res ) ;
236
- setIsSegmentsFetched ( true ) ;
237
- optimizelyClient . sendOdpEvent ( 'ttype' , '' , new Map ( [ [ 'test' , 'test' ] ] ) ) ;
238
- } ) ;
239
- } ;
297
+ // const prepareClient = () => {
298
+ // optimizelyClient.onReady().then(async (res: any) => {
299
+ // setReadyResult(res);
300
+ // setIsSegmentsFetched(true);
301
+ // optimizelyClient.sendOdpEvent('ttype', '', new Map([['test', 'test']]));
302
+ // });
303
+ // };
240
304
241
305
useEffect ( prepareClient , [ ] ) ;
242
306
0 commit comments