@builder.io/sdk-svelte 2.0.24 → 2.0.25

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.
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.24";
1
+ export declare const SDK_VERSION = "2.0.25";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.24";
1
+ export const SDK_VERSION = "2.0.25";
@@ -3,6 +3,7 @@ import { handleABTesting } from '../../helpers/ab-tests';
3
3
  import { getDefaultCanTrack } from '../../helpers/canTrack';
4
4
  import { logger } from '../../helpers/logger';
5
5
  import { getPreviewContent } from '../../helpers/preview-lru-cache/get';
6
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
6
7
  import { fetch } from '../get-fetch';
7
8
  import { isBrowser } from '../is-browser';
8
9
  import { generateContentUrl } from './generate-content-url';
@@ -23,7 +24,14 @@ export async function fetchOneEntry(options) {
23
24
  const _fetchContent = async (options) => {
24
25
  const url = generateContentUrl(options);
25
26
  const _fetch = options.fetch ?? fetch;
26
- const res = await _fetch(url.href, options.fetchOptions);
27
+ const fetchOptions = {
28
+ ...options.fetchOptions,
29
+ headers: {
30
+ ...options.fetchOptions?.headers,
31
+ ...getSdkHeaders()
32
+ }
33
+ };
34
+ const res = await _fetch(url.href, fetchOptions);
27
35
  const content = await res.json();
28
36
  return content;
29
37
  };
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  import { logger } from '../../helpers/logger';
3
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
3
4
  import { getSessionId } from '../../helpers/sessionId';
4
5
  import { getVisitorId } from '../../helpers/visitorId';
5
6
  import { isBrowser } from '../is-browser';
@@ -58,7 +59,8 @@ export async function _track(eventProps) {
58
59
  events: [await createEvent(eventProps)]
59
60
  }),
60
61
  headers: {
61
- 'content-type': 'application/json'
62
+ 'content-type': 'application/json',
63
+ ...getSdkHeaders()
62
64
  },
63
65
  mode: 'cors'
64
66
  }).catch(err => {
@@ -0,0 +1,5 @@
1
+ export declare const getSdkHeaders: () => {
2
+ 'X-Builder-SDK': import("../types/targets").Target;
3
+ 'X-Builder-SDK-GEN': string;
4
+ 'X-Builder-SDK-Version': string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { SDK_VERSION } from '../constants/sdk-version';
2
+ import { TARGET } from '../constants/target';
3
+ export const getSdkHeaders = () => ({
4
+ 'X-Builder-SDK': TARGET,
5
+ 'X-Builder-SDK-GEN': '2',
6
+ 'X-Builder-SDK-Version': SDK_VERSION
7
+ });
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.24";
1
+ export declare const SDK_VERSION = "2.0.25";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.24";
1
+ export const SDK_VERSION = "2.0.25";
@@ -3,6 +3,7 @@ import { handleABTesting } from '../../helpers/ab-tests';
3
3
  import { getDefaultCanTrack } from '../../helpers/canTrack';
4
4
  import { logger } from '../../helpers/logger';
5
5
  import { getPreviewContent } from '../../helpers/preview-lru-cache/get';
6
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
6
7
  import { fetch } from '../get-fetch';
7
8
  import { isBrowser } from '../is-browser';
8
9
  import { generateContentUrl } from './generate-content-url';
@@ -23,7 +24,14 @@ export async function fetchOneEntry(options) {
23
24
  const _fetchContent = async (options) => {
24
25
  const url = generateContentUrl(options);
25
26
  const _fetch = options.fetch ?? fetch;
26
- const res = await _fetch(url.href, options.fetchOptions);
27
+ const fetchOptions = {
28
+ ...options.fetchOptions,
29
+ headers: {
30
+ ...options.fetchOptions?.headers,
31
+ ...getSdkHeaders()
32
+ }
33
+ };
34
+ const res = await _fetch(url.href, fetchOptions);
27
35
  const content = await res.json();
28
36
  return content;
29
37
  };
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  import { logger } from '../../helpers/logger';
3
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
3
4
  import { getSessionId } from '../../helpers/sessionId';
4
5
  import { getVisitorId } from '../../helpers/visitorId';
5
6
  import { isBrowser } from '../is-browser';
@@ -58,7 +59,8 @@ export async function _track(eventProps) {
58
59
  events: [await createEvent(eventProps)]
59
60
  }),
60
61
  headers: {
61
- 'content-type': 'application/json'
62
+ 'content-type': 'application/json',
63
+ ...getSdkHeaders()
62
64
  },
63
65
  mode: 'cors'
64
66
  }).catch(err => {
@@ -0,0 +1,5 @@
1
+ export declare const getSdkHeaders: () => {
2
+ 'X-Builder-SDK': import("../types/targets").Target;
3
+ 'X-Builder-SDK-GEN': string;
4
+ 'X-Builder-SDK-Version': string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { SDK_VERSION } from '../constants/sdk-version';
2
+ import { TARGET } from '../constants/target';
3
+ export const getSdkHeaders = () => ({
4
+ 'X-Builder-SDK': TARGET,
5
+ 'X-Builder-SDK-GEN': '2',
6
+ 'X-Builder-SDK-Version': SDK_VERSION
7
+ });
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.24";
1
+ export declare const SDK_VERSION = "2.0.25";
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.24";
1
+ export const SDK_VERSION = "2.0.25";
@@ -3,6 +3,7 @@ import { handleABTesting } from '../../helpers/ab-tests';
3
3
  import { getDefaultCanTrack } from '../../helpers/canTrack';
4
4
  import { logger } from '../../helpers/logger';
5
5
  import { getPreviewContent } from '../../helpers/preview-lru-cache/get';
6
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
6
7
  import { fetch } from '../get-fetch';
7
8
  import { isBrowser } from '../is-browser';
8
9
  import { generateContentUrl } from './generate-content-url';
@@ -23,7 +24,14 @@ export async function fetchOneEntry(options) {
23
24
  const _fetchContent = async (options) => {
24
25
  const url = generateContentUrl(options);
25
26
  const _fetch = options.fetch ?? fetch;
26
- const res = await _fetch(url.href, options.fetchOptions);
27
+ const fetchOptions = {
28
+ ...options.fetchOptions,
29
+ headers: {
30
+ ...options.fetchOptions?.headers,
31
+ ...getSdkHeaders()
32
+ }
33
+ };
34
+ const res = await _fetch(url.href, fetchOptions);
27
35
  const content = await res.json();
28
36
  return content;
29
37
  };
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  import { logger } from '../../helpers/logger';
3
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
3
4
  import { getSessionId } from '../../helpers/sessionId';
4
5
  import { getVisitorId } from '../../helpers/visitorId';
5
6
  import { isBrowser } from '../is-browser';
@@ -58,7 +59,8 @@ export async function _track(eventProps) {
58
59
  events: [await createEvent(eventProps)]
59
60
  }),
60
61
  headers: {
61
- 'content-type': 'application/json'
62
+ 'content-type': 'application/json',
63
+ ...getSdkHeaders()
62
64
  },
63
65
  mode: 'cors'
64
66
  }).catch(err => {
@@ -0,0 +1,5 @@
1
+ export declare const getSdkHeaders: () => {
2
+ 'X-Builder-SDK': import("../types/targets").Target;
3
+ 'X-Builder-SDK-GEN': string;
4
+ 'X-Builder-SDK-Version': string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import { SDK_VERSION } from '../constants/sdk-version';
2
+ import { TARGET } from '../constants/target';
3
+ export const getSdkHeaders = () => ({
4
+ 'X-Builder-SDK': TARGET,
5
+ 'X-Builder-SDK-GEN': '2',
6
+ 'X-Builder-SDK-Version': SDK_VERSION
7
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-svelte",
3
3
  "description": "Builder.io SDK for Svelte",
4
- "version": "2.0.24",
4
+ "version": "2.0.25",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "lib",
@@ -1 +1 @@
1
- export const SDK_VERSION = "2.0.24"
1
+ export const SDK_VERSION = "2.0.25"
@@ -3,6 +3,7 @@ import { handleABTesting } from '../../helpers/ab-tests';
3
3
  import { getDefaultCanTrack } from '../../helpers/canTrack';
4
4
  import { logger } from '../../helpers/logger';
5
5
  import { getPreviewContent } from '../../helpers/preview-lru-cache/get';
6
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
6
7
  import type { BuilderContent } from '../../types/builder-content';
7
8
  import { fetch } from '../get-fetch';
8
9
  import { isBrowser } from '../is-browser';
@@ -33,7 +34,14 @@ type ContentResponse = ContentResults | {
33
34
  const _fetchContent = async (options: GetContentOptions) => {
34
35
  const url = generateContentUrl(options);
35
36
  const _fetch = options.fetch ?? fetch;
36
- const res = await _fetch(url.href, options.fetchOptions);
37
+ const fetchOptions = {
38
+ ...options.fetchOptions,
39
+ headers: {
40
+ ...(options.fetchOptions as any)?.headers,
41
+ ...getSdkHeaders()
42
+ }
43
+ };
44
+ const res = await _fetch(url.href, fetchOptions);
37
45
  const content = await (res.json() as Promise<ContentResponse>);
38
46
  return content;
39
47
  };
@@ -1,5 +1,6 @@
1
1
  import { TARGET } from '../../constants/target';
2
2
  import { logger } from '../../helpers/logger';
3
+ import { getSdkHeaders } from '../../helpers/sdk-headers';
3
4
  import { getSessionId } from '../../helpers/sessionId';
4
5
  import { getVisitorId } from '../../helpers/visitorId';
5
6
  import type { CanTrack } from '../../types/can-track';
@@ -118,7 +119,8 @@ export async function _track(eventProps: EventProps) {
118
119
  events: [await createEvent(eventProps)]
119
120
  }),
120
121
  headers: {
121
- 'content-type': 'application/json'
122
+ 'content-type': 'application/json',
123
+ ...getSdkHeaders()
122
124
  },
123
125
  mode: 'cors'
124
126
  }).catch(err => {
@@ -0,0 +1,7 @@
1
+ import { SDK_VERSION } from '../constants/sdk-version';
2
+ import { TARGET } from '../constants/target';
3
+ export const getSdkHeaders = () => ({
4
+ 'X-Builder-SDK': TARGET,
5
+ 'X-Builder-SDK-GEN': '2',
6
+ 'X-Builder-SDK-Version': SDK_VERSION
7
+ })