@builder.io/sdk-vue 0.0.1-68 → 0.0.1-69
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 +1 -1
- package/vue2/src/blocks/button/button.vue +2 -2
- package/vue2/src/blocks/columns/columns.vue +8 -8
- package/vue2/src/blocks/form/form.vue +2 -2
- package/vue2/src/blocks/image/image.vue +8 -8
- package/vue2/src/components/render-blocks.vue +2 -2
- package/vue2/src/components/render-content/render-content.vue +14 -5
- package/vue2/src/functions/track.js +71 -2
- package/vue2/src/helpers/cookie.js +59 -0
- package/vue2/src/helpers/localStorage.js +34 -0
- package/vue2/src/helpers/nullable.js +4 -0
- package/vue2/src/helpers/sessionId.js +26 -0
- package/vue2/src/helpers/time.js +5 -0
- package/vue2/src/helpers/url.js +10 -0
- package/vue2/src/helpers/url.test.js +15 -0
- package/vue2/src/helpers/uuid.js +13 -0
- package/vue2/src/helpers/visitorId.js +33 -0
- package/vue2/src/types/can-track.js +0 -0
- package/vue3/src/blocks/button/button.vue +2 -2
- package/vue3/src/blocks/columns/columns.vue +8 -8
- package/vue3/src/blocks/form/form.vue +2 -2
- package/vue3/src/blocks/image/image.vue +8 -8
- package/vue3/src/components/render-blocks.vue +2 -2
- package/vue3/src/components/render-content/render-content.vue +14 -5
- package/vue3/src/functions/track.js +71 -2
- package/vue3/src/helpers/cookie.js +59 -0
- package/vue3/src/helpers/localStorage.js +34 -0
- package/vue3/src/helpers/nullable.js +4 -0
- package/vue3/src/helpers/sessionId.js +26 -0
- package/vue3/src/helpers/time.js +5 -0
- package/vue3/src/helpers/url.js +10 -0
- package/vue3/src/helpers/url.test.js +15 -0
- package/vue3/src/helpers/uuid.js +13 -0
- package/vue3/src/helpers/visitorId.js +33 -0
- package/vue3/src/types/can-track.js +0 -0
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
>
|
|
9
9
|
{{ text }}
|
|
10
10
|
</a>
|
|
11
|
-
<button v-bind="attributes" class="button-
|
|
11
|
+
<button v-bind="attributes" class="button-2fnk003dqad" v-else>
|
|
12
12
|
{{ text }}
|
|
13
13
|
</button>
|
|
14
14
|
</template>
|
|
@@ -20,7 +20,7 @@ export default {
|
|
|
20
20
|
};
|
|
21
21
|
</script>
|
|
22
22
|
<style scoped>
|
|
23
|
-
.button-
|
|
23
|
+
.button-2fnk003dqad {
|
|
24
24
|
all: unset;
|
|
25
25
|
}
|
|
26
26
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="builder-columns div-
|
|
2
|
+
<div class="builder-columns div-4wbls88y960" :style="columnsCssVars">
|
|
3
3
|
<div
|
|
4
|
-
class="builder-column div-
|
|
4
|
+
class="builder-column div-4wbls88y960-2"
|
|
5
5
|
v-for="(column, index) in columns"
|
|
6
6
|
:style="{
|
|
7
7
|
width: getColumnCssWidth(index),
|
|
@@ -84,32 +84,32 @@ export default {
|
|
|
84
84
|
};
|
|
85
85
|
</script>
|
|
86
86
|
<style scoped>
|
|
87
|
-
.div-
|
|
87
|
+
.div-4wbls88y960 {
|
|
88
88
|
display: flex;
|
|
89
89
|
align-items: stretch;
|
|
90
90
|
line-height: normal;
|
|
91
91
|
}
|
|
92
92
|
@media (max-width: 991px) {
|
|
93
|
-
.div-
|
|
93
|
+
.div-4wbls88y960 {
|
|
94
94
|
flex-direction: var(--flex-dir-tablet);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
@media (max-width: 639px) {
|
|
98
|
-
.div-
|
|
98
|
+
.div-4wbls88y960 {
|
|
99
99
|
flex-direction: var(--flex-dir);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
.div-
|
|
102
|
+
.div-4wbls88y960-2 {
|
|
103
103
|
flex-grow: 1;
|
|
104
104
|
}
|
|
105
105
|
@media (max-width: 991px) {
|
|
106
|
-
.div-
|
|
106
|
+
.div-4wbls88y960-2 {
|
|
107
107
|
width: var(--column-width-tablet) !important;
|
|
108
108
|
margin-left: var(--column-margin-left-tablet) !important;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
@media (max-width: 639px) {
|
|
112
|
-
.div-
|
|
112
|
+
.div-4wbls88y960-2 {
|
|
113
113
|
width: var(--column-width) !important;
|
|
114
114
|
margin-left: var(--column-margin-left) !important;
|
|
115
115
|
}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
></builder-blocks>
|
|
29
29
|
|
|
30
30
|
<pre
|
|
31
|
-
class="builder-form-error-text pre-
|
|
31
|
+
class="builder-form-error-text pre-t43jfuqn6g"
|
|
32
32
|
v-if="submissionState === 'error' && responseData"
|
|
33
33
|
>
|
|
34
34
|
{{ JSON.stringify(responseData, null, 2) }}
|
|
@@ -301,7 +301,7 @@ export default {
|
|
|
301
301
|
};
|
|
302
302
|
</script>
|
|
303
303
|
<style scoped>
|
|
304
|
-
.pre-
|
|
304
|
+
.pre-t43jfuqn6g {
|
|
305
305
|
padding: 10px;
|
|
306
306
|
color: red;
|
|
307
307
|
text-align: center;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="div-
|
|
2
|
+
<div class="div-cvp1sc2nsao">
|
|
3
3
|
<picture>
|
|
4
4
|
<source type="image/webp" v-if="webpSrcSet" :srcset="webpSrcSet" />
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
_classStringToObject(
|
|
16
16
|
'builder-image' +
|
|
17
17
|
(this.className ? ' ' + this.className : '') +
|
|
18
|
-
' img-
|
|
18
|
+
' img-cvp1sc2nsao'
|
|
19
19
|
)
|
|
20
20
|
"
|
|
21
21
|
:src="image"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</picture>
|
|
27
27
|
|
|
28
28
|
<div
|
|
29
|
-
class="builder-image-sizer div-
|
|
29
|
+
class="builder-image-sizer div-cvp1sc2nsao-2"
|
|
30
30
|
v-if="aspectRatio && !(fitContent && ((builderBlock && builderBlock.children) && (builderBlock && builderBlock.children).length))"
|
|
31
31
|
:style="{
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
<slot></slot>
|
|
38
38
|
|
|
39
|
-
<div class="div-
|
|
39
|
+
<div class="div-cvp1sc2nsao-3" v-if="!fitContent">
|
|
40
40
|
<slot></slot>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
@@ -110,10 +110,10 @@ export default {
|
|
|
110
110
|
};
|
|
111
111
|
</script>
|
|
112
112
|
<style scoped>
|
|
113
|
-
.div-
|
|
113
|
+
.div-cvp1sc2nsao {
|
|
114
114
|
position: relative;
|
|
115
115
|
}
|
|
116
|
-
.img-
|
|
116
|
+
.img-cvp1sc2nsao {
|
|
117
117
|
opacity: 1;
|
|
118
118
|
transition: opacity 0.2s ease-in-out;
|
|
119
119
|
position: absolute;
|
|
@@ -122,12 +122,12 @@ export default {
|
|
|
122
122
|
top: 0px;
|
|
123
123
|
left: 0px;
|
|
124
124
|
}
|
|
125
|
-
.div-
|
|
125
|
+
.div-cvp1sc2nsao-2 {
|
|
126
126
|
width: 100%;
|
|
127
127
|
pointer-events: none;
|
|
128
128
|
font-size: 0;
|
|
129
129
|
}
|
|
130
|
-
.div-
|
|
130
|
+
.div-cvp1sc2nsao-3 {
|
|
131
131
|
display: flex;
|
|
132
132
|
flex-direction: column;
|
|
133
133
|
align-items: stretch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="_classStringToObject(this.className + ' div-
|
|
3
|
+
:class="_classStringToObject(this.className + ' div-23e8fqt91nf')"
|
|
4
4
|
:builder-path="path"
|
|
5
5
|
:builder-parent-id="parent"
|
|
6
6
|
:dataSet="{
|
|
@@ -84,7 +84,7 @@ export default {
|
|
|
84
84
|
};
|
|
85
85
|
</script>
|
|
86
86
|
<style scoped>
|
|
87
|
-
.div-
|
|
87
|
+
.div-23e8fqt91nf {
|
|
88
88
|
display: flex;
|
|
89
89
|
flex-direction: column;
|
|
90
90
|
align-items: stretch;
|
|
@@ -40,10 +40,10 @@ export default {
|
|
|
40
40
|
props: [
|
|
41
41
|
"content",
|
|
42
42
|
"data",
|
|
43
|
+
"canTrack",
|
|
43
44
|
"context",
|
|
44
45
|
"customComponents",
|
|
45
46
|
"model",
|
|
46
|
-
"canTrack",
|
|
47
47
|
"apiKey",
|
|
48
48
|
],
|
|
49
49
|
|
|
@@ -88,9 +88,12 @@ export default {
|
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
if (this.useContent
|
|
92
|
-
track(
|
|
91
|
+
if (this.useContent) {
|
|
92
|
+
track({
|
|
93
|
+
type: "impression",
|
|
94
|
+
canTrack: this.canTrackToUse,
|
|
93
95
|
contentId: this.useContent.id,
|
|
96
|
+
orgId: this.apiKey,
|
|
94
97
|
});
|
|
95
98
|
} // override normal content in preview mode
|
|
96
99
|
|
|
@@ -154,6 +157,9 @@ export default {
|
|
|
154
157
|
};
|
|
155
158
|
return mergedContent;
|
|
156
159
|
},
|
|
160
|
+
canTrackToUse() {
|
|
161
|
+
return this.canTrack || true;
|
|
162
|
+
},
|
|
157
163
|
contentState() {
|
|
158
164
|
return {
|
|
159
165
|
...this.content?.data?.state,
|
|
@@ -249,9 +255,12 @@ export default {
|
|
|
249
255
|
}
|
|
250
256
|
},
|
|
251
257
|
onClick(_event) {
|
|
252
|
-
if (this.useContent
|
|
253
|
-
track(
|
|
258
|
+
if (this.useContent) {
|
|
259
|
+
track({
|
|
260
|
+
type: "click",
|
|
261
|
+
canTrack: this.canTrackToUse,
|
|
254
262
|
contentId: this.useContent.id,
|
|
263
|
+
orgId: this.apiKey,
|
|
255
264
|
});
|
|
256
265
|
}
|
|
257
266
|
},
|
|
@@ -1,7 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
1
32
|
import { TARGET } from "../constants/target.js";
|
|
33
|
+
import { getSessionId } from "../helpers/sessionId.js";
|
|
34
|
+
import { getVisitorId } from "../helpers/visitorId.js";
|
|
2
35
|
import { isBrowser } from "./is-browser.js";
|
|
3
36
|
import { isEditing } from "./is-editing.js";
|
|
4
|
-
|
|
37
|
+
const getTrackingEventData = ({ canTrack }) => {
|
|
38
|
+
if (!canTrack) {
|
|
39
|
+
return { visitorId: void 0, sessionId: void 0 };
|
|
40
|
+
}
|
|
41
|
+
const sessionId = getSessionId({ canTrack });
|
|
42
|
+
const visitorId = getVisitorId({ canTrack });
|
|
43
|
+
return {
|
|
44
|
+
sessionId,
|
|
45
|
+
visitorId
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const createEvent = (_a) => {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
type: eventType,
|
|
51
|
+
canTrack,
|
|
52
|
+
orgId,
|
|
53
|
+
contentId
|
|
54
|
+
} = _b, properties = __objRest(_b, [
|
|
55
|
+
"type",
|
|
56
|
+
"canTrack",
|
|
57
|
+
"orgId",
|
|
58
|
+
"contentId"
|
|
59
|
+
]);
|
|
60
|
+
return {
|
|
61
|
+
type: eventType,
|
|
62
|
+
data: __spreadProps(__spreadValues(__spreadValues({}, properties), getTrackingEventData({ canTrack })), {
|
|
63
|
+
ownerId: orgId,
|
|
64
|
+
contentId
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
function track(eventProps) {
|
|
69
|
+
if (!eventProps.canTrack) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
5
72
|
if (isEditing()) {
|
|
6
73
|
return;
|
|
7
74
|
}
|
|
@@ -10,7 +77,9 @@ function track(event, properties) {
|
|
|
10
77
|
}
|
|
11
78
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
12
79
|
method: "POST",
|
|
13
|
-
body: JSON.stringify({
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
events: [createEvent(eventProps)]
|
|
82
|
+
}),
|
|
14
83
|
headers: {
|
|
15
84
|
"content-type": "application/json"
|
|
16
85
|
},
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser";
|
|
2
|
+
import { getTopLevelDomain } from "./url";
|
|
3
|
+
const getCookie = ({
|
|
4
|
+
name,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (!canTrack) {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[COOKIE] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).join("; ");
|
|
18
|
+
const SECURE_CONFIG = [
|
|
19
|
+
["secure", ""],
|
|
20
|
+
["SameSite", "None"]
|
|
21
|
+
];
|
|
22
|
+
const createCookieString = ({
|
|
23
|
+
name,
|
|
24
|
+
value,
|
|
25
|
+
expires
|
|
26
|
+
}) => {
|
|
27
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
28
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
29
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
30
|
+
const cookieValue = [
|
|
31
|
+
[name, value],
|
|
32
|
+
...expiresObj,
|
|
33
|
+
["path", "/"],
|
|
34
|
+
["domain", getTopLevelDomain(window.location.hostname)],
|
|
35
|
+
...secureObj
|
|
36
|
+
];
|
|
37
|
+
const cookie = stringifyCookie(cookieValue);
|
|
38
|
+
return cookie;
|
|
39
|
+
};
|
|
40
|
+
const setCookie = ({
|
|
41
|
+
name,
|
|
42
|
+
value,
|
|
43
|
+
expires,
|
|
44
|
+
canTrack
|
|
45
|
+
}) => {
|
|
46
|
+
try {
|
|
47
|
+
if (!canTrack) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
const cookie = createCookieString({ name, value, expires });
|
|
51
|
+
document.cookie = cookie;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.warn("[COOKIE] SET error: ", err);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
getCookie,
|
|
58
|
+
setCookie
|
|
59
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser";
|
|
2
|
+
const getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3
|
+
const getLocalStorageItem = ({
|
|
4
|
+
key,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (canTrack) {
|
|
10
|
+
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
11
|
+
}
|
|
12
|
+
return void 0;
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[LocalStorage] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const setLocalStorageItem = ({
|
|
18
|
+
key,
|
|
19
|
+
canTrack,
|
|
20
|
+
value
|
|
21
|
+
}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
try {
|
|
24
|
+
if (canTrack) {
|
|
25
|
+
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.debug("[LocalStorage] SET error: ", err);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
getLocalStorageItem,
|
|
33
|
+
setLocalStorageItem
|
|
34
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "./cookie";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
4
|
+
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
5
|
+
const getSessionId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const sessionId = getCookie({ name: SESSION_LOCAL_STORAGE_KEY, canTrack });
|
|
10
|
+
if (checkIsDefined(sessionId)) {
|
|
11
|
+
return sessionId;
|
|
12
|
+
} else {
|
|
13
|
+
const newSessionId = createSessionId();
|
|
14
|
+
setSessionId({ id: newSessionId, canTrack });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const createSessionId = () => uuid();
|
|
18
|
+
const setSessionId = ({
|
|
19
|
+
id,
|
|
20
|
+
canTrack
|
|
21
|
+
}) => setCookie({ name: SESSION_LOCAL_STORAGE_KEY, value: id, canTrack });
|
|
22
|
+
export {
|
|
23
|
+
createSessionId,
|
|
24
|
+
getSessionId,
|
|
25
|
+
setSessionId
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getTopLevelDomain } from "./url.js";
|
|
2
|
+
describe("getTopLevelDomain", () => {
|
|
3
|
+
test("handles root domain", () => {
|
|
4
|
+
const output = getTopLevelDomain("example.com");
|
|
5
|
+
expect(output).toBe("example.com");
|
|
6
|
+
});
|
|
7
|
+
test("handles subdomain", () => {
|
|
8
|
+
const output = getTopLevelDomain("wwww.example.com");
|
|
9
|
+
expect(output).toBe("example.com");
|
|
10
|
+
});
|
|
11
|
+
test("handles subdomain with long suffix", () => {
|
|
12
|
+
const output = getTopLevelDomain("www.example.co.uk");
|
|
13
|
+
expect(output).toBe("example.co.uk");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function uuidv4() {
|
|
2
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
4
|
+
return v.toString(16);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
function uuid() {
|
|
8
|
+
return uuidv4().replace(/-/g, "");
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
uuid,
|
|
12
|
+
uuidv4
|
|
13
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getLocalStorageItem, setLocalStorageItem } from "./localStorage";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
4
|
+
const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
5
|
+
const getVisitorId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const visitorId = getLocalStorageItem({
|
|
10
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
11
|
+
canTrack
|
|
12
|
+
});
|
|
13
|
+
if (checkIsDefined(visitorId)) {
|
|
14
|
+
return visitorId;
|
|
15
|
+
} else {
|
|
16
|
+
const newVisitorId = createVisitorId();
|
|
17
|
+
setVisitorId({ id: newVisitorId, canTrack });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const createVisitorId = () => uuid();
|
|
21
|
+
const setVisitorId = ({
|
|
22
|
+
id,
|
|
23
|
+
canTrack
|
|
24
|
+
}) => setLocalStorageItem({
|
|
25
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
26
|
+
value: id,
|
|
27
|
+
canTrack
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
createVisitorId,
|
|
31
|
+
getVisitorId,
|
|
32
|
+
setVisitorId
|
|
33
|
+
};
|
|
File without changes
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<template v-else>
|
|
14
|
-
<button v-bind="attributes" class="button-
|
|
14
|
+
<button v-bind="attributes" class="button-2oa2wtipkzk">
|
|
15
15
|
{{ text }}
|
|
16
16
|
</button>
|
|
17
17
|
</template>
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
};
|
|
27
27
|
</script>
|
|
28
28
|
<style scoped>
|
|
29
|
-
.button-
|
|
29
|
+
.button-2oa2wtipkzk {
|
|
30
30
|
all: unset;
|
|
31
31
|
}
|
|
32
32
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="builder-columns div-
|
|
2
|
+
<div class="builder-columns div-361b1o6wv2k" :style="columnsCssVars">
|
|
3
3
|
<template :key="index" v-for="(column, index) in columns">
|
|
4
4
|
<div
|
|
5
|
-
class="builder-column div-
|
|
5
|
+
class="builder-column div-361b1o6wv2k-2"
|
|
6
6
|
:style="{
|
|
7
7
|
width: getColumnCssWidth(index),
|
|
8
8
|
marginLeft: `${index === 0 ? 0 : getGutterSize()}px`,
|
|
@@ -86,32 +86,32 @@ export default {
|
|
|
86
86
|
};
|
|
87
87
|
</script>
|
|
88
88
|
<style scoped>
|
|
89
|
-
.div-
|
|
89
|
+
.div-361b1o6wv2k {
|
|
90
90
|
display: flex;
|
|
91
91
|
align-items: stretch;
|
|
92
92
|
line-height: normal;
|
|
93
93
|
}
|
|
94
94
|
@media (max-width: 991px) {
|
|
95
|
-
.div-
|
|
95
|
+
.div-361b1o6wv2k {
|
|
96
96
|
flex-direction: var(--flex-dir-tablet);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
@media (max-width: 639px) {
|
|
100
|
-
.div-
|
|
100
|
+
.div-361b1o6wv2k {
|
|
101
101
|
flex-direction: var(--flex-dir);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
.div-
|
|
104
|
+
.div-361b1o6wv2k-2 {
|
|
105
105
|
flex-grow: 1;
|
|
106
106
|
}
|
|
107
107
|
@media (max-width: 991px) {
|
|
108
|
-
.div-
|
|
108
|
+
.div-361b1o6wv2k-2 {
|
|
109
109
|
width: var(--column-width-tablet) !important;
|
|
110
110
|
margin-left: var(--column-margin-left-tablet) !important;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
@media (max-width: 639px) {
|
|
114
|
-
.div-
|
|
114
|
+
.div-361b1o6wv2k-2 {
|
|
115
115
|
width: var(--column-width) !important;
|
|
116
116
|
margin-left: var(--column-margin-left) !important;
|
|
117
117
|
}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<template v-if="submissionState === 'error' && responseData">
|
|
32
|
-
<pre class="builder-form-error-text pre-
|
|
32
|
+
<pre class="builder-form-error-text pre-7jvpanrlkn">
|
|
33
33
|
{{ JSON.stringify(responseData, null, 2) }}
|
|
34
34
|
</pre>
|
|
35
35
|
</template>
|
|
@@ -306,7 +306,7 @@ export default {
|
|
|
306
306
|
};
|
|
307
307
|
</script>
|
|
308
308
|
<style scoped>
|
|
309
|
-
.pre-
|
|
309
|
+
.pre-7jvpanrlkn {
|
|
310
310
|
padding: 10px;
|
|
311
311
|
color: red;
|
|
312
312
|
text-align: center;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="div-
|
|
2
|
+
<div class="div-1fogms4bee0">
|
|
3
3
|
<picture>
|
|
4
4
|
<template v-if="webpSrcSet">
|
|
5
5
|
<source type="image/webp" :srcset="webpSrcSet" />
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
_classStringToObject(
|
|
18
18
|
'builder-image' +
|
|
19
19
|
(this.className ? ' ' + this.className : '') +
|
|
20
|
-
' img-
|
|
20
|
+
' img-1fogms4bee0'
|
|
21
21
|
)
|
|
22
22
|
"
|
|
23
23
|
:src="image"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
v-if="aspectRatio && !(fitContent && ((builderBlock && builderBlock.children) && (builderBlock && builderBlock.children).length))"
|
|
32
32
|
>
|
|
33
33
|
<div
|
|
34
|
-
class="builder-image-sizer div-
|
|
34
|
+
class="builder-image-sizer div-1fogms4bee0-2"
|
|
35
35
|
:style="{
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
37
|
paddingTop: aspectRatio * 100 + '%',
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
</template>
|
|
45
45
|
|
|
46
46
|
<template v-if="!fitContent">
|
|
47
|
-
<div class="div-
|
|
47
|
+
<div class="div-1fogms4bee0-3">
|
|
48
48
|
<slot></slot>
|
|
49
49
|
</div>
|
|
50
50
|
</template>
|
|
@@ -121,10 +121,10 @@ export default {
|
|
|
121
121
|
};
|
|
122
122
|
</script>
|
|
123
123
|
<style scoped>
|
|
124
|
-
.div-
|
|
124
|
+
.div-1fogms4bee0 {
|
|
125
125
|
position: relative;
|
|
126
126
|
}
|
|
127
|
-
.img-
|
|
127
|
+
.img-1fogms4bee0 {
|
|
128
128
|
opacity: 1;
|
|
129
129
|
transition: opacity 0.2s ease-in-out;
|
|
130
130
|
position: absolute;
|
|
@@ -133,12 +133,12 @@ export default {
|
|
|
133
133
|
top: 0px;
|
|
134
134
|
left: 0px;
|
|
135
135
|
}
|
|
136
|
-
.div-
|
|
136
|
+
.div-1fogms4bee0-2 {
|
|
137
137
|
width: 100%;
|
|
138
138
|
pointer-events: none;
|
|
139
139
|
font-size: 0;
|
|
140
140
|
}
|
|
141
|
-
.div-
|
|
141
|
+
.div-1fogms4bee0-3 {
|
|
142
142
|
display: flex;
|
|
143
143
|
flex-direction: column;
|
|
144
144
|
align-items: stretch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
:class="_classStringToObject(this.className + ' div-
|
|
3
|
+
:class="_classStringToObject(this.className + ' div-3q96myty4lk')"
|
|
4
4
|
:builder-path="path"
|
|
5
5
|
:builder-parent-id="parent"
|
|
6
6
|
:dataSet="{
|
|
@@ -93,7 +93,7 @@ export default {
|
|
|
93
93
|
};
|
|
94
94
|
</script>
|
|
95
95
|
<style scoped>
|
|
96
|
-
.div-
|
|
96
|
+
.div-3q96myty4lk {
|
|
97
97
|
display: flex;
|
|
98
98
|
flex-direction: column;
|
|
99
99
|
align-items: stretch;
|
|
@@ -41,10 +41,10 @@ export default {
|
|
|
41
41
|
props: [
|
|
42
42
|
"content",
|
|
43
43
|
"data",
|
|
44
|
+
"canTrack",
|
|
44
45
|
"context",
|
|
45
46
|
"customComponents",
|
|
46
47
|
"model",
|
|
47
|
-
"canTrack",
|
|
48
48
|
"apiKey",
|
|
49
49
|
],
|
|
50
50
|
|
|
@@ -89,9 +89,12 @@ export default {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
if (this.useContent
|
|
93
|
-
track(
|
|
92
|
+
if (this.useContent) {
|
|
93
|
+
track({
|
|
94
|
+
type: "impression",
|
|
95
|
+
canTrack: this.canTrackToUse,
|
|
94
96
|
contentId: this.useContent.id,
|
|
97
|
+
orgId: this.apiKey,
|
|
95
98
|
});
|
|
96
99
|
} // override normal content in preview mode
|
|
97
100
|
|
|
@@ -155,6 +158,9 @@ export default {
|
|
|
155
158
|
};
|
|
156
159
|
return mergedContent;
|
|
157
160
|
},
|
|
161
|
+
canTrackToUse() {
|
|
162
|
+
return this.canTrack || true;
|
|
163
|
+
},
|
|
158
164
|
contentState() {
|
|
159
165
|
return {
|
|
160
166
|
...this.content?.data?.state,
|
|
@@ -250,9 +256,12 @@ export default {
|
|
|
250
256
|
}
|
|
251
257
|
},
|
|
252
258
|
onClick(_event) {
|
|
253
|
-
if (this.useContent
|
|
254
|
-
track(
|
|
259
|
+
if (this.useContent) {
|
|
260
|
+
track({
|
|
261
|
+
type: "click",
|
|
262
|
+
canTrack: this.canTrackToUse,
|
|
255
263
|
contentId: this.useContent.id,
|
|
264
|
+
orgId: this.apiKey,
|
|
256
265
|
});
|
|
257
266
|
}
|
|
258
267
|
},
|
|
@@ -1,7 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
1
32
|
import { TARGET } from "../constants/target.js";
|
|
33
|
+
import { getSessionId } from "../helpers/sessionId.js";
|
|
34
|
+
import { getVisitorId } from "../helpers/visitorId.js";
|
|
2
35
|
import { isBrowser } from "./is-browser.js";
|
|
3
36
|
import { isEditing } from "./is-editing.js";
|
|
4
|
-
|
|
37
|
+
const getTrackingEventData = ({ canTrack }) => {
|
|
38
|
+
if (!canTrack) {
|
|
39
|
+
return { visitorId: void 0, sessionId: void 0 };
|
|
40
|
+
}
|
|
41
|
+
const sessionId = getSessionId({ canTrack });
|
|
42
|
+
const visitorId = getVisitorId({ canTrack });
|
|
43
|
+
return {
|
|
44
|
+
sessionId,
|
|
45
|
+
visitorId
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const createEvent = (_a) => {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
type: eventType,
|
|
51
|
+
canTrack,
|
|
52
|
+
orgId,
|
|
53
|
+
contentId
|
|
54
|
+
} = _b, properties = __objRest(_b, [
|
|
55
|
+
"type",
|
|
56
|
+
"canTrack",
|
|
57
|
+
"orgId",
|
|
58
|
+
"contentId"
|
|
59
|
+
]);
|
|
60
|
+
return {
|
|
61
|
+
type: eventType,
|
|
62
|
+
data: __spreadProps(__spreadValues(__spreadValues({}, properties), getTrackingEventData({ canTrack })), {
|
|
63
|
+
ownerId: orgId,
|
|
64
|
+
contentId
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
function track(eventProps) {
|
|
69
|
+
if (!eventProps.canTrack) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
5
72
|
if (isEditing()) {
|
|
6
73
|
return;
|
|
7
74
|
}
|
|
@@ -10,7 +77,9 @@ function track(event, properties) {
|
|
|
10
77
|
}
|
|
11
78
|
return fetch(`https://builder.io/api/v1/track`, {
|
|
12
79
|
method: "POST",
|
|
13
|
-
body: JSON.stringify({
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
events: [createEvent(eventProps)]
|
|
82
|
+
}),
|
|
14
83
|
headers: {
|
|
15
84
|
"content-type": "application/json"
|
|
16
85
|
},
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser";
|
|
2
|
+
import { getTopLevelDomain } from "./url";
|
|
3
|
+
const getCookie = ({
|
|
4
|
+
name,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (!canTrack) {
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[COOKIE] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).join("; ");
|
|
18
|
+
const SECURE_CONFIG = [
|
|
19
|
+
["secure", ""],
|
|
20
|
+
["SameSite", "None"]
|
|
21
|
+
];
|
|
22
|
+
const createCookieString = ({
|
|
23
|
+
name,
|
|
24
|
+
value,
|
|
25
|
+
expires
|
|
26
|
+
}) => {
|
|
27
|
+
const secure = isBrowser() ? location.protocol === "https:" : true;
|
|
28
|
+
const secureObj = secure ? SECURE_CONFIG : [[]];
|
|
29
|
+
const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
|
|
30
|
+
const cookieValue = [
|
|
31
|
+
[name, value],
|
|
32
|
+
...expiresObj,
|
|
33
|
+
["path", "/"],
|
|
34
|
+
["domain", getTopLevelDomain(window.location.hostname)],
|
|
35
|
+
...secureObj
|
|
36
|
+
];
|
|
37
|
+
const cookie = stringifyCookie(cookieValue);
|
|
38
|
+
return cookie;
|
|
39
|
+
};
|
|
40
|
+
const setCookie = ({
|
|
41
|
+
name,
|
|
42
|
+
value,
|
|
43
|
+
expires,
|
|
44
|
+
canTrack
|
|
45
|
+
}) => {
|
|
46
|
+
try {
|
|
47
|
+
if (!canTrack) {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
const cookie = createCookieString({ name, value, expires });
|
|
51
|
+
document.cookie = cookie;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.warn("[COOKIE] SET error: ", err);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
getCookie,
|
|
58
|
+
setCookie
|
|
59
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isBrowser } from "../functions/is-browser";
|
|
2
|
+
const getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
|
|
3
|
+
const getLocalStorageItem = ({
|
|
4
|
+
key,
|
|
5
|
+
canTrack
|
|
6
|
+
}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
try {
|
|
9
|
+
if (canTrack) {
|
|
10
|
+
return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
|
|
11
|
+
}
|
|
12
|
+
return void 0;
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.debug("[LocalStorage] GET error: ", err);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const setLocalStorageItem = ({
|
|
18
|
+
key,
|
|
19
|
+
canTrack,
|
|
20
|
+
value
|
|
21
|
+
}) => {
|
|
22
|
+
var _a;
|
|
23
|
+
try {
|
|
24
|
+
if (canTrack) {
|
|
25
|
+
(_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.debug("[LocalStorage] SET error: ", err);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
getLocalStorageItem,
|
|
33
|
+
setLocalStorageItem
|
|
34
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getCookie, setCookie } from "./cookie";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
4
|
+
const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
|
|
5
|
+
const getSessionId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const sessionId = getCookie({ name: SESSION_LOCAL_STORAGE_KEY, canTrack });
|
|
10
|
+
if (checkIsDefined(sessionId)) {
|
|
11
|
+
return sessionId;
|
|
12
|
+
} else {
|
|
13
|
+
const newSessionId = createSessionId();
|
|
14
|
+
setSessionId({ id: newSessionId, canTrack });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const createSessionId = () => uuid();
|
|
18
|
+
const setSessionId = ({
|
|
19
|
+
id,
|
|
20
|
+
canTrack
|
|
21
|
+
}) => setCookie({ name: SESSION_LOCAL_STORAGE_KEY, value: id, canTrack });
|
|
22
|
+
export {
|
|
23
|
+
createSessionId,
|
|
24
|
+
getSessionId,
|
|
25
|
+
setSessionId
|
|
26
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getTopLevelDomain } from "./url.js";
|
|
2
|
+
describe("getTopLevelDomain", () => {
|
|
3
|
+
test("handles root domain", () => {
|
|
4
|
+
const output = getTopLevelDomain("example.com");
|
|
5
|
+
expect(output).toBe("example.com");
|
|
6
|
+
});
|
|
7
|
+
test("handles subdomain", () => {
|
|
8
|
+
const output = getTopLevelDomain("wwww.example.com");
|
|
9
|
+
expect(output).toBe("example.com");
|
|
10
|
+
});
|
|
11
|
+
test("handles subdomain with long suffix", () => {
|
|
12
|
+
const output = getTopLevelDomain("www.example.co.uk");
|
|
13
|
+
expect(output).toBe("example.co.uk");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function uuidv4() {
|
|
2
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
3
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
4
|
+
return v.toString(16);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
function uuid() {
|
|
8
|
+
return uuidv4().replace(/-/g, "");
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
uuid,
|
|
12
|
+
uuidv4
|
|
13
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getLocalStorageItem, setLocalStorageItem } from "./localStorage";
|
|
2
|
+
import { checkIsDefined } from "./nullable";
|
|
3
|
+
import { uuid } from "./uuid";
|
|
4
|
+
const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
|
|
5
|
+
const getVisitorId = ({ canTrack }) => {
|
|
6
|
+
if (!canTrack) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
const visitorId = getLocalStorageItem({
|
|
10
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
11
|
+
canTrack
|
|
12
|
+
});
|
|
13
|
+
if (checkIsDefined(visitorId)) {
|
|
14
|
+
return visitorId;
|
|
15
|
+
} else {
|
|
16
|
+
const newVisitorId = createVisitorId();
|
|
17
|
+
setVisitorId({ id: newVisitorId, canTrack });
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const createVisitorId = () => uuid();
|
|
21
|
+
const setVisitorId = ({
|
|
22
|
+
id,
|
|
23
|
+
canTrack
|
|
24
|
+
}) => setLocalStorageItem({
|
|
25
|
+
key: VISITOR_LOCAL_STORAGE_KEY,
|
|
26
|
+
value: id,
|
|
27
|
+
canTrack
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
createVisitorId,
|
|
31
|
+
getVisitorId,
|
|
32
|
+
setVisitorId
|
|
33
|
+
};
|
|
File without changes
|