Include analytics & new ES routes.

This commit is contained in:
Patrick Fic
2025-09-22 15:48:13 -07:00
parent 96dc5a8659
commit ec5b04304f
9 changed files with 221 additions and 140 deletions

View File

@@ -3,7 +3,11 @@ const { ipcMain } = require("electron");
const log = require("electron-log");
//const Nucleus = require("nucleus-nodejs");
const { default: ipcTypes } = require("../src/ipc.types.commonjs");
const amplitude = require('@amplitude/analytics-node');
const { store } = require("./electron-store");
const deviceId = store.get("deviceId");
let userId;
amplitude.init('a733ff926aef84f93baf95e66b5dcb75');
// Nucleus.init("5f91b569b95bac34eefdb63a", {
// disableInDev: true,
// debug: false,
@@ -19,16 +23,16 @@ const { default: ipcTypes } = require("../src/ipc.types.commonjs");
// // type will either be uncaughtException, unhandledRejection or windowError
// };
ipcMain.on(ipcTypes.app.toMain.setUserName, (event, userName) => {
// Nucleus.setUserId(userName);
// Nucleus.appStarted();
ipcMain.on(ipcTypes.app.toMain.setUserName, (event, userid) => {
userId = userid;
});
ipcMain.on(ipcTypes.app.toMain.track, (e, args) => {
log.log("NUCLEUS Event", args);
// const { event, ...eventDetails } = args;
// log.log("Analytics Event", args);
const { event, ...eventDetails } = args;
try {
//// Nucleus.track(event, eventDetails);
//// Nucleus.track(event, eventDetails);
amplitude.track(event, eventDetails, { device_id: deviceId, user_id: userId });
} catch (error) {
log.error(error);
}

View File

@@ -1,7 +1,9 @@
const { randomUUID } = require("crypto");
const Store = require("electron-store");
const store = new Store({
defaults: {
deviceId: randomUUID(),
showChangeLog: true,
enableNotifications: true,
filePaths: [],

View File

@@ -37,7 +37,10 @@ async function ScrubEstimate({ job }) {
const basicAuthUser = "Imex2";
const basicAuthpassword = "Patrick";
const currentChannel = autoUpdater.channel
const estimateScrubberUrl = process.env.NODE_ENV === undefined || currentChannel === 'alpha' ? 'https://4284-79073.el-alt.com/api/sendems' : "https://insurtechtoolkit.com/api/sendems";
const estimateScrubberUrl =
process.env.NODE_ENV === undefined ? "https://4284-79287.el-alt.com" : //dev specific URL.
currentChannel === 'beta' ? 'https://4284-79073.el-alt.com/api/sendems' //Beta specific URL.
: "https://insurtechtoolkit.com/api/sendems"; //Production route.
log.debug(`Estimate Scrubber URL: [${currentChannel} |`, estimateScrubberUrl);
const sendingEntityId = "87330f61-412b-4251-baaa-d026565b23c5";
try {

31
package-lock.json generated
View File

@@ -1,14 +1,15 @@
{
"name": "imexrps",
"version": "1.4.1-alpha.1",
"version": "1.4.2-alpha.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "imexrps",
"version": "1.4.1-alpha.1",
"version": "1.4.2-alpha.15",
"hasInstallScript": true,
"dependencies": {
"@amplitude/analytics-node": "^1.5.10",
"@ant-design/pro-layout": "^7.22.3",
"@apollo/client": "^3.13.4",
"@sentry/electron": "^6.1.0",
@@ -66,6 +67,32 @@
"vite-plugin-style-import": "^2.0.0"
}
},
"node_modules/@amplitude/analytics-connector": {
"version": "1.6.4",
"resolved": "https://registry.npmjs.org/@amplitude/analytics-connector/-/analytics-connector-1.6.4.tgz",
"integrity": "sha512-SpIv0IQMNIq6SH3UqFGiaZyGSc7PBZwRdq7lvP0pBxW8i4Ny+8zwI0pV+VMfMHQwWY3wdIbWw5WQphNjpdq1/Q==",
"license": "MIT"
},
"node_modules/@amplitude/analytics-core": {
"version": "2.24.1",
"resolved": "https://registry.npmjs.org/@amplitude/analytics-core/-/analytics-core-2.24.1.tgz",
"integrity": "sha512-cXU6/iq2NysqXR+E+5LXTcOnWSuWU9VJT/2BUPohfbDVFVss+dhLpagEe8H5HwnffexMl0bypebAgZ9At7Y75g==",
"license": "MIT",
"dependencies": {
"@amplitude/analytics-connector": "^1.6.4",
"tslib": "^2.4.1"
}
},
"node_modules/@amplitude/analytics-node": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/@amplitude/analytics-node/-/analytics-node-1.5.10.tgz",
"integrity": "sha512-u77NWS0ng17mUlc1OW6CVDHLE0XeidB6TCre9N+PdkMmu1XX+H0qjeOB0NrqfXGneRo2aHm1J5trfXBLI95xGA==",
"license": "MIT",
"dependencies": {
"@amplitude/analytics-core": "^2.24.1",
"tslib": "^2.4.1"
}
},
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",

View File

@@ -3,10 +3,11 @@
"productName": "ImEX RPS",
"author": "ImEX Systems Inc. <support@thinkimex.com>",
"description": "ImEX RPS",
"version": "1.4.2-alpha.15",
"version": "1.4.2-alpha.16",
"main": "electron/main.js",
"homepage": "./",
"dependencies": {
"@amplitude/analytics-node": "^1.5.10",
"@ant-design/pro-layout": "^7.22.3",
"@apollo/client": "^3.13.4",
"@sentry/electron": "^6.1.0",

View File

@@ -35,6 +35,12 @@ export function App({ currentUser, checkUserSession, darkMode }) {
checkUserSession();
}, [checkUserSession]);
useEffect(() => {
if (currentUser && currentUser.email) {
ipcRenderer.send(ipcTypes.app.toMain.setUserName, currentUser.email);
}
}, [currentUser]);
useEffect(() => {
//
return () => {

View File

@@ -4,6 +4,9 @@ import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { queryReportingData } from "../../../redux/reporting/reporting.actions";
import dayjs from "../../../util/day.js";
import ipcTypes from "../../../ipc.types.js";
import { range } from "lodash";
const { ipcRenderer } = window;
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
});
@@ -24,139 +27,169 @@ export function ReportingDatesMolecule({ queryReportingData }) {
return (
<Form form={form} onFinish={handleFinish}>
<Space wrap align="start">
<Form.Item
label="Ready for Payment Date Between"
name="dateRange"
rules={[
{ type: "array", required: true },
{
validator(rule, value) {
if (!value || !value.length === 2) {
return Promise.resolve();
}
<Space wrap align="baseline">
<Space wrap align="start">
<Form.Item
label="Ready for Payment Date Between"
name="dateRange"
rules={[
{ type: "array", required: true },
{
validator(rule, value) {
if (!value || !value.length === 2) {
return Promise.resolve();
}
if (dayjs(value[1]).diff(dayjs(value[0]), "years", true) > 1) {
return Promise.reject("Time period exceeds 1 year. Please select a shorter date range.");
} else {
return Promise.resolve();
if (dayjs(value[1]).diff(dayjs(value[0]), "years", true) > 1) {
return Promise.reject("Time period exceeds 1 year. Please select a shorter date range.");
} else {
return Promise.resolve();
}
}
}
}
]}
>
<DatePicker.RangePicker
format="MM/DD/YYYY"
ranges={{
"Last Month": [
dayjs().startOf("month").subtract(1, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
],
]}
>
<DatePicker.RangePicker
format="MM/DD/YYYY"
ranges={{
"Last Month": [
dayjs().startOf("month").subtract(1, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
],
"This Month": [dayjs().startOf("month"), dayjs().endOf("month")],
"Next Month": [
dayjs().startOf("month").add(1, "month"),
dayjs().startOf("month").add(1, "month").endOf("month")
],
"Last Quarter": [
dayjs().startOf("quarter").subtract(1, "quarter"),
dayjs().startOf("quarter").subtract(1, "day")
],
"This Quarter": [
dayjs().startOf("quarter"),
dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day")
],
"Last 3 Months (Exlcusive)": [
dayjs().startOf("month").subtract(3, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
],
"Last 3 Months (Inclusive)": [dayjs().startOf("month").subtract(2, "month"), dayjs().endOf("month")]
"This Month": [dayjs().startOf("month"), dayjs().endOf("month")],
"Next Month": [
dayjs().startOf("month").add(1, "month"),
dayjs().startOf("month").add(1, "month").endOf("month")
],
"Last Quarter": [
dayjs().startOf("quarter").subtract(1, "quarter"),
dayjs().startOf("quarter").subtract(1, "day")
],
"This Quarter": [
dayjs().startOf("quarter"),
dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day")
],
"Last 3 Months (Exlcusive)": [
dayjs().startOf("month").subtract(3, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
],
"Last 3 Months (Inclusive)": [dayjs().startOf("month").subtract(2, "month"), dayjs().endOf("month")]
}}
/>
</Form.Item>
<Button type="primary" htmlType="submit">
Run Search
</Button>
</Space>
<Space align="baseline" wrap>
<Typography.Title level={5}>Quick Ranges:</Typography.Title>
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "Last Month"
});
handleFinish({
dateRange: [
dayjs().startOf("month").subtract(1, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
]
});
}}
/>
</Form.Item>
<Button type="primary" htmlType="submit">
Run Search
</Button>
</Space>
<Space align="baseline" wrap>
<Typography.Title level={5}>Quick Ranges:</Typography.Title>
<Button
onClick={() =>
handleFinish({
dateRange: [
dayjs().startOf("month").subtract(1, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
]
})
}
>
Last Month
</Button>
<Button
onClick={() =>
handleFinish({
dateRange: [dayjs().startOf("month"), dayjs().endOf("month")]
})
}
>
This Month
</Button>
<Button
onClick={() =>
handleFinish({
dateRange: [
dayjs().startOf("month").add(1, "month"),
dayjs().startOf("month").add(1, "month").endOf("month")
]
})
}
>
Next Month
</Button>
<Divider type="vertical" />
<Button
onClick={() =>
handleFinish({
dateRange: [
dayjs().startOf("month").subtract(3, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
]
})
}
>
Last 3 Months (Exclusive)
</Button>
<Button
onClick={() =>
handleFinish({
dateRange: [dayjs().startOf("month").subtract(2, "month"), dayjs().endOf("month")]
})
}
>
Last 3 Months (Inclusive)
</Button>
<Divider type="vertical" />
<Button
onClick={() =>
handleFinish({
dateRange: [
dayjs().startOf("quarter").subtract(1, "quarter"),
dayjs().startOf("quarter").subtract(1, "day")
]
})
}
>
Last Quarter
</Button>
<Button
onClick={() =>
handleFinish({
dateRange: [dayjs().startOf("quarter"), dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day")]
})
}
>
This Quarter
</Button>
>
Last Month
</Button>
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "This Month"
});
handleFinish({
dateRange: [dayjs().startOf("month"), dayjs().endOf("month")]
});
}}
>
This Month
</Button>
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "Next Month"
});
handleFinish({
dateRange: [
dayjs().startOf("month").add(1, "month"),
dayjs().startOf("month").add(1, "month").endOf("month")
]
});
}}
>
Next Month
</Button>
<Divider type="vertical" />
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "3 Months Exclusive"
});
handleFinish({
dateRange: [
dayjs().startOf("month").subtract(3, "month"),
dayjs().startOf("month").subtract(1, "month").endOf("month")
]
});
}}
>
Last 3 Months (Exclusive)
</Button>
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "3 Months Inclusive"
});
handleFinish({
dateRange: [dayjs().startOf("month").subtract(2, "month"), dayjs().endOf("month")]
});
}}
>
Last 3 Months (Inclusive)
</Button>
<Divider type="vertical" />
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "Last Quarter"
});
handleFinish({
dateRange: [
dayjs().startOf("quarter").subtract(1, "quarter"),
dayjs().startOf("quarter").subtract(1, "day")
]
});
}}
>
Last Quarter
</Button>
<Button
onClick={() => {
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "REPORT_QUICK_DATE_RANGE",
range: "This Quarter"
});
handleFinish({
dateRange: [dayjs().startOf("quarter"), dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day")]
});
}}
>
This Quarter
</Button>
</Space>
</Space>
</Form>
);

View File

@@ -185,6 +185,9 @@ export function ReportingJobsListMolecule({
checked={excludedIds.includes(record.id)}
onChange={(checked) => {
checked ? addExcludedId(record.id) : removeExcludedId(record.id);
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "TOGGLE_SCENARIO_MANAGER",
});
}}
/>
)

View File

@@ -56,7 +56,9 @@ export function AuditPage({ auditError, queryReportingData, bodyshop, reportingE
};
const handleRunAudit = async ({ sheetName, dateRange }) => {
console.log("🚀 ~ handleRunAudit ~ sheetName:", sheetName);
ipcRenderer.send(ipcTypes.app.toMain.track, {
event: "RUN_AUDIT"
});
ipcRenderer.send(ipcTypes.audit.toMain.runAudit, { sheetName });
};