@builder.io/sdk-react 0.0.1 → 0.0.2
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/package.json
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
components,
|
|
33
33
|
createRegisterComponentMessage
|
|
34
34
|
} from "../../functions/register-component.js";
|
|
35
|
-
import {
|
|
35
|
+
import { _track } from "../../functions/track.js";
|
|
36
36
|
import RenderBlocks from "../render-blocks.jsx";
|
|
37
37
|
import RenderContentStyles from "./components/render-styles.jsx";
|
|
38
38
|
import {
|
|
@@ -113,13 +113,16 @@ function RenderContent(props) {
|
|
|
113
113
|
return {};
|
|
114
114
|
}
|
|
115
115
|
function onClick(_event) {
|
|
116
|
-
var _a2;
|
|
116
|
+
var _a2, _b2;
|
|
117
117
|
if (useContent()) {
|
|
118
|
-
|
|
118
|
+
const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
|
|
119
|
+
const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
|
|
120
|
+
_track({
|
|
119
121
|
type: "click",
|
|
120
122
|
canTrack: canTrackToUse(),
|
|
121
|
-
contentId
|
|
122
|
-
|
|
123
|
+
contentId,
|
|
124
|
+
apiKey: props.apiKey,
|
|
125
|
+
variationId: variationId !== contentId ? variationId : void 0
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
}
|
|
@@ -170,7 +173,7 @@ function RenderContent(props) {
|
|
|
170
173
|
return Boolean((((_b2 = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.data) == null ? void 0 : _b2.cssCode) || ((_e2 = (_d2 = (_c2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _c2.data) == null ? void 0 : _d2.customFonts) == null ? void 0 : _e2.length)) && TARGET !== "reactNative");
|
|
171
174
|
}
|
|
172
175
|
useEffect(() => {
|
|
173
|
-
var _a2;
|
|
176
|
+
var _a2, _b2;
|
|
174
177
|
if (isBrowser()) {
|
|
175
178
|
if (isEditing()) {
|
|
176
179
|
setForceReRenderCount(forceReRenderCount + 1);
|
|
@@ -185,11 +188,14 @@ function RenderContent(props) {
|
|
|
185
188
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
186
189
|
}
|
|
187
190
|
if (useContent()) {
|
|
188
|
-
|
|
191
|
+
const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
|
|
192
|
+
const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
|
|
193
|
+
_track({
|
|
189
194
|
type: "impression",
|
|
190
195
|
canTrack: canTrackToUse(),
|
|
191
|
-
contentId
|
|
192
|
-
|
|
196
|
+
contentId,
|
|
197
|
+
apiKey: props.apiKey,
|
|
198
|
+
variationId: variationId !== contentId ? variationId : void 0
|
|
193
199
|
});
|
|
194
200
|
}
|
|
195
201
|
if (isPreviewing()) {
|
package/src/functions/track.js
CHANGED
|
@@ -71,23 +71,24 @@ const createEvent = (_a) => __async(void 0, null, function* () {
|
|
|
71
71
|
var _b = _a, {
|
|
72
72
|
type: eventType,
|
|
73
73
|
canTrack,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
apiKey,
|
|
75
|
+
metadata
|
|
76
76
|
} = _b, properties = __objRest(_b, [
|
|
77
77
|
"type",
|
|
78
78
|
"canTrack",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
79
|
+
"apiKey",
|
|
80
|
+
"metadata"
|
|
81
81
|
]);
|
|
82
82
|
return {
|
|
83
83
|
type: eventType,
|
|
84
|
-
data: __spreadProps(__spreadValues(__spreadValues({}, properties),
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
data: __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, properties), {
|
|
85
|
+
metadata: JSON.stringify(metadata)
|
|
86
|
+
}), yield getTrackingEventData({ canTrack })), {
|
|
87
|
+
ownerId: apiKey
|
|
87
88
|
})
|
|
88
89
|
};
|
|
89
90
|
});
|
|
90
|
-
function
|
|
91
|
+
function _track(eventProps) {
|
|
91
92
|
return __async(this, null, function* () {
|
|
92
93
|
if (!eventProps.canTrack) {
|
|
93
94
|
return;
|
|
@@ -112,6 +113,8 @@ function track(eventProps) {
|
|
|
112
113
|
});
|
|
113
114
|
});
|
|
114
115
|
}
|
|
116
|
+
const track = (args) => _track(__spreadProps(__spreadValues({}, args), { canTrack: true }));
|
|
115
117
|
export {
|
|
118
|
+
_track,
|
|
116
119
|
track
|
|
117
120
|
};
|
package/src/index.js
CHANGED
|
@@ -8,3 +8,7 @@ export * from "./functions/register.js";
|
|
|
8
8
|
export * from "./functions/set-editor-settings.js";
|
|
9
9
|
export * from "./functions/get-content/index.js";
|
|
10
10
|
export * from "./functions/get-builder-search-params/index.js";
|
|
11
|
+
import { track } from "./functions/track";
|
|
12
|
+
export {
|
|
13
|
+
track
|
|
14
|
+
};
|