@wise/dynamic-flow-client 3.28.9 → 3.29.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.
package/build/main.mjs CHANGED
@@ -138,12 +138,12 @@ var init_clsx = __esm({
138
138
  }
139
139
  });
140
140
 
141
- // ../../node_modules/.pnpm/@wise+art@2.17.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.16_react-dom@18.3.1_reac_4hsljgguo7de2wpoipdhgf4kzi/node_modules/@wise/art/dist/index-213daaa3.esm.js
141
+ // ../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index-8Fxev6OI.esm.js
142
142
  import { useState, useEffect, forwardRef, Suspense, lazy } from "react";
143
143
  import { jsx as jsx11, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
144
144
  var unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
145
- var init_index_213daaa3_esm = __esm({
146
- "../../node_modules/.pnpm/@wise+art@2.17.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.16_react-dom@18.3.1_reac_4hsljgguo7de2wpoipdhgf4kzi/node_modules/@wise/art/dist/index-213daaa3.esm.js"() {
145
+ var init_index_8Fxev6OI_esm = __esm({
146
+ "../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index-8Fxev6OI.esm.js"() {
147
147
  "use strict";
148
148
  init_clsx();
149
149
  unknownFlagName = "wise";
@@ -187,76 +187,76 @@ var init_index_213daaa3_esm = __esm({
187
187
  [Sizes.LARGE]: 500
188
188
  };
189
189
  (function(Assets2) {
190
- Assets2["BELL"] = "bell";
191
- Assets2["BRIEFCASE"] = "briefcase";
192
- Assets2["BUSINESS_CARD"] = "business-card";
193
- Assets2["CALENDAR"] = "calendar";
194
- Assets2["CHECK_MARK"] = "check-mark";
195
- Assets2["CLOSED_WINDOW"] = "closed-window";
196
- Assets2["COIN_PILE_DOWN"] = "coin-pile-down";
197
- Assets2["COIN_PILE_UP"] = "coin-pile-up";
198
- Assets2["CONFETTI"] = "confetti";
199
- Assets2["CONSTRUCTION_FENCE"] = "construction-fence";
200
- Assets2["CONVERT"] = "convert";
201
- Assets2["COOKIE"] = "cookie";
202
- Assets2["DIGITAL_CARD_2"] = "digital-card-2";
203
- Assets2["DIGITAL_CARD"] = "digital-card";
204
- Assets2["DOCUMENTS"] = "documents";
205
- Assets2["DOOR"] = "door";
206
- Assets2["ECO_CARD"] = "eco-card";
207
- Assets2["ELECTRIC_PLUG"] = "electric-plug";
208
- Assets2["EMAIL_SUCCESS"] = "email-success";
209
- Assets2["EMAIL"] = "email";
210
- Assets2["EXCLAMATION_MARK"] = "exclamation-mark";
211
- Assets2["FLAG"] = "flag";
212
- Assets2["FLOWER"] = "flower";
213
- Assets2["GEAR"] = "gear";
214
- Assets2["GLOBE"] = "globe";
215
- Assets2["GRAPH"] = "graph";
216
- Assets2["HEART_2"] = "heart-2";
217
- Assets2["HEART_3"] = "heart-3";
218
- Assets2["HEART_4"] = "heart-4";
219
- Assets2["HEART_5"] = "heart-5";
220
- Assets2["HEART"] = "heart";
221
- Assets2["HOUSE"] = "house";
222
- Assets2["ID_CARD"] = "id-card";
223
- Assets2["INFINITE"] = "infinite";
224
- Assets2["INTEREST"] = "interest";
225
- Assets2["INVITE_LETTER"] = "invite-letter";
226
- Assets2["JARS"] = "jars";
227
- Assets2["KEY"] = "key";
228
- Assets2["LIGHT_BULB"] = "light-bulb";
229
- Assets2["LOCK_PLATFORM"] = "lock-platform";
230
- Assets2["LOCK"] = "lock";
231
- Assets2["MAGNIFYING_GLASS"] = "magnifying-glass";
232
- Assets2["MAP"] = "map";
190
+ Assets2["WALLET"] = "wallet";
191
+ Assets2["TWO_INVITE_LETTERS_OPENED"] = "two-invite-letters-opened";
192
+ Assets2["TOOL"] = "tool";
193
+ Assets2["TARGET_PLATFORM"] = "target-platform";
194
+ Assets2["STOPWATCH_PLATFORM"] = "stopwatch-platform";
195
+ Assets2["SPEECH_BUBBLE"] = "speech-bubble";
196
+ Assets2["SKIP_AUTHENTICATION"] = "skip-authentication";
197
+ Assets2["SHOPPING_BAG"] = "shopping-bag";
198
+ Assets2["SATELLITE_PLATFORM"] = "satellite-platform";
199
+ Assets2["SAND_TIMER"] = "sand-timer";
200
+ Assets2["REMINDER_LETTER"] = "reminder-letter";
201
+ Assets2["RECEIVE"] = "receive";
202
+ Assets2["QUESTION_MARK"] = "question-mark";
203
+ Assets2["PUZZLE_PIECES"] = "puzzle-pieces";
204
+ Assets2["PLANE_2"] = "plane-2";
205
+ Assets2["PLANE"] = "plane";
206
+ Assets2["PIE_CHART"] = "pie-chart";
207
+ Assets2["PHONES"] = "phones";
208
+ Assets2["PERSONAL_CARD"] = "personal-card";
209
+ Assets2["PERCENTAGE"] = "percentage";
210
+ Assets2["PALM_TREE"] = "palm-tree";
211
+ Assets2["ONE_INVITE_LETTER_OPENED"] = "one-invite-letter-opened";
212
+ Assets2["MULTI_CURRENCY"] = "multi-currency";
213
+ Assets2["MEGAPHONE"] = "megaphone";
233
214
  Assets2["MARBLE_CARD_BUSINESS"] = "marble-card-business";
234
215
  Assets2["MARBLE_CARD"] = "marble-card";
235
216
  Assets2["MARBLE"] = "marble";
236
- Assets2["MEGAPHONE"] = "megaphone";
237
- Assets2["MULTI_CURRENCY"] = "multi-currency";
238
- Assets2["ONE_INVITE_LETTER_OPENED"] = "one-invite-letter-opened";
239
- Assets2["PALM_TREE"] = "palm-tree";
240
- Assets2["PERCENTAGE"] = "percentage";
241
- Assets2["PERSONAL_CARD"] = "personal-card";
242
- Assets2["PHONES"] = "phones";
243
- Assets2["PIE_CHART"] = "pie-chart";
244
- Assets2["PLANE_2"] = "plane-2";
245
- Assets2["PLANE"] = "plane";
246
- Assets2["PUZZLE_PIECES"] = "puzzle-pieces";
247
- Assets2["QUESTION_MARK"] = "question-mark";
248
- Assets2["RECEIVE"] = "receive";
249
- Assets2["REMINDER_LETTER"] = "reminder-letter";
250
- Assets2["SAND_TIMER"] = "sand-timer";
251
- Assets2["SATELLITE_PLATFORM"] = "satellite-platform";
252
- Assets2["SHOPPING_BAG"] = "shopping-bag";
253
- Assets2["SKIP_AUTHENTICATION"] = "skip-authentication";
254
- Assets2["SPEECH_BUBBLE"] = "speech-bubble";
255
- Assets2["STOPWATCH_PLATFORM"] = "stopwatch-platform";
256
- Assets2["TARGET_PLATFORM"] = "target-platform";
257
- Assets2["TOOL"] = "tool";
258
- Assets2["TWO_INVITE_LETTERS_OPENED"] = "two-invite-letters-opened";
259
- Assets2["WALLET"] = "wallet";
217
+ Assets2["MAP"] = "map";
218
+ Assets2["MAGNIFYING_GLASS"] = "magnifying-glass";
219
+ Assets2["LOCK_PLATFORM"] = "lock-platform";
220
+ Assets2["LOCK"] = "lock";
221
+ Assets2["LIGHT_BULB"] = "light-bulb";
222
+ Assets2["KEY"] = "key";
223
+ Assets2["JARS"] = "jars";
224
+ Assets2["INVITE_LETTER"] = "invite-letter";
225
+ Assets2["INTEREST"] = "interest";
226
+ Assets2["INFINITE"] = "infinite";
227
+ Assets2["ID_CARD"] = "id-card";
228
+ Assets2["HOUSE"] = "house";
229
+ Assets2["HEART_5"] = "heart-5";
230
+ Assets2["HEART_4"] = "heart-4";
231
+ Assets2["HEART_3"] = "heart-3";
232
+ Assets2["HEART_2"] = "heart-2";
233
+ Assets2["HEART"] = "heart";
234
+ Assets2["GRAPH"] = "graph";
235
+ Assets2["GLOBE"] = "globe";
236
+ Assets2["GEAR"] = "gear";
237
+ Assets2["FLOWER"] = "flower";
238
+ Assets2["FLAG"] = "flag";
239
+ Assets2["EXCLAMATION_MARK"] = "exclamation-mark";
240
+ Assets2["EMAIL_SUCCESS"] = "email-success";
241
+ Assets2["EMAIL"] = "email";
242
+ Assets2["ELECTRIC_PLUG"] = "electric-plug";
243
+ Assets2["ECO_CARD"] = "eco-card";
244
+ Assets2["DOOR"] = "door";
245
+ Assets2["DOCUMENTS"] = "documents";
246
+ Assets2["DIGITAL_CARD_2"] = "digital-card-2";
247
+ Assets2["DIGITAL_CARD"] = "digital-card";
248
+ Assets2["COOKIE"] = "cookie";
249
+ Assets2["CONVERT"] = "convert";
250
+ Assets2["CONSTRUCTION_FENCE"] = "construction-fence";
251
+ Assets2["CONFETTI"] = "confetti";
252
+ Assets2["COIN_PILE_UP"] = "coin-pile-up";
253
+ Assets2["COIN_PILE_DOWN"] = "coin-pile-down";
254
+ Assets2["CLOSED_WINDOW"] = "closed-window";
255
+ Assets2["CHECK_MARK"] = "check-mark";
256
+ Assets2["CALENDAR"] = "calendar";
257
+ Assets2["BUSINESS_CARD"] = "business-card";
258
+ Assets2["BRIEFCASE"] = "briefcase";
259
+ Assets2["BELL"] = "bell";
260
260
  })(Assets || (Assets = {}));
261
261
  (function(RenderMode2) {
262
262
  RenderMode2[RenderMode2["INIT"] = 0] = "INIT";
@@ -1236,7 +1236,7 @@ var zh_CN_default = {
1236
1236
  "dynamicFlows.ExternalConfirmation.open": "\u5728\u65B0\u6807\u7B7E\u9875\u4E2D\u6253\u5F00",
1237
1237
  "dynamicFlows.ExternalConfirmation.title": "\u8BF7\u786E\u8BA4",
1238
1238
  "dynamicFlows.FileUploadSchema.maxFileSizeError": "\u62B1\u6B49\uFF0C\u8BE5\u6587\u4EF6\u592A\u5927\u3002\u8BF7\u4E0A\u4F20\u4E00\u4E2A\u66F4\u5C0F\u7684\u6587\u4EF6\u3002",
1239
- "dynamicFlows.FileUploadSchema.wrongFileTypeError": "Sorry, that file format is not supported. Please upload a different file.",
1239
+ "dynamicFlows.FileUploadSchema.wrongFileTypeError": "\u62B1\u6B49\uFF0C\u4E0D\u652F\u6301\u8BE5\u6587\u4EF6\u683C\u5F0F\u3002\u8BF7\u4E0A\u4F20\u5176\u4ED6\u6587\u4EF6\u3002",
1240
1240
  "dynamicFlows.Help.ariaLabel": "\u70B9\u51FB\u6B64\u5904\u83B7\u53D6\u66F4\u591A\u4FE1\u606F\u3002",
1241
1241
  "dynamicFlows.MultiSelect.summary": "{first} \u548C\u5176\u4ED6 {count} \u4E2A",
1242
1242
  "dynamicFlows.MultipleFileUploadSchema.maxFileSizeError": "\u62B1\u6B49\uFF0C\u8BE5\u6587\u4EF6\u592A\u5927\u3002\u8BF7\u4E0A\u4F20\u4E00\u4E2A\u66F4\u5C0F\u7684\u6587\u4EF6\u3002",
@@ -1754,8 +1754,8 @@ var DateInputRenderer_default = DateInputRenderer;
1754
1754
  // ../renderers/src/DecisionRenderer.tsx
1755
1755
  import { NavigationOptionsList, NavigationOption, Header } from "@transferwise/components";
1756
1756
 
1757
- // ../../node_modules/.pnpm/@wise+art@2.17.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.16_react-dom@18.3.1_reac_4hsljgguo7de2wpoipdhgf4kzi/node_modules/@wise/art/dist/index.esm.js
1758
- init_index_213daaa3_esm();
1757
+ // ../../node_modules/.pnpm/@wise+art@2.19.0_@transferwise+neptune-css@14.20.1_@types+react@18.3.18_react-dom@18.3.1_reac_mzw7cg6j4wc7ddwlhxck7linn4/node_modules/@wise/art/dist/index.esm.js
1758
+ init_index_8Fxev6OI_esm();
1759
1759
  init_clsx();
1760
1760
  import "react";
1761
1761
  import "react/jsx-runtime";
@@ -13120,6 +13120,83 @@ var mapStepToComponent = (_a) => {
13120
13120
  return stepComponent;
13121
13121
  };
13122
13122
 
13123
+ // src/revamp/flow/getResponseType.ts
13124
+ var responseTypes = ["step", "action", "exit"];
13125
+ var getResponseType = async (response) => {
13126
+ assertResponseIsValid(response);
13127
+ const headerResponseType = getResponseTypeFromHeader(response);
13128
+ if (headerResponseType) {
13129
+ return headerResponseType;
13130
+ }
13131
+ const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
13132
+ if (isObject(jsonBody) && jsonBody.action) {
13133
+ return "action";
13134
+ }
13135
+ return "step";
13136
+ };
13137
+ var getResponseTypeFromHeader = (response) => {
13138
+ var _a, _b;
13139
+ if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
13140
+ const type = response.headers.get("X-Df-Response-Type");
13141
+ assertDFResponseType(type);
13142
+ return type;
13143
+ }
13144
+ if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
13145
+ return "exit";
13146
+ }
13147
+ return void 0;
13148
+ };
13149
+ function assertDFResponseType(type) {
13150
+ if (!responseTypes.includes(type)) {
13151
+ throw new Error(
13152
+ "Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
13153
+ );
13154
+ }
13155
+ }
13156
+
13157
+ // src/revamp/flow/executePoll.ts
13158
+ var executePoll = async (props) => {
13159
+ const { errorAction, signal, url, httpClient, trackEvent } = props;
13160
+ try {
13161
+ const response = await httpClient(url != null ? url : "", {
13162
+ method: "GET",
13163
+ signal
13164
+ });
13165
+ if (!response.ok) {
13166
+ trackEvent("Polling Failed", { url, statusCode: response.status, variant: "revamp" });
13167
+ return { type: "action", action: errorAction };
13168
+ }
13169
+ const responseType = getResponseTypeFromHeader(response);
13170
+ const body = await parseResponseBodyAsJsonElement(response);
13171
+ try {
13172
+ switch (responseType) {
13173
+ case "step": {
13174
+ const etag = response.headers.get("etag") || null;
13175
+ assertStepResponseBody(body);
13176
+ return { type: "replace-step", step: body, etag };
13177
+ }
13178
+ case "exit": {
13179
+ return { type: "complete", result: body };
13180
+ }
13181
+ case "action": {
13182
+ assertActionResponseBody(body);
13183
+ return { type: "action", action: body.action };
13184
+ }
13185
+ default: {
13186
+ if (isActionResponseBody(body)) {
13187
+ return { type: "action", action: body.action };
13188
+ }
13189
+ return { type: "continue" };
13190
+ }
13191
+ }
13192
+ } catch (error) {
13193
+ return { type: "action", action: errorAction };
13194
+ }
13195
+ } catch (error) {
13196
+ return { type: "continue" };
13197
+ }
13198
+ };
13199
+
13123
13200
  // src/revamp/flow/executeRefresh.ts
13124
13201
  var executeRefresh = async (props) => {
13125
13202
  const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent } = props;
@@ -13140,8 +13217,11 @@ var executeRefresh = async (props) => {
13140
13217
  if (!response.ok) {
13141
13218
  const responseBody = await parseResponseBodyAsJsonElement(response).catch(() => ({}));
13142
13219
  const body2 = isErrorResponseBody(responseBody) ? responseBody : {};
13143
- trackEvent("Refresh Failed", __spreadValues({ schema: schemaId }, body2.analytics));
13144
- return { type: "error", body: body2 };
13220
+ trackEvent("Refresh Failed", __spreadProps(__spreadValues({}, body2.analytics), {
13221
+ schema: schemaId,
13222
+ statusCode: response.status
13223
+ }));
13224
+ return { type: "error", body: body2, statusCode: response.status };
13145
13225
  }
13146
13226
  const newEtag = response.headers.get("etag") || null;
13147
13227
  const body = await parseResponseBodyAsJsonElement(response);
@@ -13158,40 +13238,6 @@ var executeRefresh = async (props) => {
13158
13238
  }
13159
13239
  };
13160
13240
 
13161
- // src/revamp/flow/getResponseType.ts
13162
- var responseTypes = ["step", "action", "exit"];
13163
- var getResponseType = async (response) => {
13164
- assertResponseIsValid(response);
13165
- const headerResponseType = getResponseTypeFromHeader(response);
13166
- if (headerResponseType) {
13167
- return headerResponseType;
13168
- }
13169
- const jsonBody = await parseResponseBodyAsJsonElement(response.clone());
13170
- if (isObject(jsonBody) && jsonBody.action) {
13171
- return "action";
13172
- }
13173
- return "step";
13174
- };
13175
- var getResponseTypeFromHeader = (response) => {
13176
- var _a, _b;
13177
- if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
13178
- const type = response.headers.get("X-Df-Response-Type");
13179
- assertDFResponseType(type);
13180
- return type;
13181
- }
13182
- if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
13183
- return "exit";
13184
- }
13185
- return void 0;
13186
- };
13187
- function assertDFResponseType(type) {
13188
- if (!responseTypes.includes(type)) {
13189
- throw new Error(
13190
- "Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
13191
- );
13192
- }
13193
- }
13194
-
13195
13241
  // src/revamp/flow/executeSubmission.ts
13196
13242
  var executeSubmission = async (props) => {
13197
13243
  const { httpClient, trackEvent } = props;
@@ -13260,12 +13306,12 @@ var executeSubmission = async (props) => {
13260
13306
  if (isErrorResponseBody(body)) {
13261
13307
  const refreshUrl = body.refreshUrl || body.refreshFormUrl;
13262
13308
  const { error, validation, analytics } = body;
13263
- trackEvent("Action Failed", __spreadValues({ actionId }, analytics));
13309
+ trackEvent("Action Failed", __spreadProps(__spreadValues({}, analytics), { actionId, statusCode: response.status }));
13264
13310
  const errors = { error, validation };
13265
- return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics } };
13311
+ return refreshUrl ? { type: "refresh", body: { refreshUrl, errors } } : { type: "error", body: { errors, analytics }, statusCode: response.status };
13266
13312
  }
13267
- trackEvent("Action Failed", { actionId });
13268
- return { type: "error", body: {} };
13313
+ trackEvent("Action Failed", { actionId, statusCode: response.status });
13314
+ return { type: "error", body: {}, statusCode: response.status };
13269
13315
  };
13270
13316
  return triggerAction(props.action, props.model, props.isInitial);
13271
13317
  };
@@ -13507,48 +13553,6 @@ function useStableCallback(handler) {
13507
13553
  return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
13508
13554
  }
13509
13555
 
13510
- // src/revamp/flow/executePoll.ts
13511
- var executePoll = async (props) => {
13512
- const { errorAction, signal, url, httpClient } = props;
13513
- try {
13514
- const response = await httpClient(url != null ? url : "", {
13515
- method: "GET",
13516
- signal
13517
- });
13518
- if (!response.ok) {
13519
- return { type: "action", action: errorAction };
13520
- }
13521
- const responseType = getResponseTypeFromHeader(response);
13522
- const body = await parseResponseBodyAsJsonElement(response);
13523
- try {
13524
- switch (responseType) {
13525
- case "step": {
13526
- const etag = response.headers.get("etag") || null;
13527
- assertStepResponseBody(body);
13528
- return { type: "replace-step", step: body, etag };
13529
- }
13530
- case "exit": {
13531
- return { type: "complete", result: body };
13532
- }
13533
- case "action": {
13534
- assertActionResponseBody(body);
13535
- return { type: "action", action: body.action };
13536
- }
13537
- default: {
13538
- if (isActionResponseBody(body)) {
13539
- return { type: "action", action: body.action };
13540
- }
13541
- return { type: "continue" };
13542
- }
13543
- }
13544
- } catch (error) {
13545
- return { type: "action", action: errorAction };
13546
- }
13547
- } catch (error) {
13548
- return { type: "continue" };
13549
- }
13550
- };
13551
-
13552
13556
  // src/revamp/useDynamicFlowCore.tsx
13553
13557
  function useDynamicFlowCore(props) {
13554
13558
  const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
@@ -13665,9 +13669,9 @@ function useDynamicFlowCore(props) {
13665
13669
  []
13666
13670
  );
13667
13671
  const closeWithError = useCallback2(
13668
- (error, analytics) => {
13672
+ (error, analytics, statusCode) => {
13669
13673
  trackCoreEvent("Failed", __spreadValues({}, analytics));
13670
- onError(error);
13674
+ onError(error, statusCode);
13671
13675
  },
13672
13676
  // eslint-disable-next-line react-hooks/exhaustive-deps
13673
13677
  []
@@ -13702,7 +13706,7 @@ function useDynamicFlowCore(props) {
13702
13706
  if (stepRef.current) {
13703
13707
  initialiseWithStep(__spreadProps(__spreadValues({}, stepRef.current), { errors, model }), etagRef.current);
13704
13708
  } else {
13705
- closeWithError(new Error("Initial request failed"), {});
13709
+ closeWithError(new Error("Initial request failed"), {}, command.statusCode);
13706
13710
  }
13707
13711
  break;
13708
13712
  }
@@ -13739,7 +13743,11 @@ function useDynamicFlowCore(props) {
13739
13743
  }
13740
13744
  break;
13741
13745
  case "error": {
13742
- closeWithError(new Error("Failed to refresh"), command.body.analytics);
13746
+ closeWithError(
13747
+ new Error("Failed to refresh"),
13748
+ command.body.analytics,
13749
+ command.statusCode
13750
+ );
13743
13751
  break;
13744
13752
  }
13745
13753
  case "noop":
@@ -13759,7 +13767,8 @@ function useDynamicFlowCore(props) {
13759
13767
  httpClient,
13760
13768
  url,
13761
13769
  errorAction,
13762
- signal
13770
+ signal,
13771
+ trackEvent: trackCoreEvent
13763
13772
  });
13764
13773
  switch (command.type) {
13765
13774
  case "replace-step":
@@ -19467,12 +19476,18 @@ import { useCallback as useCallback8, useMemo as useMemo19 } from "react";
19467
19476
  function useStepPolling(polling, onAction) {
19468
19477
  var _a, _b;
19469
19478
  const httpClient = useHttpClient();
19479
+ const onEvent = useEventDispatcher();
19470
19480
  const asyncFn = useMemo19(() => {
19471
19481
  if (polling) {
19472
19482
  return () => httpClient(polling.url).then((response) => {
19473
19483
  if (response.ok) {
19474
- return response.json().then((pollingResponse) => pollingResponse).catch((error) => null);
19484
+ return response.json().then((pollingResponse) => pollingResponse).catch(() => null);
19475
19485
  }
19486
+ onEvent("Dynamic Flow - Polling Failed", {
19487
+ url: polling.url,
19488
+ statusCode: response.status,
19489
+ variant: "legacy"
19490
+ });
19476
19491
  throw new Error("failed");
19477
19492
  }).catch((error) => {
19478
19493
  throw new Error(error.message === "failed" ? "failed" : "network failed");
@@ -20795,13 +20810,13 @@ var DynamicFlowComponent = ({
20795
20810
  }
20796
20811
  setLoadingState("idle");
20797
20812
  };
20798
- const completeWithError = (error, message, fetchType, responseStatus) => {
20813
+ const completeWithError = (error, message, fetchType, statusCode) => {
20799
20814
  logCritical("Error fetching", message);
20800
20815
  if (fetchType === "refresh") {
20801
20816
  dispatchEvent("Dynamic Flow - Step Refreshed", { status: "failure" });
20802
20817
  }
20803
20818
  dispatchEvent("Dynamic Flow - Flow Finished", { status: "failure" });
20804
- onError(error, responseStatus);
20819
+ onError(error, statusCode);
20805
20820
  setLoadingState("idle");
20806
20821
  };
20807
20822
  const onModelChange = (onModelChangeProps) => {
@@ -11,7 +11,7 @@ export type DynamicFlowPropsWithInitialStep = DynamicFlowPropsBasic & {
11
11
  };
12
12
  export type HttpClient = typeof fetch;
13
13
  export type EventHandler = (eventName: EventName, properties: Record<string, unknown>) => void;
14
- export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched' | CameraEventName;
14
+ export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - Polling Failed' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched' | CameraEventName;
15
15
  export type LogLevel = 'debug' | 'info' | 'warning' | 'error' | 'critical';
16
16
  export type LogEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
17
17
  export type Feature = {
@@ -1,6 +1,6 @@
1
1
  export type AnalyticsEventHandler = (eventName: string, properties?: Record<string, unknown>) => void;
2
2
  export type AnalyticsEventDispatcher<E extends string = EventName> = (eventName: E, properties?: Record<string, unknown>) => void;
3
- export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Value Changed';
3
+ export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'Polling Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Value Changed';
4
4
  export type LogLevel = 'info' | 'warning' | 'error';
5
5
  export type LoggingEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
6
6
  export type LoggingEventDispatcher = (level: LogLevel, message: string, extra?: Record<string, unknown>) => void;
@@ -1,4 +1,5 @@
1
1
  import { Action, Model, Step } from '@wise/dynamic-flow-types/build/next';
2
+ import { AnalyticsEventDispatcher } from '../domain/features/events';
2
3
  type Command = {
3
4
  type: 'complete';
4
5
  result: Model;
@@ -17,5 +18,6 @@ export declare const executePoll: (props: {
17
18
  url: string;
18
19
  errorAction: Action;
19
20
  signal: AbortSignal;
21
+ trackEvent: AnalyticsEventDispatcher;
20
22
  }) => Promise<Command>;
21
23
  export {};
@@ -9,6 +9,7 @@ type Command = {
9
9
  } | {
10
10
  type: 'error';
11
11
  body: ErrorResponseBody;
12
+ statusCode?: number;
12
13
  };
13
14
  export declare const executeRefresh: (props: {
14
15
  abortSignal: AbortSignal;
@@ -13,6 +13,7 @@ type Command = {
13
13
  analytics?: ErrorResponseBody['analytics'];
14
14
  errors?: Step['errors'];
15
15
  };
16
+ statusCode?: number;
16
17
  } | {
17
18
  type: 'refresh';
18
19
  body: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.28.9",
3
+ "version": "3.29.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -36,7 +36,7 @@
36
36
  "@babel/preset-env": "7.26.0",
37
37
  "@babel/preset-react": "7.26.3",
38
38
  "@babel/preset-typescript": "7.26.0",
39
- "@chromatic-com/storybook": "3.2.2",
39
+ "@chromatic-com/storybook": "3.2.3",
40
40
  "@formatjs/cli": "^6.3.14",
41
41
  "@storybook/addon-a11y": "^8.4.7",
42
42
  "@storybook/addon-actions": "^8.4.7",
@@ -53,16 +53,16 @@
53
53
  "@testing-library/jest-dom": "6.6.3",
54
54
  "@testing-library/react": "16.1.0",
55
55
  "@testing-library/user-event": "14.5.2",
56
- "@transferwise/components": "46.84.0",
56
+ "@transferwise/components": "46.84.1",
57
57
  "@transferwise/formatting": "^2.13.0",
58
- "@transferwise/icons": "3.15.0",
58
+ "@transferwise/icons": "3.18.0",
59
59
  "@transferwise/neptune-css": "14.20.1",
60
60
  "@types/node": "22.10.2",
61
61
  "@types/jest": "29.5.14",
62
- "@types/react": "18.3.16",
62
+ "@types/react": "18.3.18",
63
63
  "@types/react-dom": "18.3.5",
64
64
  "@types/react-intl": "3.0.0",
65
- "@wise/art": "2.17.0",
65
+ "@wise/art": "2.19.0",
66
66
  "@wise/components-theming": "^1.6.1",
67
67
  "babel-jest": "29.7.0",
68
68
  "esbuild": "0.24.0",
@@ -70,7 +70,7 @@
70
70
  "jest-environment-jsdom": "29.7.0",
71
71
  "jest-fetch-mock": "^3.0.3",
72
72
  "jest-watch-typeahead": "^2.2.2",
73
- "npm-run-all2": "7.0.1",
73
+ "npm-run-all2": "7.0.2",
74
74
  "postcss": "^8.4.49",
75
75
  "postcss-cli": "^11.0.0",
76
76
  "postcss-import": "^15.1.0",