@apextelemed/partner-core 0.19.0 → 0.20.0-dev.67

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.
@@ -4541,11 +4541,59 @@ var FORWARDED = /* @__PURE__ */ new Set([
4541
4541
  "step:shown",
4542
4542
  "step:completed",
4543
4543
  "abandoned",
4544
- "submit:succeeded"
4544
+ "submit:succeeded",
4545
+ "disqualified"
4545
4546
  ]);
4547
+ var PATIENT_INFO_STEP_ID = "patient_info";
4548
+ function describeStep(steps, stepIndex) {
4549
+ if (stepIndex === steps.length && steps.length > 0) {
4550
+ return { stepId: PATIENT_INFO_STEP_ID, stepTitle: "Contact information", questions: [] };
4551
+ }
4552
+ const step2 = steps[stepIndex];
4553
+ if (!step2) return null;
4554
+ return {
4555
+ stepId: step2.stepId,
4556
+ stepTitle: step2.stepTitle || void 0,
4557
+ sectionTitle: step2.sectionTitle || void 0,
4558
+ questions: step2.questions.map((q) => q.text).filter((t) => typeof t === "string" && t.trim().length > 0)
4559
+ };
4560
+ }
4561
+ function rejectionReasons(drugResults) {
4562
+ const out = /* @__PURE__ */ new Set();
4563
+ for (const d of drugResults ?? []) {
4564
+ if (d.qualified) continue;
4565
+ const reasons = [...d.disqualificationReasons ?? [], d.disqualificationReason];
4566
+ for (const r of reasons) if (typeof r === "string" && r.trim()) out.add(r.trim());
4567
+ }
4568
+ return [...out];
4569
+ }
4546
4570
  function createFunnelTelemetry() {
4547
4571
  let enabled = null;
4548
4572
  let buffer = [];
4573
+ let source = null;
4574
+ function enrich(e) {
4575
+ if (!source) return e;
4576
+ const data = e.data ?? {};
4577
+ if (e.type === "step:shown" || e.type === "step:completed") {
4578
+ const index = typeof data.stepIndex === "number" ? data.stepIndex : null;
4579
+ const page = index === null ? null : describeStep(source.flatSteps(), index);
4580
+ if (!page) return e;
4581
+ return {
4582
+ ...e,
4583
+ data: e.type === "step:shown" ? { ...data, ...page } : { ...data, stepId: page.stepId }
4584
+ };
4585
+ }
4586
+ if (e.type === "disqualified") {
4587
+ const index = source.stepIndex();
4588
+ const page = describeStep(source.flatSteps(), index);
4589
+ const drugResults = data.drugResults;
4590
+ return {
4591
+ type: e.type,
4592
+ data: { stepIndex: index, stepId: page?.stepId, reasons: rejectionReasons(drugResults) }
4593
+ };
4594
+ }
4595
+ return e;
4596
+ }
4549
4597
  void fetchFunnelConfig().then((cfg) => {
4550
4598
  enabled = cfg.telemetry;
4551
4599
  const pending = buffer;
@@ -4556,8 +4604,12 @@ function createFunnelTelemetry() {
4556
4604
  postFunnelEvent(e.type, e.data ?? void 0);
4557
4605
  }
4558
4606
  return {
4559
- onEvent(e) {
4560
- if (!FORWARDED.has(e.type)) return;
4607
+ attach(s) {
4608
+ source = s;
4609
+ },
4610
+ onEvent(raw) {
4611
+ if (!FORWARDED.has(raw.type)) return;
4612
+ const e = enrich(raw);
4561
4613
  if (enabled === null) {
4562
4614
  if (buffer.length < 50) buffer.push(e);
4563
4615
  return;
@@ -4698,7 +4750,7 @@ function useSurveyV2Flow(opts) {
4698
4750
  templateId: opts.templateId,
4699
4751
  mode: opts.mode
4700
4752
  });
4701
- return usePackageSurveyV2Flow({
4753
+ const flow = usePackageSurveyV2Flow({
4702
4754
  apiBaseUrl: cfg.apexEmbedApiBase,
4703
4755
  publishableKey: cfg.apexPublishableKey,
4704
4756
  tenantKey: cfg.tenantKey,
@@ -4717,6 +4769,8 @@ function useSurveyV2Flow(opts) {
4717
4769
  },
4718
4770
  onError: opts.onError
4719
4771
  });
4772
+ telemetry.attach({ flatSteps: flow.flatSteps, stepIndex: flow.stepIndex });
4773
+ return flow;
4720
4774
  }
4721
4775
  var PRESCRIPTION_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
4722
4776
  async function uploadPrescriptionPhoto(file) {
@@ -6753,4 +6807,4 @@ export {
6753
6807
  useAddPharmacy,
6754
6808
  useSmsPreferences
6755
6809
  };
6756
- //# sourceMappingURL=HEXXZYK4.jsx.map
6810
+ //# sourceMappingURL=KSEIBHCD.jsx.map