@wix/himalaya-cli 0.1679.0 → 0.1680.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 (74) hide show
  1. package/dist/browser-plane/assets.json +5 -5
  2. package/dist/browser-plane/preview-deferred/{4a260ef73a6f9f421a9119eac3d67bb9978e67b44c66a870038d189e6c77a0bd.bin → 4f58be42c5c8007715860f364adb1cdcb02156d76672fa38ba7ea412ee8fac2a.bin} +1 -1
  3. package/dist/browser-plane/sw.js +8 -8
  4. package/dist/cli.mjs +160 -110
  5. package/dist/preview-assets.generated.bin +0 -0
  6. package/package.json +2 -2
  7. package/templates/beauty-salon/dev/index.ts +1 -0
  8. package/templates/beauty-salon/tier5-src/_shared/wix-bi.ts +85 -0
  9. package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  10. package/templates/beauty-salon-owner/dev/index.ts +2 -1
  11. package/templates/beauty-salon-owner/tier5-src/_shared/wix-bi.ts +85 -0
  12. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  13. package/templates/branded-lite/dev/index.ts +9 -4
  14. package/templates/branded-lite/tier5-src/_shared/wix-bi.ts +85 -0
  15. package/templates/branded-lite/tier5-src/business-chat/index.ts +8 -0
  16. package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  17. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +14 -0
  18. package/templates/branded-lite/tier5-src/wix-spaces-chat-thread/index.ts +3 -1
  19. package/templates/branded-lite/tier5-src/wix-spaces-food-orders/index.ts +15 -0
  20. package/templates/branded-lite/tier5-src/wix-spaces-forum/index.ts +22 -1
  21. package/templates/community-club-owner/dev/index.ts +2 -1
  22. package/templates/community-club-owner/tier5-src/_shared/wix-bi.ts +85 -0
  23. package/templates/community-club-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  24. package/templates/conference/dev/index.ts +2 -1
  25. package/templates/conference/tier5-src/_shared/wix-bi.ts +85 -0
  26. package/templates/conference/tier5-src/business-chat/index.ts +8 -0
  27. package/templates/events-meetups-owner/dev/index.ts +2 -1
  28. package/templates/events-meetups-owner/tier5-src/_shared/wix-bi.ts +85 -0
  29. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  30. package/templates/gym-fitness/dev/index.ts +1 -0
  31. package/templates/gym-fitness/tier5-src/_shared/wix-bi.ts +85 -0
  32. package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  33. package/templates/gym-fitness-owner/dev/index.ts +2 -1
  34. package/templates/gym-fitness-owner/tier5-src/_shared/wix-bi.ts +85 -0
  35. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  36. package/templates/nonprofit-cause-owner/dev/index.ts +2 -1
  37. package/templates/nonprofit-cause-owner/tier5-src/_shared/wix-bi.ts +85 -0
  38. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  39. package/templates/owner-lite/dev/index.ts +2 -1
  40. package/templates/owner-lite/tier5-src/_shared/wix-bi.ts +85 -0
  41. package/templates/owner-lite/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  42. package/templates/podcast-creator-owner/dev/index.ts +2 -1
  43. package/templates/podcast-creator-owner/tier5-src/_shared/wix-bi.ts +85 -0
  44. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  45. package/templates/portfolio-creative/dev/index.ts +1 -0
  46. package/templates/portfolio-creative/tier5-src/_shared/wix-bi.ts +85 -0
  47. package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  48. package/templates/portfolio-creative-owner/dev/index.ts +2 -1
  49. package/templates/portfolio-creative-owner/tier5-src/_shared/wix-bi.ts +85 -0
  50. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  51. package/templates/restaurant/dev/index.ts +2 -1
  52. package/templates/restaurant/tier5-src/_shared/wix-bi.ts +85 -0
  53. package/templates/restaurant/tier5-src/wix-spaces-food-orders/index.ts +15 -0
  54. package/templates/restaurant-owner/dev/index.ts +2 -1
  55. package/templates/restaurant-owner/tier5-src/_shared/wix-bi.ts +85 -0
  56. package/templates/restaurant-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  57. package/templates/retail-store/dev/index.ts +1 -0
  58. package/templates/retail-store/tier5-src/_shared/wix-bi.ts +85 -0
  59. package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  60. package/templates/retail-store/tier5-src/himi-store-product/index.ts +14 -0
  61. package/templates/retail-store-owner/dev/index.ts +2 -1
  62. package/templates/retail-store-owner/tier5-src/_shared/wix-bi.ts +85 -0
  63. package/templates/retail-store-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
  64. package/templates/salon-spa/dev/index.ts +2 -1
  65. package/templates/salon-spa/tier5-src/_shared/wix-bi.ts +85 -0
  66. package/templates/salon-spa/tier5-src/business-chat/index.ts +8 -0
  67. package/templates/wholesale-store/dev/index.ts +3 -1
  68. package/templates/wholesale-store/tier5-src/_shared/wix-bi.ts +85 -0
  69. package/templates/wholesale-store/tier5-src/business-chat/index.ts +8 -0
  70. package/templates/wholesale-store/tier5-src/himi-branded-lite-cart/index.ts +9 -0
  71. package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +14 -0
  72. package/templates/yoga-studio-owner/dev/index.ts +2 -1
  73. package/templates/yoga-studio-owner/tier5-src/_shared/wix-bi.ts +85 -0
  74. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-inbox-thread/index.ts +6 -2
@@ -0,0 +1,85 @@
1
+ // RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
2
+ // other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
3
+ // rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
4
+ // field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
5
+ import { bi, type BiLogEvent } from "@himalaya/wix-platform";
6
+
7
+ /** Sends one event without waiting for it and never throws: BI must not change a screen. A
8
+ * screen whose descriptor does not declare `wix_platform` is refused by the host, which is
9
+ * swallowed here like any other BI failure. */
10
+ export function logBi(event: BiLogEvent): void {
11
+ try {
12
+ void Promise.resolve(bi.log(event)).catch(() => undefined);
13
+ } catch {
14
+ /* BI is best-effort */
15
+ }
16
+ }
17
+
18
+ /** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
19
+ export function wixErrorStatus(error: unknown): number {
20
+ const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
21
+ if (Number.isFinite(own) && own > 0) return own;
22
+ const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
23
+ return match ? Number(match[1]) : 0;
24
+ }
25
+
26
+ function applicationErrorCode(body: unknown): string {
27
+ const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
28
+ const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
29
+ return typeof code === "string" ? code : "";
30
+ }
31
+
32
+ /** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
33
+ * (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
34
+ const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
35
+
36
+ /** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
37
+ * error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
38
+ * JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
39
+ * when there is none. */
40
+ export function wixErrorCode(error: unknown): string {
41
+ const own = applicationErrorCode(error);
42
+ if (own) return own;
43
+ const message = String((error as Error | null)?.message ?? error ?? "");
44
+ const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
45
+ if (bracketed) return bracketed[1];
46
+ const start = message.indexOf("{");
47
+ if (start < 0) return "";
48
+ try {
49
+ return applicationErrorCode(JSON.parse(message.slice(start)));
50
+ } catch {
51
+ return "";
52
+ }
53
+ }
54
+
55
+ // RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
56
+ const ERROR_INDICATIONS = new Set([
57
+ "ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
58
+ "FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
59
+ "INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
60
+ "MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
61
+ "RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
62
+ "TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
63
+ "TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
64
+ "TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
65
+ "TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
66
+ "UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
67
+ ]);
68
+
69
+ /** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
70
+ * send that failed and said so. RN's `errorReason` is the failed message's indication code, and
71
+ * RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
72
+ * never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
73
+ export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
74
+ const code = wixErrorCode(input.error);
75
+ const errorReason = input.offline ? "NETWORK_ISSUE"
76
+ : ERROR_INDICATIONS.has(code) ? code
77
+ : wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
78
+ : "UNSUPPORTED";
79
+ logBi({
80
+ evid: 1604,
81
+ src: 5,
82
+ endpoint: "",
83
+ params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
84
+ });
85
+ }
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
22
22
  import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
23
23
  import { formatMonthDayTime } from "../_shared/engine-intl.js";
24
24
  import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
25
- import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
25
+ import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
26
+ import { logChatSendError } from "../_shared/wix-bi.js";
26
27
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
27
28
  import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
28
29
 
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
280
281
  } catch (e) {
281
282
  // The draft stays: the owner should not have to type it again. A send that may
282
283
  // have landed says so, so a retry does not post it twice unknowingly.
283
- return { ...live(), sendHint: writeMayHaveLanded(e) ? ownerWriteError(e) : `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
+ if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
285
+ const { id, kind } = input();
286
+ logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
287
+ return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
288
  }
285
289
  // Clear the composer only if it still holds what was sent — the owner may already be
286
290
  // typing the next message — judged on the state AFTER the re-read's await.
@@ -13290,7 +13290,8 @@ const SCREENS = runtimeSetting({
13290
13290
  "declaredCapabilities": [
13291
13291
  "wix_api",
13292
13292
  "wix_chat",
13293
- "open_url"
13293
+ "open_url",
13294
+ "wix_platform"
13294
13295
  ],
13295
13296
  "minBinaryVersion": "0.1.0",
13296
13297
  "bundleVersion": "0.1.0"
@@ -0,0 +1,85 @@
1
+ // RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
2
+ // other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
3
+ // rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
4
+ // field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
5
+ import { bi, type BiLogEvent } from "@himalaya/wix-platform";
6
+
7
+ /** Sends one event without waiting for it and never throws: BI must not change a screen. A
8
+ * screen whose descriptor does not declare `wix_platform` is refused by the host, which is
9
+ * swallowed here like any other BI failure. */
10
+ export function logBi(event: BiLogEvent): void {
11
+ try {
12
+ void Promise.resolve(bi.log(event)).catch(() => undefined);
13
+ } catch {
14
+ /* BI is best-effort */
15
+ }
16
+ }
17
+
18
+ /** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
19
+ export function wixErrorStatus(error: unknown): number {
20
+ const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
21
+ if (Number.isFinite(own) && own > 0) return own;
22
+ const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
23
+ return match ? Number(match[1]) : 0;
24
+ }
25
+
26
+ function applicationErrorCode(body: unknown): string {
27
+ const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
28
+ const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
29
+ return typeof code === "string" ? code : "";
30
+ }
31
+
32
+ /** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
33
+ * (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
34
+ const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
35
+
36
+ /** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
37
+ * error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
38
+ * JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
39
+ * when there is none. */
40
+ export function wixErrorCode(error: unknown): string {
41
+ const own = applicationErrorCode(error);
42
+ if (own) return own;
43
+ const message = String((error as Error | null)?.message ?? error ?? "");
44
+ const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
45
+ if (bracketed) return bracketed[1];
46
+ const start = message.indexOf("{");
47
+ if (start < 0) return "";
48
+ try {
49
+ return applicationErrorCode(JSON.parse(message.slice(start)));
50
+ } catch {
51
+ return "";
52
+ }
53
+ }
54
+
55
+ // RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
56
+ const ERROR_INDICATIONS = new Set([
57
+ "ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
58
+ "FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
59
+ "INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
60
+ "MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
61
+ "RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
62
+ "TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
63
+ "TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
64
+ "TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
65
+ "TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
66
+ "UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
67
+ ]);
68
+
69
+ /** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
70
+ * send that failed and said so. RN's `errorReason` is the failed message's indication code, and
71
+ * RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
72
+ * never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
73
+ export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
74
+ const code = wixErrorCode(input.error);
75
+ const errorReason = input.offline ? "NETWORK_ISSUE"
76
+ : ERROR_INDICATIONS.has(code) ? code
77
+ : wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
78
+ : "UNSUPPORTED";
79
+ logBi({
80
+ evid: 1604,
81
+ src: 5,
82
+ endpoint: "",
83
+ params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
84
+ });
85
+ }
@@ -12,6 +12,7 @@ import { smartChatHistory } from '../_shared/business-chat-history.js';
12
12
  import { hostSiteFromInput } from '../_shared/branded-lite-hosted.js';
13
13
  import { productImage, searchStoreProducts } from '../_shared/himi-store.js';
14
14
  import { queryServices } from '@himalaya/wix-bookings';
15
+ import { logBi, logChatSendError } from '../_shared/wix-bi.js';
15
16
 
16
17
  type PendingIntent = BusinessChatIntent & { suggestionId?:string; answerTo?:string };
17
18
  // Only what the screen reads. This state crosses into the worker on every keystroke, so a row carries no raw
@@ -424,6 +425,8 @@ async function deliver(pending:BusinessChatIntent,draft:string):Promise<void>{
424
425
  }catch(error){
425
426
  const lost=/member_sign_in_required|MemberAccessChanged|\b401\b|\b403\b/i.test(String(error));
426
427
  result={id:pending.id,draft,error,outcome:lost?'signed_out':businessChatSendRejected(error)?'rejected':'unconfirmed'};
428
+ // 5:1604: a rejected send is the one the screen reports as failed (an unconfirmed one asks the member to check).
429
+ if(result.outcome==='rejected'&&sendEpoch===epoch)logChatSendError({chatroomId:pending.roomId,error,offline:false});
427
430
  }
428
431
  if(sendEpoch===epoch)void svc.settleSend(result);
429
432
  }
@@ -556,6 +559,11 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
556
559
  const ownName=[...s.messages].reverse().find(row=>row.mine&&row.senderName)?.senderName??'';
557
560
  const pending={...newBusinessChatIntent(text,s.roomId,s.principal),senderName:ownName,...sendAnchor(s.messages,text,s.phase==='ready'),smartChatFromStart:s.transcriptSource==='members'&&s.smartChatEmpty};
558
561
  draftRevision++;// a refresh that began before this send must not bring the sent text back into the composer
562
+ // 5:510 engageSendMessageClick, as RN's mobile-apps-inbox logSendMessage sends it for a member's typed message to the
563
+ // business (biLogger.service.ts:226-258, origin 'native' from biLogger.utils.ts). RN has no contact id here either.
564
+ // It is logged on the Send tap, before the network call, on purpose: RN calls engageSendMessageClick synchronously
565
+ // before sendMessageService.sendMessage, so a send the server then refuses has logged 510 and also logs 1604 (deliver).
566
+ logBi({evid:510,src:5,endpoint:'',params:{origin:'native',is_member:true,chatRoomType:'member to business',activity_type:'',appName:'',expand_mode:false,textLength:text.length,is_demo:false}});
559
567
  void deliver(pending,s.draft);
560
568
  return shape({...s,draft:'',pendingIntent:pending,messages:[...s.messages,pendingRow(pending)],error:'',notice:'',scrollSend:s.scrollSend+1});
561
569
  },
@@ -65783,7 +65783,8 @@ const SCREENS = runtimeSetting({
65783
65783
  "integrity": "",
65784
65784
  "contentType": "application/javascript+ts-bundle",
65785
65785
  "declaredCapabilities": [
65786
- "wix_api"
65786
+ "wix_api",
65787
+ "wix_platform"
65787
65788
  ],
65788
65789
  "minBinaryVersion": "0.1.0",
65789
65790
  "bundleVersion": "0.0.1"
@@ -0,0 +1,85 @@
1
+ // RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
2
+ // other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
3
+ // rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
4
+ // field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
5
+ import { bi, type BiLogEvent } from "@himalaya/wix-platform";
6
+
7
+ /** Sends one event without waiting for it and never throws: BI must not change a screen. A
8
+ * screen whose descriptor does not declare `wix_platform` is refused by the host, which is
9
+ * swallowed here like any other BI failure. */
10
+ export function logBi(event: BiLogEvent): void {
11
+ try {
12
+ void Promise.resolve(bi.log(event)).catch(() => undefined);
13
+ } catch {
14
+ /* BI is best-effort */
15
+ }
16
+ }
17
+
18
+ /** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
19
+ export function wixErrorStatus(error: unknown): number {
20
+ const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
21
+ if (Number.isFinite(own) && own > 0) return own;
22
+ const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
23
+ return match ? Number(match[1]) : 0;
24
+ }
25
+
26
+ function applicationErrorCode(body: unknown): string {
27
+ const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
28
+ const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
29
+ return typeof code === "string" ? code : "";
30
+ }
31
+
32
+ /** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
33
+ * (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
34
+ const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
35
+
36
+ /** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
37
+ * error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
38
+ * JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
39
+ * when there is none. */
40
+ export function wixErrorCode(error: unknown): string {
41
+ const own = applicationErrorCode(error);
42
+ if (own) return own;
43
+ const message = String((error as Error | null)?.message ?? error ?? "");
44
+ const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
45
+ if (bracketed) return bracketed[1];
46
+ const start = message.indexOf("{");
47
+ if (start < 0) return "";
48
+ try {
49
+ return applicationErrorCode(JSON.parse(message.slice(start)));
50
+ } catch {
51
+ return "";
52
+ }
53
+ }
54
+
55
+ // RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
56
+ const ERROR_INDICATIONS = new Set([
57
+ "ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
58
+ "FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
59
+ "INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
60
+ "MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
61
+ "RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
62
+ "TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
63
+ "TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
64
+ "TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
65
+ "TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
66
+ "UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
67
+ ]);
68
+
69
+ /** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
70
+ * send that failed and said so. RN's `errorReason` is the failed message's indication code, and
71
+ * RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
72
+ * never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
73
+ export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
74
+ const code = wixErrorCode(input.error);
75
+ const errorReason = input.offline ? "NETWORK_ISSUE"
76
+ : ERROR_INDICATIONS.has(code) ? code
77
+ : wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
78
+ : "UNSUPPORTED";
79
+ logBi({
80
+ evid: 1604,
81
+ src: 5,
82
+ endpoint: "",
83
+ params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
84
+ });
85
+ }
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
22
22
  import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
23
23
  import { formatMonthDayTime } from "../_shared/engine-intl.js";
24
24
  import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
25
- import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
25
+ import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
26
+ import { logChatSendError } from "../_shared/wix-bi.js";
26
27
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
27
28
  import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
28
29
 
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
280
281
  } catch (e) {
281
282
  // The draft stays: the owner should not have to type it again. A send that may
282
283
  // have landed says so, so a retry does not post it twice unknowingly.
283
- return { ...live(), sendHint: writeMayHaveLanded(e) ? ownerWriteError(e) : `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
+ if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
285
+ const { id, kind } = input();
286
+ logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
287
+ return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
288
  }
285
289
  // Clear the composer only if it still holds what was sent — the owner may already be
286
290
  // typing the next message — judged on the state AFTER the re-read's await.
@@ -39065,6 +39065,7 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
39065
39065
  "share",
39066
39066
  "local_database",
39067
39067
  "open_url",
39068
+ "wix_platform",
39068
39069
  "iap",
39069
39070
  "app_info"
39070
39071
  ],
@@ -0,0 +1,85 @@
1
+ // RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
2
+ // other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
3
+ // rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
4
+ // field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
5
+ import { bi, type BiLogEvent } from "@himalaya/wix-platform";
6
+
7
+ /** Sends one event without waiting for it and never throws: BI must not change a screen. A
8
+ * screen whose descriptor does not declare `wix_platform` is refused by the host, which is
9
+ * swallowed here like any other BI failure. */
10
+ export function logBi(event: BiLogEvent): void {
11
+ try {
12
+ void Promise.resolve(bi.log(event)).catch(() => undefined);
13
+ } catch {
14
+ /* BI is best-effort */
15
+ }
16
+ }
17
+
18
+ /** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
19
+ export function wixErrorStatus(error: unknown): number {
20
+ const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
21
+ if (Number.isFinite(own) && own > 0) return own;
22
+ const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
23
+ return match ? Number(match[1]) : 0;
24
+ }
25
+
26
+ function applicationErrorCode(body: unknown): string {
27
+ const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
28
+ const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
29
+ return typeof code === "string" ? code : "";
30
+ }
31
+
32
+ /** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
33
+ * (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
34
+ const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
35
+
36
+ /** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
37
+ * error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
38
+ * JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
39
+ * when there is none. */
40
+ export function wixErrorCode(error: unknown): string {
41
+ const own = applicationErrorCode(error);
42
+ if (own) return own;
43
+ const message = String((error as Error | null)?.message ?? error ?? "");
44
+ const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
45
+ if (bracketed) return bracketed[1];
46
+ const start = message.indexOf("{");
47
+ if (start < 0) return "";
48
+ try {
49
+ return applicationErrorCode(JSON.parse(message.slice(start)));
50
+ } catch {
51
+ return "";
52
+ }
53
+ }
54
+
55
+ // RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
56
+ const ERROR_INDICATIONS = new Set([
57
+ "ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
58
+ "FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
59
+ "INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
60
+ "MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
61
+ "RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
62
+ "TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
63
+ "TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
64
+ "TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
65
+ "TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
66
+ "UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
67
+ ]);
68
+
69
+ /** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
70
+ * send that failed and said so. RN's `errorReason` is the failed message's indication code, and
71
+ * RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
72
+ * never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
73
+ export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
74
+ const code = wixErrorCode(input.error);
75
+ const errorReason = input.offline ? "NETWORK_ISSUE"
76
+ : ERROR_INDICATIONS.has(code) ? code
77
+ : wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
78
+ : "UNSUPPORTED";
79
+ logBi({
80
+ evid: 1604,
81
+ src: 5,
82
+ endpoint: "",
83
+ params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
84
+ });
85
+ }
@@ -11,6 +11,7 @@ import { createRedirectSession } from "@himalaya/wix-redirects";
11
11
  import { isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
12
12
  import { hostedCheckoutOpener, isHostedWorker } from "../_shared/hosted-checkout.js";
13
13
  import { formatCurrency } from "../_shared/engine-intl.js";
14
+ import { logBi, wixErrorCode } from "../_shared/wix-bi.js";
14
15
 
15
16
  /** Wix Stores appDefId — the vertical that owns a cart/ecom order, and therefore the
16
17
  * `appId` its cashier order is paid under. (Same constant Wix's own tooling uses.) */
@@ -458,6 +459,14 @@ const svc = defineService<State, {
458
459
  const mayHaveLanded = added || writeMayHaveLanded(error);
459
460
  const refreshed = mayHaveLanded ? await refresh(state).catch(() => null) : null;
460
461
  if (refreshed?.appliedCode === code) return derive({ ...refreshed, promoBusy: false, promoCode: "", promoError: "" });
462
+ // 130:117 couponApplyingFailed (ecom-platform bi/storefront.ts:448, sent from cartActions.ts:345 when
463
+ // the add-coupon call throws). errorCode is RN's serializeError(e).code, the Wix application error code.
464
+ // Only the add-coupon call itself: once it answered, the coupon is on the cart, and a later step that
465
+ // throws (the cart refresh) is not a coupon that failed to apply.
466
+ if (!added) {
467
+ const errorCode = wixErrorCode(error);
468
+ logBi({ evid: 117, src: 130, endpoint: "ec-site", params: { origin: "checkout", couponCode: code, ...(errorCode ? { errorCode } : {}) } });
469
+ }
461
470
  return derive({ ...state, promoBusy: false, promoError: mayHaveLanded
462
471
  ? copyParam("cart.promoUnconfirmed", "Could not confirm the promo code. Refresh your cart.")
463
472
  : isOfflineFailure(error)
@@ -66242,7 +66242,8 @@ const SCREENS = runtimeSetting({
66242
66242
  "integrity": "",
66243
66243
  "contentType": "application/javascript+ts-bundle",
66244
66244
  "declaredCapabilities": [
66245
- "wix_api"
66245
+ "wix_api",
66246
+ "wix_platform"
66246
66247
  ],
66247
66248
  "minBinaryVersion": "0.1.0",
66248
66249
  "bundleVersion": "0.0.1"
@@ -0,0 +1,85 @@
1
+ // RN BI events whose fields exist only in a worker (epic #4973). The platform maps send every
2
+ // other RN event; these go through `wixPlatform.bi.log`, built inline with RN's own field names
3
+ // rather than by bundling a `@wix/bi-logger-*` package. The host owns every identity and common
4
+ // field (msid, uuid, installationId, contactId, _lv, ...), so none is named here.
5
+ import { bi, type BiLogEvent } from "@himalaya/wix-platform";
6
+
7
+ /** Sends one event without waiting for it and never throws: BI must not change a screen. A
8
+ * screen whose descriptor does not declare `wix_platform` is refused by the host, which is
9
+ * swallowed here like any other BI failure. */
10
+ export function logBi(event: BiLogEvent): void {
11
+ try {
12
+ void Promise.resolve(bi.log(event)).catch(() => undefined);
13
+ } catch {
14
+ /* BI is best-effort */
15
+ }
16
+ }
17
+
18
+ /** The HTTP status a Wix SDK error carries (`HTTP 429: ...`, or a `status` field), else 0. */
19
+ export function wixErrorStatus(error: unknown): number {
20
+ const own = Number((error as { status?: unknown; statusCode?: unknown } | null)?.status ?? (error as { statusCode?: unknown } | null)?.statusCode);
21
+ if (Number.isFinite(own) && own > 0) return own;
22
+ const match = /\bHTTP (\d{3})\b/.exec(String((error as Error | null)?.message ?? error ?? ""));
23
+ return match ? Number(match[1]) : 0;
24
+ }
25
+
26
+ function applicationErrorCode(body: unknown): string {
27
+ const o = body as { details?: { applicationError?: { code?: unknown } }; applicationError?: { code?: unknown }; code?: unknown } | null;
28
+ const code = o?.details?.applicationError?.code ?? o?.applicationError?.code ?? o?.code;
29
+ return typeof code === "string" ? code : "";
30
+ }
31
+
32
+ /** The code both native bridges put in an application error's message: `HTTP 400 [CODE]: description`
33
+ * (iOS JSWorker.swift `WixApiCapability.Error.application`, Android WebViewJSWorker.kt `Error.Application`). */
34
+ const BRIDGE_APPLICATION_CODE = /\bHTTP \d{3} \[([A-Za-z0-9_.:-]+)\]/;
35
+
36
+ /** The Wix application error code of a failed call (RN's `serializeError(e).code`): read from the
37
+ * error itself, else from the `[CODE]` the native bridges put after `HTTP <status> `, else from the
38
+ * JSON body after `HTTP <status>: ` (the bridges' raw-status arm and the web host's wixCall). ""
39
+ * when there is none. */
40
+ export function wixErrorCode(error: unknown): string {
41
+ const own = applicationErrorCode(error);
42
+ if (own) return own;
43
+ const message = String((error as Error | null)?.message ?? error ?? "");
44
+ const bracketed = BRIDGE_APPLICATION_CODE.exec(message);
45
+ if (bracketed) return bracketed[1];
46
+ const start = message.indexOf("{");
47
+ if (start < 0) return "";
48
+ try {
49
+ return applicationErrorCode(JSON.parse(message.slice(start)));
50
+ } catch {
51
+ return "";
52
+ }
53
+ }
54
+
55
+ // RN's `ErrorIndicationType` (mobile-apps-inbox services/errorIndications/errorIndications.type.ts).
56
+ const ERROR_INDICATIONS = new Set([
57
+ "ACCESS_TOKEN_EXPIRED", "ALLOWED_MESSAGING_TIME_WINDOW_EXPIRED", "ATTACHMENT_SIZE_EXCEEDS_ALLOWED_LIMIT", "CAMPAIGN_SUSPENDED",
58
+ "FACEBOOK_ALLOWED_WINDOW_EXPIRED", "GMAIL_ADV_PROTECTION", "INSTAGRAM_ALLOWED_WINDOW_EXPIRED", "INVALID_CHARACTERS",
59
+ "INVALID_PHONE_NUMBER", "INVALID_RECIPIENT_ADDRESS", "LANDLINE_OR_UNREACHABLE_CARRIER", "MESSAGE_FILTERED",
60
+ "MMS_NOT_SUPPORTED_RECEIVING_PHONE_NUMBER", "NETWORK_ISSUE", "NO_MATCHING_RECIPIENT_FOUND", "POLICY_VIOLATION", "QUOTA_EXCEEDED",
61
+ "RATE_LIMIT", "RATE_LIMIT_ERROR", "RECIPIENT_BLOCKED_MESSAGES", "RECIPIENT_NOT_AVAILABLE", "SERVICE_UNAVAILABLE",
62
+ "TELCO_LANDLINE_OR_UNREACHABLE_CARRIER", "TELCO_MEDIA_EXCEEDS_MESSAGING_PROVIDER_SIZE_LIMIT",
63
+ "TELCO_MESSAGE_DELIVERY_UNKNOWN_DESTINATION_HANDSET", "TELCO_MESSAGE_FILTERED", "TELCO_MESSAGE_FROM_NUMBER_STILL_BEING_CONFIGURED",
64
+ "TELCO_MESSAGE_FROM_UNREGISTERED_NUMBER", "TELCO_UNKNOWN_ERROR", "TELCO_UNREACHABLE_DESTINATION_HANDSET", "TOO_MANY_REQUESTS",
65
+ "TOTAL_ATTACHMENTS_SIZE_EXCEEDS_ALLOWED_LIMIT", "UNEXPECTED_ERROR_RETRY_LATER", "UNKNOWN_FAILED_CODE", "UNSUPPORTED",
66
+ "UNSUPPORTED_MESSAGE_TYPE", "USER_RATE_LIMIT",
67
+ ]);
68
+
69
+ /** 5:1604 inboxSendMessageErrorMsgShown (`@wix/bi-logger-crm-data` v2, endpoint ''), for a chat
70
+ * send that failed and said so. RN's `errorReason` is the failed message's indication code, and
71
+ * RN reports a code it does not know as UNSUPPORTED (`getErrorIndicationFromCode`); a send that
72
+ * never left the device is NETWORK_ISSUE and a 429 is RATE_LIMIT. */
73
+ export function logChatSendError(input: { chatroomId: string; contactId?: string; error: unknown; offline: boolean }): void {
74
+ const code = wixErrorCode(input.error);
75
+ const errorReason = input.offline ? "NETWORK_ISSUE"
76
+ : ERROR_INDICATIONS.has(code) ? code
77
+ : wixErrorStatus(input.error) === 429 ? "RATE_LIMIT"
78
+ : "UNSUPPORTED";
79
+ logBi({
80
+ evid: 1604,
81
+ src: 5,
82
+ endpoint: "",
83
+ params: { origin: "native", chatroomId: input.chatroomId, ...(input.contactId ? { contact_id: input.contactId } : {}), errorReason },
84
+ });
85
+ }
@@ -22,7 +22,8 @@ import { defineService, navigate, type NavDirective, type PollDirective, type St
22
22
  import { getMessages, sendChatMessage, listChatrooms, markChatroomRead, getChatToken, type ChatMessage } from "@himalaya/wix-chat-web";
23
23
  import { formatMonthDayTime } from "../_shared/engine-intl.js";
24
24
  import { presence, presenceAfterError, detailInputId, type PresenceFlags } from "../_shared/detail-presence.js";
25
- import { ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
25
+ import { isOfflineFailure, ownerLoadError, ownerWriteError, writeMayHaveLanded } from "../_shared/owner-load-error.js";
26
+ import { logChatSendError } from "../_shared/wix-bi.js";
26
27
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
27
28
  import { chatRealtimeConfig, createReloadGate, createSendIntents, createVisitToken, liveDirectives, postWithVisitToken, liveFallback, type ChatLiveMode, type ChatRealtimeConfig } from "../_shared/chat-live.js";
28
29
 
@@ -280,7 +281,10 @@ const svc = defineService<ThreadState, {
280
281
  } catch (e) {
281
282
  // The draft stays: the owner should not have to type it again. A send that may
282
283
  // have landed says so, so a retry does not post it twice unknowingly.
283
- return { ...live(), sendHint: writeMayHaveLanded(e) ? ownerWriteError(e) : `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
+ if (writeMayHaveLanded(e)) return { ...live(), sendHint: ownerWriteError(e) };
285
+ const { id, kind } = input();
286
+ logChatSendError({ chatroomId: s.chatroomId, contactId: kind === "contact" ? id : "", error: e, offline: isOfflineFailure(e) });
287
+ return { ...live(), sendHint: `${copyParam("ownerInbox.sendFailed", "Couldn’t send")} — ${ownerWriteError(e)}` };
284
288
  }
285
289
  // Clear the composer only if it still holds what was sent — the owner may already be
286
290
  // typing the next message — judged on the state AFTER the re-read's await.
@@ -65859,7 +65859,8 @@ const SCREENS = runtimeSetting({
65859
65859
  "integrity": "",
65860
65860
  "contentType": "application/javascript+ts-bundle",
65861
65861
  "declaredCapabilities": [
65862
- "wix_api"
65862
+ "wix_api",
65863
+ "wix_platform"
65863
65864
  ],
65864
65865
  "minBinaryVersion": "0.1.0",
65865
65866
  "bundleVersion": "0.0.1"