@builder.io/sdk-qwik 0.24.0 → 0.24.1

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 (35) hide show
  1. package/lib/browser/components/block/components/block-wrapper.qwik.cjs +8 -1
  2. package/lib/browser/components/block/components/block-wrapper.qwik.mjs +8 -1
  3. package/lib/browser/components/block/components/interactive-element.qwik.cjs +8 -1
  4. package/lib/browser/components/block/components/interactive-element.qwik.mjs +8 -1
  5. package/lib/browser/constants/sdk-version.qwik.cjs +1 -1
  6. package/lib/browser/constants/sdk-version.qwik.mjs +1 -1
  7. package/lib/browser/functions/evaluate/evaluate.qwik.cjs +2 -2
  8. package/lib/browser/functions/evaluate/evaluate.qwik.mjs +2 -2
  9. package/lib/browser/functions/evaluate/helpers.qwik.cjs +20 -2
  10. package/lib/browser/functions/evaluate/helpers.qwik.mjs +20 -2
  11. package/lib/edge/components/block/components/block-wrapper.qwik.cjs +8 -1
  12. package/lib/edge/components/block/components/block-wrapper.qwik.mjs +8 -1
  13. package/lib/edge/components/block/components/interactive-element.qwik.cjs +8 -1
  14. package/lib/edge/components/block/components/interactive-element.qwik.mjs +8 -1
  15. package/lib/edge/constants/sdk-version.qwik.cjs +1 -1
  16. package/lib/edge/constants/sdk-version.qwik.mjs +1 -1
  17. package/lib/edge/functions/evaluate/evaluate.qwik.cjs +2 -2
  18. package/lib/edge/functions/evaluate/evaluate.qwik.mjs +2 -2
  19. package/lib/edge/functions/evaluate/helpers.qwik.cjs +20 -2
  20. package/lib/edge/functions/evaluate/helpers.qwik.mjs +20 -2
  21. package/lib/node/components/block/components/block-wrapper.qwik.cjs +8 -1
  22. package/lib/node/components/block/components/block-wrapper.qwik.mjs +8 -1
  23. package/lib/node/components/block/components/interactive-element.qwik.cjs +8 -1
  24. package/lib/node/components/block/components/interactive-element.qwik.mjs +8 -1
  25. package/lib/node/constants/sdk-version.qwik.cjs +1 -1
  26. package/lib/node/constants/sdk-version.qwik.mjs +1 -1
  27. package/lib/node/functions/evaluate/evaluate.qwik.cjs +2 -2
  28. package/lib/node/functions/evaluate/evaluate.qwik.mjs +2 -2
  29. package/lib/node/functions/evaluate/helpers.qwik.cjs +20 -2
  30. package/lib/node/functions/evaluate/helpers.qwik.mjs +20 -2
  31. package/package.json +1 -1
  32. package/types/src/constants/sdk-version.d.ts +1 -1
  33. package/types/src/functions/evaluate/evaluate.d.ts +1 -1
  34. package/types/src/functions/evaluate/helpers.d.ts +9 -1
  35. package/types/src/functions/get-block-actions.d.ts +2 -0
@@ -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.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.24.1";
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 = (
@@ -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.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.24.1";
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 = (
@@ -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.24.1";
4
4
  exports.SDK_VERSION = SDK_VERSION;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.24.0";
1
+ const SDK_VERSION = "0.24.1";
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.24.1",
4
4
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/qwik",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.24.0";
1
+ export declare const SDK_VERSION = "0.24.1";
@@ -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 {};