analytica.click 0.0.261 → 0.0.264

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
@@ -679,7 +679,8 @@ var require_api = __commonJS({
679
679
  var require_logsend = __commonJS({
680
680
  "../common/dist/helpers/logsend.js"(exports) {
681
681
  Object.defineProperty(exports, "__esModule", { value: true });
682
- exports.isValidLogMessage = void 0;
682
+ exports.getErrorKey = exports.isValidLogMessage = void 0;
683
+ var hashCode_1 = require("ag-common/dist/common/helpers/hashCode");
683
684
  var log_1 = require("ag-common/dist/common/helpers/log");
684
685
  function isValidLogMessage2(m) {
685
686
  if (!m) {
@@ -697,6 +698,27 @@ var require_logsend = __commonJS({
697
698
  return true;
698
699
  }
699
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;
700
722
  }
701
723
  });
702
724
 
@@ -845,8 +867,23 @@ __export(src_exports, {
845
867
  });
846
868
  module.exports = __toCommonJS(src_exports);
847
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
+
848
886
  // src/helpers/errorTrack.tsx
849
- var import_array = require("ag-common/dist/common/helpers/array");
850
887
  var import_log = require("ag-common/dist/common/helpers/log");
851
888
  var import_callOpenApi = require("ag-common/dist/ui/helpers/callOpenApi");
852
889
  var import_api = __toESM(require_api());
@@ -863,34 +900,36 @@ function callOpenApi(p) {
863
900
  }
864
901
  var _a;
865
902
  var isLocal = typeof window !== "undefined" && ((_a = window == null ? void 0 : window.location) == null ? void 0 : _a.hostname) === "localhost";
866
- var errorBuffer = [];
903
+ var errorBuffer = {};
867
904
  var errorTimer;
868
905
  var overrideBaseUrlSet;
869
906
  var errorPush = () => __async(void 0, null, function* () {
870
907
  var _a2, _b;
871
908
  try {
872
- if (errorBuffer.length > 100) {
909
+ if (Object.keys(errorBuffer).length > 100) {
910
+ const firstKey = Object.keys(errorBuffer)[0];
911
+ const first = errorBuffer[firstKey];
873
912
  const x1 = yield callOpenApi({
874
913
  apiUrl: overrideBaseUrlSet,
875
914
  func: (s) => {
876
915
  var _a3;
877
916
  return s.postErrors([
878
917
  {
879
- key: errorBuffer[0].key,
880
- data: __spreadProps(__spreadValues({}, errorBuffer[0].data), {
881
- 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 : "?"}`
882
921
  })
883
922
  }
884
923
  ]);
885
924
  }
886
925
  });
887
- errorBuffer = [];
926
+ errorBuffer = {};
888
927
  if (x1.error) {
889
928
  throw x1.error;
890
929
  }
891
930
  return {};
892
931
  }
893
- const { part, rest } = (0, import_array.take)(errorBuffer, 10);
932
+ const { part, rest } = takeObject(errorBuffer, 10);
894
933
  errorBuffer = rest;
895
934
  const x = yield callOpenApi({
896
935
  apiUrl: overrideBaseUrlSet,
@@ -926,7 +965,8 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
926
965
  return {};
927
966
  }
928
967
  (0, import_log.debug)("error track", data.data.message, JSON.stringify(data));
929
- errorBuffer.push(data);
968
+ const key = (0, import_logsend.getErrorKey)(data.data.message);
969
+ errorBuffer[key] = data;
930
970
  overrideBaseUrlSet = overrideBaseUrl;
931
971
  if (!errorTimer) {
932
972
  errorTimer = setTimeout(errorPush, 500);
@@ -936,6 +976,7 @@ var errorTrack = (_0) => __async(void 0, [_0], function* ({
936
976
 
937
977
  // src/components/AnalyticaConfig/index.tsx
938
978
  var import_react = __toESM(require("react"));
979
+ var import_jsx_runtime = require("react/jsx-runtime");
939
980
  var stubState = {
940
981
  analyticaToken: void 0,
941
982
  overrideBaseUrl: void 0
@@ -975,9 +1016,10 @@ var AnalyticaConfigProvider = ({
975
1016
  (0, import_react.useEffect)(() => {
976
1017
  overloadConsole(values);
977
1018
  }, []);
978
- return /* @__PURE__ */ import_react.default.createElement(AnalyticaConfigContext.Provider, {
979
- value: state
980
- }, children);
1019
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnalyticaConfigContext.Provider, {
1020
+ value: state,
1021
+ children
1022
+ });
981
1023
  };
982
1024
 
983
1025
  // src/helpers/log.ts
@@ -1147,8 +1189,9 @@ var useTrack = () => {
1147
1189
 
1148
1190
  // src/components/ErrorBoundary/index.tsx
1149
1191
  var import_ErrorBoundary = __toESM(require_ErrorBoundary());
1150
- var import_react4 = __toESM(require("react"));
1192
+ var import_react4 = require("react");
1151
1193
  var import_log6 = require("ag-common/dist/common/helpers/log");
1194
+ var import_jsx_runtime = require("react/jsx-runtime");
1152
1195
  function onBrowserError(_0) {
1153
1196
  return __async(this, arguments, function* ({
1154
1197
  ev,
@@ -1193,9 +1236,11 @@ var ErrorBoundary = ({
1193
1236
  }, [analyticaToken, filterBrowserError]);
1194
1237
  if (!analyticaToken) {
1195
1238
  (0, import_log6.warn)(tokenMissing("ErrorBoundary"));
1196
- 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
+ });
1197
1242
  }
1198
- return /* @__PURE__ */ import_react4.default.createElement(import_ErrorBoundary.ErrorBoundary, {
1243
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ErrorBoundary.ErrorBoundary, {
1199
1244
  notify: (data) => __async(void 0, null, function* () {
1200
1245
  const { href } = window.location;
1201
1246
  yield errorTrack({
@@ -1206,8 +1251,9 @@ var ErrorBoundary = ({
1206
1251
  })
1207
1252
  }
1208
1253
  });
1209
- })
1210
- }, children);
1254
+ }),
1255
+ children
1256
+ });
1211
1257
  };
1212
1258
 
1213
1259
  // src/components/ExternalComponent/index.tsx
@@ -1215,6 +1261,7 @@ var import_react5 = __toESM(require("react"));
1215
1261
  var import_createRequires = require("@paciolan/remote-component/dist/createRequires");
1216
1262
  var import_useRemoteComponent = require("@paciolan/remote-component/dist/hooks/useRemoteComponent");
1217
1263
  var import_react_dom = __toESM(require("react-dom"));
1264
+ var import_jsx_runtime = require("react/jsx-runtime");
1218
1265
  var styled = require("styled-components");
1219
1266
  var cache = {};
1220
1267
  var ExternalComponent = ({
@@ -1237,19 +1284,25 @@ var ExternalComponent = ({
1237
1284
  if (!cache[url] && !loading && !error2 && Component) {
1238
1285
  cache[url] = Component;
1239
1286
  }
1240
- 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
+ });
1241
1293
  };
1242
1294
 
1243
1295
  // src/components/Feedback/index.tsx
1244
- var import_react6 = __toESM(require("react"));
1296
+ var import_react6 = require("react");
1245
1297
  var import_log7 = require("ag-common/dist/common/helpers/log");
1298
+ var import_jsx_runtime = require("react/jsx-runtime");
1246
1299
  var Feedback = (props) => {
1247
1300
  const { analyticaToken, overrideBaseUrl, devMode } = (0, import_react6.useContext)(
1248
1301
  AnalyticaConfigContext
1249
1302
  );
1250
1303
  if (!analyticaToken) {
1251
1304
  (0, import_log7.warn)(tokenMissing("Feedback"));
1252
- return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null);
1305
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
1253
1306
  }
1254
1307
  const int = __spreadProps(__spreadValues({}, props), {
1255
1308
  submitFeedback: feedback,
@@ -1260,7 +1313,7 @@ var Feedback = (props) => {
1260
1313
  if (devMode) {
1261
1314
  url = `/feedback.js`;
1262
1315
  }
1263
- return /* @__PURE__ */ import_react6.default.createElement(ExternalComponent, {
1316
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalComponent, {
1264
1317
  url,
1265
1318
  props: int
1266
1319
  });
@@ -1410,26 +1463,15 @@ function getTokensFromCode(_0) {
1410
1463
  });
1411
1464
  }
1412
1465
 
1413
- // src/components/UserProvider/useGranularHook.ts
1414
- var import_react7 = require("react");
1415
- var useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
1416
- const ref = (0, import_react7.useRef)();
1417
- if (!ref.current || !primaryDeps.every((w, i) => {
1418
- var _a2;
1419
- return Object.is(w, (_a2 = ref.current) == null ? void 0 : _a2[i]);
1420
- }))
1421
- ref.current = [...primaryDeps, ...secondaryDeps];
1422
- return hook(callback, ref.current);
1423
- };
1424
- var useGranularEffect = (effect, primaryDeps, secondaryDeps) => useGranularHook(import_react7.useEffect, effect, primaryDeps, secondaryDeps);
1425
-
1426
1466
  // src/components/UserProvider/index.tsx
1427
1467
  var import_log9 = require("ag-common/dist/common/helpers/log");
1428
- var import_react8 = __toESM(require("react"));
1468
+ var import_react7 = __toESM(require("react"));
1429
1469
  var import_useLocalStorage = require("ag-common/dist/ui/helpers/useLocalStorage");
1430
1470
  var import_cookie = require("ag-common/dist/ui/helpers/cookie");
1431
1471
  var import_dom3 = __toESM(require_dom());
1432
- var CognitoAuthContext = import_react8.default.createContext(
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(
1433
1475
  void 0
1434
1476
  );
1435
1477
  var getStatefulUrl = ({
@@ -1461,7 +1503,7 @@ var CognitoAuthProvider = ({
1461
1503
  cookieDocument
1462
1504
  }) => {
1463
1505
  var _a2, _b;
1464
- const [error2, setError] = (0, import_react8.useState)();
1506
+ const [error2, setError] = (0, import_react7.useState)();
1465
1507
  const [idTokenRaw, setIdToken] = (0, import_cookie.useCookieString)({
1466
1508
  name: "id_token",
1467
1509
  cookieDocument: typeof window === "undefined" ? cookieDocument : void 0,
@@ -1482,7 +1524,7 @@ var CognitoAuthProvider = ({
1482
1524
  setUserRaw(value2);
1483
1525
  return;
1484
1526
  };
1485
- const [loading, setLoading] = (0, import_react8.useState)(false);
1527
+ const [loading, setLoading] = (0, import_react7.useState)(false);
1486
1528
  const qs = (0, import_dom3.extractQs)({
1487
1529
  search: typeof window === "undefined" ? "" : window.location.search,
1488
1530
  sanatise: false
@@ -1497,7 +1539,7 @@ var CognitoAuthProvider = ({
1497
1539
  yield goToPageUrl({ url: location.origin, login: false });
1498
1540
  setLoading(false);
1499
1541
  });
1500
- (0, import_react8.useEffect)(() => {
1542
+ (0, import_react7.useEffect)(() => {
1501
1543
  var _a3;
1502
1544
  const newT = (_a3 = user == null ? void 0 : user.jwt) == null ? void 0 : _a3.id_token;
1503
1545
  if (!!newT && newT !== idToken) {
@@ -1523,7 +1565,7 @@ var CognitoAuthProvider = ({
1523
1565
  login: true
1524
1566
  });
1525
1567
  });
1526
- useGranularEffect(
1568
+ (0, import_useGranularHook.useGranularEffect)(
1527
1569
  () => {
1528
1570
  function run() {
1529
1571
  return __async(this, null, function* () {
@@ -1609,7 +1651,7 @@ var CognitoAuthProvider = ({
1609
1651
  user
1610
1652
  ]
1611
1653
  );
1612
- (0, import_react8.useEffect)(() => {
1654
+ (0, import_react7.useEffect)(() => {
1613
1655
  var _a3;
1614
1656
  if (error2) {
1615
1657
  (0, import_log9.error)(JSON.stringify(error2));
@@ -1634,17 +1676,19 @@ var CognitoAuthProvider = ({
1634
1676
  error: error2,
1635
1677
  user
1636
1678
  };
1637
- return /* @__PURE__ */ import_react8.default.createElement(CognitoAuthContext.Provider, {
1638
- value
1639
- }, children);
1679
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CognitoAuthContext.Provider, {
1680
+ value,
1681
+ children
1682
+ });
1640
1683
  };
1641
1684
 
1642
1685
  // src/components/UserProvider/DashboardAuthValidation.tsx
1643
1686
  var import_log10 = require("ag-common/dist/common/helpers/log");
1644
1687
  var import_string = require("ag-common/dist/common/helpers/string");
1645
1688
  var import_Loader = require("ag-common/dist/ui/components/Loader");
1689
+ var import_useGranularHook2 = require("ag-common/dist/ui/helpers/useGranularHook");
1646
1690
  var import_useQueryString = require("ag-common/dist/ui/helpers/useQueryString");
1647
- var import_react9 = __toESM(require("react"));
1691
+ var import_jsx_runtime = require("react/jsx-runtime");
1648
1692
  var DashboardAuthValidation = ({
1649
1693
  rc: { request, pushPath },
1650
1694
  cac: {
@@ -1658,7 +1702,7 @@ var DashboardAuthValidation = ({
1658
1702
  getUnauthedPage,
1659
1703
  addToast
1660
1704
  }) => {
1661
- useGranularEffect(
1705
+ (0, import_useGranularHook2.useGranularEffect)(
1662
1706
  () => {
1663
1707
  if (authError) {
1664
1708
  const emailOption = authError.message.includes("email") ? ` We require the use of your email for the functionality of this app.
@@ -1680,24 +1724,24 @@ var DashboardAuthValidation = ({
1680
1724
  if (forceLogin) {
1681
1725
  if (!isAuthenticated) {
1682
1726
  void loginWithRedirect(request.url.query.state);
1683
- 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 };
1684
1728
  }
1685
1729
  if (isAuthenticated) {
1686
1730
  void pushPath(getDashboardPath());
1687
- 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 };
1688
1732
  }
1689
1733
  }
1690
1734
  if (request.url.query.state && isAuthenticated) {
1691
1735
  const decoded = JSON.parse((0, import_string.fromBase64)(request.url.query.state));
1692
1736
  if (decoded.redirect) {
1693
1737
  void pushPath(decoded.redirect);
1694
- 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 };
1695
1739
  }
1696
1740
  }
1697
1741
  const serverAuthLoading = import_useQueryString.isServer && !authError && !authLoading && !isAuthenticated && Object.keys(request.url.query || {}).includes("code");
1698
1742
  if (authLoading || serverAuthLoading) {
1699
1743
  return {
1700
- render: /* @__PURE__ */ import_react9.default.createElement(import_Loader.Loader, {
1744
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Loader.Loader, {
1701
1745
  name: "authload"
1702
1746
  }),
1703
1747
  openApiDisabled: true
@@ -1705,7 +1749,7 @@ var DashboardAuthValidation = ({
1705
1749
  }
1706
1750
  if (!isAuthenticated && !authLoading && !authError && getUnauthedPage) {
1707
1751
  void pushPath(getUnauthedPage());
1708
- 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 };
1709
1753
  }
1710
1754
  const openApiDisabled = !isAuthenticated || authLoading || !!authError;
1711
1755
  return { openApiDisabled };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.261",
3
+ "version": "0.0.264",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",