analytica.click 0.0.262 → 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 +7 -0
- package/dist/index.js +50 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -265,6 +265,13 @@ declare module 'analytica.click/ui-npm/src/helpers/jwt' {
|
|
265
265
|
declare module 'analytica.click/ui-npm/src/helpers/log' {
|
266
266
|
export const tokenMissing: (comp: string) => string;
|
267
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
|
+
|
268
275
|
}
|
269
276
|
declare module 'analytica.click/ui-npm/src/helpers/track' {
|
270
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:
|
880
|
-
data: __spreadProps(__spreadValues({},
|
881
|
-
message: `error overload!: ${(_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 } = (
|
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
|
-
|
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);
|