| Conditions | 5 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | function generateIdentifier() { |
||
| 12 | export default function getIdentifier(userIdentifier) { |
||
| 13 | if (userIdentifier || userIdentifier === 0) { |
||
| 14 | return String(userIdentifier) |
||
| 15 | } |
||
| 16 | |||
| 17 | if (typeof window === 'undefined' || !('localStorage' in window)) { |
||
| 18 | return null |
||
| 19 | } |
||
| 20 | |||
| 21 | const key = '__ab_experiment_identifier__' |
||
| 22 | |||
| 23 | try { |
||
| 24 | userIdentifier = localStorage.getItem(key) |
||
| 25 | userIdentifier = userIdentifier && String(userIdentifier) |
||
| 26 | |||
| 27 | if (!userIdentifier) { |
||
| 28 | userIdentifier = generateIdentifier() |
||
| 29 | localStorage.setItem(key, userIdentifier) |
||
| 30 | } |
||
| 31 | } catch (exception) { |
||
| 32 | return null |
||
| 33 | } |
||
| 34 | |||
| 35 | return userIdentifier |
||
| 36 | } |
||
| 37 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.