@builder.io/sdk-svelte 2.0.29 → 2.0.31
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/lib/browser/blocks/form/form/form.svelte +5 -2
- package/lib/browser/components/content/components/enable-editor.svelte +2 -0
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/get-content/generate-content-url.js +11 -4
- package/lib/browser/functions/log-fetch.d.ts +1 -0
- package/lib/browser/functions/log-fetch.js +8 -0
- package/lib/browser/functions/register-component.js +3 -1
- package/lib/browser/functions/track/index.js +4 -1
- package/lib/edge/blocks/form/form/form.svelte +5 -2
- package/lib/edge/components/content/components/enable-editor.svelte +2 -0
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/get-content/generate-content-url.js +11 -4
- package/lib/edge/functions/log-fetch.d.ts +1 -0
- package/lib/edge/functions/log-fetch.js +8 -0
- package/lib/edge/functions/register-component.js +3 -1
- package/lib/edge/functions/track/index.js +4 -1
- package/lib/node/blocks/form/form/form.svelte +5 -2
- package/lib/node/components/content/components/enable-editor.svelte +2 -0
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/get-content/generate-content-url.js +11 -4
- package/lib/node/functions/log-fetch.d.ts +1 -0
- package/lib/node/functions/log-fetch.js +8 -0
- package/lib/node/functions/register-component.js +3 -1
- package/lib/node/functions/track/index.js +4 -1
- package/package.json +1 -1
- package/src/blocks/form/form/form.svelte +10 -8
- package/src/components/content/components/enable-editor.svelte +2 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/get-content/generate-content-url.ts +11 -3
- package/src/functions/log-fetch.ts +8 -0
- package/src/functions/register-component.ts +3 -1
- package/src/functions/track/index.ts +4 -1
|
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
|
|
|
10
10
|
import { isEditing } from "../../../functions/is-editing";
|
|
11
11
|
import { set } from "../../../functions/set";
|
|
12
12
|
import { filterAttrs } from "../../helpers";
|
|
13
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
13
14
|
import { setAttrs } from "../../helpers";
|
|
14
15
|
export let builderContext;
|
|
15
16
|
export let previewState = undefined;
|
|
@@ -148,9 +149,11 @@ function onSubmit(event) {
|
|
|
148
149
|
}
|
|
149
150
|
formState = "sending";
|
|
150
151
|
const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
|
|
151
|
-
|
|
152
|
+
const url = sendSubmissionsTo === "email"
|
|
152
153
|
? formUrl
|
|
153
|
-
: action /* TODO: throw error if no action URL
|
|
154
|
+
: action; /* TODO: throw error if no action URL */
|
|
155
|
+
logFetch(url);
|
|
156
|
+
fetch(url, {
|
|
154
157
|
body,
|
|
155
158
|
headers,
|
|
156
159
|
method: method || "post",
|
|
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
|
|
|
8
8
|
import { isBrowser } from "../../../functions/is-browser";
|
|
9
9
|
import { isEditing } from "../../../functions/is-editing";
|
|
10
10
|
import { isPreviewing } from "../../../functions/is-previewing";
|
|
11
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
11
12
|
import { createRegisterComponentMessage } from "../../../functions/register-component";
|
|
12
13
|
import { _track } from "../../../functions/track/index";
|
|
13
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
@@ -127,6 +128,7 @@ function runHttpRequests() {
|
|
|
127
128
|
rootState: $builderContextSignal.rootState,
|
|
128
129
|
rootSetState: $builderContextSignal.rootSetState,
|
|
129
130
|
})));
|
|
131
|
+
logFetch(evaluatedUrl);
|
|
130
132
|
fetch(evaluatedUrl)
|
|
131
133
|
.then((response) => response.json())
|
|
132
134
|
.then((json) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.31";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.31";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFetch(url: string): void;
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
|
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
|
|
|
5
5
|
import { getVisitorId } from '../../helpers/visitorId';
|
|
6
6
|
import { isBrowser } from '../is-browser';
|
|
7
7
|
import { isEditing } from '../is-editing';
|
|
8
|
+
import { logFetch } from '../log-fetch';
|
|
8
9
|
import { getUserAttributes } from './helpers';
|
|
9
10
|
const getTrackingEventData = async ({ canTrack }) => {
|
|
10
11
|
if (!canTrack) {
|
|
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
|
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
const baseUrl = apiHost || 'https://cdn.builder.io';
|
|
57
|
-
|
|
58
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
59
|
+
logFetch(url);
|
|
60
|
+
return fetch(url, {
|
|
58
61
|
method: 'POST',
|
|
59
62
|
body: JSON.stringify({
|
|
60
63
|
events: [await createEvent(eventProps)]
|
|
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
|
|
|
10
10
|
import { isEditing } from "../../../functions/is-editing";
|
|
11
11
|
import { set } from "../../../functions/set";
|
|
12
12
|
import { filterAttrs } from "../../helpers";
|
|
13
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
13
14
|
import { setAttrs } from "../../helpers";
|
|
14
15
|
export let builderContext;
|
|
15
16
|
export let previewState = undefined;
|
|
@@ -148,9 +149,11 @@ function onSubmit(event) {
|
|
|
148
149
|
}
|
|
149
150
|
formState = "sending";
|
|
150
151
|
const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
|
|
151
|
-
|
|
152
|
+
const url = sendSubmissionsTo === "email"
|
|
152
153
|
? formUrl
|
|
153
|
-
: action /* TODO: throw error if no action URL
|
|
154
|
+
: action; /* TODO: throw error if no action URL */
|
|
155
|
+
logFetch(url);
|
|
156
|
+
fetch(url, {
|
|
154
157
|
body,
|
|
155
158
|
headers,
|
|
156
159
|
method: method || "post",
|
|
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
|
|
|
8
8
|
import { isBrowser } from "../../../functions/is-browser";
|
|
9
9
|
import { isEditing } from "../../../functions/is-editing";
|
|
10
10
|
import { isPreviewing } from "../../../functions/is-previewing";
|
|
11
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
11
12
|
import { createRegisterComponentMessage } from "../../../functions/register-component";
|
|
12
13
|
import { _track } from "../../../functions/track/index";
|
|
13
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
@@ -127,6 +128,7 @@ function runHttpRequests() {
|
|
|
127
128
|
rootState: $builderContextSignal.rootState,
|
|
128
129
|
rootSetState: $builderContextSignal.rootSetState,
|
|
129
130
|
})));
|
|
131
|
+
logFetch(evaluatedUrl);
|
|
130
132
|
fetch(evaluatedUrl)
|
|
131
133
|
.then((response) => response.json())
|
|
132
134
|
.then((json) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.31";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.31";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFetch(url: string): void;
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
|
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
|
|
|
5
5
|
import { getVisitorId } from '../../helpers/visitorId';
|
|
6
6
|
import { isBrowser } from '../is-browser';
|
|
7
7
|
import { isEditing } from '../is-editing';
|
|
8
|
+
import { logFetch } from '../log-fetch';
|
|
8
9
|
import { getUserAttributes } from './helpers';
|
|
9
10
|
const getTrackingEventData = async ({ canTrack }) => {
|
|
10
11
|
if (!canTrack) {
|
|
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
|
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
const baseUrl = apiHost || 'https://cdn.builder.io';
|
|
57
|
-
|
|
58
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
59
|
+
logFetch(url);
|
|
60
|
+
return fetch(url, {
|
|
58
61
|
method: 'POST',
|
|
59
62
|
body: JSON.stringify({
|
|
60
63
|
events: [await createEvent(eventProps)]
|
|
@@ -10,6 +10,7 @@ import { get } from "../../../functions/get";
|
|
|
10
10
|
import { isEditing } from "../../../functions/is-editing";
|
|
11
11
|
import { set } from "../../../functions/set";
|
|
12
12
|
import { filterAttrs } from "../../helpers";
|
|
13
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
13
14
|
import { setAttrs } from "../../helpers";
|
|
14
15
|
export let builderContext;
|
|
15
16
|
export let previewState = undefined;
|
|
@@ -148,9 +149,11 @@ function onSubmit(event) {
|
|
|
148
149
|
}
|
|
149
150
|
formState = "sending";
|
|
150
151
|
const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(sendSubmissionsToEmail || "")}&name=${encodeURIComponent(name || "")}`;
|
|
151
|
-
|
|
152
|
+
const url = sendSubmissionsTo === "email"
|
|
152
153
|
? formUrl
|
|
153
|
-
: action /* TODO: throw error if no action URL
|
|
154
|
+
: action; /* TODO: throw error if no action URL */
|
|
155
|
+
logFetch(url);
|
|
156
|
+
fetch(url, {
|
|
154
157
|
body,
|
|
155
158
|
headers,
|
|
156
159
|
method: method || "post",
|
|
@@ -8,6 +8,7 @@ import { fetchOneEntry } from "../../../functions/get-content/index";
|
|
|
8
8
|
import { isBrowser } from "../../../functions/is-browser";
|
|
9
9
|
import { isEditing } from "../../../functions/is-editing";
|
|
10
10
|
import { isPreviewing } from "../../../functions/is-previewing";
|
|
11
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
11
12
|
import { createRegisterComponentMessage } from "../../../functions/register-component";
|
|
12
13
|
import { _track } from "../../../functions/track/index";
|
|
13
14
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
@@ -127,6 +128,7 @@ function runHttpRequests() {
|
|
|
127
128
|
rootState: $builderContextSignal.rootState,
|
|
128
129
|
rootSetState: $builderContextSignal.rootSetState,
|
|
129
130
|
})));
|
|
131
|
+
logFetch(evaluatedUrl);
|
|
130
132
|
fetch(evaluatedUrl)
|
|
131
133
|
.then((response) => response.json())
|
|
132
134
|
.then((json) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.0.
|
|
1
|
+
export declare const SDK_VERSION = "2.0.31";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.31";
|
|
@@ -19,8 +19,15 @@ export const generateContentUrl = (options) => {
|
|
|
19
19
|
url.searchParams.set('limit', String(limit));
|
|
20
20
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
21
21
|
url.searchParams.set('includeRefs', String(true));
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
23
|
+
let finalUserAttributes = userAttributes;
|
|
24
|
+
if (finalLocale) {
|
|
25
|
+
url.searchParams.set('locale', finalLocale);
|
|
26
|
+
finalUserAttributes = {
|
|
27
|
+
locale: finalLocale,
|
|
28
|
+
...finalUserAttributes
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
if (enrich)
|
|
25
32
|
url.searchParams.set('enrich', String(enrich));
|
|
26
33
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
@@ -56,8 +63,8 @@ export const generateContentUrl = (options) => {
|
|
|
56
63
|
for (const key in flattened) {
|
|
57
64
|
url.searchParams.set(key, String(flattened[key]));
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
66
|
+
if (finalUserAttributes) {
|
|
67
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
61
68
|
}
|
|
62
69
|
if (query) {
|
|
63
70
|
const flattened = flattenMongoQuery({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function logFetch(url: string): void;
|
|
@@ -9,7 +9,9 @@ const serializeFn = (fnValue) => {
|
|
|
9
9
|
// 1. `function name(args) => {code}`
|
|
10
10
|
// 2. `name(args) => {code}`
|
|
11
11
|
// 3. `(args) => {}`
|
|
12
|
-
|
|
12
|
+
// 4. `args => {}`
|
|
13
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
14
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
13
15
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
14
16
|
};
|
|
15
17
|
export function serializeIncludingFunctions(info) {
|
|
@@ -5,6 +5,7 @@ import { getSessionId } from '../../helpers/sessionId';
|
|
|
5
5
|
import { getVisitorId } from '../../helpers/visitorId';
|
|
6
6
|
import { isBrowser } from '../is-browser';
|
|
7
7
|
import { isEditing } from '../is-editing';
|
|
8
|
+
import { logFetch } from '../log-fetch';
|
|
8
9
|
import { getUserAttributes } from './helpers';
|
|
9
10
|
const getTrackingEventData = async ({ canTrack }) => {
|
|
10
11
|
if (!canTrack) {
|
|
@@ -54,7 +55,9 @@ export async function _track({ apiHost, ...eventProps }) {
|
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
const baseUrl = apiHost || 'https://cdn.builder.io';
|
|
57
|
-
|
|
58
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
59
|
+
logFetch(url);
|
|
60
|
+
return fetch(url, {
|
|
58
61
|
method: 'POST',
|
|
59
62
|
body: JSON.stringify({
|
|
60
63
|
events: [await createEvent(eventProps)]
|
package/package.json
CHANGED
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
} from "../../../types/builder-props";
|
|
50
50
|
import type { Dictionary } from "../../../types/typescript";
|
|
51
51
|
import { filterAttrs } from "../../helpers";
|
|
52
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
52
53
|
import { setAttrs } from "../../helpers";
|
|
53
54
|
|
|
54
55
|
export let builderContext: FormProps["builderContext"];
|
|
@@ -195,16 +196,17 @@
|
|
|
195
196
|
}/api/v1/form-submit?apiKey=${$builderContext.apiKey}&to=${btoa(
|
|
196
197
|
sendSubmissionsToEmail || ""
|
|
197
198
|
)}&name=${encodeURIComponent(name || "")}`;
|
|
198
|
-
|
|
199
|
+
const url =
|
|
199
200
|
sendSubmissionsTo === "email"
|
|
200
201
|
? formUrl
|
|
201
|
-
: action
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
: action!; /* TODO: throw error if no action URL */
|
|
203
|
+
|
|
204
|
+
logFetch(url);
|
|
205
|
+
fetch(url, {
|
|
206
|
+
body,
|
|
207
|
+
headers,
|
|
208
|
+
method: method || "post",
|
|
209
|
+
}).then(
|
|
208
210
|
async (res) => {
|
|
209
211
|
let body;
|
|
210
212
|
const contentType = res.headers.get("content-type");
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { isBrowser } from "../../../functions/is-browser";
|
|
26
26
|
import { isEditing } from "../../../functions/is-editing";
|
|
27
27
|
import { isPreviewing } from "../../../functions/is-previewing";
|
|
28
|
+
import { logFetch } from "../../../functions/log-fetch";
|
|
28
29
|
import { createRegisterComponentMessage } from "../../../functions/register-component";
|
|
29
30
|
import { _track } from "../../../functions/track/index";
|
|
30
31
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction";
|
|
@@ -163,6 +164,7 @@
|
|
|
163
164
|
})
|
|
164
165
|
)
|
|
165
166
|
);
|
|
167
|
+
logFetch(evaluatedUrl);
|
|
166
168
|
fetch(evaluatedUrl)
|
|
167
169
|
.then((response) => response.json())
|
|
168
170
|
.then((json) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "2.0.
|
|
1
|
+
export const SDK_VERSION = "2.0.31"
|
|
@@ -38,7 +38,15 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
38
38
|
url.searchParams.set('limit', String(limit));
|
|
39
39
|
url.searchParams.set('noTraverse', String(noTraverse));
|
|
40
40
|
url.searchParams.set('includeRefs', String(true));
|
|
41
|
-
|
|
41
|
+
const finalLocale = locale || userAttributes?.locale;
|
|
42
|
+
let finalUserAttributes = userAttributes;
|
|
43
|
+
if (finalLocale) {
|
|
44
|
+
url.searchParams.set('locale', finalLocale);
|
|
45
|
+
finalUserAttributes = {
|
|
46
|
+
locale: finalLocale,
|
|
47
|
+
...finalUserAttributes
|
|
48
|
+
};
|
|
49
|
+
}
|
|
42
50
|
if (enrich) url.searchParams.set('enrich', String(enrich));
|
|
43
51
|
url.searchParams.set('omit', omit || 'meta.componentsUsed');
|
|
44
52
|
if (fields) {
|
|
@@ -75,8 +83,8 @@ export const generateContentUrl = (options: GetContentOptions): URL => {
|
|
|
75
83
|
for (const key in flattened) {
|
|
76
84
|
url.searchParams.set(key, String(flattened[key]));
|
|
77
85
|
}
|
|
78
|
-
if (
|
|
79
|
-
url.searchParams.set('userAttributes', JSON.stringify(
|
|
86
|
+
if (finalUserAttributes) {
|
|
87
|
+
url.searchParams.set('userAttributes', JSON.stringify(finalUserAttributes));
|
|
80
88
|
}
|
|
81
89
|
if (query) {
|
|
82
90
|
const flattened = flattenMongoQuery({
|
|
@@ -12,7 +12,9 @@ const serializeFn = (fnValue: Function) => {
|
|
|
12
12
|
// 1. `function name(args) => {code}`
|
|
13
13
|
// 2. `name(args) => {code}`
|
|
14
14
|
// 3. `(args) => {}`
|
|
15
|
-
|
|
15
|
+
// 4. `args => {}`
|
|
16
|
+
const isArrowWithoutParens = /^[a-zA-Z0-9_]+\s*=>/i.test(fnStr);
|
|
17
|
+
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(') && !isArrowWithoutParens;
|
|
16
18
|
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
17
19
|
};
|
|
18
20
|
export function serializeIncludingFunctions(info: ComponentInfo) {
|
|
@@ -7,6 +7,7 @@ import type { CanTrack } from '../../types/can-track';
|
|
|
7
7
|
import type { Dictionary } from '../../types/typescript';
|
|
8
8
|
import { isBrowser } from '../is-browser';
|
|
9
9
|
import { isEditing } from '../is-editing';
|
|
10
|
+
import { logFetch } from '../log-fetch';
|
|
10
11
|
import { getUserAttributes } from './helpers';
|
|
11
12
|
interface Event {
|
|
12
13
|
/**
|
|
@@ -119,7 +120,9 @@ export async function _track({
|
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
const baseUrl = apiHost || 'https://cdn.builder.io';
|
|
122
|
-
|
|
123
|
+
const url = `${baseUrl}/api/v1/track`;
|
|
124
|
+
logFetch(url);
|
|
125
|
+
return fetch(url, {
|
|
123
126
|
method: 'POST',
|
|
124
127
|
body: JSON.stringify({
|
|
125
128
|
events: [await createEvent(eventProps)]
|