kitchen-simulator 1.1.1-test.39 → 1.1.1-test.41
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/es/KitchenConfigurator.js +1 -8
- package/es/KitchenConfiguratorApp.js +0 -17
- package/lib/KitchenConfigurator.js +0 -7
- package/lib/KitchenConfiguratorApp.js +0 -17
- package/package.json +4 -5
- package/es/analytics/ga4.js +0 -191
- package/es/analytics/posthog.js +0 -60
- package/lib/analytics/ga4.js +0 -197
- package/lib/analytics/posthog.js +0 -68
|
@@ -33,12 +33,10 @@ import * as convert from 'convert-units';
|
|
|
33
33
|
import { Plugins as PlannerPlugins } from "./index";
|
|
34
34
|
import * as PropTypes from 'prop-types';
|
|
35
35
|
import React, { Component } from 'react';
|
|
36
|
-
import ReactGA from 'react-ga4';
|
|
37
|
-
import { hotjar } from 'react-hotjar';
|
|
38
36
|
import { connect } from 'react-redux';
|
|
39
37
|
import { bindActionCreators } from 'redux';
|
|
40
38
|
import * as constants from "./constants";
|
|
41
|
-
import { base64Decode
|
|
39
|
+
import { base64Decode } from "./utils/helper";
|
|
42
40
|
import actions from "./actions/export";
|
|
43
41
|
import Catalog from "./catalog/catalog";
|
|
44
42
|
import { Content } from "./components/export";
|
|
@@ -361,11 +359,6 @@ var KitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
361
359
|
key: "componentDidMount",
|
|
362
360
|
value: function componentDidMount() {
|
|
363
361
|
var _this3 = this;
|
|
364
|
-
ReactGA.send({
|
|
365
|
-
hitType: 'pageview',
|
|
366
|
-
page: getPath()
|
|
367
|
-
});
|
|
368
|
-
hotjar.event && hotjar.event("pageview:".concat(getPath()));
|
|
369
362
|
window.addEventListener('beforeunload', this.handleBeforeUnload);
|
|
370
363
|
console.log('context =>', this.context);
|
|
371
364
|
window.forRedo = [];
|
|
@@ -35,8 +35,6 @@ import * as Holes from "./catalog/holes/export";
|
|
|
35
35
|
import { render2DItem, render3DApplianceItem, render3DItem, render3DLightingItem } from "./catalog/utils/item-loader";
|
|
36
36
|
import { Models as PlannerModels, Plugins as PlannerPlugins, reducer as PlannerReducer } from "./index";
|
|
37
37
|
import { Map } from 'immutable';
|
|
38
|
-
import ReactGA from 'react-ga4';
|
|
39
|
-
import { hotjar } from 'react-hotjar';
|
|
40
38
|
import * as Sentry from '@sentry/react';
|
|
41
39
|
import { loadProject, rename } from "./actions/project-actions";
|
|
42
40
|
import exporter from "./catalog/utils/exporter";
|
|
@@ -47,14 +45,6 @@ var AppState = Map({
|
|
|
47
45
|
KitchenConfigurator: new PlannerModels.State()
|
|
48
46
|
});
|
|
49
47
|
console.log('Version: 378.45-202509_DIY-364-mbox-crash');
|
|
50
|
-
ReactGA.initialize([{
|
|
51
|
-
trackingId: 'G-YK2JCC9F9G' // https://dev.addovisuals.com
|
|
52
|
-
}, {
|
|
53
|
-
trackingId: 'G-3Y44W0RY2E' // https://demo.kc.addovisuals.com/
|
|
54
|
-
}, {
|
|
55
|
-
trackingId: 'G-M2VD74KP44' // https://rtastore.diydesignspace.com/
|
|
56
|
-
}]);
|
|
57
|
-
hotjar.initialize('3010506', '6');
|
|
58
48
|
isProduction && Sentry.init({
|
|
59
49
|
dsn: process.env.SENTRY_DSN,
|
|
60
50
|
environment: process.env.SENTRY_ENVIRONMENT
|
|
@@ -481,13 +471,6 @@ KitchenConfiguratorApp.propTypes = {
|
|
|
481
471
|
dsn: PropTypes.string,
|
|
482
472
|
environment: PropTypes.string
|
|
483
473
|
}),
|
|
484
|
-
analytics: PropTypes.shape({
|
|
485
|
-
ga4Id: PropTypes.string,
|
|
486
|
-
hotjar: PropTypes.shape({
|
|
487
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
488
|
-
sv: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
489
|
-
})
|
|
490
|
-
}),
|
|
491
474
|
onEvent: PropTypes.func,
|
|
492
475
|
onSave: PropTypes.func,
|
|
493
476
|
onError: PropTypes.func,
|
|
@@ -9,8 +9,6 @@ var convert = _interopRequireWildcard(require("convert-units"));
|
|
|
9
9
|
var _index = require("./index");
|
|
10
10
|
var PropTypes = _interopRequireWildcard(require("prop-types"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _reactGa = _interopRequireDefault(require("react-ga4"));
|
|
13
|
-
var _reactHotjar = require("react-hotjar");
|
|
14
12
|
var _reactRedux = require("react-redux");
|
|
15
13
|
var _redux = require("redux");
|
|
16
14
|
var constants = _interopRequireWildcard(require("./constants"));
|
|
@@ -369,11 +367,6 @@ var KitchenConfigurator = /*#__PURE__*/function (_Component) {
|
|
|
369
367
|
key: "componentDidMount",
|
|
370
368
|
value: function componentDidMount() {
|
|
371
369
|
var _this3 = this;
|
|
372
|
-
_reactGa["default"].send({
|
|
373
|
-
hitType: 'pageview',
|
|
374
|
-
page: (0, _helper.getPath)()
|
|
375
|
-
});
|
|
376
|
-
_reactHotjar.hotjar.event && _reactHotjar.hotjar.event("pageview:".concat((0, _helper.getPath)()));
|
|
377
370
|
window.addEventListener('beforeunload', this.handleBeforeUnload);
|
|
378
371
|
console.log('context =>', this.context);
|
|
379
372
|
window.forRedo = [];
|
|
@@ -22,8 +22,6 @@ var Holes = _interopRequireWildcard(require("./catalog/holes/export"));
|
|
|
22
22
|
var _itemLoader = require("./catalog/utils/item-loader");
|
|
23
23
|
var _index = require("./index");
|
|
24
24
|
var _immutable = require("immutable");
|
|
25
|
-
var _reactGa = _interopRequireDefault(require("react-ga4"));
|
|
26
|
-
var _reactHotjar = require("react-hotjar");
|
|
27
25
|
var Sentry = _interopRequireWildcard(require("@sentry/react"));
|
|
28
26
|
var _projectActions = require("./actions/project-actions");
|
|
29
27
|
var _exporter = _interopRequireDefault(require("./catalog/utils/exporter"));
|
|
@@ -54,14 +52,6 @@ var AppState = (0, _immutable.Map)({
|
|
|
54
52
|
KitchenConfigurator: new _index.Models.State()
|
|
55
53
|
});
|
|
56
54
|
console.log('Version: 378.45-202509_DIY-364-mbox-crash');
|
|
57
|
-
_reactGa["default"].initialize([{
|
|
58
|
-
trackingId: 'G-YK2JCC9F9G' // https://dev.addovisuals.com
|
|
59
|
-
}, {
|
|
60
|
-
trackingId: 'G-3Y44W0RY2E' // https://demo.kc.addovisuals.com/
|
|
61
|
-
}, {
|
|
62
|
-
trackingId: 'G-M2VD74KP44' // https://rtastore.diydesignspace.com/
|
|
63
|
-
}]);
|
|
64
|
-
_reactHotjar.hotjar.initialize('3010506', '6');
|
|
65
55
|
isProduction && Sentry.init({
|
|
66
56
|
dsn: process.env.SENTRY_DSN,
|
|
67
57
|
environment: process.env.SENTRY_ENVIRONMENT
|
|
@@ -488,13 +478,6 @@ KitchenConfiguratorApp.propTypes = {
|
|
|
488
478
|
dsn: PropTypes.string,
|
|
489
479
|
environment: PropTypes.string
|
|
490
480
|
}),
|
|
491
|
-
analytics: PropTypes.shape({
|
|
492
|
-
ga4Id: PropTypes.string,
|
|
493
|
-
hotjar: PropTypes.shape({
|
|
494
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
495
|
-
sv: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
496
|
-
})
|
|
497
|
-
}),
|
|
498
481
|
onEvent: PropTypes.func,
|
|
499
482
|
onSave: PropTypes.func,
|
|
500
483
|
onError: PropTypes.func,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kitchen-simulator",
|
|
3
|
-
"version": "1.1.1-test.
|
|
3
|
+
"version": "1.1.1-test.41",
|
|
4
4
|
"description": "It is a kitchen simulator.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
"immutablepatch": "0.5.0",
|
|
68
68
|
"convert-units": "2.3.4",
|
|
69
69
|
"hoist-non-react-statics": "2.5.5",
|
|
70
|
-
"invariant": "^2.0.0"
|
|
70
|
+
"invariant": "^2.0.0",
|
|
71
|
+
"polylabel": "1.0.2"
|
|
71
72
|
},
|
|
72
73
|
"dependencies": {
|
|
73
74
|
"@sentry/react": "^9.10.1",
|
|
@@ -77,10 +78,7 @@
|
|
|
77
78
|
"dotenv": "^16.4.7",
|
|
78
79
|
"history": "4.10.1",
|
|
79
80
|
"path-browserify": "^1.0.1",
|
|
80
|
-
"polylabel": "1.0.2",
|
|
81
81
|
"posthog-js": "^1.271.0",
|
|
82
|
-
"react-ga4": "^1.4.1",
|
|
83
|
-
"react-hotjar": "^1.0.11",
|
|
84
82
|
"react-icons": "3.5.0",
|
|
85
83
|
"react-redux": "5.0.7",
|
|
86
84
|
"react-svg-pan-zoom": "^3.13.1",
|
|
@@ -90,6 +88,7 @@
|
|
|
90
88
|
"localstorage-slim": "^1.3.0"
|
|
91
89
|
},
|
|
92
90
|
"devDependencies": {
|
|
91
|
+
"polylabel": "1.0.2",
|
|
93
92
|
"convert-units": "2.3.4",
|
|
94
93
|
"immutable": "3.8.2",
|
|
95
94
|
"immutablediff": "0.4.4",
|
package/es/analytics/ga4.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import ReactGA from 'react-ga4';
|
|
8
|
-
|
|
9
|
-
// ---------- Helpers ----------
|
|
10
|
-
function nowMs() {
|
|
11
|
-
return Date.now();
|
|
12
|
-
}
|
|
13
|
-
function getClientName() {
|
|
14
|
-
return sessionStorage.getItem('visualizerName');
|
|
15
|
-
}
|
|
16
|
-
function isDesktopUA() {
|
|
17
|
-
// Lightweight heuristic; GA4 also provides device.category. This flag can help ad-hoc filtering.
|
|
18
|
-
var ua = navigator.userAgent.toLowerCase();
|
|
19
|
-
var isMobile = /mobi|android|iphone|ipad|ipod|windows phone/.test(ua);
|
|
20
|
-
return !isMobile;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ---------- Keys for storage ----------
|
|
24
|
-
var SSN_KEYS = {
|
|
25
|
-
sessionStartMs: 'ga4_session_start_ms',
|
|
26
|
-
introChoiceMs: 'ga4_intro_choice_ms',
|
|
27
|
-
firstCabinetPlaced: 'ga4_first_cabinet_placed',
|
|
28
|
-
contextBooted: 'ga4_context_booted',
|
|
29
|
-
enteredCanvasSent: 'ga4_entered_canvas_sent'
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// ---------- Core GA wrapper ----------
|
|
33
|
-
export var GA = {
|
|
34
|
-
init: function init(_ref) {
|
|
35
|
-
var measurementId = _ref.measurementId;
|
|
36
|
-
ReactGA.initialize([{
|
|
37
|
-
trackingId: measurementId
|
|
38
|
-
}], {
|
|
39
|
-
testMode: false
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
resetSessionKeys: function resetSessionKeys() {
|
|
43
|
-
Object.values(SSN_KEYS).forEach(function (key) {
|
|
44
|
-
sessionStorage.removeItem(key);
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Must be called ONCE per page load, *before* other events.
|
|
49
|
-
* Sets user properties (project_entry, cross_auth) and sends an initial page_view with client_name.
|
|
50
|
-
*/
|
|
51
|
-
bootSessionContext: function bootSessionContext(_ref2) {
|
|
52
|
-
var projectEntry = _ref2.projectEntry,
|
|
53
|
-
crossAuth = _ref2.crossAuth;
|
|
54
|
-
try {
|
|
55
|
-
var resolvedClient = getClientName();
|
|
56
|
-
|
|
57
|
-
// Persist session start for timing metrics (if not already set for this tab)
|
|
58
|
-
if (!sessionStorage.getItem(SSN_KEYS.sessionStartMs)) {
|
|
59
|
-
sessionStorage.setItem(SSN_KEYS.sessionStartMs, String(nowMs()));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Mark context as booted to avoid duplicate property sets on hot reloads
|
|
63
|
-
if (!sessionStorage.getItem(SSN_KEYS.contextBooted)) {
|
|
64
|
-
sessionStorage.setItem(SSN_KEYS.contextBooted, '1');
|
|
65
|
-
|
|
66
|
-
// Set GA4 user_properties (user-scoped dimensions)
|
|
67
|
-
ReactGA.gtag('set', 'user_properties', {
|
|
68
|
-
project_entry: projectEntry,
|
|
69
|
-
// user scope dimension
|
|
70
|
-
cross_auth: crossAuth // user scope dimension (boolean serialized)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Send first page_view hit enriched with event-scoped client_name
|
|
75
|
-
ReactGA.send({
|
|
76
|
-
hitType: 'pageview',
|
|
77
|
-
page: window.location.pathname + window.location.search,
|
|
78
|
-
// @ts-expect-error react-ga4 passes along additional params into gtag
|
|
79
|
-
client_name: resolvedClient
|
|
80
|
-
});
|
|
81
|
-
} catch (e) {
|
|
82
|
-
// eslint-disable-next-line no-console
|
|
83
|
-
console.warn('GA.bootSessionContext error', e);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
// Utility to derive cross_auth from URL (token or details query params)
|
|
87
|
-
deriveCrossAuthFromUrl: function deriveCrossAuthFromUrl(search) {
|
|
88
|
-
var sp = new URLSearchParams(search);
|
|
89
|
-
return sp.has('token') || sp.has('details');
|
|
90
|
-
},
|
|
91
|
-
// Utility to derive project entry (best-effort). You can also pass explicitly from router logic.
|
|
92
|
-
deriveProjectEntry: function deriveProjectEntry() {
|
|
93
|
-
var projectId = sessionStorage.getItem('projectId');
|
|
94
|
-
|
|
95
|
-
// If a project id exists, consider it "open_existing"; otherwise fallback to "new"
|
|
96
|
-
if (projectId) return 'open_existing';
|
|
97
|
-
return 'new';
|
|
98
|
-
},
|
|
99
|
-
// ---------- Event API ----------
|
|
100
|
-
events: {
|
|
101
|
-
/**
|
|
102
|
-
* intro_choice(option) — records the user's entry choice.
|
|
103
|
-
* Also stores a timestamp for later time_to_canvas calculation.
|
|
104
|
-
*/
|
|
105
|
-
introChoice: function introChoice(option, extra) {
|
|
106
|
-
var client_name = getClientName();
|
|
107
|
-
sessionStorage.setItem(SSN_KEYS.introChoiceMs, String(nowMs()));
|
|
108
|
-
ReactGA.event('intro_choice', _objectSpread({
|
|
109
|
-
client_name: client_name,
|
|
110
|
-
option: option
|
|
111
|
-
}, extra || {}));
|
|
112
|
-
},
|
|
113
|
-
/**
|
|
114
|
-
* entered_canvas(time_to_canvas) — compute (now - intro_choice)
|
|
115
|
-
*/
|
|
116
|
-
enteredCanvas: function enteredCanvas() {
|
|
117
|
-
// fire only once per tab/session
|
|
118
|
-
if (sessionStorage.getItem(SSN_KEYS.enteredCanvasSent)) return;
|
|
119
|
-
var client_name = getClientName();
|
|
120
|
-
var introMs = Number(sessionStorage.getItem(SSN_KEYS.introChoiceMs) || 0);
|
|
121
|
-
var timeSec = introMs ? Math.max(0, Math.round((Date.now() - introMs) / 1000)) : undefined;
|
|
122
|
-
ReactGA.event('entered_canvas', _objectSpread({
|
|
123
|
-
client_name: client_name
|
|
124
|
-
}, typeof timeSec === 'number' ? {
|
|
125
|
-
time_to_canvas: timeSec
|
|
126
|
-
} : {}));
|
|
127
|
-
sessionStorage.setItem(SSN_KEYS.enteredCanvasSent, '1'); // 👈 lock it
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* cabinet_placed(time_to_first_cabinet) — send only for the *first* cabinet of the session.
|
|
131
|
-
*/
|
|
132
|
-
cabinetPlaced: function cabinetPlaced() {
|
|
133
|
-
var already = sessionStorage.getItem(SSN_KEYS.firstCabinetPlaced);
|
|
134
|
-
var client_name = getClientName();
|
|
135
|
-
var params = {
|
|
136
|
-
client_name: client_name
|
|
137
|
-
};
|
|
138
|
-
if (!already) {
|
|
139
|
-
var startMs = Number(sessionStorage.getItem(SSN_KEYS.sessionStartMs) || 0);
|
|
140
|
-
var timeSec = startMs ? Math.max(0, Math.round((nowMs() - startMs) / 1000)) : undefined;
|
|
141
|
-
if (typeof timeSec === 'number') params.time_to_first_cabinet = timeSec; // custom metric (seconds)
|
|
142
|
-
sessionStorage.setItem(SSN_KEYS.firstCabinetPlaced, '1');
|
|
143
|
-
}
|
|
144
|
-
ReactGA.event('cabinet_placed', params);
|
|
145
|
-
},
|
|
146
|
-
/**
|
|
147
|
-
* door_changed(door_id)
|
|
148
|
-
*/
|
|
149
|
-
doorChanged: function doorChanged(door_id) {
|
|
150
|
-
var client_name = getClientName();
|
|
151
|
-
ReactGA.event('door_changed', {
|
|
152
|
-
client_name: client_name,
|
|
153
|
-
door_id: door_id
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
/**
|
|
157
|
-
* project_saved(project_id, save_method) — mark as conversion in GA UI.
|
|
158
|
-
*/
|
|
159
|
-
projectSaved: function projectSaved(project_id, save_method) {
|
|
160
|
-
var client_name = getClientName();
|
|
161
|
-
ReactGA.event('project_saved', {
|
|
162
|
-
client_name: client_name,
|
|
163
|
-
project_id: project_id,
|
|
164
|
-
save_method: save_method
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
/**
|
|
168
|
-
* assistance_requested(method, project_id) — mark as conversion in GA UI.
|
|
169
|
-
*/
|
|
170
|
-
assistanceRequested: function assistanceRequested(method, project_id) {
|
|
171
|
-
var client_name = getClientName();
|
|
172
|
-
ReactGA.event('assistance_requested', {
|
|
173
|
-
client_name: client_name,
|
|
174
|
-
method: method,
|
|
175
|
-
project_id: project_id
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
/**
|
|
179
|
-
* add_to_cart(project_id, sku_count, price_total) — mark as conversion in GA UI.
|
|
180
|
-
*/
|
|
181
|
-
addToCart: function addToCart(project_id, sku_count, price_total) {
|
|
182
|
-
var client_name = getClientName();
|
|
183
|
-
ReactGA.event('add_to_cart', {
|
|
184
|
-
client_name: client_name,
|
|
185
|
-
project_id: project_id,
|
|
186
|
-
sku_count: sku_count,
|
|
187
|
-
price_total: price_total
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
package/es/analytics/posthog.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import posthog from 'posthog-js';
|
|
2
|
-
|
|
3
|
-
// ---- session context ----
|
|
4
|
-
export function bootSessionContext() {
|
|
5
|
-
var url = new URL(window.location.href);
|
|
6
|
-
var client_name = sessionStorage.getItem('visualizerName');
|
|
7
|
-
var project_entry = sessionStorage.getItem('projectId') ? 'open_existing' : 'new';
|
|
8
|
-
var cross_auth = url.searchParams.has('token') || url.searchParams.has('details');
|
|
9
|
-
|
|
10
|
-
// Persist context on the client/session
|
|
11
|
-
posthog.register({
|
|
12
|
-
client_name: client_name,
|
|
13
|
-
project_entry: project_entry,
|
|
14
|
-
cross_auth: cross_auth
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// First-hit event for qualitative flow
|
|
18
|
-
posthog.capture('session_started', {
|
|
19
|
-
client_name: client_name,
|
|
20
|
-
project_entry: project_entry,
|
|
21
|
-
cross_auth: cross_auth
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Optional: expose session id for replay linkage
|
|
26
|
-
export function getSessionId() {
|
|
27
|
-
try {
|
|
28
|
-
return posthog.get_session_id();
|
|
29
|
-
} catch (_unused) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// ---- event wrappers (mirror GA4 conversions) ----
|
|
35
|
-
export var PH = {
|
|
36
|
-
projectSaved: function projectSaved(project_id) {
|
|
37
|
-
posthog.capture('project_saved', {
|
|
38
|
-
project_id: project_id,
|
|
39
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
40
|
-
session_id: getSessionId()
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
assistanceRequested: function assistanceRequested(method, project_id) {
|
|
44
|
-
posthog.capture('assistance_requested', {
|
|
45
|
-
method: method,
|
|
46
|
-
project_id: project_id,
|
|
47
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
48
|
-
session_id: getSessionId()
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
addToCart: function addToCart(project_id, sku_count, price_total) {
|
|
52
|
-
posthog.capture('add_to_cart', {
|
|
53
|
-
project_id: project_id,
|
|
54
|
-
sku_count: sku_count,
|
|
55
|
-
price_total: price_total,
|
|
56
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
57
|
-
session_id: getSessionId()
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
package/lib/analytics/ga4.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GA = void 0;
|
|
7
|
-
var _reactGa = _interopRequireDefault(require("react-ga4"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
// ---------- Helpers ----------
|
|
16
|
-
function nowMs() {
|
|
17
|
-
return Date.now();
|
|
18
|
-
}
|
|
19
|
-
function getClientName() {
|
|
20
|
-
return sessionStorage.getItem('visualizerName');
|
|
21
|
-
}
|
|
22
|
-
function isDesktopUA() {
|
|
23
|
-
// Lightweight heuristic; GA4 also provides device.category. This flag can help ad-hoc filtering.
|
|
24
|
-
var ua = navigator.userAgent.toLowerCase();
|
|
25
|
-
var isMobile = /mobi|android|iphone|ipad|ipod|windows phone/.test(ua);
|
|
26
|
-
return !isMobile;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ---------- Keys for storage ----------
|
|
30
|
-
var SSN_KEYS = {
|
|
31
|
-
sessionStartMs: 'ga4_session_start_ms',
|
|
32
|
-
introChoiceMs: 'ga4_intro_choice_ms',
|
|
33
|
-
firstCabinetPlaced: 'ga4_first_cabinet_placed',
|
|
34
|
-
contextBooted: 'ga4_context_booted',
|
|
35
|
-
enteredCanvasSent: 'ga4_entered_canvas_sent'
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// ---------- Core GA wrapper ----------
|
|
39
|
-
var GA = exports.GA = {
|
|
40
|
-
init: function init(_ref) {
|
|
41
|
-
var measurementId = _ref.measurementId;
|
|
42
|
-
_reactGa["default"].initialize([{
|
|
43
|
-
trackingId: measurementId
|
|
44
|
-
}], {
|
|
45
|
-
testMode: false
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
resetSessionKeys: function resetSessionKeys() {
|
|
49
|
-
Object.values(SSN_KEYS).forEach(function (key) {
|
|
50
|
-
sessionStorage.removeItem(key);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Must be called ONCE per page load, *before* other events.
|
|
55
|
-
* Sets user properties (project_entry, cross_auth) and sends an initial page_view with client_name.
|
|
56
|
-
*/
|
|
57
|
-
bootSessionContext: function bootSessionContext(_ref2) {
|
|
58
|
-
var projectEntry = _ref2.projectEntry,
|
|
59
|
-
crossAuth = _ref2.crossAuth;
|
|
60
|
-
try {
|
|
61
|
-
var resolvedClient = getClientName();
|
|
62
|
-
|
|
63
|
-
// Persist session start for timing metrics (if not already set for this tab)
|
|
64
|
-
if (!sessionStorage.getItem(SSN_KEYS.sessionStartMs)) {
|
|
65
|
-
sessionStorage.setItem(SSN_KEYS.sessionStartMs, String(nowMs()));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Mark context as booted to avoid duplicate property sets on hot reloads
|
|
69
|
-
if (!sessionStorage.getItem(SSN_KEYS.contextBooted)) {
|
|
70
|
-
sessionStorage.setItem(SSN_KEYS.contextBooted, '1');
|
|
71
|
-
|
|
72
|
-
// Set GA4 user_properties (user-scoped dimensions)
|
|
73
|
-
_reactGa["default"].gtag('set', 'user_properties', {
|
|
74
|
-
project_entry: projectEntry,
|
|
75
|
-
// user scope dimension
|
|
76
|
-
cross_auth: crossAuth // user scope dimension (boolean serialized)
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Send first page_view hit enriched with event-scoped client_name
|
|
81
|
-
_reactGa["default"].send({
|
|
82
|
-
hitType: 'pageview',
|
|
83
|
-
page: window.location.pathname + window.location.search,
|
|
84
|
-
// @ts-expect-error react-ga4 passes along additional params into gtag
|
|
85
|
-
client_name: resolvedClient
|
|
86
|
-
});
|
|
87
|
-
} catch (e) {
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
|
-
console.warn('GA.bootSessionContext error', e);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
// Utility to derive cross_auth from URL (token or details query params)
|
|
93
|
-
deriveCrossAuthFromUrl: function deriveCrossAuthFromUrl(search) {
|
|
94
|
-
var sp = new URLSearchParams(search);
|
|
95
|
-
return sp.has('token') || sp.has('details');
|
|
96
|
-
},
|
|
97
|
-
// Utility to derive project entry (best-effort). You can also pass explicitly from router logic.
|
|
98
|
-
deriveProjectEntry: function deriveProjectEntry() {
|
|
99
|
-
var projectId = sessionStorage.getItem('projectId');
|
|
100
|
-
|
|
101
|
-
// If a project id exists, consider it "open_existing"; otherwise fallback to "new"
|
|
102
|
-
if (projectId) return 'open_existing';
|
|
103
|
-
return 'new';
|
|
104
|
-
},
|
|
105
|
-
// ---------- Event API ----------
|
|
106
|
-
events: {
|
|
107
|
-
/**
|
|
108
|
-
* intro_choice(option) — records the user's entry choice.
|
|
109
|
-
* Also stores a timestamp for later time_to_canvas calculation.
|
|
110
|
-
*/
|
|
111
|
-
introChoice: function introChoice(option, extra) {
|
|
112
|
-
var client_name = getClientName();
|
|
113
|
-
sessionStorage.setItem(SSN_KEYS.introChoiceMs, String(nowMs()));
|
|
114
|
-
_reactGa["default"].event('intro_choice', _objectSpread({
|
|
115
|
-
client_name: client_name,
|
|
116
|
-
option: option
|
|
117
|
-
}, extra || {}));
|
|
118
|
-
},
|
|
119
|
-
/**
|
|
120
|
-
* entered_canvas(time_to_canvas) — compute (now - intro_choice)
|
|
121
|
-
*/
|
|
122
|
-
enteredCanvas: function enteredCanvas() {
|
|
123
|
-
// fire only once per tab/session
|
|
124
|
-
if (sessionStorage.getItem(SSN_KEYS.enteredCanvasSent)) return;
|
|
125
|
-
var client_name = getClientName();
|
|
126
|
-
var introMs = Number(sessionStorage.getItem(SSN_KEYS.introChoiceMs) || 0);
|
|
127
|
-
var timeSec = introMs ? Math.max(0, Math.round((Date.now() - introMs) / 1000)) : undefined;
|
|
128
|
-
_reactGa["default"].event('entered_canvas', _objectSpread({
|
|
129
|
-
client_name: client_name
|
|
130
|
-
}, typeof timeSec === 'number' ? {
|
|
131
|
-
time_to_canvas: timeSec
|
|
132
|
-
} : {}));
|
|
133
|
-
sessionStorage.setItem(SSN_KEYS.enteredCanvasSent, '1'); // 👈 lock it
|
|
134
|
-
},
|
|
135
|
-
/**
|
|
136
|
-
* cabinet_placed(time_to_first_cabinet) — send only for the *first* cabinet of the session.
|
|
137
|
-
*/
|
|
138
|
-
cabinetPlaced: function cabinetPlaced() {
|
|
139
|
-
var already = sessionStorage.getItem(SSN_KEYS.firstCabinetPlaced);
|
|
140
|
-
var client_name = getClientName();
|
|
141
|
-
var params = {
|
|
142
|
-
client_name: client_name
|
|
143
|
-
};
|
|
144
|
-
if (!already) {
|
|
145
|
-
var startMs = Number(sessionStorage.getItem(SSN_KEYS.sessionStartMs) || 0);
|
|
146
|
-
var timeSec = startMs ? Math.max(0, Math.round((nowMs() - startMs) / 1000)) : undefined;
|
|
147
|
-
if (typeof timeSec === 'number') params.time_to_first_cabinet = timeSec; // custom metric (seconds)
|
|
148
|
-
sessionStorage.setItem(SSN_KEYS.firstCabinetPlaced, '1');
|
|
149
|
-
}
|
|
150
|
-
_reactGa["default"].event('cabinet_placed', params);
|
|
151
|
-
},
|
|
152
|
-
/**
|
|
153
|
-
* door_changed(door_id)
|
|
154
|
-
*/
|
|
155
|
-
doorChanged: function doorChanged(door_id) {
|
|
156
|
-
var client_name = getClientName();
|
|
157
|
-
_reactGa["default"].event('door_changed', {
|
|
158
|
-
client_name: client_name,
|
|
159
|
-
door_id: door_id
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
/**
|
|
163
|
-
* project_saved(project_id, save_method) — mark as conversion in GA UI.
|
|
164
|
-
*/
|
|
165
|
-
projectSaved: function projectSaved(project_id, save_method) {
|
|
166
|
-
var client_name = getClientName();
|
|
167
|
-
_reactGa["default"].event('project_saved', {
|
|
168
|
-
client_name: client_name,
|
|
169
|
-
project_id: project_id,
|
|
170
|
-
save_method: save_method
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
/**
|
|
174
|
-
* assistance_requested(method, project_id) — mark as conversion in GA UI.
|
|
175
|
-
*/
|
|
176
|
-
assistanceRequested: function assistanceRequested(method, project_id) {
|
|
177
|
-
var client_name = getClientName();
|
|
178
|
-
_reactGa["default"].event('assistance_requested', {
|
|
179
|
-
client_name: client_name,
|
|
180
|
-
method: method,
|
|
181
|
-
project_id: project_id
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
/**
|
|
185
|
-
* add_to_cart(project_id, sku_count, price_total) — mark as conversion in GA UI.
|
|
186
|
-
*/
|
|
187
|
-
addToCart: function addToCart(project_id, sku_count, price_total) {
|
|
188
|
-
var client_name = getClientName();
|
|
189
|
-
_reactGa["default"].event('add_to_cart', {
|
|
190
|
-
client_name: client_name,
|
|
191
|
-
project_id: project_id,
|
|
192
|
-
sku_count: sku_count,
|
|
193
|
-
price_total: price_total
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
};
|
package/lib/analytics/posthog.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PH = void 0;
|
|
7
|
-
exports.bootSessionContext = bootSessionContext;
|
|
8
|
-
exports.getSessionId = getSessionId;
|
|
9
|
-
var _posthogJs = _interopRequireDefault(require("posthog-js"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
// ---- session context ----
|
|
12
|
-
function bootSessionContext() {
|
|
13
|
-
var url = new URL(window.location.href);
|
|
14
|
-
var client_name = sessionStorage.getItem('visualizerName');
|
|
15
|
-
var project_entry = sessionStorage.getItem('projectId') ? 'open_existing' : 'new';
|
|
16
|
-
var cross_auth = url.searchParams.has('token') || url.searchParams.has('details');
|
|
17
|
-
|
|
18
|
-
// Persist context on the client/session
|
|
19
|
-
_posthogJs["default"].register({
|
|
20
|
-
client_name: client_name,
|
|
21
|
-
project_entry: project_entry,
|
|
22
|
-
cross_auth: cross_auth
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// First-hit event for qualitative flow
|
|
26
|
-
_posthogJs["default"].capture('session_started', {
|
|
27
|
-
client_name: client_name,
|
|
28
|
-
project_entry: project_entry,
|
|
29
|
-
cross_auth: cross_auth
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Optional: expose session id for replay linkage
|
|
34
|
-
function getSessionId() {
|
|
35
|
-
try {
|
|
36
|
-
return _posthogJs["default"].get_session_id();
|
|
37
|
-
} catch (_unused) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// ---- event wrappers (mirror GA4 conversions) ----
|
|
43
|
-
var PH = exports.PH = {
|
|
44
|
-
projectSaved: function projectSaved(project_id) {
|
|
45
|
-
_posthogJs["default"].capture('project_saved', {
|
|
46
|
-
project_id: project_id,
|
|
47
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
48
|
-
session_id: getSessionId()
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
assistanceRequested: function assistanceRequested(method, project_id) {
|
|
52
|
-
_posthogJs["default"].capture('assistance_requested', {
|
|
53
|
-
method: method,
|
|
54
|
-
project_id: project_id,
|
|
55
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
56
|
-
session_id: getSessionId()
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
addToCart: function addToCart(project_id, sku_count, price_total) {
|
|
60
|
-
_posthogJs["default"].capture('add_to_cart', {
|
|
61
|
-
project_id: project_id,
|
|
62
|
-
sku_count: sku_count,
|
|
63
|
-
price_total: price_total,
|
|
64
|
-
client_name: sessionStorage.getItem('visualizerName'),
|
|
65
|
-
session_id: getSessionId()
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|