analytica.click 0.0.253 → 0.0.256
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 +6 -5
- package/dist/index.js +92 -46
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -18,6 +18,7 @@ declare module 'analytica.click/common-ui/src/types/index' {
|
|
18
18
|
|
19
19
|
}
|
20
20
|
declare module 'analytica.click/common-ui/src/types/widgets' {
|
21
|
+
/// <reference types="react" />
|
21
22
|
import { ICognitoAuth, TOnMessage } from 'ag-common/dist/ui/helpers/cognito';
|
22
23
|
export type TTrackNoEvent = (p: Omit<ITrack, 'eventName'>) => Promise<{
|
23
24
|
error?: string;
|
@@ -109,6 +110,7 @@ declare module 'analytica.click/ui-npm/src/components/AnalyticaConfig/types' {
|
|
109
110
|
|
110
111
|
}
|
111
112
|
declare module 'analytica.click/ui-npm/src/components/ErrorBoundary/index' {
|
113
|
+
/// <reference types="react" />
|
112
114
|
export const ErrorBoundary: ({ children, filterBrowserError, }: {
|
113
115
|
children?: JSX.Element | JSX.Element[] | undefined;
|
114
116
|
filterBrowserError?: ((e: ErrorEvent | Error) => boolean) | undefined;
|
@@ -116,6 +118,7 @@ declare module 'analytica.click/ui-npm/src/components/ErrorBoundary/index' {
|
|
116
118
|
|
117
119
|
}
|
118
120
|
declare module 'analytica.click/ui-npm/src/components/ExternalComponent/index' {
|
121
|
+
/// <reference types="react" />
|
119
122
|
export const ExternalComponent: ({ url, props, }: {
|
120
123
|
url: string;
|
121
124
|
props: Record<string, any>;
|
@@ -123,11 +126,13 @@ declare module 'analytica.click/ui-npm/src/components/ExternalComponent/index' {
|
|
123
126
|
|
124
127
|
}
|
125
128
|
declare module 'analytica.click/ui-npm/src/components/Feedback/index' {
|
129
|
+
/// <reference types="react" />
|
126
130
|
import { IFeedbackWidget } from 'analytica.click/common-ui/src/types/index';
|
127
131
|
export const Feedback: (props: IFeedbackWidget) => JSX.Element;
|
128
132
|
|
129
133
|
}
|
130
134
|
declare module 'analytica.click/ui-npm/src/components/UserProvider/DashboardAuthValidation' {
|
135
|
+
/// <reference types="react" />
|
131
136
|
import { AuthedUserContext } from 'ag-common/dist/ui/helpers/jwt';
|
132
137
|
import { IRequestCommon } from 'ag-common/dist/ui/helpers/routes';
|
133
138
|
/**
|
@@ -234,11 +239,7 @@ declare module 'analytica.click/ui-npm/src/helpers/errorTrack' {
|
|
234
239
|
export const errorTrack: ({ data, overrideBaseUrl, }: {
|
235
240
|
data: PostError;
|
236
241
|
overrideBaseUrl?: string | undefined;
|
237
|
-
}) => Promise<{
|
238
|
-
error?: undefined;
|
239
|
-
} | {
|
240
|
-
error: string;
|
241
|
-
}>;
|
242
|
+
}) => Promise<{}>;
|
242
243
|
|
243
244
|
}
|
244
245
|
declare module 'analytica.click/ui-npm/src/helpers/feedback' {
|
package/dist/index.js
CHANGED
@@ -384,9 +384,9 @@ var require_api = __commonJS({
|
|
384
384
|
options: localVarRequestOptions
|
385
385
|
};
|
386
386
|
}),
|
387
|
-
|
387
|
+
postErrors: (postError, options = {}) => __awaiter(this, void 0, void 0, function* () {
|
388
388
|
if (postError === null || postError === void 0) {
|
389
|
-
throw new base_1.RequiredError("postError", "Required parameter postError was null or undefined when calling
|
389
|
+
throw new base_1.RequiredError("postError", "Required parameter postError was null or undefined when calling postErrors.");
|
390
390
|
}
|
391
391
|
const localVarPath = `/errors`;
|
392
392
|
const localVarUrlObj = globalImportUrl.parse(localVarPath, true);
|
@@ -556,9 +556,9 @@ var require_api = __commonJS({
|
|
556
556
|
};
|
557
557
|
});
|
558
558
|
},
|
559
|
-
|
559
|
+
postErrors(postError, options) {
|
560
560
|
return __awaiter(this, void 0, void 0, function* () {
|
561
|
-
const localVarAxiosArgs = yield (0, exports.DefaultApiAxiosParamCreator)(configuration).
|
561
|
+
const localVarAxiosArgs = yield (0, exports.DefaultApiAxiosParamCreator)(configuration).postErrors(postError, options);
|
562
562
|
return (axios = axios_1.default, basePath = base_1.BASE_PATH) => {
|
563
563
|
const axiosRequestArgs = Object.assign(Object.assign({}, localVarAxiosArgs.options), { url: basePath + localVarAxiosArgs.url });
|
564
564
|
return axios.request(axiosRequestArgs);
|
@@ -618,8 +618,8 @@ var require_api = __commonJS({
|
|
618
618
|
googleIntegrationPost(googleIntegration, options) {
|
619
619
|
return (0, exports.DefaultApiFp)(configuration).googleIntegrationPost(googleIntegration, options).then((request) => request(axios, basePath));
|
620
620
|
},
|
621
|
-
|
622
|
-
return (0, exports.DefaultApiFp)(configuration).
|
621
|
+
postErrors(postError, options) {
|
622
|
+
return (0, exports.DefaultApiFp)(configuration).postErrors(postError, options).then((request) => request(axios, basePath));
|
623
623
|
},
|
624
624
|
postPageTrack(postSiteTrack, options) {
|
625
625
|
return (0, exports.DefaultApiFp)(configuration).postPageTrack(postSiteTrack, options).then((request) => request(axios, basePath));
|
@@ -655,8 +655,8 @@ var require_api = __commonJS({
|
|
655
655
|
googleIntegrationPost(googleIntegration, options) {
|
656
656
|
return (0, exports.DefaultApiFp)(this.configuration).googleIntegrationPost(googleIntegration, options).then((request) => request(this.axios, this.basePath));
|
657
657
|
}
|
658
|
-
|
659
|
-
return (0, exports.DefaultApiFp)(this.configuration).
|
658
|
+
postErrors(postError, options) {
|
659
|
+
return (0, exports.DefaultApiFp)(this.configuration).postErrors(postError, options).then((request) => request(this.axios, this.basePath));
|
660
660
|
}
|
661
661
|
postPageTrack(postSiteTrack, options) {
|
662
662
|
return (0, exports.DefaultApiFp)(this.configuration).postPageTrack(postSiteTrack, options).then((request) => request(this.axios, this.basePath));
|
@@ -692,8 +692,8 @@ var require_ErrorBoundary = __commonJS({
|
|
692
692
|
this.state = { hasError: void 0 };
|
693
693
|
}
|
694
694
|
static getDerivedStateFromError(errorV) {
|
695
|
-
var
|
696
|
-
const href = typeof window !== "undefined" && ((
|
695
|
+
var _a2;
|
696
|
+
const href = typeof window !== "undefined" && ((_a2 = window === null || window === void 0 ? void 0 : window.location) === null || _a2 === void 0 ? void 0 : _a2.href);
|
697
697
|
return {
|
698
698
|
hasError: Object.assign(Object.assign(Object.assign(Object.assign({}, errorV), { message: (errorV === null || errorV === void 0 ? void 0 : errorV.message) || errorV }), (errorV === null || errorV === void 0 ? void 0 : errorV.stack) && { stack: errorV === null || errorV === void 0 ? void 0 : errorV.stack }), href && { href })
|
699
699
|
};
|
@@ -723,8 +723,8 @@ var require_dom = __commonJS({
|
|
723
723
|
var log_1 = require("ag-common/dist/common/helpers/log");
|
724
724
|
var querystring_1 = require("querystring");
|
725
725
|
var getChildrenArray = (ref) => {
|
726
|
-
var
|
727
|
-
const children = ((
|
726
|
+
var _a2;
|
727
|
+
const children = ((_a2 = ref.current) === null || _a2 === void 0 ? void 0 : _a2.children) || [];
|
728
728
|
const ret = [];
|
729
729
|
for (let i = 0; i < children.length; i += 1) {
|
730
730
|
ret.push(children[i]);
|
@@ -735,14 +735,14 @@ var require_dom = __commonJS({
|
|
735
735
|
var getChildrenPositions = (ref) => (0, exports.getChildrenArray)(ref).map((c) => c.getBoundingClientRect().top + c.getBoundingClientRect().height);
|
736
736
|
exports.getChildrenPositions = getChildrenPositions;
|
737
737
|
var getClientY = (e) => {
|
738
|
-
var
|
738
|
+
var _a2, _b, _c, _d;
|
739
739
|
if (!e) {
|
740
740
|
return void 0;
|
741
741
|
}
|
742
742
|
let ret;
|
743
743
|
if ((e === null || e === void 0 ? void 0 : e.changedTouches) || (e === null || e === void 0 ? void 0 : e.touches)) {
|
744
744
|
const et = e;
|
745
|
-
ret = ((_b = (
|
745
|
+
ret = ((_b = (_a2 = et.changedTouches) === null || _a2 === void 0 ? void 0 : _a2[0]) === null || _b === void 0 ? void 0 : _b.clientY) || ((_d = (_c = et.touches) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.clientY);
|
746
746
|
} else if (e === null || e === void 0 ? void 0 : e.clientY) {
|
747
747
|
const me = e;
|
748
748
|
ret = me.clientY;
|
@@ -809,6 +809,7 @@ __export(src_exports, {
|
|
809
809
|
module.exports = __toCommonJS(src_exports);
|
810
810
|
|
811
811
|
// src/helpers/errorTrack.tsx
|
812
|
+
var import_array = require("ag-common/dist/common/helpers/array");
|
812
813
|
var import_log = require("ag-common/dist/common/helpers/log");
|
813
814
|
var import_callOpenApi = require("ag-common/dist/ui/helpers/callOpenApi");
|
814
815
|
var import_api = __toESM(require_api());
|
@@ -822,22 +823,67 @@ function callOpenApi(p) {
|
|
822
823
|
})
|
823
824
|
}));
|
824
825
|
}
|
826
|
+
var _a;
|
827
|
+
var isLocal = typeof window !== "undefined" && ((_a = window == null ? void 0 : window.location) == null ? void 0 : _a.hostname) === "localhost";
|
828
|
+
var errorBuffer = [];
|
829
|
+
var errorTimer;
|
830
|
+
var overrideBaseUrlSet;
|
831
|
+
var errorPush = () => __async(void 0, null, function* () {
|
832
|
+
var _a2, _b;
|
833
|
+
try {
|
834
|
+
if (errorBuffer.length > 100) {
|
835
|
+
const x1 = yield callOpenApi({
|
836
|
+
apiUrl: overrideBaseUrlSet,
|
837
|
+
func: (s) => {
|
838
|
+
var _a3;
|
839
|
+
return s.postErrors([
|
840
|
+
{
|
841
|
+
key: errorBuffer[0].key,
|
842
|
+
data: __spreadProps(__spreadValues({}, errorBuffer[0].data), {
|
843
|
+
message: `error overload!: ${(_a3 = errorBuffer[0].data.message) != null ? _a3 : "?"}`
|
844
|
+
})
|
845
|
+
}
|
846
|
+
]);
|
847
|
+
}
|
848
|
+
});
|
849
|
+
errorBuffer = [];
|
850
|
+
if (x1.error) {
|
851
|
+
throw x1.error;
|
852
|
+
}
|
853
|
+
return {};
|
854
|
+
}
|
855
|
+
const { part, rest } = (0, import_array.take)(errorBuffer, 10);
|
856
|
+
errorBuffer = rest;
|
857
|
+
const x = yield callOpenApi({
|
858
|
+
apiUrl: overrideBaseUrlSet,
|
859
|
+
func: (s) => s.postErrors(part)
|
860
|
+
});
|
861
|
+
if (x.error) {
|
862
|
+
throw x.error;
|
863
|
+
}
|
864
|
+
} catch (e) {
|
865
|
+
return { error: (_b = (_a2 = e == null ? void 0 : e.error) == null ? void 0 : _a2.message) != null ? _b : e.message };
|
866
|
+
} finally {
|
867
|
+
if (errorBuffer.length) {
|
868
|
+
errorTimer = setTimeout(errorPush, 1e3);
|
869
|
+
} else {
|
870
|
+
errorTimer = void 0;
|
871
|
+
}
|
872
|
+
}
|
873
|
+
});
|
825
874
|
var errorTrack = (_0) => __async(void 0, [_0], function* ({
|
826
875
|
data,
|
827
876
|
overrideBaseUrl = "https://api.analytica.click"
|
828
877
|
}) {
|
829
|
-
|
830
|
-
if (typeof window !== "undefined" && ((_a = window == null ? void 0 : window.location) == null ? void 0 : _a.hostname) === "localhost") {
|
878
|
+
if (isLocal) {
|
831
879
|
(0, import_log.debug)(`local error tracking ignored:${data.data.message} ${JSON.stringify(data)}, to ${overrideBaseUrl}`);
|
832
880
|
return {};
|
833
881
|
}
|
834
882
|
(0, import_log.debug)("error track", data.data.message, JSON.stringify(data));
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
if (x.error) {
|
840
|
-
return { error: x.error.message };
|
883
|
+
errorBuffer.push(data);
|
884
|
+
overrideBaseUrlSet = overrideBaseUrl;
|
885
|
+
if (!errorTimer) {
|
886
|
+
errorTimer = setTimeout(errorPush, 500);
|
841
887
|
}
|
842
888
|
return {};
|
843
889
|
});
|
@@ -911,8 +957,8 @@ var feedback = (_0) => __async(void 0, [_0], function* ({
|
|
911
957
|
analyticaToken,
|
912
958
|
overrideBaseUrl = "https://api.analytica.click"
|
913
959
|
}) {
|
914
|
-
var
|
915
|
-
if (typeof window !== "undefined" && ((
|
960
|
+
var _a2;
|
961
|
+
if (typeof window !== "undefined" && ((_a2 = window == null ? void 0 : window.location) == null ? void 0 : _a2.hostname) === "localhost") {
|
916
962
|
(0, import_log3.debug)(`local feedback ignored:${JSON.stringify(data)}, to ${overrideBaseUrl}`);
|
917
963
|
return {};
|
918
964
|
}
|
@@ -939,9 +985,9 @@ var useFeedback = () => {
|
|
939
985
|
|
940
986
|
// src/components/UserProvider/picture.ts
|
941
987
|
var parsePicture = (raw) => {
|
942
|
-
var
|
988
|
+
var _a2, _b;
|
943
989
|
try {
|
944
|
-
return (_b = (
|
990
|
+
return (_b = (_a2 = JSON.parse(raw)) == null ? void 0 : _a2.data) == null ? void 0 : _b.url;
|
945
991
|
} catch (e) {
|
946
992
|
return raw;
|
947
993
|
}
|
@@ -951,7 +997,7 @@ var parsePicture = (raw) => {
|
|
951
997
|
var import_jsonwebtoken = require("jsonwebtoken");
|
952
998
|
var decodeIdToken = (s) => (0, import_jsonwebtoken.decode)(s);
|
953
999
|
var getUserFromIdToken = (idToken) => {
|
954
|
-
var
|
1000
|
+
var _a2;
|
955
1001
|
const idJwt = decodeIdToken(idToken);
|
956
1002
|
if (!idJwt) {
|
957
1003
|
throw new Error("bad token");
|
@@ -963,7 +1009,7 @@ var getUserFromIdToken = (idToken) => {
|
|
963
1009
|
picture: parsePicture(idJwt.picture),
|
964
1010
|
updatedAt: new Date().getTime(),
|
965
1011
|
idJwt,
|
966
|
-
isAdmin: (
|
1012
|
+
isAdmin: (_a2 = idJwt == null ? void 0 : idJwt["cognito:groups"]) == null ? void 0 : _a2.includes("Admin")
|
967
1013
|
};
|
968
1014
|
return defUser;
|
969
1015
|
};
|
@@ -989,12 +1035,12 @@ var track = (_0) => __async(void 0, [_0], function* ({
|
|
989
1035
|
overrideBaseUrl = "https://api.analytica.click",
|
990
1036
|
eventName
|
991
1037
|
}) {
|
992
|
-
var
|
1038
|
+
var _a2, _b, _c;
|
993
1039
|
let data = { eventName };
|
994
1040
|
if (typeof window !== "undefined") {
|
995
1041
|
data = __spreadProps(__spreadValues({}, data), {
|
996
1042
|
pageLocation: window.location.href,
|
997
|
-
browserResolution: `${(
|
1043
|
+
browserResolution: `${(_a2 = window == null ? void 0 : window.screen) == null ? void 0 : _a2.width}:${(_b = window == null ? void 0 : window.screen) == null ? void 0 : _b.height}`
|
998
1044
|
});
|
999
1045
|
}
|
1000
1046
|
if (typeof document !== "undefined") {
|
@@ -1173,8 +1219,8 @@ function getAwsCreds(_0) {
|
|
1173
1219
|
user,
|
1174
1220
|
config
|
1175
1221
|
}) {
|
1176
|
-
var
|
1177
|
-
if (!((
|
1222
|
+
var _a2, _b, _c;
|
1223
|
+
if (!((_a2 = user == null ? void 0 : user.jwt) == null ? void 0 : _a2.id_token) || !user.idJwt || !config.identityPool) {
|
1178
1224
|
return void 0;
|
1179
1225
|
}
|
1180
1226
|
const idToken = (_b = user == null ? void 0 : user.jwt) == null ? void 0 : _b.id_token;
|
@@ -1224,9 +1270,9 @@ function refreshToken(_0) {
|
|
1224
1270
|
config,
|
1225
1271
|
logout
|
1226
1272
|
}) {
|
1227
|
-
var
|
1273
|
+
var _a2, _b;
|
1228
1274
|
try {
|
1229
|
-
if (((
|
1275
|
+
if (((_a2 = user == null ? void 0 : user.jwt) == null ? void 0 : _a2.id_token) && !jwtExpired(user == null ? void 0 : user.jwt)) {
|
1230
1276
|
return user;
|
1231
1277
|
}
|
1232
1278
|
const token = (_b = user == null ? void 0 : user.jwt) == null ? void 0 : _b.refresh_token;
|
@@ -1315,8 +1361,8 @@ var import_react7 = require("react");
|
|
1315
1361
|
var useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
1316
1362
|
const ref = (0, import_react7.useRef)();
|
1317
1363
|
if (!ref.current || !primaryDeps.every((w, i) => {
|
1318
|
-
var
|
1319
|
-
return Object.is(w, (
|
1364
|
+
var _a2;
|
1365
|
+
return Object.is(w, (_a2 = ref.current) == null ? void 0 : _a2[i]);
|
1320
1366
|
}))
|
1321
1367
|
ref.current = [...primaryDeps, ...secondaryDeps];
|
1322
1368
|
return hook(callback, ref.current);
|
@@ -1358,7 +1404,7 @@ var CognitoAuthProvider = ({
|
|
1358
1404
|
onMessage,
|
1359
1405
|
cookieDocument
|
1360
1406
|
}) => {
|
1361
|
-
var
|
1407
|
+
var _a2, _b;
|
1362
1408
|
const [error2, setError] = (0, import_react8.useState)();
|
1363
1409
|
const [idTokenRaw, setIdToken] = (0, import_cookie.useCookieString)({
|
1364
1410
|
name: "id_token",
|
@@ -1396,15 +1442,15 @@ var CognitoAuthProvider = ({
|
|
1396
1442
|
setLoading(false);
|
1397
1443
|
});
|
1398
1444
|
(0, import_react8.useEffect)(() => {
|
1399
|
-
var
|
1400
|
-
const newT = (
|
1445
|
+
var _a3;
|
1446
|
+
const newT = (_a3 = user == null ? void 0 : user.jwt) == null ? void 0 : _a3.id_token;
|
1401
1447
|
if (!!newT && newT !== idToken) {
|
1402
1448
|
setIdToken(newT || "");
|
1403
1449
|
}
|
1404
|
-
}, [idToken, setIdToken, user, (
|
1450
|
+
}, [idToken, setIdToken, user, (_a2 = user == null ? void 0 : user.jwt) == null ? void 0 : _a2.id_token]);
|
1405
1451
|
const loginWithRedirect = (stateqs) => __async(void 0, null, function* () {
|
1406
|
-
var
|
1407
|
-
if (error2 || loading || location.hash && Object.keys(location.hash).length > 0 || location.search && ((
|
1452
|
+
var _a3;
|
1453
|
+
if (error2 || loading || location.hash && Object.keys(location.hash).length > 0 || location.search && ((_a3 = Object.keys(location.search)) == null ? void 0 : _a3.length) > 0) {
|
1408
1454
|
return;
|
1409
1455
|
}
|
1410
1456
|
setLoading(true);
|
@@ -1424,11 +1470,11 @@ var CognitoAuthProvider = ({
|
|
1424
1470
|
useGranularEffect(() => {
|
1425
1471
|
function run() {
|
1426
1472
|
return __async(this, null, function* () {
|
1427
|
-
var
|
1473
|
+
var _a3, _b2, _c, _d;
|
1428
1474
|
const hasQs = !!(qs == null ? void 0 : qs.code) || !!(qs == null ? void 0 : qs.error);
|
1429
1475
|
const expired = jwtExpired(user == null ? void 0 : user.jwt);
|
1430
1476
|
const onlyJwt = !(user == null ? void 0 : user.userId) && !!(user == null ? void 0 : user.jwt);
|
1431
|
-
if (loading || error2 || ((
|
1477
|
+
if (loading || error2 || ((_a3 = user == null ? void 0 : user.idJwt) == null ? void 0 : _a3.email) && !hasQs && !expired) {
|
1432
1478
|
return;
|
1433
1479
|
}
|
1434
1480
|
try {
|
@@ -1502,11 +1548,11 @@ var CognitoAuthProvider = ({
|
|
1502
1548
|
user
|
1503
1549
|
]);
|
1504
1550
|
(0, import_react8.useEffect)(() => {
|
1505
|
-
var
|
1551
|
+
var _a3;
|
1506
1552
|
if (error2) {
|
1507
1553
|
(0, import_log9.error)(JSON.stringify(error2));
|
1508
1554
|
if (onMessage) {
|
1509
|
-
onMessage(`error:${(
|
1555
|
+
onMessage(`error:${(_a3 = error2.response) == null ? void 0 : _a3.status}`, { appearance: "error" });
|
1510
1556
|
}
|
1511
1557
|
}
|
1512
1558
|
}, [onMessage, error2]);
|