@useinsider/guido 1.0.3-beta.dfb1fcf → 1.0.3-beta.e1adf59

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 (130) hide show
  1. package/README.md +3 -144
  2. package/dist/components/Guido.vue.js +10 -12
  3. package/dist/components/Guido.vue2.js +101 -84
  4. package/dist/components/organisms/header/LeftSlot.vue.js +1 -1
  5. package/dist/components/organisms/header/LeftSlot.vue2.js +15 -16
  6. package/dist/components/organisms/header/RightSlot.vue.js +11 -11
  7. package/dist/components/organisms/header/RightSlot.vue2.js +22 -23
  8. package/dist/components/organisms/onboarding/NewVersionPopup.vue.js +9 -9
  9. package/dist/components/organisms/onboarding/NewVersionPopup.vue2.js +17 -30
  10. package/dist/components/organisms/onboarding/OnboardingWrapper.vue.js +10 -12
  11. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -19
  12. package/dist/composables/useApiErrorTracking.js +120 -0
  13. package/dist/composables/useErrorTracking.js +98 -0
  14. package/dist/composables/useGuidoActions.js +9 -19
  15. package/dist/composables/useHttp.js +89 -52
  16. package/dist/composables/useStripo.js +163 -66
  17. package/dist/composables/useStripoErrorCategory.js +86 -0
  18. package/dist/composables/useStripoSlackNotifier.js +47 -0
  19. package/dist/config/compiler/unsubscribeCompilerRules.js +28 -33
  20. package/dist/config/migrator/index.js +6 -7
  21. package/dist/enums/defaults.js +8 -16
  22. package/dist/enums/onboarding.js +1 -2
  23. package/dist/enums/unsubscribe.js +25 -27
  24. package/dist/extensions/Blocks/Checkbox/extension.js +2 -2
  25. package/dist/extensions/Blocks/CouponBlock/extension.js +2 -2
  26. package/dist/extensions/Blocks/Recommendation/block.js +3 -6
  27. package/dist/extensions/Blocks/Recommendation/control.js +65 -109
  28. package/dist/extensions/Blocks/Recommendation/extension.js +7 -18
  29. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -159
  30. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -1
  31. package/dist/extensions/Blocks/Recommendation/template.js +200 -0
  32. package/dist/extensions/Blocks/common-control.js +43 -125
  33. package/dist/extensions/DynamicContent/dynamic-content-modal.js +19 -25
  34. package/dist/extensions/DynamicContent/dynamic-content.js +33 -128
  35. package/dist/guido.css +1 -1
  36. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +100 -312
  37. package/dist/package.json.js +1 -1
  38. package/dist/services/slackNotificationService.js +167 -0
  39. package/dist/services/stripoApi.js +49 -19
  40. package/dist/services/stripoErrorDeduplicationService.js +91 -0
  41. package/dist/src/@types/generic.d.ts +6 -42
  42. package/dist/src/components/Guido.vue.d.ts +3 -4
  43. package/dist/src/components/organisms/onboarding/NewVersionPopup.vue.d.ts +1 -3
  44. package/dist/src/components/organisms/onboarding/OnboardingWrapper.vue.d.ts +1 -3
  45. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  46. package/dist/src/composables/useApiErrorTracking.d.ts +26 -0
  47. package/dist/src/composables/useErrorTracking.d.ts +30 -0
  48. package/dist/src/composables/useGuidoActions.d.ts +0 -9
  49. package/dist/src/composables/useStripoErrorCategory.d.ts +26 -0
  50. package/dist/src/composables/useStripoSlackNotifier.d.ts +8 -0
  51. package/dist/src/enums/onboarding.d.ts +0 -1
  52. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  53. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +2 -11
  54. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Recommendation/template.d.ts +6 -0
  56. package/dist/src/extensions/Blocks/common-control.d.ts +0 -21
  57. package/dist/src/extensions/DynamicContent/dynamic-content-modal.d.ts +2 -9
  58. package/dist/src/extensions/DynamicContent/dynamic-content.d.ts +2 -52
  59. package/dist/src/services/slackNotificationService.d.ts +110 -0
  60. package/dist/src/services/stripoErrorDeduplicationService.d.ts +75 -0
  61. package/dist/src/stores/config.d.ts +2 -10
  62. package/dist/src/stores/dynamic-content.d.ts +3 -3
  63. package/dist/src/stores/editor.d.ts +1 -1
  64. package/dist/src/stores/onboarding.d.ts +1 -1
  65. package/dist/src/stores/preview.d.ts +1 -1
  66. package/dist/src/stores/recommendation.d.ts +1 -1
  67. package/dist/src/stores/save-as-template.d.ts +1 -1
  68. package/dist/src/stores/toaster.d.ts +1 -1
  69. package/dist/src/stores/unsubscribe.d.ts +1 -1
  70. package/dist/src/stores/version-history.d.ts +1 -1
  71. package/dist/src/utils/dateUtil.d.ts +0 -21
  72. package/dist/src/utils/genericUtil.d.ts +0 -1
  73. package/dist/static/styles/components/narrow-panel.css.js +0 -10
  74. package/dist/static/styles/components/wide-panel.css.js +4 -0
  75. package/dist/static/styles/customEditorStyle.css.js +0 -19
  76. package/dist/stores/config.js +5 -5
  77. package/dist/stores/dynamic-content.js +2 -2
  78. package/dist/stores/editor.js +1 -1
  79. package/dist/stores/onboarding.js +27 -27
  80. package/dist/stores/preview.js +1 -1
  81. package/dist/stores/recommendation.js +3 -3
  82. package/dist/stores/save-as-template.js +2 -2
  83. package/dist/stores/toaster.js +1 -1
  84. package/dist/stores/unsubscribe.js +1 -1
  85. package/dist/stores/version-history.js +4 -4
  86. package/dist/utils/dateUtil.js +3 -24
  87. package/dist/utils/genericUtil.js +9 -20
  88. package/package.json +3 -3
  89. package/dist/composables/useBlocksConfig.js +0 -49
  90. package/dist/config/migrator/recommendationMigrator.js +0 -293
  91. package/dist/enums/date.js +0 -6
  92. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -193
  93. package/dist/extensions/Blocks/Recommendation/constants.js +0 -14
  94. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  95. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -272
  96. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  97. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.js +0 -71
  98. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.js +0 -71
  99. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.js +0 -71
  100. package/dist/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.js +0 -71
  101. package/dist/extensions/Blocks/Recommendation/controls/priceHideControl.js +0 -60
  102. package/dist/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.js +0 -160
  103. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  104. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -184
  105. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  106. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  107. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +0 -25
  108. package/dist/extensions/Blocks/controlFactories.js +0 -234
  109. package/dist/src/composables/useBlocksConfig.d.ts +0 -11
  110. package/dist/src/config/migrator/recommendationMigrator.d.ts +0 -1
  111. package/dist/src/enums/date.d.ts +0 -4
  112. package/dist/src/extensions/Blocks/Recommendation/cardCompositionControl.d.ts +0 -79
  113. package/dist/src/extensions/Blocks/Recommendation/constants.d.ts +0 -91
  114. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.d.ts +0 -25
  115. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +0 -71
  116. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  117. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextAfterControl.d.ts +0 -15
  118. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscountTextBeforeControl.d.ts +0 -15
  119. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextAfterControl.d.ts +0 -15
  120. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPriceTextBeforeControl.d.ts +0 -15
  121. package/dist/src/extensions/Blocks/Recommendation/controls/priceHideControl.d.ts +0 -16
  122. package/dist/src/extensions/Blocks/Recommendation/controls/priceInlineLayoutControl.d.ts +0 -50
  123. package/dist/src/extensions/Blocks/Recommendation/controls/spacingControl.d.ts +0 -60
  124. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  125. package/dist/src/extensions/Blocks/Recommendation/templates/migrationTemplate.d.ts +0 -16
  126. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
  127. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -19
  128. package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -95
  129. package/dist/src/utils/environmentUtil.d.ts +0 -5
  130. package/dist/utils/environmentUtil.js +0 -4
@@ -1,17 +1,17 @@
1
- import t from "./NewVersionPopup.vue2.js";
1
+ import s from "./NewVersionPopup.vue2.js";
2
2
  import n from "../../../_virtual/_plugin-vue2_normalizer.js";
3
- var i = function() {
4
- var e = this, s = e._self._c, o = e._self._setupProxy;
5
- return o.isVisible ? s(o.WpModal, { attrs: { id: "guido__new-version-popup", size: "medium", "close-on-outside-click": !1, "footer-button-options": o.footerButtonOptions, title: o.popupTitle }, on: { close: o.handleClose, "primary-action": o.handleDiscoverNow, "secondary-action": o.handleRemindLater } }, [s("div", { staticClass: "d-f f-d-c" }, [s("img", { staticClass: "w-1 h-1 d-b p-e-n mb-5", attrs: { src: o.onboardingImageSvg } }), s("p", { staticClass: "f-s-2 f-w-400", domProps: { innerHTML: e._s(o.popupDescription) } })])]) : e._e();
6
- }, r = [], a = /* @__PURE__ */ n(
7
- t,
8
- i,
3
+ var r = function() {
4
+ var e = this, t = e._self._c, o = e._self._setupProxy;
5
+ return o.isVisible ? t(o.WpModal, { attrs: { id: "guido__new-version-popup", "close-on-outside-click": !1, "footer-button-options": o.footerButtonOptions, title: o.trans("email-editor.onboarding-title") }, on: { close: o.handleClose, "primary-action": o.handleDiscoverNow, "secondary-action": o.handleRemindLater } }, [t("div", { staticClass: "d-f f-d-c" }, [t("img", { staticClass: "w-1 h-1 d-b p-e-n mb-5", attrs: { src: o.onboardingImageSvg } }), t("p", { staticClass: "f-s-2 f-w-400", domProps: { innerHTML: e._s(o.trans("email-editor.onboarding-description")) } })])]) : e._e();
6
+ }, i = [], a = /* @__PURE__ */ n(
7
+ s,
9
8
  r,
9
+ i,
10
10
  !1,
11
11
  null,
12
12
  null
13
13
  );
14
- const _ = a.exports;
14
+ const p = a.exports;
15
15
  export {
16
- _ as default
16
+ p as default
17
17
  };
@@ -1,43 +1,30 @@
1
- import { defineComponent as g, ref as b, computed as o } from "vue";
2
- import v from "../../wrappers/WpModal.vue.js";
3
- import { useConfig as D } from "../../../composables/useConfig.js";
4
- import { useTranslations as h } from "../../../composables/useTranslations.js";
5
- import { ACADEMY_LINK as l } from "../../../enums/onboarding.js";
6
- import y from "../../../static/assets/onboarding-img.svg.js";
7
- import { useOnboardingStore as _ } from "../../../stores/onboarding.js";
8
- import { isAfterDate as C, formatShortDate as L } from "../../../utils/dateUtil.js";
9
- const I = /* @__PURE__ */ g({
1
+ import { defineComponent as s, ref as r } from "vue";
2
+ import a from "../../wrappers/WpModal.vue.js";
3
+ import { useTranslations as i } from "../../../composables/useTranslations.js";
4
+ import l from "../../../static/assets/onboarding-img.svg.js";
5
+ import { useOnboardingStore as m } from "../../../stores/onboarding.js";
6
+ const w = /* @__PURE__ */ s({
10
7
  __name: "NewVersionPopup",
11
- emits: ["onboarding-finished"],
12
- setup(w, { emit: a }) {
13
- const e = h(), t = _(), s = b(!0), { config: p } = D(), i = o(() => p.migrationDate), n = o(() => C(i.value || 0)), d = o(() => L(
14
- i.value
15
- )), m = o(() => n.value ? e("email-editor.onboarding-popup-sunsetted-title") : e("email-editor.onboarding-title")), c = o(() => n.value ? e("email-editor.onboarding-popup-sunsetted-description", {
16
- sunsetDate: d.value,
17
- academyLink: l
18
- }) : e("email-editor.onboarding-description", {
19
- academyLink: l
20
- })), u = o(() => n.value ? e("products.cancel") : e("products.remind-me-later")), f = o(() => ({
8
+ setup(p) {
9
+ const n = i(), e = m(), o = r(!0), t = r({
21
10
  primaryButton: {
22
11
  type: "primary",
23
- labelText: e("left-menu.discover-now")
12
+ labelText: n("left-menu.discover-now")
24
13
  },
25
14
  secondaryButton: {
26
15
  type: "subtle-primary",
27
- labelText: u.value
16
+ labelText: n("products.remind-me-later")
28
17
  }
29
- })), r = () => {
30
- s.value = !1, a("onboarding-finished");
31
- };
32
- return { __sfc: !0, emit: a, trans: e, onboardingStore: t, isVisible: s, config: p, migrationDate: i, isAfterMigrationDate: n, formattedSunsetDate: d, popupTitle: m, popupDescription: c, secondaryButtonLabel: u, footerButtonOptions: f, closePopup: r, handleDiscoverNow: () => {
33
- t.onDiscoverNowClicked(), r();
18
+ });
19
+ return { __sfc: !0, trans: n, onboardingStore: e, isVisible: o, footerButtonOptions: t, handleDiscoverNow: () => {
20
+ e.onDiscoverNowClicked(), o.value = !1;
34
21
  }, handleRemindLater: () => {
35
- t.onRemindMeLater(), r();
22
+ e.onRemindMeLater(), o.value = !1;
36
23
  }, handleClose: () => {
37
- t.onNewVersionPopupClose(), r();
38
- }, WpModal: v, onboardingImageSvg: y };
24
+ e.onNewVersionPopupClose(), o.value = !1;
25
+ }, WpModal: a, onboardingImageSvg: l };
39
26
  }
40
27
  });
41
28
  export {
42
- I as default
29
+ w as default
43
30
  };
@@ -1,21 +1,19 @@
1
- import t from "./OnboardingWrapper.vue2.js";
2
- import i from "../../../_virtual/_plugin-vue2_normalizer.js";
1
+ import o from "./OnboardingWrapper.vue2.js";
2
+ import _ from "../../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var s = function() {
4
- var n = this, e = n._self._c, r = n._self._setupProxy;
5
- return e("div", n._l(r.visibleOnboardings, function(o) {
6
- return e(o.component, { key: o.type, tag: "component", on: { "onboarding-finished": function(p) {
7
- return r.emit("onboarding-finished");
8
- } } });
4
+ var n = this, e = n._self._c, t = n._self._setupProxy;
5
+ return e("div", n._l(t.visibleOnboardings, function(r) {
6
+ return e(r.component, { key: r.type, tag: "component" });
9
7
  }), 1);
10
- }, _ = [], a = /* @__PURE__ */ i(
11
- t,
8
+ }, a = [], p = /* @__PURE__ */ _(
9
+ o,
12
10
  s,
13
- _,
11
+ a,
14
12
  !1,
15
13
  null,
16
14
  null
17
15
  );
18
- const d = a.exports;
16
+ const m = p.exports;
19
17
  export {
20
- d as default
18
+ m as default
21
19
  };
@@ -1,25 +1,24 @@
1
- import { defineComponent as b, computed as e, onMounted as O, watch as t } from "vue";
2
- import { usePartner as u } from "../../../composables/usePartner.js";
3
- import { useEditorStore as v } from "../../../stores/editor.js";
4
- import { useOnboardingStore as l } from "../../../stores/onboarding.js";
5
- import { usePreviewStore as y } from "../../../stores/preview.js";
6
- import S from "./AMPOnboarding.vue.js";
7
- import h from "./GenericOnboarding.vue.js";
1
+ import { defineComponent as g, computed as e, onMounted as b, watch as t } from "vue";
2
+ import { usePartner as O } from "../../../composables/usePartner.js";
3
+ import { useEditorStore as u } from "../../../stores/editor.js";
4
+ import { useOnboardingStore as v } from "../../../stores/onboarding.js";
5
+ import { usePreviewStore as l } from "../../../stores/preview.js";
6
+ import y from "./AMPOnboarding.vue.js";
7
+ import S from "./GenericOnboarding.vue.js";
8
8
  import w from "./NewVersionPopup.vue.js";
9
9
  import P from "./TextBlockOnboarding.vue.js";
10
- import _ from "./VersionHistoryOnboarding.vue.js";
11
- const F = /* @__PURE__ */ b({
10
+ import h from "./VersionHistoryOnboarding.vue.js";
11
+ const E = /* @__PURE__ */ g({
12
12
  __name: "OnboardingWrapper",
13
- emits: ["onboarding-finished"],
14
- setup(A, { emit: f }) {
15
- const o = l(), r = v(), s = y(), { isTestPartner: a } = u(), p = e(() => r.isStripoInitialized), d = e(() => a()), m = [
13
+ setup(_) {
14
+ const o = v(), r = u(), s = l(), { isTestPartner: a } = O(), p = e(() => r.isStripoInitialized), d = e(() => a()), m = [
16
15
  { type: "newVersionPopup", component: w },
17
- { type: "genericOnboarding", component: h },
16
+ { type: "genericOnboarding", component: S },
18
17
  { type: "textBlockOnboarding", component: P },
19
- { type: "versionHistoryOnboarding", component: _ },
20
- { type: "ampOnboarding", component: S }
21
- ], c = (n) => d.value || !p.value ? !1 : n === "newVersionPopup" ? o.shouldShowOnboarding(n) : o.isActive(n), g = e(() => m.filter((n) => c(n.type)));
22
- return O(async () => {
18
+ { type: "versionHistoryOnboarding", component: h },
19
+ { type: "ampOnboarding", component: y }
20
+ ], c = (n) => d.value || !p.value ? !1 : n === "newVersionPopup" ? o.shouldShowOnboarding(n) : o.isActive(n), f = e(() => m.filter((n) => c(n.type)));
21
+ return b(async () => {
23
22
  await o.fetchUserModalState();
24
23
  }), t(
25
24
  () => r.isVersionHistoryOpen,
@@ -36,9 +35,9 @@ const F = /* @__PURE__ */ b({
36
35
  (n) => {
37
36
  !n && o.isActive("ampOnboarding") && o.close("ampOnboarding");
38
37
  }
39
- ), { __sfc: !0, emit: f, onboardingStore: o, editorStore: r, previewStore: s, isTestPartner: a, isStripoReady: p, isTestPartnerActive: d, onboardingConfigs: m, shouldShow: c, visibleOnboardings: g };
38
+ ), { __sfc: !0, onboardingStore: o, editorStore: r, previewStore: s, isTestPartner: a, isStripoReady: p, isTestPartnerActive: d, onboardingConfigs: m, shouldShow: c, visibleOnboardings: f };
40
39
  }
41
40
  });
42
41
  export {
43
- F as default
42
+ E as default
44
43
  };
@@ -0,0 +1,120 @@
1
+ import { useErrorTracking as p } from "./useErrorTracking.js";
2
+ const h = () => {
3
+ const { captureError: i } = p(), E = (e, t, o = {}) => {
4
+ const s = {
5
+ endpoint: t,
6
+ method: o.method,
7
+ statusCode: e.status,
8
+ statusText: e.statusText,
9
+ errorType: "http_error",
10
+ component: "api-client",
11
+ operation: `http_error_${e.status}`,
12
+ retryable: e.status ? e.status >= 500 : !1,
13
+ // 5xx errors are retryable
14
+ ...o
15
+ }, r = new Error(
16
+ `HTTP ${e.status} ${e.statusText} - ${t}`
17
+ );
18
+ return i(r, s), s;
19
+ }, u = (e, t, o = {}) => {
20
+ const s = e.message, r = s.toLowerCase().includes("timeout"), n = e.name === "AbortError";
21
+ let a;
22
+ r ? a = "network_timeout" : n ? a = "request_abort" : a = "network_error";
23
+ const c = {
24
+ endpoint: t,
25
+ errorType: "network_error",
26
+ component: "api-client",
27
+ operation: a,
28
+ retryable: !0,
29
+ ...o
30
+ }, l = new Error(
31
+ `Network Error (${String(c.operation)}) - ${String(t)}: ${s}`
32
+ );
33
+ return i(l, c), c;
34
+ }, g = (e, t, o, s = {}) => {
35
+ const r = e instanceof Error ? e.message : String(e), n = {
36
+ endpoint: t,
37
+ errorType: "parsing_error",
38
+ component: "api-client",
39
+ operation: "response_parsing_failed",
40
+ retryable: !1,
41
+ responsePreview: o instanceof Object ? JSON.stringify(o).slice(0, 200) : String(o).slice(0, 200),
42
+ ...s
43
+ }, a = new Error(
44
+ `Failed to parse API response from ${t}: ${r}`
45
+ );
46
+ return i(a, n), n;
47
+ }, m = (e, t, o = {}) => {
48
+ const s = {
49
+ endpoint: e,
50
+ errorType: "timeout",
51
+ component: "api-client",
52
+ operation: "request_timeout",
53
+ timeoutMs: t,
54
+ retryable: !0,
55
+ ...o
56
+ }, r = new Error(
57
+ `Request to ${e} timed out after ${t}ms`
58
+ );
59
+ return i(r, s), s;
60
+ };
61
+ return {
62
+ captureHttpError: E,
63
+ captureNetworkError: u,
64
+ captureParsingError: g,
65
+ captureTimeoutError: m,
66
+ withApiErrorTracking: async (e, t, o = "GET", s = {}) => {
67
+ try {
68
+ return await e();
69
+ } catch (r) {
70
+ if (r instanceof Error)
71
+ if (r.message === "Request timeout") {
72
+ const n = s.timeoutMs || 1e4;
73
+ m(t, n, {
74
+ method: o,
75
+ ...s
76
+ });
77
+ } else if (r.name === "AbortError" || r.message.includes("cancelled"))
78
+ u(r, t, {
79
+ method: o,
80
+ ...s
81
+ });
82
+ else if (r.message.includes("HTTP Error")) {
83
+ const n = r.message.match(/HTTP Error: (\d+)/), a = n ? parseInt(n[1]) : void 0, c = {
84
+ message: r.message,
85
+ status: a,
86
+ statusText: r.message
87
+ };
88
+ E(c, t, {
89
+ method: o,
90
+ ...s
91
+ });
92
+ } else
93
+ u(r, t, {
94
+ method: o,
95
+ ...s
96
+ });
97
+ else {
98
+ const n = new Error(String(r));
99
+ u(n, t, {
100
+ method: o,
101
+ ...s
102
+ });
103
+ }
104
+ throw r;
105
+ }
106
+ },
107
+ withParsingErrorTracking: (e, t, o, s = {}) => {
108
+ try {
109
+ return e();
110
+ } catch (r) {
111
+ throw g(r, t, o, {
112
+ ...s
113
+ }), r;
114
+ }
115
+ }
116
+ };
117
+ };
118
+ export {
119
+ h as useApiErrorTracking
120
+ };
@@ -0,0 +1,98 @@
1
+ import { inject as S, ref as g } from "vue";
2
+ const f = () => {
3
+ const s = S("traceId", ""), n = g(0), i = g(null), d = (r, e = {}) => {
4
+ const t = r instanceof Error ? r.message : String(r), o = {
5
+ ...e,
6
+ errorMessage: t,
7
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
8
+ userAgent: navigator.userAgent,
9
+ url: window.location.href,
10
+ traceId: s || void 0
11
+ };
12
+ return n.value += 1, r instanceof Error && (i.value = r), window.Sentry && window.Sentry.captureException(r, {
13
+ tags: {
14
+ component: e.component,
15
+ operation: e.operation,
16
+ source: "guido"
17
+ },
18
+ contexts: {
19
+ guido: o
20
+ },
21
+ extra: {
22
+ traceId: s || void 0
23
+ }
24
+ }), window.FS && window.FS("event", "guido_error", {
25
+ errorMessageStr: t,
26
+ componentStr: e.component || "unknown",
27
+ operationStr: e.operation || "unknown",
28
+ templateIdStr: e.templateId || "",
29
+ userIdStr: e.userId || "",
30
+ traceIdStr: s || "",
31
+ errorCountInt: n.value,
32
+ timestampInt: Date.now()
33
+ }), o;
34
+ }, c = (r, e, t = {}, o = !0) => {
35
+ const a = r instanceof Error ? r : new Error(String(r)), u = a.message, p = {
36
+ component: "stripo-wrapper",
37
+ operation: e,
38
+ ...t,
39
+ errorMessage: u,
40
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
41
+ userAgent: navigator.userAgent,
42
+ url: window.location.href
43
+ };
44
+ return n.value += 1, i.value = a, o && window.Sentry && window.Sentry.captureException(a, {
45
+ tags: {
46
+ component: "stripo-wrapper",
47
+ operation: e
48
+ },
49
+ contexts: {
50
+ guido: p
51
+ }
52
+ }), o && window.FS && window.FS("event", "guido_stripo_error", {
53
+ errorMessageStr: u,
54
+ operationStr: e || "unknown",
55
+ timestampInt: Date.now()
56
+ }), p;
57
+ }, w = (r, e, t = {}) => {
58
+ const o = new Error(
59
+ `Timeout waiting for Stripo ${r} (${e}ms)`
60
+ );
61
+ return c(o, `${r}_timeout`, {
62
+ timeoutMs: e,
63
+ ...t
64
+ });
65
+ }, m = (r, e, t = {}) => new Promise((o, a) => {
66
+ setTimeout(() => {
67
+ const u = w(
68
+ e,
69
+ r,
70
+ t
71
+ );
72
+ a(new Error(u.errorMessage));
73
+ }, r);
74
+ });
75
+ return {
76
+ traceId: s,
77
+ errorCount: n,
78
+ lastError: i,
79
+ captureError: d,
80
+ captureStripoError: c,
81
+ captureTimeoutError: w,
82
+ createTimeoutPromise: m,
83
+ withTimeout: (r, e, t, o = {}) => Promise.race([
84
+ r,
85
+ m(e, t, o)
86
+ ]),
87
+ getErrorSummary: () => ({
88
+ errorCount: n.value,
89
+ lastError: i.value
90
+ }),
91
+ resetErrorTracking: () => {
92
+ n.value = 0, i.value = null;
93
+ }
94
+ };
95
+ };
96
+ export {
97
+ f as useErrorTracking
98
+ };
@@ -1,6 +1,6 @@
1
1
  import { provideValue as o, useInjectedValue as t } from "./useProvideInject.js";
2
- const r = Symbol.for("guido.back"), n = Symbol.for("guido.save.start"), c = Symbol.for("guido.save.complete"), a = Symbol.for("guido.test.email.click"), i = (e) => {
3
- o(r, e.onBack), o(n, e.onSaveStart), o(c, e.onSaveComplete), o(a, e.onTestEmailClick);
2
+ const r = Symbol.for("guido.back"), n = Symbol.for("guido.save.start"), a = Symbol.for("guido.save.complete"), s = (e) => {
3
+ o(r, e.onBack), o(n, e.onSaveStart), o(a, e.onSaveComplete);
4
4
  }, u = () => {
5
5
  try {
6
6
  return t(r);
@@ -9,7 +9,7 @@ const r = Symbol.for("guido.back"), n = Symbol.for("guido.save.start"), c = Symb
9
9
  "useBack: No back handler provided. Make sure Guido component is in the component tree."
10
10
  );
11
11
  }
12
- }, l = () => {
12
+ }, d = () => {
13
13
  try {
14
14
  return t(n);
15
15
  } catch {
@@ -17,31 +17,21 @@ const r = Symbol.for("guido.back"), n = Symbol.for("guido.save.start"), c = Symb
17
17
  "useSaveStart: No save start handler provided. Make sure Guido component is in the component tree."
18
18
  );
19
19
  }
20
- }, d = () => {
21
- try {
22
- return t(c);
23
- } catch {
24
- throw new Error(
25
- "useSaveComplete: No save complete handler provided. Make sure Guido component is in the component tree."
26
- );
27
- }
28
- }, m = () => {
20
+ }, i = () => {
29
21
  try {
30
22
  return t(a);
31
23
  } catch {
32
24
  throw new Error(
33
- "useTestEmailClick: No test email click handler provided. Make sure Guido component is in the component tree."
25
+ "useSaveComplete: No save complete handler provided. Make sure Guido component is in the component tree."
34
26
  );
35
27
  }
36
28
  };
37
29
  export {
38
30
  r as BACK_KEY,
39
- c as SAVE_COMPLETE_KEY,
31
+ a as SAVE_COMPLETE_KEY,
40
32
  n as SAVE_START_KEY,
41
- a as TEST_EMAIL_CLICK_KEY,
42
- i as provideGuidoActions,
33
+ s as provideGuidoActions,
43
34
  u as useBack,
44
- d as useSaveComplete,
45
- l as useSaveStart,
46
- m as useTestEmailClick
35
+ i as useSaveComplete,
36
+ d as useSaveStart
47
37
  };
@@ -1,86 +1,123 @@
1
- import { getCsrfToken as H } from "../utils/genericUtil.js";
2
- import { ref as p, computed as T } from "vue";
3
- const k = (b = {}) => {
4
- const h = p(!1), a = p(null), u = p(null), g = T(() => h.value), y = T(() => a.value !== null), v = {
1
+ import { getCsrfToken as S } from "../utils/genericUtil.js";
2
+ import { ref as h, computed as w } from "vue";
3
+ let b;
4
+ const g = async () => {
5
+ if (!b)
6
+ try {
7
+ const { useApiErrorTracking: E } = await import("./useApiErrorTracking.js");
8
+ b = E();
9
+ } catch {
10
+ }
11
+ return b;
12
+ }, M = (E = {}) => {
13
+ const d = h(!1), i = h(null), l = h(null), P = w(() => d.value), k = w(() => i.value !== null), v = {
5
14
  baseURL: "",
6
15
  timeout: 1e4,
7
16
  retry: 0,
8
17
  retryDelay: 1e3,
9
18
  headers: {
10
19
  "Content-Type": "application/json",
11
- "X-CSRF-TOKEN": H()
20
+ "X-CSRF-TOKEN": S()
12
21
  },
13
- ...b
14
- }, w = (e, s) => {
15
- if (e.startsWith("http://") || e.startsWith("https://"))
16
- return e;
17
- const t = s || v.baseURL || "";
18
- return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
19
- }, P = (e) => new Promise((s, t) => {
22
+ ...E
23
+ }, C = (t, s) => {
24
+ if (t.startsWith("http://") || t.startsWith("https://"))
25
+ return t;
26
+ const e = s || v.baseURL || "";
27
+ return e.endsWith("/") && t.startsWith("/") ? `${e}${t.slice(1)}` : e.endsWith("/") || t.startsWith("/") ? `${e}${t}` : `${e}/${t}`;
28
+ }, A = (t) => new Promise((s, e) => {
20
29
  setTimeout(() => {
21
- t(new Error("Request timeout"));
22
- }, e);
23
- }), x = (e) => new Promise((s) => {
24
- setTimeout(s, e);
25
- }), i = async (e, s, t, D = {}) => {
26
- a.value = null, h.value = !0, u.value = new AbortController();
27
- const n = { ...v, ...D }, L = w(s, n.baseURL), c = {
28
- method: e,
30
+ e(new Error("Request timeout"));
31
+ }, t);
32
+ }), $ = (t) => new Promise((s) => {
33
+ setTimeout(() => {
34
+ s();
35
+ }, t);
36
+ }), c = async (t, s, e, L = {}) => {
37
+ i.value = null, d.value = !0, l.value = new AbortController();
38
+ const n = { ...v, ...L }, T = C(s, n.baseURL), m = {
39
+ method: t,
29
40
  headers: { ...n.headers },
30
- signal: u.value.signal,
41
+ signal: l.value.signal,
31
42
  ...n
32
43
  };
33
- t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
34
- const E = async (m = 0) => {
44
+ e && ["POST", "PUT", "PATCH"].includes(t) && (e instanceof FormData ? (delete m.headers["Content-Type"], m.body = e) : m.body = JSON.stringify(e));
45
+ const y = async (f = 0) => {
35
46
  try {
36
- const o = [fetch(L, c)];
37
- n.timeout && o.push(P(n.timeout));
47
+ const o = [fetch(T, m)];
48
+ n.timeout && o.push(A(n.timeout));
38
49
  const r = await Promise.race(o);
39
50
  if (!r.ok) {
40
- const O = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(O);
41
- throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
51
+ const O = `HTTP Error: ${r.status} ${r.statusText}`, p = new Error(O);
52
+ p.status = r.status, p.statusText = r.statusText, p.response = r;
53
+ const x = await g();
54
+ throw x && x.captureHttpError(p, T, {
55
+ method: t,
56
+ statusCode: r.status,
57
+ statusText: r.statusText
58
+ }), p;
42
59
  }
43
- let f;
44
- const l = r.headers.get("content-type");
45
- return l != null && l.includes("application/json") ? f = await r.json() : l != null && l.includes("text/") ? f = await r.text() : f = await r.blob(), {
46
- data: f,
60
+ let a;
61
+ const u = r.headers.get("content-type");
62
+ return u != null && u.includes("application/json") ? a = await r.json() : u != null && u.includes("text/") ? a = await r.text() : a = await r.blob(), {
63
+ data: a,
47
64
  status: r.status,
48
65
  statusText: r.statusText,
49
66
  headers: r.headers
50
67
  };
51
68
  } catch (o) {
52
69
  const r = o instanceof Error && o.name === "AbortError";
53
- if (m < (n.retry || 0) && !r)
54
- return await x(n.retryDelay || 1e3), E(m + 1);
55
- throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
70
+ if (f < (n.retry || 0) && !r)
71
+ return await $(n.retryDelay || 1e3), y(f + 1);
72
+ if (o instanceof Error)
73
+ if (o.name === "AbortError")
74
+ i.value = { message: "Request was cancelled" };
75
+ else {
76
+ i.value = { message: o.message };
77
+ const a = await g();
78
+ a && a.captureNetworkError(o, T, {
79
+ method: t,
80
+ attemptNumber: f + 1,
81
+ timeoutMs: n.timeout
82
+ });
83
+ }
84
+ else {
85
+ i.value = o;
86
+ const a = await g();
87
+ a && o instanceof Error && a.captureNetworkError(o, T, {
88
+ method: t,
89
+ attemptNumber: f + 1
90
+ });
91
+ }
92
+ throw o;
56
93
  }
57
94
  };
58
95
  try {
59
- return await E();
96
+ return await y();
60
97
  } finally {
61
- h.value = !1, u.value = null;
98
+ d.value = !1, l.value = null;
62
99
  }
63
- }, C = (e, s) => i("GET", e, void 0, s), $ = (e, s, t) => i("POST", e, s, t), R = (e, s, t) => i("PUT", e, s, t), U = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), W = (e) => {
64
- u.value && u.value.abort(e);
65
- }, q = () => {
66
- a.value = null;
100
+ }, R = (t, s) => c("GET", t, void 0, s), U = (t, s, e) => c("POST", t, s, e), N = (t, s, e) => c("PUT", t, s, e), W = (t, s, e) => c("PATCH", t, s, e), q = (t, s) => c("DELETE", t, void 0, s), D = (t) => {
101
+ l.value && l.value.abort(t);
102
+ }, H = () => {
103
+ i.value = null;
67
104
  };
68
105
  return {
69
106
  // State
70
- loading: g,
71
- error: T(() => a.value),
72
- hasError: y,
107
+ loading: P,
108
+ error: w(() => i.value),
109
+ hasError: k,
73
110
  // Methods
74
- request: i,
75
- get: C,
76
- post: $,
77
- put: R,
78
- patch: U,
79
- delete: A,
80
- cancel: W,
81
- clearError: q
111
+ request: c,
112
+ get: R,
113
+ post: U,
114
+ put: N,
115
+ patch: W,
116
+ delete: q,
117
+ cancel: D,
118
+ clearError: H
82
119
  };
83
120
  };
84
121
  export {
85
- k as useHttp
122
+ M as useHttp
86
123
  };