@builder.io/sdk-react 0.0.1-5 → 0.0.1-6

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",
3
3
  "description": "Builder.io SDK for React",
4
- "version": "0.0.1-5",
4
+ "version": "0.0.1-6",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -29,6 +29,26 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
32
52
  import { TARGET } from "../constants/target.js";
33
53
  import { getSessionId } from "../helpers/sessionId.js";
34
54
  import { getVisitorId } from "../helpers/visitorId.js";
@@ -66,24 +86,28 @@ const createEvent = (_a) => {
66
86
  };
67
87
  };
68
88
  function track(eventProps) {
69
- if (!eventProps.canTrack) {
70
- return;
71
- }
72
- if (isEditing()) {
73
- return;
74
- }
75
- if (!(isBrowser() || TARGET === "reactNative")) {
76
- return;
77
- }
78
- return fetch(`https://builder.io/api/v1/track`, {
79
- method: "POST",
80
- body: JSON.stringify({
81
- events: [createEvent(eventProps)]
82
- }),
83
- headers: {
84
- "content-type": "application/json"
85
- },
86
- mode: "cors"
89
+ return __async(this, null, function* () {
90
+ if (!eventProps.canTrack) {
91
+ return;
92
+ }
93
+ if (isEditing()) {
94
+ return;
95
+ }
96
+ if (!(isBrowser() || TARGET === "reactNative")) {
97
+ return;
98
+ }
99
+ return fetch(`https://builder.io/api/v1/track`, {
100
+ method: "POST",
101
+ body: JSON.stringify({
102
+ events: [createEvent(eventProps)]
103
+ }),
104
+ headers: {
105
+ "content-type": "application/json"
106
+ },
107
+ mode: "cors"
108
+ }).catch((err) => {
109
+ console.error("Failed to track: ", err);
110
+ });
87
111
  });
88
112
  }
89
113
  export {