@threekit-tools/treble 0.0.97 → 0.0.98
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/Treble/Treble.d.ts +1 -1
- package/dist/components/Share/index.js +13 -21
- package/dist/components/ThreekitProvider/index.d.ts +1 -0
- package/dist/components/ThreekitProvider/index.js +6 -3
- package/dist/hooks/useAnalyticsSession/index.d.ts +6 -0
- package/dist/hooks/useAnalyticsSession/index.js +17 -0
- package/dist/hooks/useAttribute/index.js +34 -6
- package/dist/hooks/useShare/index.js +15 -0
- package/dist/icons/types.d.ts +1 -1
- package/dist/store/attributes.js +26 -2
- package/dist/store/treble.js +6 -4
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +65 -3
- package/package.json +3 -1
package/dist/Treble/Treble.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class Treble {
|
|
|
22
22
|
_player: IThreekitPrivatePlayer;
|
|
23
23
|
wishlist: IWishlist;
|
|
24
24
|
private _snapshots;
|
|
25
|
-
takeSnapshots:
|
|
25
|
+
takeSnapshots: typeof snapshots['takeSnapshots'];
|
|
26
26
|
_debugMode: boolean;
|
|
27
27
|
constructor({ player, orgId }: ITreble);
|
|
28
28
|
createOrder: (order?: IOrder) => Promise<import("../http/orders").IOrderResponse>;
|
|
@@ -71,6 +71,7 @@ var Share_1 = __importDefault(require("../../icons/Share"));
|
|
|
71
71
|
var useThreekitInitStatus_1 = __importDefault(require("../../hooks/useThreekitInitStatus"));
|
|
72
72
|
var utils_1 = require("../../utils");
|
|
73
73
|
var share_styles_1 = require("./share.styles");
|
|
74
|
+
var useShare_1 = __importDefault(require("../../hooks/useShare"));
|
|
74
75
|
var Share = function (props) {
|
|
75
76
|
var _a = Object.assign({
|
|
76
77
|
type: 'threekit',
|
|
@@ -80,7 +81,8 @@ var Share = function (props) {
|
|
|
80
81
|
}, props), shape = _a.shape, type = _a.type, className = _a.className, msg = _a.message, position = _a.position;
|
|
81
82
|
var hasLoaded = (0, useThreekitInitStatus_1.default)();
|
|
82
83
|
var _b = (0, react_1.useState)(false), show = _b[0], setShow = _b[1];
|
|
83
|
-
var _c = (0, react_1.useState)(
|
|
84
|
+
var _c = (0, react_1.useState)(undefined), resumeUrl = _c[0], setResumeUrl = _c[1];
|
|
85
|
+
var handleShare = (0, useShare_1.default)();
|
|
84
86
|
var resumeUrlElRef = (0, react_1.useRef)(null);
|
|
85
87
|
var shareButtonRef = (0, react_1.useRef)(null);
|
|
86
88
|
var shareContentRef = (0, react_1.useRef)(null);
|
|
@@ -100,37 +102,27 @@ var Share = function (props) {
|
|
|
100
102
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
101
103
|
};
|
|
102
104
|
}, [show, shareButtonRef, shareContentRef]);
|
|
103
|
-
if (!hasLoaded)
|
|
105
|
+
if (!hasLoaded || !handleShare)
|
|
104
106
|
return null;
|
|
105
107
|
var cls = (0, utils_1.generateWidgetClassName)('share', className);
|
|
106
108
|
var handleClick = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
-
var
|
|
109
|
+
var resumableUrl;
|
|
108
110
|
return __generator(this, function (_a) {
|
|
109
111
|
switch (_a.label) {
|
|
110
112
|
case 0:
|
|
111
113
|
if (show) {
|
|
112
|
-
setResumeUrl(
|
|
114
|
+
setResumeUrl(undefined);
|
|
113
115
|
setShow(!show);
|
|
114
116
|
return [2];
|
|
115
117
|
}
|
|
116
|
-
return [4,
|
|
118
|
+
return [4, handleShare(msg)];
|
|
117
119
|
case 1:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
_a.sent();
|
|
125
|
-
if (msg === null || msg === void 0 ? void 0 : msg.length)
|
|
126
|
-
message_1.default.info(msg);
|
|
127
|
-
return [3, 5];
|
|
128
|
-
case 4:
|
|
129
|
-
e_1 = _a.sent();
|
|
130
|
-
setResumeUrl(configuration.resumableUrl);
|
|
131
|
-
setShow(!show);
|
|
132
|
-
return [3, 5];
|
|
133
|
-
case 5: return [2];
|
|
120
|
+
resumableUrl = _a.sent();
|
|
121
|
+
if (resumableUrl !== undefined) {
|
|
122
|
+
setResumeUrl(resumableUrl);
|
|
123
|
+
setShow(!show);
|
|
124
|
+
}
|
|
125
|
+
return [2];
|
|
134
126
|
}
|
|
135
127
|
});
|
|
136
128
|
}); };
|
|
@@ -10,6 +10,7 @@ interface AppProps extends Partial<ILaunchConfig> {
|
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
}
|
|
12
12
|
export interface ThreekitProviderProps extends AppProps {
|
|
13
|
+
display?: ILaunchConfig['playerConfig']['display'];
|
|
13
14
|
reducer?: Record<string, Reducer>;
|
|
14
15
|
removeTheme?: boolean;
|
|
15
16
|
}
|
|
@@ -48,7 +48,7 @@ var GlobalStyles_styles_1 = __importDefault(require("./GlobalStyles.styles"));
|
|
|
48
48
|
var DevTools_1 = __importDefault(require("../DevTools"));
|
|
49
49
|
var App = function (props) {
|
|
50
50
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
51
|
-
var
|
|
51
|
+
var _a = props.playerConfig, playerConfig = _a === void 0 ? {} : _a, assetId = props.assetId, customId = props.customId, productId = props.productId, project = props.project, locale = props.locale, threekitEnv = props.threekitEnv, eventHandlers = props.eventHandlers;
|
|
52
52
|
(0, react_1.useEffect)(function () {
|
|
53
53
|
dispatch((0, treble_1.launch)({
|
|
54
54
|
playerConfig: playerConfig,
|
|
@@ -61,17 +61,20 @@ var App = function (props) {
|
|
|
61
61
|
eventHandlers: eventHandlers,
|
|
62
62
|
}));
|
|
63
63
|
return;
|
|
64
|
-
}, [assetId, props.project, props.threekitEnv,
|
|
64
|
+
}, [assetId, props.project, props.threekitEnv, playerConfig === null || playerConfig === void 0 ? void 0 : playerConfig.display]);
|
|
65
65
|
return react_1.default.createElement(react_1.default.Fragment, null, props.children);
|
|
66
66
|
};
|
|
67
67
|
var ThreekitProvider = function (props) {
|
|
68
|
+
var _a;
|
|
68
69
|
var appProps = {
|
|
69
70
|
locale: props.locale,
|
|
70
71
|
assetId: props.assetId,
|
|
71
72
|
customId: props.customId,
|
|
72
73
|
productId: props.productId,
|
|
73
74
|
project: props.project,
|
|
74
|
-
playerConfig: props.playerConfig,
|
|
75
|
+
playerConfig: Object.assign({}, props.playerConfig, {
|
|
76
|
+
display: props.display || ((_a = props.playerConfig) === null || _a === void 0 ? void 0 : _a.display),
|
|
77
|
+
}),
|
|
75
78
|
threekitEnv: props.threekitEnv,
|
|
76
79
|
eventHandlers: props.eventHandlers,
|
|
77
80
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Session } from '@threekit/analytics';
|
|
2
|
+
declare type UseAnalyticsSessionSuccess = Session;
|
|
3
|
+
declare type UseAnalyticsSessionError = undefined;
|
|
4
|
+
declare type UseAnalyticsSession = UseAnalyticsSessionSuccess | UseAnalyticsSessionError;
|
|
5
|
+
declare const useAnalyticsSession: () => UseAnalyticsSession;
|
|
6
|
+
export default useAnalyticsSession;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var analytics_1 = require("@threekit/analytics");
|
|
4
|
+
var connection_1 = require("../../connection");
|
|
5
|
+
var useAnalyticsSession = function () {
|
|
6
|
+
var connection = new connection_1.ThreekitConnection();
|
|
7
|
+
var auth = {
|
|
8
|
+
orgId: connection._orgId,
|
|
9
|
+
host: connection._threekitDomain,
|
|
10
|
+
publicToken: connection._authToken,
|
|
11
|
+
};
|
|
12
|
+
var analyticsSession = (0, analytics_1.getSession)({ auth: auth });
|
|
13
|
+
if (!analyticsSession)
|
|
14
|
+
return undefined;
|
|
15
|
+
return analyticsSession;
|
|
16
|
+
};
|
|
17
|
+
exports.default = useAnalyticsSession;
|
|
@@ -35,17 +35,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
38
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
42
|
var store_1 = require("../../store");
|
|
40
43
|
var attributes_1 = require("../../store/attributes");
|
|
41
44
|
var utils_1 = require("../../utils");
|
|
42
45
|
var utils_2 = require("../../utils");
|
|
46
|
+
var useAnalyticsSession_1 = __importDefault(require("../useAnalyticsSession"));
|
|
47
|
+
var rest_api_1 = require("@threekit/rest-api");
|
|
43
48
|
var useAttribute = function (attributeName) {
|
|
44
49
|
var _a;
|
|
45
50
|
if (!attributeName)
|
|
46
51
|
return [undefined, undefined];
|
|
47
52
|
var dispatch = (0, store_1.useThreekitDispatch)();
|
|
48
53
|
var _b = (0, store_1.useThreekitSelector)(attributes_1.getHydrationData), attributes = _b[0], translations = _b[1];
|
|
54
|
+
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
49
55
|
if (!attributeName || !attributes)
|
|
50
56
|
return [undefined, undefined];
|
|
51
57
|
var attribute = attributes[attributeName];
|
|
@@ -53,20 +59,31 @@ var useAttribute = function (attributeName) {
|
|
|
53
59
|
return [undefined, undefined];
|
|
54
60
|
var preppedAttributes = (0, utils_2.hydrateAttribute)([(_a = {}, _a[attributeName] = attribute, _a), translations], function (config) { return dispatch((0, attributes_1.setConfiguration)(config)); });
|
|
55
61
|
var handleChange = function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var preppedValue,
|
|
62
|
+
var preppedValue, uploadId;
|
|
57
63
|
var _a;
|
|
58
64
|
return __generator(this, function (_b) {
|
|
59
65
|
switch (_b.label) {
|
|
60
66
|
case 0:
|
|
61
67
|
if (!(attribute.type === 'Asset' && attribute.assetType === 'upload')) return [3, 4];
|
|
62
|
-
if (!!value) return [3, 1];
|
|
63
|
-
preppedValue = (0, utils_1.selectionToConfiguration)('', attribute.type);
|
|
68
|
+
if (!!(value instanceof File)) return [3, 1];
|
|
69
|
+
preppedValue = (0, utils_1.selectionToConfiguration)(value !== null && value !== void 0 ? value : '', attribute.type);
|
|
64
70
|
return [3, 3];
|
|
65
71
|
case 1: return [4, window.threekit.player.uploadImage(value)];
|
|
66
72
|
case 2:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
uploadId = _b.sent();
|
|
74
|
+
try {
|
|
75
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.imageUpload({
|
|
76
|
+
assetId: window.threekit.player.assetId,
|
|
77
|
+
imageUploadId: attributeName,
|
|
78
|
+
imageUploadFileId: uploadId,
|
|
79
|
+
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
console.log('v2Analytics: Error reporting imageUpload event:', e);
|
|
84
|
+
}
|
|
85
|
+
if (uploadId)
|
|
86
|
+
preppedValue = (0, utils_1.selectionToConfiguration)(uploadId, attribute.type);
|
|
70
87
|
_b.label = 3;
|
|
71
88
|
case 3: return [3, 5];
|
|
72
89
|
case 4:
|
|
@@ -76,6 +93,17 @@ var useAttribute = function (attributeName) {
|
|
|
76
93
|
dispatch((0, attributes_1.setConfiguration)((_a = {},
|
|
77
94
|
_a[attributeName] = preppedValue,
|
|
78
95
|
_a)));
|
|
96
|
+
try {
|
|
97
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
98
|
+
optionsSetId: attribute.id,
|
|
99
|
+
optionId: attribute.name,
|
|
100
|
+
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
101
|
+
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
console.log('v2Analytics: Error reporting optionInteraction event:', e);
|
|
106
|
+
}
|
|
79
107
|
return [2];
|
|
80
108
|
}
|
|
81
109
|
});
|
|
@@ -43,10 +43,13 @@ var store_1 = require("../../store");
|
|
|
43
43
|
var treble_1 = require("../../store/treble");
|
|
44
44
|
var message_1 = __importDefault(require("../../components/message"));
|
|
45
45
|
var utils_1 = require("../../utils");
|
|
46
|
+
var useAnalyticsSession_1 = __importDefault(require("../useAnalyticsSession"));
|
|
47
|
+
var rest_api_1 = require("@threekit/rest-api");
|
|
46
48
|
var useShare = function () {
|
|
47
49
|
var isLoaded = (0, store_1.useThreekitSelector)(treble_1.isThreekitInitialized);
|
|
48
50
|
if (!isLoaded)
|
|
49
51
|
return undefined;
|
|
52
|
+
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
50
53
|
var handleShare = function (msg) {
|
|
51
54
|
if (msg === void 0) { msg = 'Link copied'; }
|
|
52
55
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -63,6 +66,18 @@ var useShare = function () {
|
|
|
63
66
|
(0, utils_1.copyToClipboard)(configuration.resumableUrl);
|
|
64
67
|
if (msg === null || msg === void 0 ? void 0 : msg.length)
|
|
65
68
|
message_1.default.info(msg);
|
|
69
|
+
try {
|
|
70
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.share({
|
|
71
|
+
shareLink: configuration.resumableUrl,
|
|
72
|
+
shareType: rest_api_1.ShareType.Share,
|
|
73
|
+
assetId: window.threekit.player.assetId,
|
|
74
|
+
configurationId: configuration.id,
|
|
75
|
+
configuration: window.threekit.configurator.getFullConfiguration(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
console.log('v2Analytics: Error reporting share event.');
|
|
80
|
+
}
|
|
66
81
|
return [2, Promise.resolve((configuration === null || configuration === void 0 ? void 0 : configuration.resumableUrl) || undefined)];
|
|
67
82
|
}
|
|
68
83
|
});
|
package/dist/icons/types.d.ts
CHANGED
package/dist/store/attributes.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -56,8 +67,21 @@ var reducer = (0, toolkit_1.createSlice)({
|
|
|
56
67
|
builder.addCase(treble_1.setThreekitInitialized, function () {
|
|
57
68
|
var attributes = window.threekit.configurator.getDisplayAttributes();
|
|
58
69
|
return attributes.reduce(function (output, attr) {
|
|
59
|
-
var _a;
|
|
60
|
-
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (attr.type === 'Color') {
|
|
72
|
+
return Object.assign(output, (_a = {},
|
|
73
|
+
_a[attr.name] = __assign(__assign({}, attr), { defaultValue: {
|
|
74
|
+
r: attr.defaultValue.r,
|
|
75
|
+
g: attr.defaultValue.g,
|
|
76
|
+
b: attr.defaultValue.b,
|
|
77
|
+
}, value: {
|
|
78
|
+
r: attr.value.r,
|
|
79
|
+
g: attr.value.g,
|
|
80
|
+
b: attr.value.b,
|
|
81
|
+
} }),
|
|
82
|
+
_a));
|
|
83
|
+
}
|
|
84
|
+
return Object.assign(output, (_b = {}, _b[attr.name] = attr, _b));
|
|
61
85
|
}, {});
|
|
62
86
|
});
|
|
63
87
|
builder.addCase(exports.setAttributes, function (_, action) {
|
package/dist/store/treble.js
CHANGED
|
@@ -173,7 +173,7 @@ var initPlayer = function (config) {
|
|
|
173
173
|
case 0:
|
|
174
174
|
el = config.el, authToken = config.authToken, assetId = config.assetId, customId = config.customId, stageId = config.stageId, playerConfig = config.playerConfig, initialConfiguration = config.initialConfiguration;
|
|
175
175
|
dispatch((0, exports.updateLoadingProgress)(0));
|
|
176
|
-
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId, customId: customId }, playerConfig), { initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
176
|
+
return [4, window.threekitPlayer(__assign(__assign({ el: el, authToken: authToken, stageId: stageId, assetId: assetId, customId: customId }, playerConfig), { pricing: false, initialConfiguration: initialConfiguration, onLoadingProgress: function (progress) {
|
|
177
177
|
var _a;
|
|
178
178
|
if (progress > 0)
|
|
179
179
|
el.style.visibility = 'visible';
|
|
@@ -413,8 +413,10 @@ var launch = function (launchConfig) {
|
|
|
413
413
|
dispatch((0, product_1.initProduct)());
|
|
414
414
|
dispatch((0, exports.setThreekitEnv)(threekitEnv));
|
|
415
415
|
dispatch((0, translations_1.initTranslations)(launchConfig === null || launchConfig === void 0 ? void 0 : launchConfig.locale));
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
if (playerConfig.pricing) {
|
|
417
|
+
dispatch((0, price_1.initPrice)());
|
|
418
|
+
dispatch((0, price_1.updatePrice)());
|
|
419
|
+
}
|
|
418
420
|
dispatch((0, wishlist_1.refreshWishlist)());
|
|
419
421
|
return [2];
|
|
420
422
|
}
|
|
@@ -429,7 +431,7 @@ var unloadPlayer = function (playerEl) { return function (dispatch) { return __a
|
|
|
429
431
|
dispatch((0, exports.setThreekitInitialized)(false));
|
|
430
432
|
dispatch((0, exports.setPlayerLoading)(true));
|
|
431
433
|
dispatch((0, attributes_1.setAttributes)([]));
|
|
432
|
-
dispatch((0, product_1.setName)(
|
|
434
|
+
dispatch((0, product_1.setName)());
|
|
433
435
|
dispatch((0, product_1.setMetadata)({}));
|
|
434
436
|
return [4, window.threekit.player.unload()];
|
|
435
437
|
case 1:
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export declare const downloadSnapshot: (snapshot: string, filename: string) => P
|
|
|
48
48
|
export declare const copyToClipboard: (data: string | Record<string, string | number | boolean>) => void;
|
|
49
49
|
export declare const easeInOutCubic: (val: number) => number;
|
|
50
50
|
export declare const metadataValueToObject: (data: string) => Record<string, string | number>;
|
|
51
|
+
export declare const recordOptionsShowAnalytics: (attributes: Record<string, IThreekitDisplayAttribute>) => void;
|
|
52
|
+
export declare const recordOptionInteractionAnalytics: (attribute: IThreekitDisplayAttribute, chosenAttribute: string, configuration?: IConfiguration) => void;
|
|
51
53
|
export declare const hydrateAttribute: (data: [Record<string, IThreekitDisplayAttribute>, ITranslationsMap], optionSelectionHandler: (config: ISetConfiguration) => Promise<void>, configuration?: IConfiguration) => Record<string, IHydratedAttribute>;
|
|
52
54
|
export declare const selectionToConfiguration: (value: RawAttributeValue, attributeType: ATTRIBUTE_TYPES) => string | number | boolean | File | IConfigurationColor | {
|
|
53
55
|
assetId: RawAttributeValue;
|
package/dist/utils.js
CHANGED
|
@@ -44,10 +44,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
44
44
|
}
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
47
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.loadTrebleConfig = exports.runDebugger = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.isIOS = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
51
|
+
exports.loadTrebleConfig = exports.runDebugger = exports.isUuid = exports.filterFormAttributes = exports.selectionToConfiguration = exports.hydrateAttribute = exports.recordOptionInteractionAnalytics = exports.recordOptionsShowAnalytics = exports.metadataValueToObject = exports.easeInOutCubic = exports.copyToClipboard = exports.downloadSnapshot = exports.dataURItoFile = exports.dataURItoBlob = exports.setCameraPosition = exports.getCameraPosition = exports.findHitNode = exports.deflateRgb = exports.inflateRgb = exports.rgbToHex = exports.hexToRgb = exports.regularToKebabCase = exports.deepCompare = exports.shallowCompare = exports.getResumableUrl = exports.getParams = exports.objectToQueryStr = exports.isJsonString = exports.isIOS = exports.generateFormClassName = exports.generateDisplayClassName = exports.generateToolClassName = exports.generateLayoutClassName = exports.generateWidgetClassName = exports.generateInputClassName = exports.generateClassName = void 0;
|
|
49
52
|
var constants_1 = require("./constants");
|
|
50
53
|
var types_1 = require("./types");
|
|
54
|
+
var useAnalyticsSession_1 = __importDefault(require("./hooks/useAnalyticsSession"));
|
|
55
|
+
var rest_api_1 = require("@threekit/rest-api");
|
|
51
56
|
var generateClassName = function (baseClass) {
|
|
52
57
|
return function (component, customClassName, title) {
|
|
53
58
|
var result = "".concat(baseClass, "-").concat(component);
|
|
@@ -303,10 +308,65 @@ var metadataValueToObject = function (data) {
|
|
|
303
308
|
}, {});
|
|
304
309
|
};
|
|
305
310
|
exports.metadataValueToObject = metadataValueToObject;
|
|
311
|
+
var recordOptionsShowAnalytics = function (attributes) {
|
|
312
|
+
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
313
|
+
Object.values(attributes).forEach(function (attribute) {
|
|
314
|
+
if ((attribute.type === 'String' || attribute.type === 'Asset') &&
|
|
315
|
+
attribute.values.length) {
|
|
316
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionsShow({
|
|
317
|
+
optionsSetId: attribute.id,
|
|
318
|
+
optionsSetName: attribute.name,
|
|
319
|
+
options: attribute.values,
|
|
320
|
+
optionsType: attribute.type === 'Asset' ? rest_api_1.OptionsType.Asset : rest_api_1.OptionsType.Value,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
exports.recordOptionsShowAnalytics = recordOptionsShowAnalytics;
|
|
326
|
+
var recordOptionInteractionAnalytics = function (attribute, chosenAttribute, configuration) {
|
|
327
|
+
var analyticsSession = (0, useAnalyticsSession_1.default)();
|
|
328
|
+
var castedConfiguration = configuration;
|
|
329
|
+
var id = attribute.type === 'Asset' ? attribute.value.assetId : attribute.id;
|
|
330
|
+
if (attribute.type === 'String') {
|
|
331
|
+
if (attribute.values.length > 0) {
|
|
332
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
333
|
+
optionsSetId: id,
|
|
334
|
+
optionId: chosenAttribute,
|
|
335
|
+
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
336
|
+
configuration: castedConfiguration,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.personalizeText({
|
|
341
|
+
assetId: id,
|
|
342
|
+
configuration: castedConfiguration,
|
|
343
|
+
personalizeId: attribute.id,
|
|
344
|
+
personalizedText: attribute.value,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (attribute.type === 'Asset' || attribute.type === 'Color') {
|
|
349
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.optionInteraction({
|
|
350
|
+
optionsSetId: id,
|
|
351
|
+
optionId: chosenAttribute,
|
|
352
|
+
interactionType: rest_api_1.OptionInteractionType.Select,
|
|
353
|
+
configuration: castedConfiguration,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
if (attribute.type === 'Number') {
|
|
357
|
+
analyticsSession === null || analyticsSession === void 0 ? void 0 : analyticsSession.parametricValue({
|
|
358
|
+
parametricId: id,
|
|
359
|
+
parametricValue: attribute.value,
|
|
360
|
+
configuration: castedConfiguration,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
exports.recordOptionInteractionAnalytics = recordOptionInteractionAnalytics;
|
|
306
365
|
var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
307
366
|
var _a, _b;
|
|
308
367
|
var attributes = data[0], translations = data[1];
|
|
309
368
|
var resolvedConfig = configuration !== null && configuration !== void 0 ? configuration : (_b = (_a = window.threekit) === null || _a === void 0 ? void 0 : _a.configurator) === null || _b === void 0 ? void 0 : _b.getResolvedConfiguration();
|
|
369
|
+
(0, exports.recordOptionsShowAnalytics)(attributes);
|
|
310
370
|
return Object.values(attributes).reduce(function (output, attribute) {
|
|
311
371
|
var _a;
|
|
312
372
|
var _b;
|
|
@@ -321,7 +381,8 @@ var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
|
321
381
|
label: (_a = translations[el.label]) !== null && _a !== void 0 ? _a : el.label,
|
|
322
382
|
handleSelect: function () {
|
|
323
383
|
var _a;
|
|
324
|
-
|
|
384
|
+
(0, exports.recordOptionInteractionAnalytics)(attribute, attribute.value, configuration);
|
|
385
|
+
optionSelectionHandler((_a = {},
|
|
325
386
|
_a[attribute.name] = el.value,
|
|
326
387
|
_a));
|
|
327
388
|
},
|
|
@@ -337,7 +398,8 @@ var hydrateAttribute = function (data, optionSelectionHandler, configuration) {
|
|
|
337
398
|
label: (_a = translations[el.name]) !== null && _a !== void 0 ? _a : el.name,
|
|
338
399
|
handleSelect: function () {
|
|
339
400
|
var _a;
|
|
340
|
-
|
|
401
|
+
(0, exports.recordOptionInteractionAnalytics)(attribute, attribute.label, configuration);
|
|
402
|
+
optionSelectionHandler((_a = {},
|
|
341
403
|
_a[attribute.name] = { assetId: el.assetId },
|
|
342
404
|
_a));
|
|
343
405
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threekit-tools/treble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.98",
|
|
4
4
|
"author": "Amaan Saeed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -82,6 +82,8 @@
|
|
|
82
82
|
"typescript": ">=4.4.4"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
+
"@threekit/analytics": "0.2.13",
|
|
86
|
+
"@threekit/rest-api": ">=0.2.2",
|
|
85
87
|
"react": ">=17.0.2",
|
|
86
88
|
"react-dom": ">=17.0.2"
|
|
87
89
|
},
|