analytica.click 0.0.260 → 0.0.263

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.d.ts CHANGED
@@ -216,14 +216,6 @@ declare module 'analytica.click/ui-npm/src/components/UserProvider/refreshToken'
216
216
  logout: () => void;
217
217
  }): Promise<User | undefined>;
218
218
 
219
- }
220
- declare module 'analytica.click/ui-npm/src/components/UserProvider/useGranularHook' {
221
- import { DependencyList, EffectCallback } from 'react';
222
- type HookWithDependencies<C, R> = (callback: C, deps: DependencyList) => R;
223
- export const useGranularHook: <T extends HookWithDependencies<C, ReturnType<T>>, C>(hook: T, callback: C, primaryDeps: DependencyList, secondaryDeps: DependencyList) => ReturnType<T>;
224
- export const useGranularEffect: (effect: EffectCallback, primaryDeps: DependencyList, secondaryDeps: DependencyList) => void;
225
- export {};
226
-
227
219
  }
228
220
  declare module 'analytica.click/ui-npm/src/components/index' {
229
221
  export * from 'analytica.click/ui-npm/src/components/AnalyticaConfig/index';
@@ -273,6 +265,13 @@ declare module 'analytica.click/ui-npm/src/helpers/jwt' {
273
265
  declare module 'analytica.click/ui-npm/src/helpers/log' {
274
266
  export const tokenMissing: (comp: string) => string;
275
267
 
268
+ }
269
+ declare module 'analytica.click/ui-npm/src/helpers/object' {
270
+ export const takeObject: <T>(ob: Record<string, T>, num: number) => {
271
+ part: T[];
272
+ rest: Record<string, T>;
273
+ };
274
+
276
275
  }
277
276
  declare module 'analytica.click/ui-npm/src/helpers/track' {
278
277
  import { ITrack, TTrack, TTrackNoEvent } from 'analytica.click/common-ui/src/types/index';
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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
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) => {
@@ -676,7 +679,8 @@ var require_api = __commonJS({
676
679
  var require_logsend = __commonJS({
677
680
  "../common/dist/helpers/logsend.js"(exports) {
678
681
  Object.defineProperty(exports, "__esModule", { value: true });
679
- exports.isValidLogMessage = void 0;
682
+ exports.getErrorKey = exports.isValidLogMessage = void 0;
683
+ var hashCode_1 = require("ag-common/dist/common/helpers/hashCode");
680
684
  var log_1 = require("ag-common/dist/common/helpers/log");
681
685
  function isValidLogMessage2(m) {
682
686
  if (!m) {
@@ -694,6 +698,27 @@ var require_logsend = __commonJS({
694
698
  return true;
695
699
  }
696
700
  exports.isValidLogMessage = isValidLogMessage2;
701
+ var getErrorKey2 = (message = "") => {
702
+ var _a2, _b, _c;
703
+ let messageHash = "";
704
+ try {
705
+ const ob = JSON.parse(message);
706
+ const toClean = Array.isArray(ob) && ((_a2 = ob[0]) === null || _a2 === void 0 ? void 0 : _a2.match(/^\[?[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\]?$/));
707
+ if (toClean) {
708
+ (0, log_1.info)("removing date from hash");
709
+ ob[0] = "(date)";
710
+ messageHash = (0, hashCode_1.hashCode)(JSON.stringify(ob));
711
+ } else {
712
+ messageHash = ob.message || ob.name || ob.description || void 0;
713
+ }
714
+ } catch (e) {
715
+ }
716
+ if (!messageHash) {
717
+ messageHash = (_c = (_b = (0, hashCode_1.hashCode)(message)) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
718
+ }
719
+ return messageHash;
720
+ };
721
+ exports.getErrorKey = getErrorKey2;
697
722
  }
698
723
  });
699
724
 
@@ -730,8 +755,17 @@ var require_ErrorBoundary = __commonJS({
730
755
  if (notify) {
731
756
  notify(hasError);
732
757
  }
733
- return react_1.default.createElement(Modal_1.Modal, { open: true, setOpen: () => {
734
- } }, react_1.default.createElement(Base, null, "A fatal error has occurred - the admin has been notified.", react_1.default.createElement("button", { type: "button", onClick: () => window.location.reload() }, "Press here to restart app")));
758
+ return react_1.default.createElement(
759
+ Modal_1.Modal,
760
+ { open: true, setOpen: () => {
761
+ } },
762
+ react_1.default.createElement(
763
+ Base,
764
+ null,
765
+ "A fatal error has occurred - the admin has been notified.",
766
+ react_1.default.createElement("button", { type: "button", onClick: () => window.location.reload() }, "Press here to restart app")
767
+ )
768
+ );
735
769
  }
736
770
  return children;
737
771
  }
@@ -833,8 +867,23 @@ __export(src_exports, {
833
867
  });
834
868
  module.exports = __toCommonJS(src_exports);
835
869
 
870
+ // src/helpers/object.ts
871
+ var takeObject = (ob, num) => {
872
+ const part = [];
873
+ const rest = {};
874
+ let c = 0;
875
+ Object.entries(ob).forEach(([index, item]) => {
876
+ if (c < num) {
877
+ part.push(item);
878
+ } else {
879
+ rest[index] = item;
880
+ }
881
+ c += 1;
882
+ });
883
+ return { part, rest };
884
+ };
885
+
836
886
  // src/helpers/errorTrack.tsx
837
- var import_array = require("ag-common/dist/common/helpers/array");
838
887
  var import_log = require("ag-common/dist/common/helpers/log");
839
888
  var import_callOpenApi = require("ag-common/dist/ui/helpers/callOpenApi");
840
889
  var import_api = __toESM(require_api());
@@ -851,34 +900,36 @@ function callOpenApi(p) {
851
900
  }
852
901
  var _a;
853
902
  var isLocal = typeof window !== "undefined" && ((_a = window == null ? void 0 : window.location) == null ? void 0 : _a.hostname) === "localhost";
854
- var errorBuffer = [];
903
+ var errorBuffer = {};
855
904
  var errorTimer;
856
905
  var overrideBaseUrlSet;
857
906
  var errorPush = () => __async(void 0, null, function* () {
858
907
  var _a2, _b;
859
908
  try {
860
- if (errorBuffer.length > 100) {
909
+ if (Object.keys(errorBuffer).length > 100) {
910
+ const firstKey = Object.keys(errorBuffer)[0];
911
+ const first = errorBuffer[firstKey];
861
912
  const x1 = yield callOpenApi({
862
913
  apiUrl: overrideBaseUrlSet,
863
914
  func: (s) => {
864
915
  var _a3;
865
916
  return s.postErrors([
866
917
  {
867
- key: errorBuffer[0].key,
868
- data: __spreadProps(__spreadValues({}, errorBuffer[0].data), {
869
- message: `error overload!: ${(_a3 = errorBuffer[0].data.message) != null ? _a3 : "?"}`
918
+ key: first.key,
919
+ data: __spreadProps(__spreadValues({}, first.data), {
920
+ message: `error overload!: ${(_a3 = first.data.message) != null ? _a3 : "?"}`
870
921
  })
871
922
  }
872
923
  ]);
873
924
  }
874
925
  });
875
- errorBuffer = [];
926
+ errorBuffer = {};
876
927
  if (x1.error) {
877
928
  throw x1.error;
878
929
  }
879
930
  return {};
880
931
  }
881
- const { part, rest } = (0, import_array.take)(errorBuffer, 10);
932
+ const { part, rest } = takeObject(errorBuffer, 10);
882
933
  errorBuffer = rest;
883
934
  const x = yield callOpenApi({
884
935
  apiUrl: overrideBaseUrlSet,
@@ -903,14 +954,19 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
903
954
  }) {
904
955
  var _a2;
905
956
  if (isLocal) {
906
- (0, import_log.debug)(`local error tracking ignored:${data.data.message} ${JSON.stringify(data)}, to ${overrideBaseUrl}`);
957
+ (0, import_log.debug)(
958
+ `local error tracking ignored:${data.data.message} ${JSON.stringify(
959
+ data
960
+ )}, to ${overrideBaseUrl}`
961
+ );
907
962
  return {};
908
963
  }
909
964
  if (!(0, import_logsend.isValidLogMessage)((_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.message)) {
910
965
  return {};
911
966
  }
912
967
  (0, import_log.debug)("error track", data.data.message, JSON.stringify(data));
913
- errorBuffer.push(data);
968
+ const key = (0, import_logsend.getErrorKey)(data.data.message);
969
+ errorBuffer[key] = data;
914
970
  overrideBaseUrlSet = overrideBaseUrl;
915
971
  if (!errorTimer) {
916
972
  errorTimer = setTimeout(errorPush, 500);
@@ -920,6 +976,7 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
920
976
 
921
977
  // src/components/AnalyticaConfig/index.tsx
922
978
  var import_react = __toESM(require("react"));
979
+ var import_jsx_runtime = require("react/jsx-runtime");
923
980
  var stubState = {
924
981
  analyticaToken: void 0,
925
982
  overrideBaseUrl: void 0
@@ -959,9 +1016,10 @@ var AnalyticaConfigProvider = ({
959
1016
  (0, import_react.useEffect)(() => {
960
1017
  overloadConsole(values);
961
1018
  }, []);
962
- return /* @__PURE__ */ import_react.default.createElement(AnalyticaConfigContext.Provider, {
963
- value: state
964
- }, children);
1019
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnalyticaConfigContext.Provider, {
1020
+ value: state,
1021
+ children
1022
+ });
965
1023
  };
966
1024
 
967
1025
  // src/helpers/log.ts
@@ -989,7 +1047,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
989
1047
  }) {
990
1048
  var _a2;
991
1049
  if (typeof window !== "undefined" && ((_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname) === "localhost") {
992
- (0, import_log3.debug)(`local feedback ignored:${JSON.stringify(data)}, to ${overrideBaseUrl}`);
1050
+ (0, import_log3.debug)(
1051
+ `local feedback ignored:${JSON.stringify(data)}, to ${overrideBaseUrl}`
1052
+ );
993
1053
  return {};
994
1054
  }
995
1055
  (0, import_log3.debug)("feedback", JSON.stringify(data));
@@ -1003,7 +1063,9 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
1003
1063
  return {};
1004
1064
  });
1005
1065
  var useFeedback = () => {
1006
- const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(AnalyticaConfigContext);
1066
+ const { analyticaToken, overrideBaseUrl } = (0, import_react2.useContext)(
1067
+ AnalyticaConfigContext
1068
+ );
1007
1069
  if (!analyticaToken) {
1008
1070
  (0, import_log3.warn)(tokenMissing("useFeedback"));
1009
1071
  return { trackWithToken: () => ({ error: "no token" }) };
@@ -1109,7 +1171,9 @@ var page = (_0) => __async(void 0, [_0], function* ({
1109
1171
  return track({ analyticaToken, userData, overrideBaseUrl, eventName: "PAGE" });
1110
1172
  });
1111
1173
  var useTrack = () => {
1112
- const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(AnalyticaConfigContext);
1174
+ const { analyticaToken, overrideBaseUrl } = (0, import_react3.useContext)(
1175
+ AnalyticaConfigContext
1176
+ );
1113
1177
  if (!analyticaToken) {
1114
1178
  (0, import_log5.warn)(tokenMissing("useTrack"));
1115
1179
  const def = () => __async(void 0, null, function* () {
@@ -1125,8 +1189,9 @@ var useTrack = () => {
1125
1189
 
1126
1190
  // src/components/ErrorBoundary/index.tsx
1127
1191
  var import_ErrorBoundary = __toESM(require_ErrorBoundary());
1128
- var import_react4 = __toESM(require("react"));
1192
+ var import_react4 = require("react");
1129
1193
  var import_log6 = require("ag-common/dist/common/helpers/log");
1194
+ var import_jsx_runtime = require("react/jsx-runtime");
1130
1195
  function onBrowserError(_0) {
1131
1196
  return __async(this, arguments, function* ({
1132
1197
  ev,
@@ -1171,9 +1236,11 @@ var ErrorBoundary = ({
1171
1236
  }, [analyticaToken, filterBrowserError]);
1172
1237
  if (!analyticaToken) {
1173
1238
  (0, import_log6.warn)(tokenMissing("ErrorBoundary"));
1174
- return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, children);
1239
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
1240
+ children
1241
+ });
1175
1242
  }
1176
- return /* @__PURE__ */ import_react4.default.createElement(import_ErrorBoundary.ErrorBoundary, {
1243
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorBoundary.ErrorBoundary, {
1177
1244
  notify: (data) => __async(void 0, null, function* () {
1178
1245
  const { href } = window.location;
1179
1246
  yield errorTrack({
@@ -1184,8 +1251,9 @@ var ErrorBoundary = ({
1184
1251
  })
1185
1252
  }
1186
1253
  });
1187
- })
1188
- }, children);
1254
+ }),
1255
+ children
1256
+ });
1189
1257
  };
1190
1258
 
1191
1259
  // src/components/ExternalComponent/index.tsx
@@ -1193,6 +1261,7 @@ var import_react5 = __toESM(require("react"));
1193
1261
  var import_createRequires = require("@paciolan/remote-component/dist/createRequires");
1194
1262
  var import_useRemoteComponent = require("@paciolan/remote-component/dist/hooks/useRemoteComponent");
1195
1263
  var import_react_dom = __toESM(require("react-dom"));
1264
+ var import_jsx_runtime = require("react/jsx-runtime");
1196
1265
  var styled = require("styled-components");
1197
1266
  var cache = {};
1198
1267
  var ExternalComponent = ({
@@ -1215,17 +1284,25 @@ var ExternalComponent = ({
1215
1284
  if (!cache[url] && !loading && !error2 && Component) {
1216
1285
  cache[url] = Component;
1217
1286
  }
1218
- return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, !loading && !error2 && /* @__PURE__ */ import_react5.default.createElement(Component, __spreadValues({}, props)), error2 && error2);
1287
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
1288
+ children: [
1289
+ !loading && !error2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
1290
+ error2 && error2
1291
+ ]
1292
+ });
1219
1293
  };
1220
1294
 
1221
1295
  // src/components/Feedback/index.tsx
1222
- var import_react6 = __toESM(require("react"));
1296
+ var import_react6 = require("react");
1223
1297
  var import_log7 = require("ag-common/dist/common/helpers/log");
1298
+ var import_jsx_runtime = require("react/jsx-runtime");
1224
1299
  var Feedback = (props) => {
1225
- const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(AnalyticaConfigContext);
1300
+ const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
1301
+ AnalyticaConfigContext
1302
+ );
1226
1303
  if (!analyticaToken) {
1227
1304
  (0, import_log7.warn)(tokenMissing("Feedback"));
1228
- return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null);
1305
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
1229
1306
  }
1230
1307
  const int = __spreadProps(__spreadValues({}, props), {
1231
1308
  submitFeedback: feedback,
@@ -1236,7 +1313,7 @@ var Feedback = (props) => {
1236
1313
  if (devMode) {
1237
1314
  url = `/feedback.js`;
1238
1315
  }
1239
- return /* @__PURE__ */ import_react6.default.createElement(ExternalComponent, {
1316
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalComponent, {
1240
1317
  url,
1241
1318
  props: int
1242
1319
  });
@@ -1386,26 +1463,17 @@ function getTokensFromCode(_0) {
1386
1463
  });
1387
1464
  }
1388
1465
 
1389
- // src/components/UserProvider/useGranularHook.ts
1390
- var import_react7 = require("react");
1391
- var useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
1392
- const ref = (0, import_react7.useRef)();
1393
- if (!ref.current || !primaryDeps.every((w, i) => {
1394
- var _a2;
1395
- return Object.is(w, (_a2 = ref.current) == null ? void 0 : _a2[i]);
1396
- }))
1397
- ref.current = [...primaryDeps, ...secondaryDeps];
1398
- return hook(callback, ref.current);
1399
- };
1400
- var useGranularEffect = (effect, primaryDeps, secondaryDeps) => useGranularHook(import_react7.useEffect, effect, primaryDeps, secondaryDeps);
1401
-
1402
1466
  // src/components/UserProvider/index.tsx
1403
1467
  var import_log9 = require("ag-common/dist/common/helpers/log");
1404
- var import_react8 = __toESM(require("react"));
1468
+ var import_react7 = __toESM(require("react"));
1405
1469
  var import_useLocalStorage = require("ag-common/dist/ui/helpers/useLocalStorage");
1406
1470
  var import_cookie = require("ag-common/dist/ui/helpers/cookie");
1407
1471
  var import_dom3 = __toESM(require_dom());
1408
- var CognitoAuthContext = import_react8.default.createContext(void 0);
1472
+ var import_useGranularHook = require("ag-common/dist/ui/helpers/useGranularHook");
1473
+ var import_jsx_runtime = require("react/jsx-runtime");
1474
+ var CognitoAuthContext = import_react7.default.createContext(
1475
+ void 0
1476
+ );
1409
1477
  var getStatefulUrl = ({
1410
1478
  redirectUrl,
1411
1479
  qs
@@ -1435,7 +1503,7 @@ var CognitoAuthProvider = ({
1435
1503
  cookieDocument
1436
1504
  }) => {
1437
1505
  var _a2, _b;
1438
- const [error2, setError] = (0, import_react8.useState)();
1506
+ const [error2, setError] = (0, import_react7.useState)();
1439
1507
  const [idTokenRaw, setIdToken] = (0, import_cookie.useCookieString)({
1440
1508
  name: "id_token",
1441
1509
  cookieDocument: typeof window === "undefined" ? cookieDocument : void 0,
@@ -1456,7 +1524,7 @@ var CognitoAuthProvider = ({
1456
1524
  setUserRaw(value2);
1457
1525
  return;
1458
1526
  };
1459
- const [loading, setLoading] = (0, import_react8.useState)(false);
1527
+ const [loading, setLoading] = (0, import_react7.useState)(false);
1460
1528
  const qs = (0, import_dom3.extractQs)({
1461
1529
  search: typeof window === "undefined" ? "" : window.location.search,
1462
1530
  sanatise: false
@@ -1471,7 +1539,7 @@ var CognitoAuthProvider = ({
1471
1539
  yield goToPageUrl({ url: location.origin, login: false });
1472
1540
  setLoading(false);
1473
1541
  });
1474
- (0, import_react8.useEffect)(() => {
1542
+ (0, import_react7.useEffect)(() => {
1475
1543
  var _a3;
1476
1544
  const newT = (_a3 = user == null ? void 0 : user.jwt) == null ? void 0 : _a3.id_token;
1477
1545
  if (!!newT && newT !== idToken) {
@@ -1497,87 +1565,93 @@ var CognitoAuthProvider = ({
1497
1565
  login: true
1498
1566
  });
1499
1567
  });
1500
- useGranularEffect(() => {
1501
- function run() {
1502
- return __async(this, null, function* () {
1503
- var _a3, _b2, _c, _d;
1504
- const hasQs = !!(qs == null ? void 0 : qs.code) || !!(qs == null ? void 0 : qs.error);
1505
- const expired = jwtExpired(user == null ? void 0 : user.jwt);
1506
- const onlyJwt = !(user == null ? void 0 : user.userId) && !!(user == null ? void 0 : user.jwt);
1507
- if (loading || error2 || ((_a3 = user == null ? void 0 : user.idJwt) == null ? void 0 : _a3.email) && !hasQs && !expired) {
1508
- return;
1509
- }
1510
- try {
1511
- setLoading(true);
1512
- if (qs == null ? void 0 : qs.error) {
1513
- const newerror = {
1514
- message: (qs == null ? void 0 : qs.error_description) || "auth error"
1515
- };
1516
- if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
1517
- setError(newerror);
1518
- }
1519
- return;
1520
- }
1521
- if ((qs == null ? void 0 : qs.code) && !expired) {
1522
- yield goToPageUrl({ url: redirectUrl, login: false });
1568
+ (0, import_useGranularHook.useGranularEffect)(
1569
+ () => {
1570
+ function run() {
1571
+ return __async(this, null, function* () {
1572
+ var _a3, _b2, _c, _d;
1573
+ const hasQs = !!(qs == null ? void 0 : qs.code) || !!(qs == null ? void 0 : qs.error);
1574
+ const expired = jwtExpired(user == null ? void 0 : user.jwt);
1575
+ const onlyJwt = !(user == null ? void 0 : user.userId) && !!(user == null ? void 0 : user.jwt);
1576
+ if (loading || error2 || ((_a3 = user == null ? void 0 : user.idJwt) == null ? void 0 : _a3.email) && !hasQs && !expired) {
1523
1577
  return;
1524
1578
  }
1525
- if (qs == null ? void 0 : qs.code) {
1526
- if (expired) {
1527
- yield getTokensFromCode({
1528
- code: qs.code,
1529
- redirectUrl,
1579
+ try {
1580
+ setLoading(true);
1581
+ if (qs == null ? void 0 : qs.error) {
1582
+ const newerror = {
1583
+ message: (qs == null ? void 0 : qs.error_description) || "auth error"
1584
+ };
1585
+ if (JSON.stringify(newerror || {}) !== JSON.stringify(error2 || {})) {
1586
+ setError(newerror);
1587
+ }
1588
+ return;
1589
+ }
1590
+ if ((qs == null ? void 0 : qs.code) && !expired) {
1591
+ yield goToPageUrl({ url: redirectUrl, login: false });
1592
+ return;
1593
+ }
1594
+ if (qs == null ? void 0 : qs.code) {
1595
+ if (expired) {
1596
+ yield getTokensFromCode({
1597
+ code: qs.code,
1598
+ redirectUrl,
1599
+ config,
1600
+ setUser
1601
+ });
1602
+ }
1603
+ yield goToPageUrl({
1604
+ url: getStatefulUrl({ redirectUrl, qs }),
1605
+ login: false
1606
+ });
1607
+ return;
1608
+ }
1609
+ if (expired && ((_b2 = user == null ? void 0 : user.jwt) == null ? void 0 : _b2.refresh_token)) {
1610
+ yield refreshToken({
1611
+ setUser,
1612
+ setError,
1613
+ user,
1530
1614
  config,
1531
- setUser
1615
+ logout
1532
1616
  });
1617
+ return;
1533
1618
  }
1534
- yield goToPageUrl({
1535
- url: getStatefulUrl({ redirectUrl, qs }),
1536
- login: false
1537
- });
1538
- return;
1539
- }
1540
- if (expired && ((_b2 = user == null ? void 0 : user.jwt) == null ? void 0 : _b2.refresh_token)) {
1541
- yield refreshToken({
1542
- setUser,
1543
- setError,
1544
- user,
1545
- config,
1546
- logout
1547
- });
1548
- return;
1549
- }
1550
- if (onlyJwt) {
1551
- 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);
1552
- if (!user || !token) {
1553
- (0, import_log9.info)("logging out no token");
1554
- setUser(void 0);
1555
- setError(void 0);
1556
- } else {
1557
- setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
1558
- jwt: user.jwt,
1559
- credentials: user.credentials
1560
- }));
1619
+ if (onlyJwt) {
1620
+ const token = (_d = (_c = user == null ? void 0 : user.jwt) == null ? void 0 : _c.id_token) == null ? void 0 : _d.substr(
1621
+ user.jwt.id_token.indexOf(" ") + 1
1622
+ );
1623
+ if (!user || !token) {
1624
+ (0, import_log9.info)("logging out no token");
1625
+ setUser(void 0);
1626
+ setError(void 0);
1627
+ } else {
1628
+ setUser(__spreadProps(__spreadValues({}, getUserFromIdToken(token)), {
1629
+ jwt: user.jwt,
1630
+ credentials: user.credentials
1631
+ }));
1632
+ }
1561
1633
  }
1634
+ } finally {
1635
+ setLoading(false);
1562
1636
  }
1563
- } finally {
1564
- setLoading(false);
1565
- }
1566
- });
1567
- }
1568
- void run();
1569
- }, [user == null ? void 0 : user.jwt, qs], [
1570
- config,
1571
- error2,
1572
- goToPageUrl,
1573
- logout,
1574
- loading,
1575
- qs,
1576
- redirectUrl,
1577
- setUser,
1578
- user
1579
- ]);
1580
- (0, import_react8.useEffect)(() => {
1637
+ });
1638
+ }
1639
+ void run();
1640
+ },
1641
+ [user == null ? void 0 : user.jwt, qs],
1642
+ [
1643
+ config,
1644
+ error2,
1645
+ goToPageUrl,
1646
+ logout,
1647
+ loading,
1648
+ qs,
1649
+ redirectUrl,
1650
+ setUser,
1651
+ user
1652
+ ]
1653
+ );
1654
+ (0, import_react7.useEffect)(() => {
1581
1655
  var _a3;
1582
1656
  if (error2) {
1583
1657
  (0, import_log9.error)(JSON.stringify(error2));
@@ -1602,17 +1676,19 @@ var CognitoAuthProvider = ({
1602
1676
  error: error2,
1603
1677
  user
1604
1678
  };
1605
- return /* @__PURE__ */ import_react8.default.createElement(CognitoAuthContext.Provider, {
1606
- value
1607
- }, children);
1679
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CognitoAuthContext.Provider, {
1680
+ value,
1681
+ children
1682
+ });
1608
1683
  };
1609
1684
 
1610
1685
  // src/components/UserProvider/DashboardAuthValidation.tsx
1611
1686
  var import_log10 = require("ag-common/dist/common/helpers/log");
1612
1687
  var import_string = require("ag-common/dist/common/helpers/string");
1613
1688
  var import_Loader = require("ag-common/dist/ui/components/Loader");
1689
+ var import_useGranularHook2 = require("ag-common/dist/ui/helpers/useGranularHook");
1614
1690
  var import_useQueryString = require("ag-common/dist/ui/helpers/useQueryString");
1615
- var import_react9 = __toESM(require("react"));
1691
+ var import_jsx_runtime = require("react/jsx-runtime");
1616
1692
  var DashboardAuthValidation = ({
1617
1693
  rc: { request, pushPath },
1618
1694
  cac: {
@@ -1626,39 +1702,46 @@ var DashboardAuthValidation = ({
1626
1702
  getUnauthedPage,
1627
1703
  addToast
1628
1704
  }) => {
1629
- useGranularEffect(() => {
1630
- if (authError) {
1631
- const emailOption = authError.message.includes("email") ? ` We require the use of your email for the functionality of this app.
1705
+ (0, import_useGranularHook2.useGranularEffect)(
1706
+ () => {
1707
+ if (authError) {
1708
+ const emailOption = authError.message.includes("email") ? ` We require the use of your email for the functionality of this app.
1632
1709
  You can update your settings at https://www.facebook.com/settings?tab=applications` : "";
1633
- addToast(`An Error has occured with your login attempt.${emailOption}`, {
1634
- appearance: "error"
1635
- });
1636
- (0, import_log10.error)(`auth error:`, JSON.stringify(authError, null, 2));
1637
- void logout();
1638
- }
1639
- }, [authError], [authError, addToast, logout]);
1710
+ addToast(
1711
+ `An Error has occured with your login attempt.${emailOption}`,
1712
+ {
1713
+ appearance: "error"
1714
+ }
1715
+ );
1716
+ (0, import_log10.error)(`auth error:`, JSON.stringify(authError, null, 2));
1717
+ void logout();
1718
+ }
1719
+ },
1720
+ [authError],
1721
+ [authError, addToast, logout]
1722
+ );
1640
1723
  const forceLogin = Object.keys(request.url.query || {}).includes("login");
1641
1724
  if (forceLogin) {
1642
1725
  if (!isAuthenticated) {
1643
1726
  void loginWithRedirect(request.url.query.state);
1644
- return { render: /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null), openApiDisabled: true };
1727
+ return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
1645
1728
  }
1646
1729
  if (isAuthenticated) {
1647
1730
  void pushPath(getDashboardPath());
1648
- return { render: /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null), openApiDisabled: true };
1731
+ return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
1649
1732
  }
1650
1733
  }
1651
1734
  if (request.url.query.state && isAuthenticated) {
1652
1735
  const decoded = JSON.parse((0, import_string.fromBase64)(request.url.query.state));
1653
1736
  if (decoded.redirect) {
1654
1737
  void pushPath(decoded.redirect);
1655
- return { render: /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null), openApiDisabled: true };
1738
+ return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
1656
1739
  }
1657
1740
  }
1658
1741
  const serverAuthLoading = import_useQueryString.isServer && !authError && !authLoading && !isAuthenticated && Object.keys(request.url.query || {}).includes("code");
1659
1742
  if (authLoading || serverAuthLoading) {
1660
1743
  return {
1661
- render: /* @__PURE__ */ import_react9.default.createElement(import_Loader.Loader, {
1744
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Loader.Loader, {
1662
1745
  name: "authload"
1663
1746
  }),
1664
1747
  openApiDisabled: true
@@ -1666,7 +1749,7 @@ var DashboardAuthValidation = ({
1666
1749
  }
1667
1750
  if (!isAuthenticated && !authLoading && !authError && getUnauthedPage) {
1668
1751
  void pushPath(getUnauthedPage());
1669
- return { render: /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null), openApiDisabled: true };
1752
+ return { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}), openApiDisabled: true };
1670
1753
  }
1671
1754
  const openApiDisabled = !isAuthenticated || authLoading || !!authError;
1672
1755
  return { openApiDisabled };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.260",
3
+ "version": "0.0.263",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",