mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Refactored index.js
This commit is contained in:
parent
109e8d6d31
commit
224961447c
1 changed files with 7 additions and 6 deletions
|
|
@ -235,23 +235,24 @@
|
||||||
const track = (obj, data) => {
|
const track = (obj, data) => {
|
||||||
let identity;
|
let identity;
|
||||||
try {
|
try {
|
||||||
identity = JSON.parse(localStorage.getItem('umami.identity'));
|
const parsedIdentity = JSON.parse(localStorage.getItem('umami.identity'));
|
||||||
|
identity = parsedIdentity !== null ? parsedIdentity : undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
identity = null;
|
identity = undefined;
|
||||||
}
|
}
|
||||||
if (typeof obj === 'string') {
|
if (typeof obj === 'string') {
|
||||||
return send({
|
return send({
|
||||||
...getPayload(),
|
...getPayload(),
|
||||||
name: obj,
|
name: obj,
|
||||||
data: typeof data === 'object' ? data : undefined,
|
data: typeof data === 'object' ? data : undefined,
|
||||||
identity: identity !== null ? identity : undefined,
|
identity,
|
||||||
});
|
});
|
||||||
} else if (typeof obj === 'object') {
|
} else if (typeof obj === 'object') {
|
||||||
return send({ ...obj, identity: identity !== null ? identity : undefined });
|
return send({ ...obj, identity });
|
||||||
} else if (typeof obj === 'function') {
|
} else if (typeof obj === 'function') {
|
||||||
return send({ ...obj(getPayload()), identity: identity !== null ? identity : undefined });
|
return send({ ...obj(getPayload()), identity });
|
||||||
}
|
}
|
||||||
return send({ ...getPayload(), identity: identity !== null ? identity : undefined });
|
return send({ ...getPayload(), identity });
|
||||||
};
|
};
|
||||||
|
|
||||||
const identify = data => {
|
const identify = data => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue