Commit 7163adf
authored
feat!: Only support identify with result. (#1000)
Originally the SDK API had an `identify` method which didn't return any
result. We added an `identifyResult` which is a safer API.
We have decided that we shouldn't support the less-safe API and instead
should have a single identify method. So the regular identify method
will now have the behavior of `identifyResult`.
This moves the browser client to use a PIMPL implementation to decouple
its interface of the inheritance hierarchy. Which allows for identify to
have a completely different signature than the base implementation. It
also allows us to retain identify in RN until we are ready to do a major
version.
For the PIMPL implementation I decided to use a factory instead of a
class. So tests needed updated to use that factory.
I also re-organized plugin registration so the better encapsulate PIMPL
implementation would be passed to register.
The "compat" adapter needed to be updated to use the new API. For now it
supports using the old interface, but we may want to consider removing
it if we determine it isn't safe.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Replaces the BrowserClient class with a makeClient factory using a
PIMPL impl and changes identify to return LDIdentifyResult (replacing
identifyResult); updates plugin registration, compat, initialization,
and tests.
>
> - **API**
> - `identify` now returns `LDIdentifyResult` (with statuses like
`completed/shed/timeout/error`) and accepts browser-specific options;
`identifyResult` is removed from the public interface.
> - Introduce factory `makeClient` wrapping an internal
`BrowserClientImpl` (PIMPL); `initialize` now uses `makeClient`.
> - `LDClient` type updated to expose the new `identify` signature and
omit the old one.
> - **Plugins**
> - Refactor plugin registration to register against the public PIMPL
client; hook retrieval unchanged; environment metadata still forwarded.
> - **Compat**
> - `LDClientCompatImpl` updated to use `makeClient` and new `identify`
result handling; passes `sheddable: false`, propagates `bootstrap/hash`,
and maps failures/timeouts.
> - **Tests**
> - Migrate tests to `makeClient`; adjust expectations for `identify`
return values and shedding behavior; verify plugin registration and
environment metadata.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4df7885. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent af138c1 commit 7163adf
File tree
7 files changed
+152
-110
lines changed- packages/sdk/browser
- __tests__
- compat
- src
- compat
7 files changed
+152
-110
lines changedLines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
| 201 | + | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
| |||
280 | 279 | | |
281 | 280 | | |
282 | 281 | | |
283 | | - | |
284 | | - | |
| 282 | + | |
285 | 283 | | |
286 | 284 | | |
287 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
| 192 | + | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
| 215 | + | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
327 | | - | |
328 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
339 | | - | |
| 338 | + | |
| 339 | + | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
376 | 367 | | |
377 | 368 | | |
378 | 369 | | |
| |||
Lines changed: 31 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | | - | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | | - | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | | - | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
| 115 | + | |
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
| |||
161 | 166 | | |
162 | 167 | | |
163 | 168 | | |
164 | | - | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
169 | | - | |
| 174 | + | |
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
174 | 179 | | |
175 | | - | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | | - | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
186 | 191 | | |
187 | | - | |
| 192 | + | |
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
192 | | - | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
| |||
427 | 432 | | |
428 | 433 | | |
429 | 434 | | |
| 435 | + | |
430 | 436 | | |
431 | 437 | | |
432 | 438 | | |
| |||
451 | 457 | | |
452 | 458 | | |
453 | 459 | | |
454 | | - | |
| 460 | + | |
455 | 461 | | |
456 | 462 | | |
457 | 463 | | |
| |||
464 | 470 | | |
465 | 471 | | |
466 | 472 | | |
467 | | - | |
| 473 | + | |
468 | 474 | | |
469 | 475 | | |
470 | 476 | | |
| |||
475 | 481 | | |
476 | 482 | | |
477 | 483 | | |
478 | | - | |
| 484 | + | |
479 | 485 | | |
480 | 486 | | |
481 | 487 | | |
| |||
487 | 493 | | |
488 | 494 | | |
489 | 495 | | |
490 | | - | |
| 496 | + | |
491 | 497 | | |
492 | 498 | | |
493 | 499 | | |
| |||
0 commit comments