@ludo.ninja/components 2.4.21 → 2.4.22
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type MarkerReporter, type MarkerSdk } from '@marker.io/browser';
|
|
2
|
+
export declare const useMarkerIo: (mode?: "prod" | "dev") => {
|
|
3
|
+
loadMarkerSDK: () => Promise<void>;
|
|
4
|
+
unloadMarkerSDK: () => void;
|
|
5
|
+
clearReporter: () => void;
|
|
6
|
+
updateReporterInfo: (reporter: MarkerReporter) => void;
|
|
7
|
+
updateCustomData: () => void;
|
|
8
|
+
setProjectId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
9
|
+
projectId: string;
|
|
10
|
+
eventLog: string;
|
|
11
|
+
setCustomDataRaw: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
12
|
+
customDataInvalid: boolean;
|
|
13
|
+
customDataRaw: string;
|
|
14
|
+
loaded: boolean;
|
|
15
|
+
widget: MarkerSdk | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useMarkerIo = void 0;
|
|
7
|
+
const browser_1 = __importDefault(require("@marker.io/browser"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const useMarkerIo = (mode = 'prod') => {
|
|
10
|
+
const [widget, setWidget] = (0, react_1.useState)(null);
|
|
11
|
+
const [eventLog, setEventLog] = (0, react_1.useState)('');
|
|
12
|
+
const [projectId, setProjectId] = (0, react_1.useState)(mode === 'prod' ? '6909097dfc7751c05ae1bb9f' : '690909d2c42a324667c29bcb');
|
|
13
|
+
const [customDataObject, setCustomDataObject] = (0, react_1.useState)({
|
|
14
|
+
project: 'Ludo',
|
|
15
|
+
});
|
|
16
|
+
const [customDataInvalid, setCustomDataInvalid] = (0, react_1.useState)(false);
|
|
17
|
+
const [customDataRaw, setCustomDataRaw] = (0, react_1.useState)('');
|
|
18
|
+
async function loadMarkerSDK() {
|
|
19
|
+
const widget = await browser_1.default.loadWidget({
|
|
20
|
+
project: projectId,
|
|
21
|
+
});
|
|
22
|
+
setWidget(widget);
|
|
23
|
+
const MarkerEventNames = [
|
|
24
|
+
'load',
|
|
25
|
+
'loaderror',
|
|
26
|
+
'beforeunload',
|
|
27
|
+
'show',
|
|
28
|
+
'hide',
|
|
29
|
+
'capture',
|
|
30
|
+
'feedbackbeforesend',
|
|
31
|
+
'feedbacksent',
|
|
32
|
+
'feedbackerror',
|
|
33
|
+
'feedbackdiscarded',
|
|
34
|
+
];
|
|
35
|
+
const events = [...MarkerEventNames];
|
|
36
|
+
for (const eventName of events) {
|
|
37
|
+
widget.on(eventName, () => {
|
|
38
|
+
setEventLog((prev) => prev + `Event "${eventName}"\n`);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function unloadMarkerSDK() {
|
|
43
|
+
widget?.unload();
|
|
44
|
+
setWidget(null);
|
|
45
|
+
}
|
|
46
|
+
function updateReporterInfo(reporter) {
|
|
47
|
+
widget?.setReporter(reporter);
|
|
48
|
+
}
|
|
49
|
+
function clearReporter() {
|
|
50
|
+
widget?.setReporter({ email: '', fullName: '' });
|
|
51
|
+
}
|
|
52
|
+
function updateCustomData() {
|
|
53
|
+
try {
|
|
54
|
+
setCustomDataObject(JSON.parse(customDataRaw));
|
|
55
|
+
setCustomDataInvalid(false);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
setCustomDataInvalid(true);
|
|
59
|
+
}
|
|
60
|
+
widget?.setCustomData(customDataObject);
|
|
61
|
+
}
|
|
62
|
+
const loaded = (0, react_1.useMemo)(() => !!widget, [widget]);
|
|
63
|
+
return {
|
|
64
|
+
loadMarkerSDK,
|
|
65
|
+
unloadMarkerSDK,
|
|
66
|
+
clearReporter,
|
|
67
|
+
updateReporterInfo,
|
|
68
|
+
updateCustomData,
|
|
69
|
+
setProjectId,
|
|
70
|
+
projectId,
|
|
71
|
+
eventLog,
|
|
72
|
+
setCustomDataRaw,
|
|
73
|
+
customDataInvalid,
|
|
74
|
+
customDataRaw,
|
|
75
|
+
loaded,
|
|
76
|
+
widget,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.useMarkerIo = useMarkerIo;
|
|
@@ -3,18 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AppLayout = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const apollo_1 = require("../hooks/apollo");
|
|
6
|
+
const marker_io_1 = require("../hooks/marker-io");
|
|
7
|
+
const useGlobalRefCode_1 = require("../hooks/refCode/useGlobalRefCode");
|
|
6
8
|
const GlobalLayout_1 = require("./GlobalLayout");
|
|
7
9
|
const HOCAuthSearchParamsLocalhostInterceptor_1 = require("../modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor");
|
|
8
10
|
const store_1 = require("../modules/user/store");
|
|
11
|
+
const env_1 = require("../store/env");
|
|
9
12
|
const index_1 = require("../store/index");
|
|
10
13
|
const ui_1 = require("../store/ui");
|
|
11
14
|
const client_1 = require("@apollo/client");
|
|
15
|
+
const react_1 = require("react");
|
|
12
16
|
const styled_components_1 = require("styled-components");
|
|
13
|
-
const useGlobalRefCode_1 = require("../hooks/refCode/useGlobalRefCode");
|
|
14
17
|
const AppLayoutProviders = ({ children, pageProps }) => {
|
|
15
18
|
const apolloClient = (0, apollo_1.useApollo)(pageProps);
|
|
16
19
|
const theme = (0, ui_1.useUiStore)((state) => state.theme);
|
|
17
20
|
(0, useGlobalRefCode_1.useGlobalRefCode)();
|
|
21
|
+
const isProd = (0, env_1.useEnvStore)((state) => state.isProd);
|
|
22
|
+
const { loadMarkerSDK } = (0, marker_io_1.useMarkerIo)(isProd() ? "prod" : "dev");
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
loadMarkerSDK();
|
|
25
|
+
}, []);
|
|
18
26
|
return ((0, jsx_runtime_1.jsx)(index_1.SSRProvider, { initialState: {
|
|
19
27
|
isMobile: pageProps.isMobile,
|
|
20
28
|
}, children: (0, jsx_runtime_1.jsx)(client_1.ApolloProvider, { client: apolloClient, children: (0, jsx_runtime_1.jsx)(styled_components_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(store_1.UserProvider, { initialState: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludo.ninja/components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.22",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ludo.ninja/api": "^3.2.48",
|
|
27
|
+
"@marker.io/browser": "^0.19.0",
|
|
27
28
|
"@next/third-parties": "^15.3.4",
|
|
28
29
|
"@react-three/drei": "^9.68.3",
|
|
29
30
|
"@react-three/fiber": "^8.13.0",
|