Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 4x 2565x 4x 2565x 2565x 2564x 2564x 2x 2x 2x 2x 4x 2563x 2563x 2563x 4x 2x | import {getConfig, setConfig} from './config.js' import {dispatchEvent} from '@s-ui/js/lib/events' const USER_DATA_READY_EVENT = 'USER_DATA_READY' /* mirar en window si hay los datos (que habría info de si el usuario está logado+hash, no logado o undefined porque aún no se sabe) -> window.__mpi.segmentWrapper.universalId si undefined nos subscribiríamos a un evento (to be defined) por el cual recibiríamos la info que se grabaría en el window (podría ser un evento como USER_DATA_READY lanzado como custom event en el document, quizá no haría falta payload si el dato se graba en window y después se emite evento, dado que los datos son los mismos) Nosotros esperábamos la forma de subscribirnos xDD necesitáis que os pasemos alguna info? */ export const getUniversalIdFromConfig = () => getConfig('universalId') export const getUniversalId = async () => { // 1. Try to get universalId from config let universalId = getUniversalIdFromConfig() if (universalId) return universalId // 2. If not available, then we use the email and hash it const userEmail = getConfig('userEmail') if (userEmail) { universalId = await import('./hashEmail.js') .then(({createUniversalId}) => createUniversalId(userEmail)) .catch(() => undefined) setUniversalId(universalId) return universalId } } export const getUniversalIdAndNotify = async () => { const universalId = await getUniversalId() dispatchEvent({eventName: USER_DATA_READY_EVENT, detail: {universalId}}) return universalId } export const setUniversalId = universalId => setConfig('universalId', universalId) |