@builder.io/sdk-svelte 0.0.5 → 0.0.7
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/--package.json +2 -1
- package/package/blocks/button/button.svelte +2 -2
- package/package/blocks/columns/columns.svelte +1 -2
- package/package/blocks/columns/component-info.js +2 -2
- package/package/blocks/embed/component-info.js +2 -2
- package/package/blocks/form/form.svelte +1 -1
- package/package/blocks/image/component-info.js +2 -2
- package/package/blocks/img/img.svelte +1 -1
- package/package/blocks/section/section.svelte +1 -1
- package/package/blocks/submit-button/submit-button.svelte +1 -1
- package/package/blocks/symbol/symbol.svelte +4 -7
- package/package/blocks/util.d.ts +4 -1
- package/package/blocks/util.js +13 -4
- package/package/blocks/video/video.svelte +1 -1
- package/package/components/render-block/block-styles.svelte +5 -3
- package/package/components/render-block/render-block.svelte +9 -9
- package/package/components/render-block/render-component.svelte +1 -2
- package/package/components/render-content/builder-editing.svelte +4 -0
- package/package/components/render-content/builder-editing.svelte.d.ts +14 -0
- package/package/components/render-content/render-content.svelte +14 -10
- package/package/components/render-inlined-styles.svelte +3 -3
- package/package/constants/device-sizes.d.ts +12 -1
- package/package/constants/device-sizes.js +27 -1
- package/package/functions/get-content/index.js +5 -2
- package/package/functions/get-content/types.d.ts +4 -0
- package/package/functions/register-component.js +1 -13
- package/package/functions/track.d.ts +35 -5
- package/package/functions/track.js +5 -4
- package/package/index.d.ts +4 -1
- package/package/index.js +2 -1
- package/package/scripts/init-editing.js +6 -0
- package/package/types/builder-content.d.ts +7 -0
- package/package.json +1 -1
- package/src/blocks/button/button.svelte +2 -2
- package/src/blocks/columns/columns.svelte +1 -2
- package/src/blocks/columns/component-info.ts +2 -2
- package/src/blocks/embed/component-info.ts +2 -2
- package/src/blocks/form/form.svelte +1 -1
- package/src/blocks/image/component-info.ts +2 -2
- package/src/blocks/img/img.svelte +1 -1
- package/src/blocks/section/section.svelte +1 -1
- package/src/blocks/submit-button/submit-button.svelte +1 -1
- package/src/blocks/symbol/symbol.svelte +4 -7
- package/src/blocks/util.ts +18 -6
- package/src/blocks/video/video.svelte +1 -1
- package/src/components/render-block/block-styles.svelte +16 -3
- package/src/components/render-block/render-block.svelte +9 -9
- package/src/components/render-block/render-component.svelte +1 -2
- package/src/components/render-content/builder-editing.svelte +4 -0
- package/src/components/render-content/render-content.svelte +14 -10
- package/src/components/render-inlined-styles.svelte +3 -3
- package/src/constants/device-sizes.ts +39 -2
- package/src/functions/get-content/index.ts +6 -1
- package/src/functions/get-content/types.ts +5 -0
- package/src/functions/register-component.ts +1 -18
- package/src/functions/track.ts +45 -11
- package/src/index.ts +4 -1
- package/src/scripts/init-editing.ts +6 -0
- package/src/types/builder-content.ts +7 -0
package/src/functions/track.ts
CHANGED
|
@@ -8,11 +8,30 @@ import { isEditing } from './is-editing.js';
|
|
|
8
8
|
interface Event {
|
|
9
9
|
type: 'click' | 'impression';
|
|
10
10
|
data: {
|
|
11
|
+
/**
|
|
12
|
+
* (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
|
|
13
|
+
*/
|
|
11
14
|
contentId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* This is the ID of the space that the content belongs to.
|
|
17
|
+
*/
|
|
12
18
|
ownerId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Stringified JSON object containing any additional metadata you want to track.
|
|
21
|
+
*/
|
|
13
22
|
metadata?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Session ID of the user. This is provided by the SDK by checking session storage.
|
|
25
|
+
*/
|
|
14
26
|
sessionId: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Visitor ID of the user. This is provided by the SDK by checking cookies.
|
|
29
|
+
*/
|
|
15
30
|
visitorId: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* (Optional) If running an A/B test, the ID of the variation that the user is in.
|
|
33
|
+
*/
|
|
34
|
+
variationId?: string;
|
|
16
35
|
[index: string]: any;
|
|
17
36
|
};
|
|
18
37
|
}
|
|
@@ -38,32 +57,44 @@ const getTrackingEventData = async ({
|
|
|
38
57
|
};
|
|
39
58
|
};
|
|
40
59
|
|
|
41
|
-
type EventProperties =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
type EventProperties = Pick<Event, 'type'> &
|
|
61
|
+
Pick<Event['data'], 'contentId' | 'variationId'> & {
|
|
62
|
+
/**
|
|
63
|
+
* Your organization's API key.
|
|
64
|
+
*/
|
|
65
|
+
apiKey: Event['data']['ownerId'];
|
|
66
|
+
/**
|
|
67
|
+
* (Optional) metadata that you want to provide with your event.
|
|
68
|
+
*/
|
|
69
|
+
metadata?: {
|
|
70
|
+
[index: string]: any;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* (Optional) Any additional (non-metadata) properties to add to the event.
|
|
75
|
+
*/
|
|
76
|
+
[index: string]: any;
|
|
77
|
+
};
|
|
47
78
|
|
|
48
79
|
export type EventProps = EventProperties & CanTrack;
|
|
49
80
|
|
|
50
81
|
const createEvent = async ({
|
|
51
82
|
type: eventType,
|
|
52
83
|
canTrack,
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
apiKey,
|
|
85
|
+
metadata,
|
|
55
86
|
...properties
|
|
56
87
|
}: EventProps): Promise<Event> => ({
|
|
57
88
|
type: eventType,
|
|
58
89
|
data: {
|
|
59
90
|
...properties,
|
|
91
|
+
metadata: JSON.stringify(metadata),
|
|
60
92
|
...(await getTrackingEventData({ canTrack })),
|
|
61
|
-
ownerId:
|
|
62
|
-
contentId,
|
|
93
|
+
ownerId: apiKey,
|
|
63
94
|
},
|
|
64
95
|
});
|
|
65
96
|
|
|
66
|
-
export async function
|
|
97
|
+
export async function _track(eventProps: EventProps) {
|
|
67
98
|
if (!eventProps.canTrack) {
|
|
68
99
|
return;
|
|
69
100
|
}
|
|
@@ -88,3 +119,6 @@ export async function track(eventProps: EventProps) {
|
|
|
88
119
|
console.error('Failed to track: ', err);
|
|
89
120
|
});
|
|
90
121
|
}
|
|
122
|
+
|
|
123
|
+
export const track = (args: EventProperties) =>
|
|
124
|
+
_track({ ...args, canTrack: true });
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
import './scripts/init-editing.js';
|
|
3
3
|
|
|
4
4
|
export * from './index-helpers/blocks-exports.js';
|
|
@@ -10,3 +10,6 @@ export * from './functions/register.js';
|
|
|
10
10
|
export * from './functions/set-editor-settings.js';
|
|
11
11
|
export * from './functions/get-content/index.js';
|
|
12
12
|
export * from './functions/get-builder-search-params/index.js';
|
|
13
|
+
export { track } from './functions/track';
|
|
14
|
+
export type { RegisteredComponent } from './context/types';
|
|
15
|
+
export type { ComponentInfo } from './types/components';
|
|
@@ -23,7 +23,12 @@ export const registerInsertMenu = () => {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
let isSetupForEditing = false;
|
|
26
27
|
export const setupBrowserForEditing = () => {
|
|
28
|
+
if (isSetupForEditing) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
isSetupForEditing = true;
|
|
27
32
|
if (isBrowser()) {
|
|
28
33
|
window.parent?.postMessage(
|
|
29
34
|
{
|
|
@@ -37,6 +42,7 @@ export const setupBrowserForEditing = () => {
|
|
|
37
42
|
// Supports builder-model="..." attribute which is needed to
|
|
38
43
|
// scope our '+ add block' button styling
|
|
39
44
|
supportsAddBlockScoping: true,
|
|
45
|
+
supportsCustomBreakpoints: true,
|
|
40
46
|
},
|
|
41
47
|
},
|
|
42
48
|
'*'
|
|
@@ -17,6 +17,13 @@ export interface BuilderContentVariation {
|
|
|
17
17
|
name?: string;
|
|
18
18
|
testRatio?: number;
|
|
19
19
|
id?: string;
|
|
20
|
+
meta?: {
|
|
21
|
+
breakpoints?: {
|
|
22
|
+
small: number;
|
|
23
|
+
medium: number;
|
|
24
|
+
};
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
};
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
// TODO: separate full and partial versions
|