analytica.click 0.0.262 → 0.0.265

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
@@ -89,25 +89,22 @@ declare module 'analytica.click/common-ui/src/types/widgets' {
89
89
  */
90
90
  cookieDocument?: string;
91
91
  }
92
+ export interface IAnalyticaConfig {
93
+ analyticaToken?: string;
94
+ overrideBaseUrl?: string;
95
+ devMode?: boolean;
96
+ }
92
97
 
93
98
  }
94
99
  declare module 'analytica.click/ui-npm/src/components/AnalyticaConfig/index' {
95
- import { IAnalyticaConfig } from 'analytica.click/ui-npm/src/components/AnalyticaConfig/types';
96
100
  import React from 'react';
101
+ import { IAnalyticaConfig } from 'analytica.click/common-ui/src/types';
97
102
  export const AnalyticaConfigContext: React.Context<IAnalyticaConfig>;
98
103
  export const AnalyticaConfigProvider: ({ children, values, }: {
99
104
  children: JSX.Element | JSX.Element[];
100
105
  values: IAnalyticaConfig;
101
106
  }) => JSX.Element;
102
107
 
103
- }
104
- declare module 'analytica.click/ui-npm/src/components/AnalyticaConfig/types' {
105
- export interface IAnalyticaConfig {
106
- analyticaToken?: string;
107
- overrideBaseUrl?: string;
108
- devMode?: boolean;
109
- }
110
-
111
108
  }
112
109
  declare module 'analytica.click/ui-npm/src/components/ErrorBoundary/index' {
113
110
  /// <reference types="react" />
@@ -265,6 +262,13 @@ declare module 'analytica.click/ui-npm/src/helpers/jwt' {
265
262
  declare module 'analytica.click/ui-npm/src/helpers/log' {
266
263
  export const tokenMissing: (comp: string) => string;
267
264
 
265
+ }
266
+ declare module 'analytica.click/ui-npm/src/helpers/object' {
267
+ export const takeObject: <T>(ob: Record<string, T>, num: number) => {
268
+ part: T[];
269
+ rest: Record<string, T>;
270
+ };
271
+
268
272
  }
269
273
  declare module 'analytica.click/ui-npm/src/helpers/track' {
270
274
  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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analytica.click",
3
- "version": "0.0.262",
3
+ "version": "0.0.265",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",