@inploi/plugin-chatbot 3.28.5 → 3.28.7

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.
@@ -1,4 +1,4 @@
1
- import { g as get$1, i as isString$2, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, c as getFlowSubmissionsPayload, N, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-d86fb8f9.js";
1
+ import { g as get$1, i as isString$2, k as kbToReadableSize, a as getHeadOrThrow, b as invariant, A as AbortedError, c as getFlowSubmissionsPayload, N, _, d as getDefaultExportFromCjs, h, e as _$1, p, F, o as o$1, f as clsx, y, s as store, j as a$2, l as k, m as k$1, n as getFormSubmitter, q as parse, r as picklist, t as isSubmissionOfType, C as Cn, u as parseAsync, V as ValiError, v as object, w as transform, x as cva, z as maxLength, B as minLength, D as record, E as boolean, G as number, H as minValue, I as maxValue, J as custom, K as string, L as regex, M as email, O as url, P as LoadingIndicator, Q as ERROR_MESSAGES } from "./index-12c8b547.js";
2
2
  import "@inploi/sdk";
3
3
  const isConditionMet = ({
4
4
  condition,
@@ -450,6 +450,13 @@ async function interpret(params) {
450
450
  throw new Error(`Unknown node: ${JSON.stringify(node)}`);
451
451
  }
452
452
  }
453
+ const getSubmissionValue = (submissions, key) => {
454
+ var _a;
455
+ const value = (_a = submissions[key]) == null ? void 0 : _a.value;
456
+ if (typeof value !== "string" && typeof value !== "number")
457
+ throw new Error(`Submission at “${key}” is not a string or number`);
458
+ return value;
459
+ };
453
460
  async function interpretIdentifyNode({
454
461
  next,
455
462
  node,
@@ -457,21 +464,31 @@ async function interpretIdentifyNode({
457
464
  submissions,
458
465
  logger
459
466
  }) {
460
- var _a;
461
467
  if (!submissions)
462
468
  return next(node.nextId);
463
- const identifier = (_a = submissions[node.data.key]) == null ? void 0 : _a.value;
464
- if (typeof identifier !== "string" && typeof identifier !== "number") {
465
- logger.warn(`Failed to identify user, key “${node.data.key}” is not a string or number`);
466
- return next(node.nextId);
469
+ try {
470
+ analytics.log({
471
+ event: "IDENTIFY",
472
+ properties: {
473
+ identifier: getSubmissionValue(submissions, node.data.key).toString(),
474
+ first_name: node.data.firstName ? getSubmissionValue(submissions, node.data.firstName).toString() : void 0,
475
+ last_name: node.data.lastName ? getSubmissionValue(submissions, node.data.lastName).toString() : void 0,
476
+ email: node.data.email ? getSubmissionValue(submissions, node.data.email).toString() : void 0,
477
+ phone_number: node.data.phoneNumber ? getSubmissionValue(submissions, node.data.phoneNumber).toString() : void 0,
478
+ custom_traits: node.data.customTraits ? Object.fromEntries(node.data.customTraits.map(({
479
+ key,
480
+ value
481
+ }) => {
482
+ var _a;
483
+ return [key, (_a = submissions[value]) == null ? void 0 : _a.value];
484
+ })) : void 0
485
+ }
486
+ });
487
+ } catch (e) {
488
+ logger.error(e);
489
+ } finally {
490
+ next(node.nextId);
467
491
  }
468
- analytics.log({
469
- event: "IDENTIFY",
470
- properties: {
471
- identifier: identifier.toString()
472
- }
473
- });
474
- next(node.nextId);
475
492
  }
476
493
  async function interpretJumpNode({
477
494
  next,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-a5203fc5.cjs");
3
+ const index = require("./index-ab7e5077.cjs");
4
4
  require("@inploi/sdk");
5
5
  const isConditionMet = ({
6
6
  condition,
@@ -452,6 +452,13 @@ async function interpret(params) {
452
452
  throw new Error(`Unknown node: ${JSON.stringify(node)}`);
453
453
  }
454
454
  }
455
+ const getSubmissionValue = (submissions, key) => {
456
+ var _a;
457
+ const value = (_a = submissions[key]) == null ? void 0 : _a.value;
458
+ if (typeof value !== "string" && typeof value !== "number")
459
+ throw new Error(`Submission at “${key}” is not a string or number`);
460
+ return value;
461
+ };
455
462
  async function interpretIdentifyNode({
456
463
  next,
457
464
  node,
@@ -459,21 +466,31 @@ async function interpretIdentifyNode({
459
466
  submissions,
460
467
  logger
461
468
  }) {
462
- var _a;
463
469
  if (!submissions)
464
470
  return next(node.nextId);
465
- const identifier = (_a = submissions[node.data.key]) == null ? void 0 : _a.value;
466
- if (typeof identifier !== "string" && typeof identifier !== "number") {
467
- logger.warn(`Failed to identify user, key “${node.data.key}” is not a string or number`);
468
- return next(node.nextId);
471
+ try {
472
+ analytics.log({
473
+ event: "IDENTIFY",
474
+ properties: {
475
+ identifier: getSubmissionValue(submissions, node.data.key).toString(),
476
+ first_name: node.data.firstName ? getSubmissionValue(submissions, node.data.firstName).toString() : void 0,
477
+ last_name: node.data.lastName ? getSubmissionValue(submissions, node.data.lastName).toString() : void 0,
478
+ email: node.data.email ? getSubmissionValue(submissions, node.data.email).toString() : void 0,
479
+ phone_number: node.data.phoneNumber ? getSubmissionValue(submissions, node.data.phoneNumber).toString() : void 0,
480
+ custom_traits: node.data.customTraits ? Object.fromEntries(node.data.customTraits.map(({
481
+ key,
482
+ value
483
+ }) => {
484
+ var _a;
485
+ return [key, (_a = submissions[value]) == null ? void 0 : _a.value];
486
+ })) : void 0
487
+ }
488
+ });
489
+ } catch (e) {
490
+ logger.error(e);
491
+ } finally {
492
+ next(node.nextId);
469
493
  }
470
- analytics.log({
471
- event: "IDENTIFY",
472
- properties: {
473
- identifier: identifier.toString()
474
- }
475
- });
476
- next(node.nextId);
477
494
  }
478
495
  async function interpretJumpNode({
479
496
  next,
@@ -203,6 +203,14 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
203
203
  } | {
204
204
  data: {
205
205
  key: string;
206
+ firstName?: string | undefined;
207
+ lastName?: string | undefined;
208
+ phoneNumber?: string | undefined;
209
+ email?: string | undefined;
210
+ customTraits?: {
211
+ value: string;
212
+ key: string;
213
+ }[] | undefined;
206
214
  };
207
215
  type: "identify";
208
216
  id: string;
@@ -400,6 +408,14 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
400
408
  } | {
401
409
  data: {
402
410
  key: string;
411
+ firstName?: string | undefined;
412
+ lastName?: string | undefined;
413
+ phoneNumber?: string | undefined;
414
+ email?: string | undefined;
415
+ customTraits?: {
416
+ value: string;
417
+ key: string;
418
+ }[] | undefined;
403
419
  };
404
420
  type: "identify";
405
421
  id: string;
@@ -624,6 +640,14 @@ export declare const FlowSchema: import("valibot").ObjectSchema<{
624
640
  } | {
625
641
  data: {
626
642
  key: string;
643
+ firstName?: string | undefined;
644
+ lastName?: string | undefined;
645
+ phoneNumber?: string | undefined;
646
+ email?: string | undefined;
647
+ customTraits?: {
648
+ value: string;
649
+ key: string;
650
+ }[] | undefined;
627
651
  };
628
652
  type: "identify";
629
653
  id: string;
@@ -835,6 +859,14 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
835
859
  } | {
836
860
  data: {
837
861
  key: string;
862
+ firstName?: string | undefined;
863
+ lastName?: string | undefined;
864
+ phoneNumber?: string | undefined;
865
+ email?: string | undefined;
866
+ customTraits?: {
867
+ value: string;
868
+ key: string;
869
+ }[] | undefined;
838
870
  };
839
871
  type: "identify";
840
872
  id: string;
@@ -1032,6 +1064,14 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1032
1064
  } | {
1033
1065
  data: {
1034
1066
  key: string;
1067
+ firstName?: string | undefined;
1068
+ lastName?: string | undefined;
1069
+ phoneNumber?: string | undefined;
1070
+ email?: string | undefined;
1071
+ customTraits?: {
1072
+ value: string;
1073
+ key: string;
1074
+ }[] | undefined;
1035
1075
  };
1036
1076
  type: "identify";
1037
1077
  id: string;
@@ -1256,6 +1296,14 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1256
1296
  } | {
1257
1297
  data: {
1258
1298
  key: string;
1299
+ firstName?: string | undefined;
1300
+ lastName?: string | undefined;
1301
+ phoneNumber?: string | undefined;
1302
+ email?: string | undefined;
1303
+ customTraits?: {
1304
+ value: string;
1305
+ key: string;
1306
+ }[] | undefined;
1259
1307
  };
1260
1308
  type: "identify";
1261
1309
  id: string;
@@ -1466,6 +1514,14 @@ export declare const FlowByIdPayloadSchema: import("valibot").ObjectSchema<{
1466
1514
  } | {
1467
1515
  data: {
1468
1516
  key: string;
1517
+ firstName?: string | undefined;
1518
+ lastName?: string | undefined;
1519
+ phoneNumber?: string | undefined;
1520
+ email?: string | undefined;
1521
+ customTraits?: {
1522
+ value: string;
1523
+ key: string;
1524
+ }[] | undefined;
1469
1525
  };
1470
1526
  type: "identify";
1471
1527
  id: string;
@@ -1682,6 +1738,14 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
1682
1738
  } | {
1683
1739
  data: {
1684
1740
  key: string;
1741
+ firstName?: string | undefined;
1742
+ lastName?: string | undefined;
1743
+ phoneNumber?: string | undefined;
1744
+ email?: string | undefined;
1745
+ customTraits?: {
1746
+ value: string;
1747
+ key: string;
1748
+ }[] | undefined;
1685
1749
  };
1686
1750
  type: "identify";
1687
1751
  id: string;
@@ -1879,6 +1943,14 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
1879
1943
  } | {
1880
1944
  data: {
1881
1945
  key: string;
1946
+ firstName?: string | undefined;
1947
+ lastName?: string | undefined;
1948
+ phoneNumber?: string | undefined;
1949
+ email?: string | undefined;
1950
+ customTraits?: {
1951
+ value: string;
1952
+ key: string;
1953
+ }[] | undefined;
1882
1954
  };
1883
1955
  type: "identify";
1884
1956
  id: string;
@@ -2103,6 +2175,14 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
2103
2175
  } | {
2104
2176
  data: {
2105
2177
  key: string;
2178
+ firstName?: string | undefined;
2179
+ lastName?: string | undefined;
2180
+ phoneNumber?: string | undefined;
2181
+ email?: string | undefined;
2182
+ customTraits?: {
2183
+ value: string;
2184
+ key: string;
2185
+ }[] | undefined;
2106
2186
  };
2107
2187
  type: "identify";
2108
2188
  id: string;
@@ -2320,6 +2400,14 @@ export declare const FlowByJobPayloadSchema: import("valibot").ObjectSchema<{
2320
2400
  } | {
2321
2401
  data: {
2322
2402
  key: string;
2403
+ firstName?: string | undefined;
2404
+ lastName?: string | undefined;
2405
+ phoneNumber?: string | undefined;
2406
+ email?: string | undefined;
2407
+ customTraits?: {
2408
+ value: string;
2409
+ key: string;
2410
+ }[] | undefined;
2323
2411
  };
2324
2412
  type: "identify";
2325
2413
  id: string;
@@ -194,6 +194,14 @@ export declare const getHeadOrThrow: (nodes: FlowNode[]) => {
194
194
  } | {
195
195
  data: {
196
196
  key: string;
197
+ firstName?: string | undefined;
198
+ lastName?: string | undefined;
199
+ phoneNumber?: string | undefined;
200
+ email?: string | undefined;
201
+ customTraits?: {
202
+ value: string;
203
+ key: string;
204
+ }[] | undefined;
197
205
  };
198
206
  type: "identify";
199
207
  id: string;
@@ -5320,7 +5320,7 @@ const StatusBar = ({
5320
5320
  };
5321
5321
  function noop() {
5322
5322
  }
5323
- const ChatbotBody = M(() => import("./chatbot-body-3937530b.js").then((module) => module.ChatbotBody));
5323
+ const ChatbotBody = M(() => import("./chatbot-body-a8a1e4f3.js").then((module) => module.ChatbotBody));
5324
5324
  const chatbotContentClass = cva("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none [&:has(.view-switch:active)]:scale-[0.98] transition-all duration-1000 ease-expo-out", {
5325
5325
  variants: {
5326
5326
  view: {
@@ -5321,7 +5321,7 @@ const StatusBar = ({
5321
5321
  };
5322
5322
  function noop() {
5323
5323
  }
5324
- const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-37310a05.cjs")).then((module2) => module2.ChatbotBody));
5324
+ const ChatbotBody = M(() => Promise.resolve().then(() => require("./chatbot-body-ea9d97f5.cjs")).then((module2) => module2.ChatbotBody));
5325
5325
  const chatbotContentClass = cva("selection:bg-accent-4 selection:text-accent-12 fixed bottom-2 left-2 right-2 isolate mx-auto max-h-full max-w-[450px] focus:outline-none [&:has(.view-switch:active)]:scale-[0.98] transition-all duration-1000 ease-expo-out", {
5326
5326
  variants: {
5327
5327
  view: {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./index-a5203fc5.cjs");
3
+ const index = require("./index-ab7e5077.cjs");
4
4
  require("@inploi/sdk");
5
5
  exports.chatbotPlugin = index.chatbotPlugin;
@@ -1,4 +1,4 @@
1
- import { R } from "./index-d86fb8f9.js";
1
+ import { R } from "./index-12c8b547.js";
2
2
  import "@inploi/sdk";
3
3
  export {
4
4
  R as chatbotPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inploi/plugin-chatbot",
3
- "version": "3.28.5",
3
+ "version": "3.28.7",
4
4
  "type": "module",
5
5
  "main": "dist/plugin-chatbot.js",
6
6
  "types": "dist/index.d.ts",
@@ -67,7 +67,7 @@
67
67
  "vite": "^4.4.5",
68
68
  "vite-plugin-dts": "^3.7.0",
69
69
  "vite-tsconfig-paths": "^4.2.1",
70
- "@inploi/core": "1.14.6",
70
+ "@inploi/core": "1.14.8",
71
71
  "@inploi/design-tokens": "0.2.1",
72
72
  "@inploi/sdk": "1.14.9",
73
73
  "eslint-config-custom": "0.1.0",