analytica.click 0.0.258 → 0.0.261
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +161 -92
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -36,7 +36,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
36
36
|
}
|
37
37
|
return to;
|
38
38
|
};
|
39
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
39
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
40
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
41
|
+
mod
|
42
|
+
));
|
40
43
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
41
44
|
var __async = (__this, __arguments, generator) => {
|
42
45
|
return new Promise((resolve, reject) => {
|
@@ -672,6 +675,31 @@ var require_api = __commonJS({
|
|
672
675
|
}
|
673
676
|
});
|
674
677
|
|
678
|
+
// ../common/dist/helpers/logsend.js
|
679
|
+
var require_logsend = __commonJS({
|
680
|
+
"../common/dist/helpers/logsend.js"(exports) {
|
681
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
682
|
+
exports.isValidLogMessage = void 0;
|
683
|
+
var log_1 = require("ag-common/dist/common/helpers/log");
|
684
|
+
function isValidLogMessage2(m) {
|
685
|
+
if (!m) {
|
686
|
+
(0, log_1.info)("no message?");
|
687
|
+
return false;
|
688
|
+
}
|
689
|
+
if (m.match(/^"?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}"?$/)) {
|
690
|
+
(0, log_1.info)("ignoring react devtools message");
|
691
|
+
return false;
|
692
|
+
}
|
693
|
+
if (m === JSON.stringify([{}])) {
|
694
|
+
(0, log_1.info)("empty message payload?");
|
695
|
+
return false;
|
696
|
+
}
|
697
|
+
return true;
|
698
|
+
}
|
699
|
+
exports.isValidLogMessage = isValidLogMessage2;
|
700
|
+
}
|
701
|
+
});
|
702
|
+
|
675
703
|
// ../common-ui/dist/components/ErrorBoundary/index.js
|
676
704
|
var require_ErrorBoundary = __commonJS({
|
677
705
|
"../common-ui/dist/components/ErrorBoundary/index.js"(exports) {
|
@@ -705,8 +733,17 @@ var require_ErrorBoundary = __commonJS({
|
|
705
733
|
if (notify) {
|
706
734
|
notify(hasError);
|
707
735
|
}
|
708
|
-
return react_1.default.createElement(
|
709
|
-
|
736
|
+
return react_1.default.createElement(
|
737
|
+
Modal_1.Modal,
|
738
|
+
{ open: true, setOpen: () => {
|
739
|
+
} },
|
740
|
+
react_1.default.createElement(
|
741
|
+
Base,
|
742
|
+
null,
|
743
|
+
"A fatal error has occurred - the admin has been notified.",
|
744
|
+
react_1.default.createElement("button", { type: "button", onClick: () => window.location.reload() }, "Press here to restart app")
|
745
|
+
)
|
746
|
+
);
|
710
747
|
}
|
711
748
|
return children;
|
712
749
|
}
|
@@ -813,6 +850,7 @@ var import_array = require("ag-common/dist/common/helpers/array");
|
|
813
850
|
var import_log = require("ag-common/dist/common/helpers/log");
|
814
851
|
var import_callOpenApi = require("ag-common/dist/ui/helpers/callOpenApi");
|
815
852
|
var import_api = __toESM(require_api());
|
853
|
+
var import_logsend = __toESM(require_logsend());
|
816
854
|
function callOpenApi(p) {
|
817
855
|
return (0, import_callOpenApi.callOpenApi)(__spreadProps(__spreadValues({}, p), {
|
818
856
|
func: (d) => p.func(d),
|
@@ -875,8 +913,16 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
|
|
875
913
|
data,
|
876
914
|
overrideBaseUrl = "https://api.analytica.click"
|
877
915
|
}) {
|
916
|
+
var _a2;
|
878
917
|
if (isLocal) {
|
879
|
-
(0, import_log.debug)(
|
918
|
+
(0, import_log.debug)(
|
919
|
+
`local error tracking ignored:${data.data.message} ${JSON.stringify(
|
920
|
+
data
|
921
|
+
)}, to ${overrideBaseUrl}`
|
922
|
+
);
|
923
|
+
return {};
|
924
|
+
}
|
925
|
+
if (!(0, import_logsend.isValidLogMessage)((_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.message)) {
|
880
926
|
return {};
|
881
927
|
}
|
882
928
|
(0, import_log.debug)("error track", data.data.message, JSON.stringify(data));
|
@@ -959,7 +1005,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
|
|
959
1005
|
}) {
|
960
1006
|
var _a2;
|
961
1007
|
if (typeof window !== "undefined" && ((_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname) === "localhost") {
|
962
|
-
(0, import_log3.debug)(
|
1008
|
+
(0, import_log3.debug)(
|
1009
|
+
`local feedback ignored:${JSON.stringify(data)}, to ${overrideBaseUrl}`
|
1010
|
+
);
|
963
1011
|
return {};
|
964
1012
|
}
|
965
1013
|
(0, import_log3.debug)("feedback", JSON.stringify(data));
|
@@ -973,7 +1021,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
|
|
973
1021
|
return {};
|
974
1022
|
});
|
975
1023
|
var useFeedback = () => {
|
976
|
-
const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(
|
1024
|
+
const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(
|
1025
|
+
AnalyticaConfigContext
|
1026
|
+
);
|
977
1027
|
if (!analyticaToken) {
|
978
1028
|
(0, import_log3.warn)(tokenMissing("useFeedback"));
|
979
1029
|
return { trackWithToken: () => ({ error: "no token" }) };
|
@@ -1079,7 +1129,9 @@ var page = (_0) => __async(void 0, [_0], function* ({
|
|
1079
1129
|
return track({ analyticaToken, userData, overrideBaseUrl, eventName: "PAGE" });
|
1080
1130
|
});
|
1081
1131
|
var useTrack = () => {
|
1082
|
-
const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(
|
1132
|
+
const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(
|
1133
|
+
AnalyticaConfigContext
|
1134
|
+
);
|
1083
1135
|
if (!analyticaToken) {
|
1084
1136
|
(0, import_log5.warn)(tokenMissing("useTrack"));
|
1085
1137
|
const def = () => __async(void 0, null, function* () {
|
@@ -1192,7 +1244,9 @@ var ExternalComponent = ({
|
|
1192
1244
|
var import_react6 = __toESM(require("react"));
|
1193
1245
|
var import_log7 = require("ag-common/dist/common/helpers/log");
|
1194
1246
|
var Feedback = (props) => {
|
1195
|
-
const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
|
1247
|
+
const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
|
1248
|
+
AnalyticaConfigContext
|
1249
|
+
);
|
1196
1250
|
if (!analyticaToken) {
|
1197
1251
|
(0, import_log7.warn)(tokenMissing("Feedback"));
|
1198
1252
|
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null);
|
@@ -1375,7 +1429,9 @@ var import_react8 = __toESM(require("react"));
|
|
1375
1429
|
var import_useLocalStorage = require("ag-common/dist/ui/helpers/useLocalStorage");
|
1376
1430
|
var import_cookie = require("ag-common/dist/ui/helpers/cookie");
|
1377
1431
|
var import_dom3 = __toESM(require_dom());
|
1378
|
-
var CognitoAuthContext = import_react8.default.createContext(
|
1432
|
+
var CognitoAuthContext = import_react8.default.createContext(
|
1433
|
+
void 0
|
1434
|
+
);
|
1379
1435
|
var getStatefulUrl = ({
|
1380
1436
|
redirectUrl,
|
1381
1437
|
qs
|
@@ -1467,86 +1523,92 @@ var CognitoAuthProvider = ({
|
|
1467
1523
|
login: true
|
1468
1524
|
});
|
1469
1525
|
});
|
1470
|
-
useGranularEffect(
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
}
|
1480
|
-
try {
|
1481
|
-
setLoading(true);
|
1482
|
-
if (qs == null ? void 0 : qs.error) {
|
1483
|
-
const newerror = {
|
1484
|
-
message: (qs == null ? void 0 : qs.error_description) || "auth error"
|
1485
|
-
};
|
1486
|
-
if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
|
1487
|
-
setError(newerror);
|
1488
|
-
}
|
1489
|
-
return;
|
1490
|
-
}
|
1491
|
-
if ((qs == null ? void 0 : qs.code) && !expired) {
|
1492
|
-
yield goToPageUrl({ url: redirectUrl, login: false });
|
1526
|
+
useGranularEffect(
|
1527
|
+
() => {
|
1528
|
+
function run() {
|
1529
|
+
return __async(this, null, function* () {
|
1530
|
+
var _a3, _b2, _c, _d;
|
1531
|
+
const hasQs = !!(qs == null ? void 0 : qs.code) || !!(qs == null ? void 0 : qs.error);
|
1532
|
+
const expired = jwtExpired(user == null ? void 0 : user.jwt);
|
1533
|
+
const onlyJwt = !(user == null ? void 0 : user.userId) && !!(user == null ? void 0 : user.jwt);
|
1534
|
+
if (loading || error2 || ((_a3 = user == null ? void 0 : user.idJwt) == null ? void 0 : _a3.email) && !hasQs && !expired) {
|
1493
1535
|
return;
|
1494
1536
|
}
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1537
|
+
try {
|
1538
|
+
setLoading(true);
|
1539
|
+
if (qs == null ? void 0 : qs.error) {
|
1540
|
+
const newerror = {
|
1541
|
+
message: (qs == null ? void 0 : qs.error_description) || "auth error"
|
1542
|
+
};
|
1543
|
+
if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
|
1544
|
+
setError(newerror);
|
1545
|
+
}
|
1546
|
+
return;
|
1547
|
+
}
|
1548
|
+
if ((qs == null ? void 0 : qs.code) && !expired) {
|
1549
|
+
yield goToPageUrl({ url: redirectUrl, login: false });
|
1550
|
+
return;
|
1551
|
+
}
|
1552
|
+
if (qs == null ? void 0 : qs.code) {
|
1553
|
+
if (expired) {
|
1554
|
+
yield getTokensFromCode({
|
1555
|
+
code: qs.code,
|
1556
|
+
redirectUrl,
|
1557
|
+
config,
|
1558
|
+
setUser
|
1559
|
+
});
|
1560
|
+
}
|
1561
|
+
yield goToPageUrl({
|
1562
|
+
url: getStatefulUrl({ redirectUrl, qs }),
|
1563
|
+
login: false
|
1564
|
+
});
|
1565
|
+
return;
|
1566
|
+
}
|
1567
|
+
if (expired && ((_b2 = user == null ? void 0 : user.jwt) == null ? void 0 : _b2.refresh_token)) {
|
1568
|
+
yield refreshToken({
|
1569
|
+
setUser,
|
1570
|
+
setError,
|
1571
|
+
user,
|
1500
1572
|
config,
|
1501
|
-
|
1573
|
+
logout
|
1502
1574
|
});
|
1575
|
+
return;
|
1503
1576
|
}
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
return;
|
1519
|
-
}
|
1520
|
-
if (onlyJwt) {
|
1521
|
-
const token = (_d = (_c = user == null ? void 0 : user.jwt) == null ? void 0 : _c.id_token) == null ? void 0 : _d.substr(user.jwt.id_token.indexOf(" ") + 1);
|
1522
|
-
if (!user || !token) {
|
1523
|
-
(0, import_log9.info)("logging out no token");
|
1524
|
-
setUser(void 0);
|
1525
|
-
setError(void 0);
|
1526
|
-
} else {
|
1527
|
-
setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
|
1528
|
-
jwt: user.jwt,
|
1529
|
-
credentials: user.credentials
|
1530
|
-
}));
|
1577
|
+
if (onlyJwt) {
|
1578
|
+
const token = (_d = (_c = user == null ? void 0 : user.jwt) == null ? void 0 : _c.id_token) == null ? void 0 : _d.substr(
|
1579
|
+
user.jwt.id_token.indexOf(" ") + 1
|
1580
|
+
);
|
1581
|
+
if (!user || !token) {
|
1582
|
+
(0, import_log9.info)("logging out no token");
|
1583
|
+
setUser(void 0);
|
1584
|
+
setError(void 0);
|
1585
|
+
} else {
|
1586
|
+
setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
|
1587
|
+
jwt: user.jwt,
|
1588
|
+
credentials: user.credentials
|
1589
|
+
}));
|
1590
|
+
}
|
1531
1591
|
}
|
1592
|
+
} finally {
|
1593
|
+
setLoading(false);
|
1532
1594
|
}
|
1533
|
-
}
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1595
|
+
});
|
1596
|
+
}
|
1597
|
+
void run();
|
1598
|
+
},
|
1599
|
+
[user == null ? void 0 : user.jwt, qs],
|
1600
|
+
[
|
1601
|
+
config,
|
1602
|
+
error2,
|
1603
|
+
goToPageUrl,
|
1604
|
+
logout,
|
1605
|
+
loading,
|
1606
|
+
qs,
|
1607
|
+
redirectUrl,
|
1608
|
+
setUser,
|
1609
|
+
user
|
1610
|
+
]
|
1611
|
+
);
|
1550
1612
|
(0, import_react8.useEffect)(() => {
|
1551
1613
|
var _a3;
|
1552
1614
|
if (error2) {
|
@@ -1596,17 +1658,24 @@ var DashboardAuthValidation = ({
|
|
1596
1658
|
getUnauthedPage,
|
1597
1659
|
addToast
|
1598
1660
|
}) => {
|
1599
|
-
useGranularEffect(
|
1600
|
-
|
1601
|
-
|
1661
|
+
useGranularEffect(
|
1662
|
+
() => {
|
1663
|
+
if (authError) {
|
1664
|
+
const emailOption = authError.message.includes("email") ? ` We require the use of your email for the functionality of this app.
|
1602
1665
|
You can update your settings at https://www.facebook.com/settings?tab=applications` : "";
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1666
|
+
addToast(
|
1667
|
+
`An Error has occured with your login attempt.${emailOption}`,
|
1668
|
+
{
|
1669
|
+
appearance: "error"
|
1670
|
+
}
|
1671
|
+
);
|
1672
|
+
(0, import_log10.error)(`auth error:`, JSON.stringify(authError, null, 2));
|
1673
|
+
void logout();
|
1674
|
+
}
|
1675
|
+
},
|
1676
|
+
[authError],
|
1677
|
+
[authError, addToast, logout]
|
1678
|
+
);
|
1610
1679
|
const forceLogin = Object.keys(request.url.query || {}).includes("login");
|
1611
1680
|
if (forceLogin) {
|
1612
1681
|
if (!isAuthenticated) {
|