@builder.io/sdk-qwik 0.24.0 → 0.25.0

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.
Files changed (49) hide show
  1. package/lib/browser/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
  2. package/lib/browser/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
  3. package/lib/browser/blocks/symbol/symbol.qwik.cjs +7 -3
  4. package/lib/browser/blocks/symbol/symbol.qwik.mjs +7 -3
  5. package/lib/browser/components/block/components/block-wrapper.qwik.cjs +8 -1
  6. package/lib/browser/components/block/components/block-wrapper.qwik.mjs +8 -1
  7. package/lib/browser/components/block/components/interactive-element.qwik.cjs +8 -1
  8. package/lib/browser/components/block/components/interactive-element.qwik.mjs +8 -1
  9. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  10. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  11. package/lib/browser/functions/evaluate/evaluate.qwik.cjs +2 -2
  12. package/lib/browser/functions/evaluate/evaluate.qwik.mjs +2 -2
  13. package/lib/browser/functions/evaluate/helpers.qwik.cjs +20 -2
  14. package/lib/browser/functions/evaluate/helpers.qwik.mjs +20 -2
  15. package/lib/edge/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
  16. package/lib/edge/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
  17. package/lib/edge/blocks/symbol/symbol.qwik.cjs +7 -3
  18. package/lib/edge/blocks/symbol/symbol.qwik.mjs +7 -3
  19. package/lib/edge/components/block/components/block-wrapper.qwik.cjs +8 -1
  20. package/lib/edge/components/block/components/block-wrapper.qwik.mjs +8 -1
  21. package/lib/edge/components/block/components/interactive-element.qwik.cjs +8 -1
  22. package/lib/edge/components/block/components/interactive-element.qwik.mjs +8 -1
  23. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  24. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  25. package/lib/edge/functions/evaluate/evaluate.qwik.cjs +2 -2
  26. package/lib/edge/functions/evaluate/evaluate.qwik.mjs +2 -2
  27. package/lib/edge/functions/evaluate/helpers.qwik.cjs +20 -2
  28. package/lib/edge/functions/evaluate/helpers.qwik.mjs +20 -2
  29. package/lib/node/blocks/symbol/symbol.helpers.qwik.cjs +1 -1
  30. package/lib/node/blocks/symbol/symbol.helpers.qwik.mjs +1 -1
  31. package/lib/node/blocks/symbol/symbol.qwik.cjs +7 -3
  32. package/lib/node/blocks/symbol/symbol.qwik.mjs +7 -3
  33. package/lib/node/components/block/components/block-wrapper.qwik.cjs +8 -1
  34. package/lib/node/components/block/components/block-wrapper.qwik.mjs +8 -1
  35. package/lib/node/components/block/components/interactive-element.qwik.cjs +8 -1
  36. package/lib/node/components/block/components/interactive-element.qwik.mjs +8 -1
  37. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  38. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  39. package/lib/node/functions/evaluate/evaluate.qwik.cjs +2 -2
  40. package/lib/node/functions/evaluate/evaluate.qwik.mjs +2 -2
  41. package/lib/node/functions/evaluate/helpers.qwik.cjs +20 -2
  42. package/lib/node/functions/evaluate/helpers.qwik.mjs +20 -2
  43. package/package.json +1 -1
  44. package/types/src/blocks/symbol/symbol.helpers.d.ts +2 -0
  45. package/types/src/blocks/symbol/symbol.types.d.ts +2 -0
  46. package/types/src/constants/sdk-version.d.ts +1 -1
  47. package/types/src/functions/evaluate/evaluate.d.ts +1 -1
  48. package/types/src/functions/evaluate/helpers.d.ts +9 -1
  49. package/types/src/functions/get-block-actions.d.ts +2 -0
@@ -7,7 +7,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
7
7
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
8
8
  return index.fetchOneEntry({
9
9
  model: symbol.model,
10
- apiKey: builderContextValue.apiKey,
10
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
11
11
  apiVersion: builderContextValue.apiVersion,
12
12
  ...(symbol == null ? void 0 : symbol.entry) && {
13
13
  query: {
@@ -5,7 +5,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
5
5
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
6
6
  return fetchOneEntry({
7
7
  model: symbol.model,
8
- apiKey: builderContextValue.apiKey,
8
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
9
9
  apiVersion: builderContextValue.apiVersion,
10
10
  ...(symbol == null ? void 0 : symbol.entry) && {
11
11
  query: {
@@ -72,7 +72,8 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
72
72
  return props.builderContext.apiVersion;
73
73
  },
74
74
  get apiKey() {
75
- return props.builderContext.apiKey;
75
+ var _a2, _b2;
76
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
76
77
  },
77
78
  get context() {
78
79
  var _a2;
@@ -112,9 +113,12 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
112
113
  return contentWrapper.value;
113
114
  },
114
115
  [qwik._IMMUTABLE]: {
115
- apiKey: qwik._fnSignal((p0) => p0.builderContext.apiKey, [
116
+ apiKey: qwik._fnSignal((p0) => {
117
+ var _a2, _b2;
118
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
119
+ }, [
116
120
  props
117
- ], "p0.builderContext.apiKey"),
121
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
118
122
  apiVersion: qwik._fnSignal((p0) => p0.builderContext.apiVersion, [
119
123
  props
120
124
  ], "p0.builderContext.apiVersion"),
@@ -70,7 +70,8 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
70
70
  return props.builderContext.apiVersion;
71
71
  },
72
72
  get apiKey() {
73
- return props.builderContext.apiKey;
73
+ var _a2, _b2;
74
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
74
75
  },
75
76
  get context() {
76
77
  var _a2;
@@ -110,9 +111,12 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
110
111
  return contentWrapper.value;
111
112
  },
112
113
  [_IMMUTABLE]: {
113
- apiKey: _fnSignal((p0) => p0.builderContext.apiKey, [
114
+ apiKey: _fnSignal((p0) => {
115
+ var _a2, _b2;
116
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
117
+ }, [
114
118
  props
115
- ], "p0.builderContext.apiKey"),
119
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
116
120
  apiVersion: _fnSignal((p0) => p0.builderContext.apiVersion, [
117
121
  props
118
122
  ], "p0.builderContext.apiVersion"),
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.24.0";
3
+ const SDK_VERSION = "0.25.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.25.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
@@ -7,7 +7,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
7
7
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
8
8
  return index.fetchOneEntry({
9
9
  model: symbol.model,
10
- apiKey: builderContextValue.apiKey,
10
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
11
11
  apiVersion: builderContextValue.apiVersion,
12
12
  ...(symbol == null ? void 0 : symbol.entry) && {
13
13
  query: {
@@ -5,7 +5,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
5
5
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
6
6
  return fetchOneEntry({
7
7
  model: symbol.model,
8
- apiKey: builderContextValue.apiKey,
8
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
9
9
  apiVersion: builderContextValue.apiVersion,
10
10
  ...(symbol == null ? void 0 : symbol.entry) && {
11
11
  query: {
@@ -72,7 +72,8 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
72
72
  return props.builderContext.apiVersion;
73
73
  },
74
74
  get apiKey() {
75
- return props.builderContext.apiKey;
75
+ var _a2, _b2;
76
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
76
77
  },
77
78
  get context() {
78
79
  var _a2;
@@ -112,9 +113,12 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
112
113
  return contentWrapper.value;
113
114
  },
114
115
  [qwik._IMMUTABLE]: {
115
- apiKey: qwik._fnSignal((p0) => p0.builderContext.apiKey, [
116
+ apiKey: qwik._fnSignal((p0) => {
117
+ var _a2, _b2;
118
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
119
+ }, [
116
120
  props
117
- ], "p0.builderContext.apiKey"),
121
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
118
122
  apiVersion: qwik._fnSignal((p0) => p0.builderContext.apiVersion, [
119
123
  props
120
124
  ], "p0.builderContext.apiVersion"),
@@ -70,7 +70,8 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
70
70
  return props.builderContext.apiVersion;
71
71
  },
72
72
  get apiKey() {
73
- return props.builderContext.apiKey;
73
+ var _a2, _b2;
74
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
74
75
  },
75
76
  get context() {
76
77
  var _a2;
@@ -110,9 +111,12 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
110
111
  return contentWrapper.value;
111
112
  },
112
113
  [_IMMUTABLE]: {
113
- apiKey: _fnSignal((p0) => p0.builderContext.apiKey, [
114
+ apiKey: _fnSignal((p0) => {
115
+ var _a2, _b2;
116
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
117
+ }, [
114
118
  props
115
- ], "p0.builderContext.apiKey"),
119
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
116
120
  apiVersion: _fnSignal((p0) => p0.builderContext.apiVersion, [
117
121
  props
118
122
  ], "p0.builderContext.apiVersion"),
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.24.0";
3
+ const SDK_VERSION = "0.25.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.25.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
@@ -7,7 +7,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
7
7
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
8
8
  return index.fetchOneEntry({
9
9
  model: symbol.model,
10
- apiKey: builderContextValue.apiKey,
10
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
11
11
  apiVersion: builderContextValue.apiVersion,
12
12
  ...(symbol == null ? void 0 : symbol.entry) && {
13
13
  query: {
@@ -5,7 +5,7 @@ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
5
5
  (builderContextValue == null ? void 0 : builderContextValue.apiKey))
6
6
  return fetchOneEntry({
7
7
  model: symbol.model,
8
- apiKey: builderContextValue.apiKey,
8
+ apiKey: symbol.global && symbol.ownerId ? symbol.ownerId : builderContextValue.apiKey,
9
9
  apiVersion: builderContextValue.apiVersion,
10
10
  ...(symbol == null ? void 0 : symbol.entry) && {
11
11
  query: {
@@ -72,7 +72,8 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
72
72
  return props.builderContext.apiVersion;
73
73
  },
74
74
  get apiKey() {
75
- return props.builderContext.apiKey;
75
+ var _a2, _b2;
76
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
76
77
  },
77
78
  get context() {
78
79
  var _a2;
@@ -112,9 +113,12 @@ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQ
112
113
  return contentWrapper.value;
113
114
  },
114
115
  [qwik._IMMUTABLE]: {
115
- apiKey: qwik._fnSignal((p0) => p0.builderContext.apiKey, [
116
+ apiKey: qwik._fnSignal((p0) => {
117
+ var _a2, _b2;
118
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
119
+ }, [
116
120
  props
117
- ], "p0.builderContext.apiKey"),
121
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
118
122
  apiVersion: qwik._fnSignal((p0) => p0.builderContext.apiVersion, [
119
123
  props
120
124
  ], "p0.builderContext.apiVersion"),
@@ -70,7 +70,8 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
70
70
  return props.builderContext.apiVersion;
71
71
  },
72
72
  get apiKey() {
73
- return props.builderContext.apiKey;
73
+ var _a2, _b2;
74
+ return ((_a2 = props.symbol) == null ? void 0 : _a2.global) && ((_b2 = props.symbol) == null ? void 0 : _b2.ownerId) ? props.symbol.ownerId : props.builderContext.apiKey;
74
75
  },
75
76
  get context() {
76
77
  var _a2;
@@ -110,9 +111,12 @@ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
110
111
  return contentWrapper.value;
111
112
  },
112
113
  [_IMMUTABLE]: {
113
- apiKey: _fnSignal((p0) => p0.builderContext.apiKey, [
114
+ apiKey: _fnSignal((p0) => {
115
+ var _a2, _b2;
116
+ return ((_a2 = p0.symbol) == null ? void 0 : _a2.global) && ((_b2 = p0.symbol) == null ? void 0 : _b2.ownerId) ? p0.symbol.ownerId : p0.builderContext.apiKey;
117
+ }, [
114
118
  props
115
- ], "p0.builderContext.apiKey"),
119
+ ], "p0.symbol?.global&&p0.symbol?.ownerId?p0.symbol.ownerId:p0.builderContext.apiKey"),
116
120
  apiVersion: _fnSignal((p0) => p0.builderContext.apiVersion, [
117
121
  props
118
122
  ], "p0.builderContext.apiVersion"),
@@ -5,6 +5,7 @@ const getBlockActions = require("../../../functions/get-block-actions.qwik.cjs")
5
5
  const getBlockProperties = require("../../../functions/get-block-properties.qwik.cjs");
6
6
  const dynamicRenderer = require("../../dynamic-renderer/dynamic-renderer.qwik.cjs");
7
7
  const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
8
+ var _a, _b;
8
9
  return /* @__PURE__ */ qwik._jsxC(dynamicRenderer.DynamicRenderer, {
9
10
  get TagName() {
10
11
  return props.Wrapper;
@@ -15,7 +16,13 @@ const BlockWrapper = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
15
16
  rootSetState: props.context.rootSetState,
16
17
  localState: props.context.localState,
17
18
  context: props.context.context,
18
- stripPrefix: true
19
+ stripPrefix: true,
20
+ trackingContext: {
21
+ apiKey: props.context.apiKey,
22
+ canTrack: props.context.canTrack ?? true,
23
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
24
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
25
+ }
19
26
  }),
20
27
  attributes: getBlockProperties.getBlockProperties({
21
28
  block: props.block,
@@ -3,6 +3,7 @@ import { getBlockActions } from "../../../functions/get-block-actions.qwik.mjs";
3
3
  import { getBlockProperties } from "../../../functions/get-block-properties.qwik.mjs";
4
4
  import { DynamicRenderer } from "../../dynamic-renderer/dynamic-renderer.qwik.mjs";
5
5
  const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
6
+ var _a, _b;
6
7
  return /* @__PURE__ */ _jsxC(DynamicRenderer, {
7
8
  get TagName() {
8
9
  return props.Wrapper;
@@ -13,7 +14,13 @@ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
13
14
  rootSetState: props.context.rootSetState,
14
15
  localState: props.context.localState,
15
16
  context: props.context.context,
16
- stripPrefix: true
17
+ stripPrefix: true,
18
+ trackingContext: {
19
+ apiKey: props.context.apiKey,
20
+ canTrack: props.context.canTrack ?? true,
21
+ contentId: (_a = props.context.content) == null ? void 0 : _a.id,
22
+ variationId: (_b = props.context.content) == null ? void 0 : _b.testVariationId
23
+ }
17
24
  }),
18
25
  attributes: getBlockProperties({
19
26
  block: props.block,
@@ -11,6 +11,7 @@ require("../../../context/builder.context.qwik.cjs");
11
11
  const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
12
12
  qwik._jsxBranch();
13
13
  const attributes = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
14
+ var _a, _b;
14
15
  const [props2] = qwik.useLexicalScope();
15
16
  return props2.includeBlockProps ? {
16
17
  ...getBlockProperties.getBlockProperties({
@@ -22,7 +23,13 @@ const InteractiveElement = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwi
22
23
  rootState: props2.context.rootState,
23
24
  rootSetState: props2.context.rootSetState,
24
25
  localState: props2.context.localState,
25
- context: props2.context.context
26
+ context: props2.context.context,
27
+ trackingContext: {
28
+ apiKey: props2.context.apiKey,
29
+ canTrack: props2.context.canTrack ?? true,
30
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
31
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
32
+ }
26
33
  })
27
34
  } : {};
28
35
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -9,6 +9,7 @@ import "../../../context/builder.context.qwik.mjs";
9
9
  const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
10
10
  _jsxBranch();
11
11
  const attributes = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
12
+ var _a, _b;
12
13
  const [props2] = useLexicalScope();
13
14
  return props2.includeBlockProps ? {
14
15
  ...getBlockProperties({
@@ -20,7 +21,13 @@ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQ
20
21
  rootState: props2.context.rootState,
21
22
  rootSetState: props2.context.rootSetState,
22
23
  localState: props2.context.localState,
23
- context: props2.context.context
24
+ context: props2.context.context,
25
+ trackingContext: {
26
+ apiKey: props2.context.apiKey,
27
+ canTrack: props2.context.canTrack ?? true,
28
+ contentId: (_a = props2.context.content) == null ? void 0 : _a.id,
29
+ variationId: (_b = props2.context.content) == null ? void 0 : _b.testVariationId
30
+ }
24
31
  })
25
32
  } : {};
26
33
  }, "InteractiveElement_component_attributes_useComputed_0kUhl8Qa4CE", [
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const SDK_VERSION = "0.24.0";
3
+ const SDK_VERSION = "0.25.0";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.25.0";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -10,7 +10,7 @@ const getSimpleExpressionGetPath = (code) => {
10
10
  var _a, _b, _c, _d, _e, _f;
11
11
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
12
12
  };
13
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
13
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
14
14
  if (code.trim() === "")
15
15
  return void 0;
16
16
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -23,7 +23,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
23
23
  code: helpers.parseCode(code, {
24
24
  isExpression
25
25
  }),
26
- builder: helpers.getBuilderGlobals(),
26
+ builder: helpers.getBuilderGlobals(trackingContext),
27
27
  context,
28
28
  event,
29
29
  rootSetState,
@@ -8,7 +8,7 @@ const getSimpleExpressionGetPath = (code) => {
8
8
  var _a, _b, _c, _d, _e, _f;
9
9
  return ((_c = (_b = (_a = STATE_GETTER_REGEX.exec(code.trim())) == null ? void 0 : _a.groups) == null ? void 0 : _b.getPath) == null ? void 0 : _c.slice(1)) || ((_f = (_e = (_d = VIRTUAL_INDEX_REGEX.exec(code.trim())) == null ? void 0 : _d.groups) == null ? void 0 : _e.getPath) == null ? void 0 : _f.slice(1));
10
10
  };
11
- function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
11
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true, trackingContext }) {
12
12
  if (code.trim() === "")
13
13
  return void 0;
14
14
  const getPath = getSimpleExpressionGetPath(code.trim());
@@ -21,7 +21,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
21
21
  code: parseCode(code, {
22
22
  isExpression
23
23
  }),
24
- builder: getBuilderGlobals(),
24
+ builder: getBuilderGlobals(trackingContext),
25
25
  context,
26
26
  event,
27
27
  rootSetState,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const isBrowser = require("../is-browser.qwik.cjs");
4
4
  const isEditing = require("../is-editing.qwik.cjs");
5
5
  const helpers = require("../track/helpers.qwik.cjs");
6
+ const index = require("../track/index.qwik.cjs");
6
7
  const getFunctionArguments = ({ builder, context, event, state }) => {
7
8
  return Object.entries({
8
9
  state,
@@ -13,11 +14,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
13
14
  event
14
15
  });
15
16
  };
16
- const getBuilderGlobals = () => ({
17
+ const getBuilderGlobals = (trackingContext) => ({
17
18
  isEditing: isEditing.isEditing(),
18
19
  isBrowser: isBrowser.isBrowser(),
19
20
  isServer: !isBrowser.isBrowser(),
20
- getUserAttributes: () => helpers.getUserAttributes()
21
+ getUserAttributes: () => helpers.getUserAttributes(),
22
+ trackConversion: (amount, customProperties) => {
23
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
24
+ return;
25
+ index._track({
26
+ type: "conversion",
27
+ apiKey: trackingContext.apiKey,
28
+ canTrack: trackingContext.canTrack ?? true,
29
+ contentId: trackingContext.contentId,
30
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
31
+ metadata: {
32
+ ...customProperties || {},
33
+ ...amount !== void 0 ? {
34
+ amount
35
+ } : {}
36
+ }
37
+ });
38
+ }
21
39
  });
22
40
  const parseCode = (code, { isExpression = true }) => {
23
41
  const useReturn = (
@@ -1,6 +1,7 @@
1
1
  import { isBrowser } from "../is-browser.qwik.mjs";
2
2
  import { isEditing } from "../is-editing.qwik.mjs";
3
3
  import { getUserAttributes } from "../track/helpers.qwik.mjs";
4
+ import { _track } from "../track/index.qwik.mjs";
4
5
  const getFunctionArguments = ({ builder, context, event, state }) => {
5
6
  return Object.entries({
6
7
  state,
@@ -11,11 +12,28 @@ const getFunctionArguments = ({ builder, context, event, state }) => {
11
12
  event
12
13
  });
13
14
  };
14
- const getBuilderGlobals = () => ({
15
+ const getBuilderGlobals = (trackingContext) => ({
15
16
  isEditing: isEditing(),
16
17
  isBrowser: isBrowser(),
17
18
  isServer: !isBrowser(),
18
- getUserAttributes: () => getUserAttributes()
19
+ getUserAttributes: () => getUserAttributes(),
20
+ trackConversion: (amount, customProperties) => {
21
+ if (!(trackingContext == null ? void 0 : trackingContext.apiKey) || (trackingContext == null ? void 0 : trackingContext.canTrack) === false)
22
+ return;
23
+ _track({
24
+ type: "conversion",
25
+ apiKey: trackingContext.apiKey,
26
+ canTrack: trackingContext.canTrack ?? true,
27
+ contentId: trackingContext.contentId,
28
+ variationId: trackingContext.variationId !== trackingContext.contentId ? trackingContext.variationId : void 0,
29
+ metadata: {
30
+ ...customProperties || {},
31
+ ...amount !== void 0 ? {
32
+ amount
33
+ } : {}
34
+ }
35
+ });
36
+ }
19
37
  });
20
38
  const parseCode = (code, { isExpression = true }) => {
21
39
  const useReturn = (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-qwik",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -7,6 +7,8 @@ export interface SymbolInfo {
7
7
  content?: BuilderContent;
8
8
  inline?: boolean;
9
9
  dynamic?: boolean;
10
+ ownerId?: string;
11
+ global?: boolean;
10
12
  }
11
13
  export declare const fetchSymbolContent: ({ builderContextValue, symbol }: {
12
14
  symbol: SymbolInfo | undefined;
@@ -7,6 +7,8 @@ export interface SymbolInfo {
7
7
  content?: BuilderContent;
8
8
  inline?: boolean;
9
9
  dynamic?: boolean;
10
+ ownerId?: string;
11
+ global?: boolean;
10
12
  }
11
13
  export interface SymbolProps extends BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp {
12
14
  symbol?: SymbolInfo;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.24.0";
1
+ export declare const SDK_VERSION = "0.25.0";
@@ -1,5 +1,5 @@
1
1
  import type { EvaluatorArgs } from './helpers';
2
2
  type EvalValue = unknown;
3
3
  export declare const getSimpleExpressionGetPath: (code: string) => string | undefined;
4
- export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): EvalValue;
4
+ export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, trackingContext }: EvaluatorArgs): EvalValue;
5
5
  export {};
@@ -1,14 +1,22 @@
1
1
  import type { BuilderContextInterface, BuilderRenderState } from '../../context/types';
2
2
  import { getUserAttributes } from '../track/helpers';
3
+ export type TrackingContext = {
4
+ apiKey: string | null;
5
+ canTrack?: boolean;
6
+ contentId?: string;
7
+ variationId?: string;
8
+ };
3
9
  export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
4
10
  event?: Event;
5
11
  isExpression?: boolean;
12
+ trackingContext?: TrackingContext;
6
13
  };
7
14
  export type BuilderGlobals = {
8
15
  isEditing: boolean | undefined;
9
16
  isBrowser: boolean | undefined;
10
17
  isServer: boolean | undefined;
11
18
  getUserAttributes: typeof getUserAttributes;
19
+ trackConversion: (amount?: number, customProperties?: Record<string, any>) => void;
12
20
  };
13
21
  export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
14
22
  code: string;
@@ -20,7 +28,7 @@ export type FunctionArguments = ReturnType<typeof getFunctionArguments>;
20
28
  export declare const getFunctionArguments: ({ builder, context, event, state }: Pick<ExecutorArgs, "builder" | "context" | "event"> & {
21
29
  state: BuilderRenderState;
22
30
  }) => [string, Event | BuilderRenderState | import("../../context/types").BuilderRenderContext | BuilderGlobals | undefined][];
23
- export declare const getBuilderGlobals: () => BuilderGlobals;
31
+ export declare const getBuilderGlobals: (trackingContext?: TrackingContext) => BuilderGlobals;
24
32
  export declare const parseCode: (code: string, { isExpression }: Pick<EvaluatorArgs, "isExpression">) => string;
25
33
  export declare function flattenState({ rootState, localState, rootSetState }: {
26
34
  rootState: Record<string | symbol, any>;
@@ -1,10 +1,12 @@
1
1
  import type { BuilderContextInterface } from '../context/types';
2
2
  import type { BuilderBlock } from '../types/builder-block';
3
+ import type { TrackingContext } from './evaluate/helpers';
3
4
  type Actions = {
4
5
  [index: string]: (event: Event) => any;
5
6
  };
6
7
  export declare function getBlockActions(options: {
7
8
  block: BuilderBlock;
8
9
  stripPrefix?: boolean;
10
+ trackingContext?: TrackingContext;
9
11
  } & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): Actions;
10
12
  export {};