@builder.io/sdk-react-native 0.0.10 → 0.0.11

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-native",
3
3
  "description": "Builder.io SDK for React Native",
4
- "version": "0.0.10",
4
+ "version": "0.0.11",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src"
@@ -33,7 +33,7 @@ import {
33
33
  components,
34
34
  createRegisterComponentMessage
35
35
  } from "../../functions/register-component.js";
36
- import { track } from "../../functions/track.js";
36
+ import { _track } from "../../functions/track.js";
37
37
  import RenderBlocks from "../render-blocks.js";
38
38
  import RenderContentStyles from "./components/render-styles.js";
39
39
  import {
@@ -114,13 +114,16 @@ function RenderContent(props) {
114
114
  return {};
115
115
  }
116
116
  function onClick(_event) {
117
- var _a2;
117
+ var _a2, _b2;
118
118
  if (useContent()) {
119
- track({
119
+ const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
120
+ const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
121
+ _track({
120
122
  type: "click",
121
123
  canTrack: canTrackToUse(),
122
- contentId: (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.id,
123
- orgId: props.apiKey
124
+ contentId,
125
+ apiKey: props.apiKey,
126
+ variationId: variationId !== contentId ? variationId : void 0
124
127
  });
125
128
  }
126
129
  }
@@ -171,7 +174,7 @@ function RenderContent(props) {
171
174
  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");
172
175
  }
173
176
  useEffect(() => {
174
- var _a2;
177
+ var _a2, _b2;
175
178
  if (isBrowser()) {
176
179
  if (isEditing()) {
177
180
  setForceReRenderCount(forceReRenderCount + 1);
@@ -186,11 +189,14 @@ function RenderContent(props) {
186
189
  window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
187
190
  }
188
191
  if (useContent()) {
189
- track({
192
+ const variationId = (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.testVariationId;
193
+ const contentId = (_b2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _b2.id;
194
+ _track({
190
195
  type: "impression",
191
196
  canTrack: canTrackToUse(),
192
- contentId: (_a2 = useContent == null ? void 0 : useContent()) == null ? void 0 : _a2.id,
193
- orgId: props.apiKey
197
+ contentId,
198
+ apiKey: props.apiKey,
199
+ variationId: variationId !== contentId ? variationId : void 0
194
200
  });
195
201
  }
196
202
  if (isPreviewing()) {
@@ -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
- orgId,
75
- contentId
74
+ apiKey,
75
+ metadata
76
76
  } = _b, properties = __objRest(_b, [
77
77
  "type",
78
78
  "canTrack",
79
- "orgId",
80
- "contentId"
79
+ "apiKey",
80
+ "metadata"
81
81
  ]);
82
82
  return {
83
83
  type: eventType,
84
- data: __spreadProps(__spreadValues(__spreadValues({}, properties), yield getTrackingEventData({ canTrack })), {
85
- ownerId: orgId,
86
- contentId
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 track(eventProps) {
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
+ };