@edx/frontend-app-alacarte-checkout 1.42.0 → 1.44.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 (68) hide show
  1. package/dist/Main.js.map +1 -1
  2. package/dist/analytics/buildProducts.d.ts +13 -0
  3. package/dist/analytics/buildProducts.js +65 -0
  4. package/dist/analytics/buildProducts.js.map +1 -0
  5. package/dist/analytics/events.d.ts +73 -0
  6. package/dist/analytics/events.js +12 -0
  7. package/dist/analytics/events.js.map +1 -0
  8. package/dist/analytics/segmentClient.d.ts +22 -0
  9. package/dist/analytics/segmentClient.js +70 -0
  10. package/dist/analytics/segmentClient.js.map +1 -0
  11. package/dist/analytics/trackEvent.d.ts +22 -0
  12. package/dist/analytics/trackEvent.js +69 -0
  13. package/dist/analytics/trackEvent.js.map +1 -0
  14. package/dist/app.js +1 -1
  15. package/dist/app.js.map +1 -1
  16. package/dist/components/CheckoutGate/CheckoutGate.js +3 -3
  17. package/dist/components/CheckoutGate/CheckoutGate.js.map +1 -1
  18. package/dist/components/OrderHistory/OrderHistoryDetails.js +130 -9
  19. package/dist/components/OrderHistory/OrderHistoryDetails.js.map +1 -1
  20. package/dist/components/OrderHistory/OrderList.js +1 -1
  21. package/dist/components/OrderHistory/OrderList.js.map +1 -1
  22. package/dist/components/OrderHistory/ProgramItemsTable.d.ts +3 -3
  23. package/dist/components/OrderHistory/ProgramItemsTable.js +15 -9
  24. package/dist/components/OrderHistory/ProgramItemsTable.js.map +1 -1
  25. package/dist/components/OrderHistory/data/orderDetailsData.d.ts +18 -10
  26. package/dist/components/OrderHistory/data/orderDetailsData.js +1 -59
  27. package/dist/components/OrderHistory/data/orderDetailsData.js.map +1 -1
  28. package/dist/components/OrderHistory/data/receiptRows.d.ts +2 -2
  29. package/dist/components/OrderHistory/data/receiptRows.js +5 -5
  30. package/dist/components/OrderHistory/data/receiptRows.js.map +1 -1
  31. package/dist/components/OrderHistory/messages.js +9 -9
  32. package/dist/components/OrderHistory/messages.js.map +1 -1
  33. package/dist/data/hooks/keys.d.ts +1 -0
  34. package/dist/data/hooks/keys.js +1 -0
  35. package/dist/data/hooks/keys.js.map +1 -1
  36. package/dist/data/hooks/useAlacarteCheckout.js +152 -9
  37. package/dist/data/hooks/useAlacarteCheckout.js.map +1 -1
  38. package/dist/data/hooks/useAlacarteQueries.d.ts +2 -0
  39. package/dist/data/hooks/useAlacarteQueries.js +11 -0
  40. package/dist/data/hooks/useAlacarteQueries.js.map +1 -1
  41. package/dist/data/hooks/useCheckoutGate.d.ts +2 -0
  42. package/dist/data/hooks/useCheckoutGate.js +35 -16
  43. package/dist/data/hooks/useCheckoutGate.js.map +1 -1
  44. package/dist/data/hooks/useCheckoutQueries.d.ts +7 -1
  45. package/dist/data/hooks/useCheckoutQueries.js +32 -2
  46. package/dist/data/hooks/useCheckoutQueries.js.map +1 -1
  47. package/dist/routes.js +1 -1
  48. package/dist/routes.js.map +1 -1
  49. package/dist/types/alacarte.d.ts +1 -0
  50. package/dist/types/alacarte.js.map +1 -1
  51. package/dist/utils/alacarteApi.d.ts +1 -0
  52. package/dist/utils/alacarteApi.js +8 -1
  53. package/dist/utils/alacarteApi.js.map +1 -1
  54. package/dist/utils/alacarteCheckout.d.ts +3 -1
  55. package/dist/utils/alacarteCheckout.js +3 -2
  56. package/dist/utils/alacarteCheckout.js.map +1 -1
  57. package/dist/utils/alacarteQueries.d.ts +2 -0
  58. package/dist/utils/alacarteQueries.js +4 -0
  59. package/dist/utils/alacarteQueries.js.map +1 -1
  60. package/dist/utils/graphqlClient.d.ts +5 -1
  61. package/dist/utils/graphqlClient.js +14 -1
  62. package/dist/utils/graphqlClient.js.map +1 -1
  63. package/dist/utils/orderHistory.js +2 -2
  64. package/dist/utils/orderHistory.js.map +1 -1
  65. package/dist/utils/provision.d.ts +22 -1
  66. package/dist/utils/provision.js +172 -23
  67. package/dist/utils/provision.js.map +1 -1
  68. package/package.json +2 -1
package/dist/Main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","sourceRoot":"","sources":["../src/Main.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,cAAc,CAAC;AAEtB,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,OAAO,CACL,MAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,aAC9B,KAAC,MAAM,cACL,0BACG,aAAa,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE;wBAC9C,QAAQ,EAAE,aAAa,EAAE,CAAC,QAAQ;qBACnC,CAAC,GACI,GACD,EACT,KAAC,WAAW,cACV,eAAM,SAAS,EAAC,gCAAgC,YAC9C,KAAC,MAAM,KAAG,GACL,GACK,IACK,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n CurrentAppProvider,\n getSiteConfig,\n useIntl,\n} from '@openedx/frontend-base';\nimport { Helmet } from 'react-helmet';\nimport { Outlet } from 'react-router-dom';\nimport { NuqsAdapter } from 'nuqs/adapters/react-router/v6';\nimport { appId } from './constants';\nimport messages from './messages';\n\nimport './style.scss';\n\nconst Main = () => {\n const { formatMessage } = useIntl();\n return (\n <CurrentAppProvider appId={appId}>\n <Helmet>\n <title>\n {formatMessage(messages['template.page.title'], {\n siteName: getSiteConfig().siteName,\n })}\n </title>\n </Helmet>\n <NuqsAdapter>\n <main className=\"d-flex flex-column flex-grow-1\">\n <Outlet />\n </main>\n </NuqsAdapter>\n </CurrentAppProvider>\n );\n};\n\nexport default Main;\n"]}
1
+ {"version":3,"file":"Main.js","sourceRoot":"","sources":["../src/Main.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,OAAO,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,cAAc,CAAC;AAEtB,MAAM,IAAI,GAAG,GAAG,EAAE;IAChB,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IAEpC,OAAO,CACL,MAAC,kBAAkB,IAAC,KAAK,EAAE,KAAK,aAC9B,KAAC,MAAM,cACL,0BACG,aAAa,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE;wBAC9C,QAAQ,EAAE,aAAa,EAAE,CAAC,QAAQ;qBACnC,CAAC,GACI,GACD,EACT,KAAC,WAAW,cACV,eAAM,SAAS,EAAC,gCAAgC,YAC9C,KAAC,MAAM,KAAG,GACL,GACK,IACK,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n CurrentAppProvider,\n getSiteConfig,\n useIntl,\n} from '@openedx/frontend-base';\nimport { Helmet } from 'react-helmet';\nimport { Outlet } from 'react-router-dom';\nimport { NuqsAdapter } from 'nuqs/adapters/react-router/v6';\nimport { appId } from './constants';\nimport messages from './messages';\n\nimport './style.scss';\n\nconst Main = () => {\n const { formatMessage } = useIntl();\n\n return (\n <CurrentAppProvider appId={appId}>\n <Helmet>\n <title>\n {formatMessage(messages['template.page.title'], {\n siteName: getSiteConfig().siteName,\n })}\n </title>\n </Helmet>\n <NuqsAdapter>\n <main className=\"d-flex flex-column flex-grow-1\">\n <Outlet />\n </main>\n </NuqsAdapter>\n </CurrentAppProvider>\n );\n};\n\nexport default Main;\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Builds the Segment `products` array from checkout and catalog data.
3
+ *
4
+ * The checkout line gives us name, price, and kind. The catalog detail
5
+ * (CourseDetail / ProgramDetail) fills in category, url, image, and brand.
6
+ * Fields that the checkout doesn't carry are set to null.
7
+ */
8
+ import type { AlacarteLine, PlacedOrderLine, ProductDetail } from '../types/alacarte';
9
+ import type { SegmentProduct } from './events';
10
+ /** Build products from a checkout line + optional catalog detail. */
11
+ export declare function buildProductsFromLine(line: AlacarteLine, productDetail: ProductDetail | null): SegmentProduct[];
12
+ /** Build products from placed order lines + optional catalog detail. */
13
+ export declare function buildProductsFromOrder(lines: PlacedOrderLine[], productDetail: ProductDetail | null): SegmentProduct[];
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Builds the Segment `products` array from checkout and catalog data.
3
+ *
4
+ * The checkout line gives us name, price, and kind. The catalog detail
5
+ * (CourseDetail / ProgramDetail) fills in category, url, image, and brand.
6
+ * Fields that the checkout doesn't carry are set to null.
7
+ */
8
+ function isCourseDetail(d) {
9
+ return 'maId' in d;
10
+ }
11
+ /** Build products from a checkout line + optional catalog detail. */
12
+ export function buildProductsFromLine(line, productDetail) {
13
+ var _a, _b, _c, _d, _e, _f, _g, _h;
14
+ const courseDetail = productDetail && isCourseDetail(productDetail) ? productDetail : null;
15
+ if (line.kind === 'course') {
16
+ return [{
17
+ product_id: line.courseUid,
18
+ sku: null,
19
+ name: line.courseName,
20
+ price: (_b = (_a = line.price) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0,
21
+ quantity: 1,
22
+ category: (_c = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tPrimarySubjectArea) !== null && _c !== void 0 ? _c : null,
23
+ url: (_d = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tUrlCourse) !== null && _d !== void 0 ? _d : null,
24
+ lob: 'edx',
25
+ image_url: (_e = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.imageUrl) !== null && _e !== void 0 ? _e : null,
26
+ brand: (_f = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tBrandText) !== null && _f !== void 0 ? _f : null,
27
+ product_type: 'edX Course Entitlement',
28
+ }];
29
+ }
30
+ // Program: one product entry for the program itself.
31
+ return [{
32
+ product_id: line.programId,
33
+ sku: null,
34
+ name: line.programName,
35
+ price: (_h = (_g = line.price) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : 0,
36
+ quantity: 1,
37
+ category: null,
38
+ url: null,
39
+ lob: 'edx',
40
+ image_url: null,
41
+ brand: null,
42
+ product_type: 'program',
43
+ }];
44
+ }
45
+ /** Build products from placed order lines + optional catalog detail. */
46
+ export function buildProductsFromOrder(lines, productDetail) {
47
+ const courseDetail = productDetail && isCourseDetail(productDetail) ? productDetail : null;
48
+ return lines.map((line) => {
49
+ var _a, _b, _c, _d, _e;
50
+ return ({
51
+ product_id: (_a = line.productId) !== null && _a !== void 0 ? _a : line.lineId,
52
+ sku: null,
53
+ name: line.name,
54
+ price: line.amounts.price,
55
+ quantity: 1,
56
+ category: (_b = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tPrimarySubjectArea) !== null && _b !== void 0 ? _b : null,
57
+ url: (_c = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tUrlCourse) !== null && _c !== void 0 ? _c : null,
58
+ lob: 'edx',
59
+ image_url: (_d = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.imageUrl) !== null && _d !== void 0 ? _d : null,
60
+ brand: (_e = courseDetail === null || courseDetail === void 0 ? void 0 : courseDetail.tBrandText) !== null && _e !== void 0 ? _e : null,
61
+ product_type: line.kind === 'course' ? 'edX Course Entitlement' : 'program',
62
+ });
63
+ });
64
+ }
65
+ //# s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ent":["/**\n * Builds the Segment `products` array from checkout and catalog data.\n *\n * The checkout line gives us name, price, and kind. The catalog detail\n * (CourseDetail / ProgramDetail) fills in category, url, image, and brand.\n * Fields that the checkout doesn't carry are set to null.\n */\n\nimport type { AlacarteLine, PlacedOrderLine, ProductDetail } from '../types/alacarte';\nimport type { CourseDetail } from '../types';\nimport type { SegmentProduct } from './events';\n\nfunction isCourseDetail(d: ProductDetail): d is CourseDetail {\n return 'maId' in d;\n}\n\n/** Build products from a checkout line + optional catalog detail. */\nexport function buildProductsFromLine(\n line: AlacarteLine,\n productDetail: ProductDetail | null,\n): SegmentProduct[] {\n const courseDetail = productDetail && isCourseDetail(productDetail) ? productDetail : null;\n\n if (line.kind === 'course') {\n return [{\n product_id: line.courseUid,\n sku: null,\n name: line.courseName,\n price: line.price?.amount ?? 0,\n quantity: 1,\n category: courseDetail?.tPrimarySubjectArea ?? null,\n url: courseDetail?.tUrlCourse ?? null,\n lob: 'edx',\n image_url: courseDetail?.imageUrl ?? null,\n brand: courseDetail?.tBrandText ?? null,\n product_type: 'edX Course Entitlement',\n }];\n }\n\n // Program: one product entry for the program itself.\n return [{\n product_id: line.programId,\n sku: null,\n name: line.programName,\n price: line.price?.amount ?? 0,\n quantity: 1,\n category: null,\n url: null,\n lob: 'edx',\n image_url: null,\n brand: null,\n product_type: 'program',\n }];\n}\n\n/** Build products from placed order lines + optional catalog detail. */\nexport function buildProductsFromOrder(\n lines: PlacedOrderLine[],\n productDetail: ProductDetail | null,\n): SegmentProduct[] {\n const courseDetail = productDetail && isCourseDetail(productDetail) ? productDetail : null;\n\n return lines.map((line) => ({\n product_id: line.productId ?? line.lineId,\n sku: null,\n name: line.name,\n price: line.amounts.price,\n quantity: 1,\n category: courseDetail?.tPrimarySubjectArea ?? null,\n url: courseDetail?.tUrlCourse ?? null,\n lob: 'edx',\n image_url: courseDetail?.imageUrl ?? null,\n brand: courseDetail?.tBrandText ?? null,\n product_type: line.kind === 'course' ? 'edX Course Entitlement' : 'program',\n }));\n}\n"]}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Typed event catalog for à la carte checkout analytics.
3
+ *
4
+ * Every event that this app can send must be listed here. If an event name is
5
+ * not in EventCatalog, trackEvent() will reject it at compile time.
6
+ *
7
+ * Client-side events are forwarded to Segment via the app's own source
8
+ * (alacarte-{env}-ui). Each event carries a track_plan_id so it can be
9
+ * distinguished from the server-side copy of the same event name.
10
+ */
11
+ export interface SegmentProduct {
12
+ product_id: string;
13
+ sku: string | null;
14
+ name: string;
15
+ price: number;
16
+ quantity: number;
17
+ category: string | null;
18
+ url: string | null;
19
+ lob: string;
20
+ image_url: string | null;
21
+ brand: string | null;
22
+ product_type: string | null;
23
+ }
24
+ export interface CouponAppliedProperties {
25
+ checkoutType: 'a_la_carte';
26
+ track_plan_id: 30;
27
+ trigger_source: 'client-side';
28
+ cart_id: string;
29
+ checkout_id: string;
30
+ coupon_name: string;
31
+ discount: number;
32
+ currency: string;
33
+ products: SegmentProduct[];
34
+ }
35
+ export interface PaymentInfoEnteredProperties {
36
+ checkoutType: 'a_la_carte';
37
+ track_plan_id: 31;
38
+ trigger_source: 'client-side';
39
+ cart_id: string;
40
+ checkout_id: string;
41
+ currency: string;
42
+ revenue: number;
43
+ payment_method: string;
44
+ discount: number;
45
+ products: SegmentProduct[];
46
+ }
47
+ export interface OrderCompletedProperties {
48
+ checkoutType: 'a_la_carte';
49
+ track_plan_id: 32;
50
+ trigger_source: 'client-side';
51
+ order_id: string;
52
+ checkout_id: string;
53
+ total: number;
54
+ revenue: number;
55
+ currency: string;
56
+ tax: number;
57
+ coupon: string | null;
58
+ coupon_name: string[];
59
+ discount: number;
60
+ processor_name: string;
61
+ payment_method: string;
62
+ products: SegmentProduct[];
63
+ }
64
+ export interface EventCatalog {
65
+ /** track_plan_id: 30 — discount code successfully applied. */
66
+ 'Coupon Applied': CouponAppliedProperties;
67
+ /** track_plan_id: 31 — learner submits payment form (including free orders). */
68
+ 'Payment Info Entered': PaymentInfoEnteredProperties;
69
+ /** track_plan_id: 32 — browser receives order confirmation. */
70
+ 'Order Completed': OrderCompletedProperties;
71
+ }
72
+ /** Union of every registered event name. */
73
+ export type EventName = keyof EventCatalog;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Typed event catalog for à la carte checkout analytics.
3
+ *
4
+ * Every event that this app can send must be listed here. If an event name is
5
+ * not in EventCatalog, trackEvent() will reject it at compile time.
6
+ *
7
+ * Client-side events are forwarded to Segment via the app's own source
8
+ * (alacarte-{env}-ui). Each event carries a track_plan_id so it can be
9
+ * distinguished from the server-side copy of the same event name.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/analytics/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG","sourcesContent":["/**\n * Typed event catalog for à la carte checkout analytics.\n *\n * Every event that this app can send must be listed here. If an event name is\n * not in EventCatalog, trackEvent() will reject it at compile time.\n *\n * Client-side events are forwarded to Segment via the app's own source\n * (alacarte-{env}-ui). Each event carries a track_plan_id so it can be\n * distinguished from the server-side copy of the same event name.\n */\n\n// ── Product object (shared across events) ────────────────────────────────────\n\nexport interface SegmentProduct {\n product_id: string,\n sku: string | null,\n name: string,\n price: number,\n quantity: number,\n category: string | null,\n url: string | null,\n lob: string,\n image_url: string | null,\n brand: string | null,\n product_type: string | null,\n}\n\n// ── Event property interfaces ────────────────────────────────────────────────\n\nexport interface CouponAppliedProperties {\n checkoutType: 'a_la_carte',\n track_plan_id: 30,\n trigger_source: 'client-side',\n cart_id: string,\n checkout_id: string,\n coupon_name: string,\n discount: number,\n currency: string,\n products: SegmentProduct[],\n}\n\nexport interface PaymentInfoEnteredProperties {\n checkoutType: 'a_la_carte',\n track_plan_id: 31,\n trigger_source: 'client-side',\n cart_id: string,\n checkout_id: string,\n currency: string,\n revenue: number,\n payment_method: string,\n discount: number,\n products: SegmentProduct[],\n}\n\nexport interface OrderCompletedProperties {\n checkoutType: 'a_la_carte',\n track_plan_id: 32,\n trigger_source: 'client-side',\n order_id: string,\n checkout_id: string,\n total: number,\n revenue: number,\n currency: string,\n tax: number,\n coupon: string | null,\n coupon_name: string[],\n discount: number,\n processor_name: string,\n payment_method: string,\n products: SegmentProduct[],\n}\n\n// ── Event catalog ────────────────────────────────────────────────────────────\n\nexport interface EventCatalog {\n /** track_plan_id: 30 — discount code successfully applied. */\n 'Coupon Applied': CouponAppliedProperties,\n\n /** track_plan_id: 31 — learner submits payment form (including free orders). */\n 'Payment Info Entered': PaymentInfoEnteredProperties,\n\n /** track_plan_id: 32 — browser receives order confirmation. */\n 'Order Completed': OrderCompletedProperties,\n}\n\n/** Union of every registered event name. */\nexport type EventName = keyof EventCatalog;\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Isolated Segment client for à la carte checkout.
3
+ *
4
+ * Uses @segment/analytics-next so it does NOT touch window.analytics and
5
+ * coexists with the shell's site-wide Segment instance.
6
+ *
7
+ * The client is created lazily on first use. When
8
+ * ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY is absent or empty, no client is
9
+ * created and all tracking calls are silently skipped.
10
+ */
11
+ import { AnalyticsBrowser } from '@segment/analytics-next';
12
+ /**
13
+ * Return the shared AnalyticsBrowser instance, creating it on first call.
14
+ * Returns `null` when the write key is not configured.
15
+ */
16
+ export declare function getSegmentClient(): AnalyticsBrowser | null;
17
+ /**
18
+ * Identify the current user. Call once after the edX session is resolved.
19
+ */
20
+ export declare function identifyUser(edxUserId: string): void;
21
+ /** Reset client state — useful for testing. */
22
+ export declare function resetSegmentClient(): void;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Isolated Segment client for à la carte checkout.
3
+ *
4
+ * Uses @segment/analytics-next so it does NOT touch window.analytics and
5
+ * coexists with the shell's site-wide Segment instance.
6
+ *
7
+ * The client is created lazily on first use. When
8
+ * ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY is absent or empty, no client is
9
+ * created and all tracking calls are silently skipped.
10
+ */
11
+ import { AnalyticsBrowser } from '@segment/analytics-next';
12
+ import { getAppConfig, getSiteConfig, EnvironmentTypes } from '@openedx/frontend-base';
13
+ import { appId } from '../constants';
14
+ let client = null;
15
+ let initialised = false;
16
+ function isDevelopment() {
17
+ return getSiteConfig().environment === EnvironmentTypes.DEVELOPMENT;
18
+ }
19
+ /**
20
+ * Return the shared AnalyticsBrowser instance, creating it on first call.
21
+ * Returns `null` when the write key is not configured.
22
+ */
23
+ export function getSegmentClient() {
24
+ if (initialised)
25
+ return client;
26
+ initialised = true;
27
+ try {
28
+ const config = getAppConfig(appId);
29
+ const writeKey = config.ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY;
30
+ // In development, require DEV_ENABLE_SEGMENT=true to actually load the
31
+ // client. This keeps local dev quiet by default while still allowing
32
+ // on-demand testing against the real Segment source.
33
+ if (isDevelopment() && config.DEV_ENABLE_SEGMENT !== true) {
34
+ console.info('[analytics] DEV_ENABLE_SEGMENT is not true — Segment disabled locally. Set DEV_ENABLE_SEGMENT: true in site.config.dev.tsx to push events.');
35
+ return null;
36
+ }
37
+ if (!writeKey) {
38
+ if (isDevelopment()) {
39
+ console.info('[analytics] ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY not set — tracking disabled.');
40
+ }
41
+ return null;
42
+ }
43
+ client = AnalyticsBrowser.load({ writeKey });
44
+ if (isDevelopment()) {
45
+ console.info('[analytics] Segment client initialised (DEV_ENABLE_SEGMENT=true).');
46
+ }
47
+ }
48
+ catch (error) {
49
+ console.error('[analytics] Failed to initialise Segment client:', error);
50
+ }
51
+ return client;
52
+ }
53
+ /**
54
+ * Identify the current user. Call once after the edX session is resolved.
55
+ */
56
+ export function identifyUser(edxUserId) {
57
+ const analytics = getSegmentClient();
58
+ if (!analytics)
59
+ return;
60
+ analytics.identify(edxUserId);
61
+ if (isDevelopment()) {
62
+ console.info(`[analytics] identify(${edxUserId})`);
63
+ }
64
+ }
65
+ /** Reset client state — useful for testing. */
66
+ export function resetSegmentClient() {
67
+ client = null;
68
+ initialised = false;
69
+ }
70
+ //# sourceMappingURL=segmentClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmentClient.js","sourceRoot":"","sources":["../../src/analytics/segmentClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,IAAI,MAAM,GAA4B,IAAI,CAAC;AAC3C,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,SAAS,aAAa;IACpB,OAAO,aAAa,EAAE,CAAC,WAAW,KAAK,gBAAgB,CAAC,WAAW,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,WAAW;QAAE,OAAO,MAAM,CAAC;IAC/B,WAAW,GAAG,IAAI,CAAC;IAEnB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,mCAAyD,CAAC;QAElF,uEAAuE;QACvE,sEAAsE;QACtE,qDAAqD;QACrD,IAAI,aAAa,EAAE,IAAI,MAAM,CAAC,kBAAkB,KAAK,IAAI,EAAE,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,4IAA4I,CAAC,CAAC;YAC3J,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,aAAa,EAAE,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;YAC/F,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE7C,IAAI,aAAa,EAAE,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;IACrC,IAAI,CAAC,SAAS;QAAE,OAAO;IAEvB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAE9B,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,wBAAwB,SAAS,GAAG,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,IAAI,CAAC;IACd,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC","sourcesContent":["/**\n * Isolated Segment client for à la carte checkout.\n *\n * Uses @segment/analytics-next so it does NOT touch window.analytics and\n * coexists with the shell's site-wide Segment instance.\n *\n * The client is created lazily on first use. When\n * ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY is absent or empty, no client is\n * created and all tracking calls are silently skipped.\n */\n\nimport { AnalyticsBrowser } from '@segment/analytics-next';\nimport { getAppConfig, getSiteConfig, EnvironmentTypes } from '@openedx/frontend-base';\nimport { appId } from '../constants';\n\nlet client: AnalyticsBrowser | null = null;\nlet initialised = false;\n\nfunction isDevelopment(): boolean {\n return getSiteConfig().environment === EnvironmentTypes.DEVELOPMENT;\n}\n\n/**\n * Return the shared AnalyticsBrowser instance, creating it on first call.\n * Returns `null` when the write key is not configured.\n */\nexport function getSegmentClient(): AnalyticsBrowser | null {\n if (initialised) return client;\n initialised = true;\n\n try {\n const config = getAppConfig(appId);\n const writeKey = config.ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY as string | undefined;\n\n // In development, require DEV_ENABLE_SEGMENT=true to actually load the\n // client. This keeps local dev quiet by default while still allowing\n // on-demand testing against the real Segment source.\n if (isDevelopment() && config.DEV_ENABLE_SEGMENT !== true) {\n console.info('[analytics] DEV_ENABLE_SEGMENT is not true — Segment disabled locally. Set DEV_ENABLE_SEGMENT: true in site.config.dev.tsx to push events.');\n return null;\n }\n\n if (!writeKey) {\n if (isDevelopment()) {\n console.info('[analytics] ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY not set — tracking disabled.');\n }\n return null;\n }\n\n client = AnalyticsBrowser.load({ writeKey });\n\n if (isDevelopment()) {\n console.info('[analytics] Segment client initialised (DEV_ENABLE_SEGMENT=true).');\n }\n } catch (error) {\n console.error('[analytics] Failed to initialise Segment client:', error);\n }\n\n return client;\n}\n\n/**\n * Identify the current user. Call once after the edX session is resolved.\n */\nexport function identifyUser(edxUserId: string): void {\n const analytics = getSegmentClient();\n if (!analytics) return;\n\n analytics.identify(edxUserId);\n\n if (isDevelopment()) {\n console.info(`[analytics] identify(${edxUserId})`);\n }\n}\n\n/** Reset client state — useful for testing. */\nexport function resetSegmentClient(): void {\n client = null;\n initialised = false;\n}\n"]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * trackEvent / trackEventOnce — the only API that components and hooks use
3
+ * to send analytics events.
4
+ *
5
+ * - Never throws: errors are caught and logged.
6
+ * - In development, events are logged to the console.
7
+ * - trackEventOnce() prevents duplicate sends from StrictMode or remounts.
8
+ */
9
+ import type { EventCatalog, EventName } from './events';
10
+ /**
11
+ * Send a typed analytics event.
12
+ *
13
+ * Only events listed in EventCatalog are accepted.
14
+ */
15
+ export declare function trackEvent<E extends EventName>(event: E, properties: EventCatalog[E]): Promise<void>;
16
+ /**
17
+ * Send an event at most once per page load.
18
+ * Useful for events triggered by mounts — prevents StrictMode double-fires.
19
+ */
20
+ export declare function trackEventOnce<E extends EventName>(event: E, properties: EventCatalog[E]): Promise<void>;
21
+ /** Reset dedupe state — useful for testing. */
22
+ export declare function resetTrackEventOnce(): void;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * trackEvent / trackEventOnce — the only API that components and hooks use
3
+ * to send analytics events.
4
+ *
5
+ * - Never throws: errors are caught and logged.
6
+ * - In development, events are logged to the console.
7
+ * - trackEventOnce() prevents duplicate sends from StrictMode or remounts.
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ import { getSiteConfig, EnvironmentTypes } from '@openedx/frontend-base';
19
+ import { getSegmentClient } from './segmentClient';
20
+ const sentOnce = new Set();
21
+ function isDevelopment() {
22
+ return getSiteConfig().environment === EnvironmentTypes.DEVELOPMENT;
23
+ }
24
+ /**
25
+ * Send a typed analytics event.
26
+ *
27
+ * Only events listed in EventCatalog are accepted.
28
+ */
29
+ export function trackEvent(event, properties) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ try {
32
+ if (isDevelopment()) {
33
+ console.info(`[analytics] track("${event}")`, properties);
34
+ }
35
+ const analytics = getSegmentClient();
36
+ if (!analytics) {
37
+ if (isDevelopment()) {
38
+ console.warn(`[analytics] track("${event}") — Segment client is null, event NOT sent to Segment`);
39
+ }
40
+ return;
41
+ }
42
+ yield analytics.track(event, properties);
43
+ if (isDevelopment()) {
44
+ console.info(`[analytics] track("${event}") — dispatched to Segment`);
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(`[analytics] trackEvent("${event}") failed:`, error);
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * Send an event at most once per page load.
54
+ * Useful for events triggered by mounts — prevents StrictMode double-fires.
55
+ */
56
+ export function trackEventOnce(event, properties) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const key = `${event}:${JSON.stringify(properties)}`;
59
+ if (sentOnce.has(key))
60
+ return;
61
+ sentOnce.add(key);
62
+ return trackEvent(event, properties);
63
+ });
64
+ }
65
+ /** Reset dedupe state — useful for testing. */
66
+ export function resetTrackEventOnce() {
67
+ sentOnce.clear();
68
+ }
69
+ //# sourceMappingURL=trackEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackEvent.js","sourceRoot":"","sources":["../../src/analytics/trackEvent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;AAEnC,SAAS,aAAa;IACpB,OAAO,aAAa,EAAE,CAAC,WAAW,KAAK,gBAAgB,CAAC,WAAW,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAgB,UAAU,CAC9B,KAAQ,EACR,UAA2B;;QAE3B,IAAI,CAAC;YACH,IAAI,aAAa,EAAE,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,sBAAsB,KAAK,IAAI,EAAE,UAAU,CAAC,CAAC;YAC5D,CAAC;YAED,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;YACrC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,IAAI,aAAa,EAAE,EAAE,CAAC;oBACpB,OAAO,CAAC,IAAI,CAAC,sBAAsB,KAAK,wDAAwD,CAAC,CAAC;gBACpG,CAAC;gBACD,OAAO;YACT,CAAC;YAED,MAAM,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,UAAgD,CAAC,CAAC;YAC/E,IAAI,aAAa,EAAE,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,sBAAsB,KAAK,4BAA4B,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,KAAK,YAAY,EAAE,KAAK,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CAAA;AAED;;;GAGG;AACH,MAAM,UAAgB,cAAc,CAClC,KAAQ,EACR,UAA2B;;QAE3B,MAAM,GAAG,GAAG,GAAG,KAAK,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,IAAI,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAC9B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;CAAA;AAED,+CAA+C;AAC/C,MAAM,UAAU,mBAAmB;IACjC,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC","sourcesContent":["/**\n * trackEvent / trackEventOnce — the only API that components and hooks use\n * to send analytics events.\n *\n * - Never throws: errors are caught and logged.\n * - In development, events are logged to the console.\n * - trackEventOnce() prevents duplicate sends from StrictMode or remounts.\n */\n\nimport { getSiteConfig, EnvironmentTypes } from '@openedx/frontend-base';\nimport type { EventCatalog, EventName } from './events';\nimport { getSegmentClient } from './segmentClient';\n\nconst sentOnce = new Set<string>();\n\nfunction isDevelopment(): boolean {\n return getSiteConfig().environment === EnvironmentTypes.DEVELOPMENT;\n}\n\n/**\n * Send a typed analytics event.\n *\n * Only events listed in EventCatalog are accepted.\n */\nexport async function trackEvent<E extends EventName>(\n event: E,\n properties: EventCatalog[E],\n): Promise<void> {\n try {\n if (isDevelopment()) {\n console.info(`[analytics] track(\"${event}\")`, properties);\n }\n\n const analytics = getSegmentClient();\n if (!analytics) {\n if (isDevelopment()) {\n console.warn(`[analytics] track(\"${event}\") — Segment client is null, event NOT sent to Segment`);\n }\n return;\n }\n\n await analytics.track(event, properties as unknown as Record<string, unknown>);\n if (isDevelopment()) {\n console.info(`[analytics] track(\"${event}\") — dispatched to Segment`);\n }\n } catch (error) {\n console.error(`[analytics] trackEvent(\"${event}\") failed:`, error);\n }\n}\n\n/**\n * Send an event at most once per page load.\n * Useful for events triggered by mounts — prevents StrictMode double-fires.\n */\nexport async function trackEventOnce<E extends EventName>(\n event: E,\n properties: EventCatalog[E],\n): Promise<void> {\n const key = `${event}:${JSON.stringify(properties)}`;\n if (sentOnce.has(key)) return;\n sentOnce.add(key);\n return trackEvent(event, properties);\n}\n\n/** Reset dedupe state — useful for testing. */\nexport function resetTrackEventOnce(): void {\n sentOnce.clear();\n}\n"]}
package/dist/app.js CHANGED
@@ -5,7 +5,7 @@ const app = {
5
5
  appId,
6
6
  routes,
7
7
  slots,
8
- // Environment-specific values (STRIPE_PUBLIC_KEY, VIAX_API_URL, PAYPAL_CLIENT_ID)
8
+ // Environment-specific values (STRIPE_PUBLIC_KEY, VIAX_API_URL, PAYPAL_CLIENT_ID, ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY)
9
9
  // are supplied by site.config.{dev,stage,prod}.tsx at site build time.
10
10
  };
11
11
  export default app;
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,GAAG,GAAQ;IACf,KAAK;IACL,MAAM;IACN,KAAK;IACL,kFAAkF;IAClF,uEAAuE;CACxE,CAAC;AAEF,eAAe,GAAG,CAAC","sourcesContent":["import { App } from '@openedx/frontend-base';\nimport { appId } from '@src/constants';\nimport routes from '@src/routes';\nimport slots from '@src/slots';\n\nconst app: App = {\n appId,\n routes,\n slots,\n // Environment-specific values (STRIPE_PUBLIC_KEY, VIAX_API_URL, PAYPAL_CLIENT_ID)\n // are supplied by site.config.{dev,stage,prod}.tsx at site build time.\n};\n\nexport default app;\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,GAAG,GAAQ;IACf,KAAK;IACL,MAAM;IACN,KAAK;IACL,uHAAuH;IACvH,uEAAuE;CACxE,CAAC;AAEF,eAAe,GAAG,CAAC","sourcesContent":["import { App } from '@openedx/frontend-base';\nimport { appId } from '@src/constants';\nimport routes from '@src/routes';\nimport slots from '@src/slots';\n\nconst app: App = {\n appId,\n routes,\n slots,\n // Environment-specific values (STRIPE_PUBLIC_KEY, VIAX_API_URL, PAYPAL_CLIENT_ID, ALACARTE_CHECKOUT_SEGMENT_WRITE_KEY)\n // are supplied by site.config.{dev,stage,prod}.tsx at site build time.\n};\n\nexport default app;\n"]}
@@ -20,7 +20,7 @@ import messages from './Messages';
20
20
  const CheckoutGate = (_a) => {
21
21
  var { learnerDashboardUrl, homeUrl = '/', complianceCheckUrl, disableComplianceCheck, restrictCompliance } = _a, checkoutProps = __rest(_a, ["learnerDashboardUrl", "homeUrl", "complianceCheckUrl", "disableComplianceCheck", "restrictCompliance"]);
22
22
  const { formatMessage } = useIntl();
23
- const { gateStatus, userCountry, gateMessage } = useCheckoutGate({
23
+ const { gateStatus, userCountry, gateMessage, isAccountLinkError: accountLinkError } = useCheckoutGate({
24
24
  apiUrl: checkoutProps.apiUrl,
25
25
  edxSessionUrl: checkoutProps.edxSessionUrl,
26
26
  geolocationUrl: checkoutProps.geolocationUrl,
@@ -30,10 +30,10 @@ const CheckoutGate = (_a) => {
30
30
  learnerDashboardUrl,
31
31
  });
32
32
  if (gateStatus === 'loading') {
33
- return (_jsx("div", { className: "processing-screen", role: "status", "aria-live": "polite", children: _jsx(Spinner, { animation: "border", screenReaderText: "Checking your account\u2026" }) }));
33
+ return (_jsx("div", { className: "processing-screen", role: "status", "aria-live": "polite", children: _jsx(Spinner, { animation: "border", screenReaderText: "Loading" }) }));
34
34
  }
35
35
  if (gateStatus === 'error') {
36
- return (_jsxs(Alert, { variant: "danger", icon: ErrorIcon, children: [gateMessage !== null && gateMessage !== void 0 ? gateMessage : formatMessage(messages.defaultErrorMessage), ' ', learnerDashboardUrl && (_jsx("a", { href: learnerDashboardUrl, className: "alert-link", children: "Go to your learner dashboard" }))] }));
36
+ return (_jsxs(Alert, { variant: "danger", icon: ErrorIcon, children: [gateMessage !== null && gateMessage !== void 0 ? gateMessage : formatMessage(messages.defaultErrorMessage), ' ', !accountLinkError && learnerDashboardUrl && (_jsx("a", { href: learnerDashboardUrl, className: "alert-link", children: "Go to your learner dashboard" }))] }));
37
37
  }
38
38
  if (gateStatus === 'blocked') {
39
39
  return (_jsx(_Fragment, { children: _jsx(CountryUnavailableModal, { isOpen: true, homeUrl: homeUrl }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutGate.js","sourceRoot":"","sources":["../../../src/components/CheckoutGate/CheckoutGate.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAEzF,OAAO,QAAQ,MAAM,YAAY,CAAC;AAelC,MAAM,YAAY,GAAG,CAAC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WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAC,oBAAoB,IACpC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { Alert, Spinner } from '@openedx/paragon';\nimport { Error as ErrorIcon } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { useCheckoutGate } from '../../data/hooks/useCheckoutGate';\nimport Checkout from '../Checkout/Checkout';\nimport CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport type { CheckoutProps } from '../Checkout/Checkout';\nimport messages from './Messages';\n\nexport interface CheckoutGateProps extends CheckoutProps {\n /** URL linked in session-error recovery messaging. */\n learnerDashboardUrl?: string,\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** ALC-307 compliance-check endpoint — decides whether the learner is embargoed. */\n complianceCheckUrl?: string,\n /** When true, skip the compliance-check request. */\n disableComplianceCheck?: boolean,\n /** When true, skip the compliance-check request and show the blocked modal. */\n restrictCompliance?: boolean,\n}\n\nconst CheckoutGate = ({\n learnerDashboardUrl,\n homeUrl = '/',\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n ...checkoutProps\n}: CheckoutGateProps) => {\n const { formatMessage } = useIntl();\n const { gateStatus, userCountry, gateMessage } = useCheckoutGate({\n apiUrl: checkoutProps.apiUrl,\n edxSessionUrl: checkoutProps.edxSessionUrl,\n geolocationUrl: checkoutProps.geolocationUrl,\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n learnerDashboardUrl,\n });\n\n if (gateStatus === 'loading') {\n return (\n <div className=\"processing-screen\" role=\"status\" aria-live=\"polite\">\n <Spinner animation=\"border\" screenReaderText=\"Checking your account…\" />\n </div>\n );\n }\n\n if (gateStatus === 'error') {\n return (\n <Alert variant=\"danger\" icon={ErrorIcon}>\n {gateMessage\n ?? formatMessage(messages.defaultErrorMessage)}{' '}\n {learnerDashboardUrl && (\n <a href={learnerDashboardUrl} className=\"alert-link\">\n Go to your learner dashboard\n </a>\n )}\n </Alert>\n );\n }\n\n if (gateStatus === 'blocked') {\n return (\n <>\n <CountryUnavailableModal isOpen homeUrl={homeUrl} />\n </>\n );\n }\n return (\n <Checkout\n {...checkoutProps}\n userCountry={userCountry}\n homeUrl={homeUrl}\n orderHistoryUrl=\"/aca-order-history\"\n />\n );\n};\n\nexport default CheckoutGate;\n"]}
1
+ {"version":3,"file":"CheckoutGate.js","sourceRoot":"","sources":["../../../src/components/CheckoutGate/CheckoutGate.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,uBAAuB,MAAM,oDAAoD,CAAC;AAEzF,OAAO,QAAQ,MAAM,YAAY,CAAC;AAelC,MAAM,YAAY,GAAG,CAAC,EAOF,EAAE,EAAE;QAPF,EACpB,mBAAmB,EACnB,OAAO,GAAG,GAAG,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,OAEA,EADf,aAAa,cANI,wGAOrB,CADiB;IAEhB,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,GAAG,eAAe,CAAC;QACrG,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,aAAa,EAAE,aAAa,CAAC,aAAa;QAC1C,cAAc,EAAE,aAAa,CAAC,cAAc;QAC5C,kBAAkB;QAClB,sBAAsB;QACtB,kBAAkB;QAClB,mBAAmB;KACpB,CAAC,CAAC;IAEH,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CACL,cAAK,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,QAAQ,eAAW,QAAQ,YACjE,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,EAAC,gBAAgB,EAAC,SAAS,GAAG,GACrD,CACP,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO,CACL,MAAC,KAAK,IAAC,OAAO,EAAC,QAAQ,EAAC,IAAI,EAAE,SAAS,aACpC,WAAW,aAAX,WAAW,cAAX,WAAW,GACT,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAClD,CAAC,gBAAgB,IAAI,mBAAmB,IAAI,CAC3C,YAAG,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAC,YAAY,6CAEhD,CACL,IACK,CACT,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CACL,4BACE,KAAC,uBAAuB,IAAC,MAAM,QAAC,OAAO,EAAE,OAAO,GAAI,GACnD,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,CACL,KAAC,QAAQ,oBACH,aAAa,IACjB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAC,oBAAoB,IACpC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { Alert, Spinner } from '@openedx/paragon';\nimport { Error as ErrorIcon } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { useCheckoutGate } from '../../data/hooks/useCheckoutGate';\nimport Checkout from '../Checkout/Checkout';\nimport CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport type { CheckoutProps } from '../Checkout/Checkout';\nimport messages from './Messages';\n\nexport interface CheckoutGateProps extends CheckoutProps {\n /** URL linked in session-error recovery messaging. */\n learnerDashboardUrl?: string,\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** ALC-307 compliance-check endpoint — decides whether the learner is embargoed. */\n complianceCheckUrl?: string,\n /** When true, skip the compliance-check request. */\n disableComplianceCheck?: boolean,\n /** When true, skip the compliance-check request and show the blocked modal. */\n restrictCompliance?: boolean,\n}\n\nconst CheckoutGate = ({\n learnerDashboardUrl,\n homeUrl = '/',\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n ...checkoutProps\n}: CheckoutGateProps) => {\n const { formatMessage } = useIntl();\n const { gateStatus, userCountry, gateMessage, isAccountLinkError: accountLinkError } = useCheckoutGate({\n apiUrl: checkoutProps.apiUrl,\n edxSessionUrl: checkoutProps.edxSessionUrl,\n geolocationUrl: checkoutProps.geolocationUrl,\n complianceCheckUrl,\n disableComplianceCheck,\n restrictCompliance,\n learnerDashboardUrl,\n });\n\n if (gateStatus === 'loading') {\n return (\n <div className=\"processing-screen\" role=\"status\" aria-live=\"polite\">\n <Spinner animation=\"border\" screenReaderText=\"Loading\" />\n </div>\n );\n }\n\n if (gateStatus === 'error') {\n return (\n <Alert variant=\"danger\" icon={ErrorIcon}>\n {gateMessage\n ?? formatMessage(messages.defaultErrorMessage)}{' '}\n {!accountLinkError && learnerDashboardUrl && (\n <a href={learnerDashboardUrl} className=\"alert-link\">\n Go to your learner dashboard\n </a>\n )}\n </Alert>\n );\n }\n\n if (gateStatus === 'blocked') {\n return (\n <>\n <CountryUnavailableModal isOpen homeUrl={homeUrl} />\n </>\n );\n }\n return (\n <Checkout\n {...checkoutProps}\n userCountry={userCountry}\n homeUrl={homeUrl}\n orderHistoryUrl=\"/aca-order-history\"\n />\n );\n};\n\nexport default CheckoutGate;\n"]}