@convokitapp/chat-embed 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -101,6 +101,10 @@ who never open chat never become chat users.
101
101
 
102
102
  ## Limits and billing
103
103
 
104
+ On ConvoKit's free plan the widget works in `guest` mode for up to 100 new
105
+ visitors a month and shows a small "Powered by ConvoKit" link. `uid` and
106
+ `authToken` modes, and removing the link, need a paid plan.
107
+
104
108
  Widget users are ordinary app users and count toward monthly active users.
105
109
  The dashboard sets a monthly cap on new widget users (default 1,000), and the
106
110
  API rate-limits session requests per client IP. An optional list of allowed
package/dist/index.js CHANGED
@@ -198,14 +198,22 @@ var ICONS = {
198
198
  };
199
199
  var FRIENDLY = {
200
200
  WIDGET_USER_LIMIT_REACHED: "Chat is busy right now. Please try again later.",
201
+ PLAN_USER_LIMIT_REACHED: "Chat is busy right now. Please try again later.",
202
+ PLAN_UPGRADE_REQUIRED: "Chat is currently unavailable.",
201
203
  RATE_LIMITED: "Too many attempts. Please wait a few minutes and try again.",
202
204
  ORIGIN_NOT_ALLOWED: "Chat is not enabled for this website.",
203
205
  WIDGET_DISABLED: "Chat is currently unavailable.",
204
206
  WIDGET_MODE_DISABLED: "Chat is currently unavailable.",
205
207
  SUBSCRIPTION_REQUIRED: "Chat is currently unavailable."
206
208
  };
209
+ var OWNER_HINTS = {
210
+ PLAN_UPGRADE_REQUIRED: 'This ConvoKit plan only supports guest mode. Use mode: "guest", or upgrade to Starter for "uid" and "authToken".',
211
+ PLAN_USER_LIMIT_REACHED: "This ConvoKit plan has reached its monthly active user limit. Upgrade the plan in the ConvoKit dashboard.",
212
+ WIDGET_USER_LIMIT_REACHED: "The monthly limit of new widget users is reached. Raise it in the ConvoKit dashboard or upgrade the plan."
213
+ };
214
+ var errorCode = (error) => error instanceof WidgetSessionError || error instanceof ConvoKitError ? error.code : void 0;
207
215
  function friendly(error) {
208
- const code = error instanceof WidgetSessionError || error instanceof ConvoKitError ? error.code : void 0;
216
+ const code = errorCode(error);
209
217
  if (code && FRIENDLY[code]) return FRIENDLY[code];
210
218
  return "Could not connect to chat. Check your connection and try again.";
211
219
  }
@@ -326,6 +334,8 @@ var ChatWidget = class {
326
334
  if (this.config.startConversationWith.length) await this.openConversation(await this.findOrCreateConversation());
327
335
  else await this.showInbox();
328
336
  } catch (error) {
337
+ const hint = OWNER_HINTS[errorCode(error) ?? ""];
338
+ if (hint) console.warn(`[ConvoKitWidget] ${hint}`);
329
339
  console.error("[ConvoKitWidget] could not start chat:", error);
330
340
  this.client = null;
331
341
  this.session = null;