@langwatch/server 3.1.0-beta.4 → 3.1.0-beta.6
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/langwatch/ee/admin/ImpersonationBanner.tsx +61 -0
- package/langwatch/ee/admin/ImpersonationSwitchBackMenuItem.tsx +30 -0
- package/langwatch/ee/admin/__tests__/ImpersonationBanner.integration.test.tsx +82 -0
- package/langwatch/ee/admin/__tests__/impersonation.service.unit.test.ts +231 -0
- package/langwatch/ee/admin/backoffice/BackofficeTable.tsx +200 -0
- package/langwatch/ee/admin/backoffice/__tests__/adminClient.unit.test.ts +147 -0
- package/langwatch/ee/admin/backoffice/__tests__/dateInputToISO.unit.test.ts +42 -0
- package/langwatch/ee/admin/backoffice/__tests__/userVisibility.unit.test.ts +174 -0
- package/langwatch/ee/admin/backoffice/adminClient.ts +114 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationFeaturesView.tsx +373 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationsView.tsx +677 -0
- package/langwatch/ee/admin/backoffice/resources/ProjectsView.tsx +647 -0
- package/langwatch/ee/admin/backoffice/resources/SubscriptionsView.tsx +628 -0
- package/langwatch/ee/admin/backoffice/resources/UsersView.tsx +556 -0
- package/langwatch/ee/admin/backoffice/useAdminResource.ts +104 -0
- package/langwatch/ee/admin/backoffice/userVisibility.ts +105 -0
- package/langwatch/ee/admin/impersonation.service.ts +170 -0
- package/langwatch/ee/admin/isAdmin.ts +9 -0
- package/langwatch/ee/admin/routes/admin.ts +531 -0
- package/langwatch/ee/admin/safeSelects.ts +64 -0
- package/langwatch/ee/billing/__tests__/customerService.unit.test.ts +183 -0
- package/langwatch/ee/billing/__tests__/growthSeatEvent.unit.test.ts +213 -0
- package/langwatch/ee/billing/__tests__/licensePurchaseHandler.unit.test.ts +250 -0
- package/langwatch/ee/billing/__tests__/notification.service.unit.test.ts +768 -0
- package/langwatch/ee/billing/__tests__/planLimits.unit.test.ts +19 -0
- package/langwatch/ee/billing/__tests__/planProvider.unit.test.ts +440 -0
- package/langwatch/ee/billing/__tests__/planTypes.unit.test.ts +32 -0
- package/langwatch/ee/billing/__tests__/pricing.unit.test.ts +54 -0
- package/langwatch/ee/billing/__tests__/seatEventSubscription.unit.test.ts +717 -0
- package/langwatch/ee/billing/__tests__/stripe.integration.test.ts +344 -0
- package/langwatch/ee/billing/__tests__/stripePrices.types.unit.test.ts +27 -0
- package/langwatch/ee/billing/__tests__/stripePricesLoader.unit.test.ts +72 -0
- package/langwatch/ee/billing/__tests__/subscription.service.unit.test.ts +730 -0
- package/langwatch/ee/billing/__tests__/subscriptionItemCalculator.unit.test.ts +176 -0
- package/langwatch/ee/billing/__tests__/usage-limit.service.unit.test.ts +706 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.integration.test.ts +421 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.unit.test.ts +515 -0
- package/langwatch/ee/billing/__tests__/webhookService.unit.test.ts +958 -0
- package/langwatch/ee/billing/currencyRouter.ts +18 -0
- package/langwatch/ee/billing/errors.ts +129 -0
- package/langwatch/ee/billing/index.ts +67 -0
- package/langwatch/ee/billing/middleware.ts +17 -0
- package/langwatch/ee/billing/notifications/notification.service.ts +651 -0
- package/langwatch/ee/billing/notifications/repositories/notification.repository.ts +51 -0
- package/langwatch/ee/billing/notifications/types.ts +9 -0
- package/langwatch/ee/billing/notifications/usage-limit.service.ts +622 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.ts +90 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.unit.test.ts +237 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.ts +120 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.unit.test.ts +324 -0
- package/langwatch/ee/billing/nurturing/hooks/index.ts +17 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.ts +68 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.unit.test.ts +138 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.integration.test.ts +288 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.ts +131 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.unit.test.ts +134 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.ts +101 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.unit.test.ts +317 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.ts +49 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.unit.test.ts +170 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.ts +143 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.unit.test.ts +307 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.ts +179 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.unit.test.ts +266 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.wiring.unit.test.ts +109 -0
- package/langwatch/ee/billing/nurturing/types.ts +125 -0
- package/langwatch/ee/billing/planLimits.ts +190 -0
- package/langwatch/ee/billing/planProvider.ts +119 -0
- package/langwatch/ee/billing/planTypes.ts +53 -0
- package/langwatch/ee/billing/pricing.ts +57 -0
- package/langwatch/ee/billing/services/billableEventsQuery.ts +248 -0
- package/langwatch/ee/billing/services/customerService.ts +90 -0
- package/langwatch/ee/billing/services/licensePurchaseHandler.ts +73 -0
- package/langwatch/ee/billing/services/seatEventSubscription.ts +351 -0
- package/langwatch/ee/billing/services/seatSyncService.ts +34 -0
- package/langwatch/ee/billing/services/subscription.repository.ts +203 -0
- package/langwatch/ee/billing/services/subscription.service.ts +549 -0
- package/langwatch/ee/billing/services/subscriptionItemCalculator.ts +249 -0
- package/langwatch/ee/billing/services/usageReportingService.ts +301 -0
- package/langwatch/ee/billing/services/webhookService.ts +858 -0
- package/langwatch/ee/billing/stripe/stripeCatalog.json +1781 -0
- package/langwatch/ee/billing/stripe/stripeClient.ts +13 -0
- package/langwatch/ee/billing/stripe/stripePriceCatalog.ts +70 -0
- package/langwatch/ee/billing/stripe/stripePrices.types.ts +118 -0
- package/langwatch/ee/billing/subscriptionRouter.ts +202 -0
- package/langwatch/ee/billing/types.ts +102 -0
- package/langwatch/ee/billing/utils/currency.ts +99 -0
- package/langwatch/ee/billing/utils/growthSeatEvent.ts +137 -0
- package/langwatch/ee/licensing/__tests__/constants.unit.test.ts +56 -0
- package/langwatch/ee/licensing/__tests__/defaults.unit.test.ts +192 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testKeys.ts +86 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testLicenses.ts +92 -0
- package/langwatch/ee/licensing/__tests__/licenseGenerationService.unit.test.ts +232 -0
- package/langwatch/ee/licensing/__tests__/licenseHandler.integration.test.ts +419 -0
- package/langwatch/ee/licensing/__tests__/planMapping.unit.test.ts +195 -0
- package/langwatch/ee/licensing/__tests__/planTemplates.unit.test.ts +193 -0
- package/langwatch/ee/licensing/__tests__/signing.unit.test.ts +164 -0
- package/langwatch/ee/licensing/__tests__/validation.unit.test.ts +281 -0
- package/langwatch/ee/licensing/client.ts +29 -0
- package/langwatch/ee/licensing/constants.ts +195 -0
- package/langwatch/ee/licensing/defaults.ts +55 -0
- package/langwatch/ee/licensing/errors.ts +11 -0
- package/langwatch/ee/licensing/index.ts +52 -0
- package/langwatch/ee/licensing/licenseGenerationService.ts +87 -0
- package/langwatch/ee/licensing/licenseHandler.ts +308 -0
- package/langwatch/ee/licensing/planInfo.ts +46 -0
- package/langwatch/ee/licensing/planMapping.ts +37 -0
- package/langwatch/ee/licensing/planTemplates.ts +109 -0
- package/langwatch/ee/licensing/server.ts +43 -0
- package/langwatch/ee/licensing/signing.ts +43 -0
- package/langwatch/ee/licensing/types.ts +156 -0
- package/langwatch/ee/licensing/validation.ts +107 -0
- package/langwatch/ee/managed-providers/ManagedModelProviderAlert.tsx +29 -0
- package/langwatch/ee/managed-providers/managedBedrockConfig.ts +226 -0
- package/langwatch/ee/saas/ExtraFooterComponents.tsx +169 -0
- package/langwatch/package.json +1 -1
- package/langwatch/pnpm-workspace.yaml +0 -1
- package/mcp-server/.env.example +2 -0
- package/mcp-server/.eslintrc.cjs +36 -0
- package/mcp-server/CHANGELOG.md +165 -0
- package/mcp-server/CONTRIBUTING.md +96 -0
- package/mcp-server/README.md +172 -0
- package/mcp-server/dist/archive-scenario-WJ2A7ETN.js +19 -0
- package/mcp-server/dist/archive-suite-4JOM4SSL.js +15 -0
- package/mcp-server/dist/assign-prompt-tag-GL7EAAF3.js +19 -0
- package/mcp-server/dist/chunk-2GT7IFWK.js +40 -0
- package/mcp-server/dist/chunk-2WPLXEKF.js +127 -0
- package/mcp-server/dist/chunk-4AUB2BIA.js +71 -0
- package/mcp-server/dist/chunk-BWWY5KEF.js +71 -0
- package/mcp-server/dist/chunk-CCWCIJJ3.js +22 -0
- package/mcp-server/dist/chunk-EGH5RPXM.js +25 -0
- package/mcp-server/dist/chunk-EUQDVOSU.js +39 -0
- package/mcp-server/dist/chunk-HYMIWO3U.js +44 -0
- package/mcp-server/dist/chunk-IE4M5OGE.js +42 -0
- package/mcp-server/dist/chunk-LUMEZEHL.js +48 -0
- package/mcp-server/dist/chunk-NUFPTHKU.js +9 -0
- package/mcp-server/dist/chunk-UDHJYT6P.js +1567 -0
- package/mcp-server/dist/chunk-WQG2DFHX.js +86 -0
- package/mcp-server/dist/chunk-WVI5CJ6S.js +21 -0
- package/mcp-server/dist/chunk-ZVS4UKN2.js +35 -0
- package/mcp-server/dist/chunk-ZXKLPC2E.js +27 -0
- package/mcp-server/dist/config.d.ts +17 -0
- package/mcp-server/dist/config.js +13 -0
- package/mcp-server/dist/create-agent-MBOOT3XK.js +23 -0
- package/mcp-server/dist/create-annotation-XMV6A7ED.js +24 -0
- package/mcp-server/dist/create-dashboard-VRKLFVZJ.js +18 -0
- package/mcp-server/dist/create-dataset-7HQPZCRE.js +22 -0
- package/mcp-server/dist/create-dataset-records-2NIVFYTV.js +22 -0
- package/mcp-server/dist/create-evaluator-WYFRFLRC.js +27 -0
- package/mcp-server/dist/create-mcp-server.d.ts +8 -0
- package/mcp-server/dist/create-mcp-server.js +8 -0
- package/mcp-server/dist/create-prompt-IEN7O6JT.js +39 -0
- package/mcp-server/dist/create-prompt-tag-CAEZ45VO.js +17 -0
- package/mcp-server/dist/create-scenario-6YHSMGLP.js +26 -0
- package/mcp-server/dist/create-suite-H5XOFDE5.js +38 -0
- package/mcp-server/dist/delete-agent-JKTNBWAA.js +18 -0
- package/mcp-server/dist/delete-annotation-ACMDV6QO.js +17 -0
- package/mcp-server/dist/delete-dashboard-VJSR7CRU.js +18 -0
- package/mcp-server/dist/delete-dataset-RTTTWP4D.js +20 -0
- package/mcp-server/dist/delete-dataset-records-KNQTIPQK.js +21 -0
- package/mcp-server/dist/delete-evaluator-7FVC5WM4.js +15 -0
- package/mcp-server/dist/delete-prompt-tag-ZMZUAGFW.js +17 -0
- package/mcp-server/dist/delete-workflow-EYQ3T4RQ.js +17 -0
- package/mcp-server/dist/discover-evaluator-schema-H23XCLNE.js +1402 -0
- package/mcp-server/dist/discover-scenario-schema-MEEEVND7.js +65 -0
- package/mcp-server/dist/discover-schema-3T52ORPB.js +446 -0
- package/mcp-server/dist/get-agent-E3QSTVKG.js +28 -0
- package/mcp-server/dist/get-analytics-2OHV763I.js +72 -0
- package/mcp-server/dist/get-dashboard-PC7JDHH6.js +29 -0
- package/mcp-server/dist/get-dataset-H5IK5FVU.js +48 -0
- package/mcp-server/dist/get-evaluator-UWVUPYTM.js +47 -0
- package/mcp-server/dist/get-prompt-WZUOLLQC.js +45 -0
- package/mcp-server/dist/get-scenario-Q6LCNUYN.js +33 -0
- package/mcp-server/dist/get-simulation-run-Z2XKO256.js +56 -0
- package/mcp-server/dist/get-suite-BXK5TN7P.js +44 -0
- package/mcp-server/dist/get-trace-4EJAYVBG.js +50 -0
- package/mcp-server/dist/get-workflow-O34QJLHD.js +25 -0
- package/mcp-server/dist/http-server-RSTXN4CN.js +224 -0
- package/mcp-server/dist/index.d.ts +2 -0
- package/mcp-server/dist/index.js +67774 -0
- package/mcp-server/dist/langwatch-api-annotations-ERBG27RF.js +17 -0
- package/mcp-server/dist/langwatch-api-dashboards-G6TR7VVO.js +17 -0
- package/mcp-server/dist/langwatch-api-monitors-WSXZLS2B.js +52 -0
- package/mcp-server/dist/langwatch-api-secrets-RR5DKG2X.js +40 -0
- package/mcp-server/dist/langwatch-api-triggers-2RTNSWQY.js +30 -0
- package/mcp-server/dist/langwatch-api-workflows-VJRIIDZ7.js +15 -0
- package/mcp-server/dist/list-agents-AW3P6FJV.js +32 -0
- package/mcp-server/dist/list-annotations-QNCGWPQ3.js +33 -0
- package/mcp-server/dist/list-dashboards-R7RK2IXL.js +32 -0
- package/mcp-server/dist/list-dataset-records-WVCSQP7P.js +39 -0
- package/mcp-server/dist/list-datasets-KEXRLDEU.js +60 -0
- package/mcp-server/dist/list-evaluators-7R2LB4JH.js +34 -0
- package/mcp-server/dist/list-model-providers-OBYJCKBX.js +35 -0
- package/mcp-server/dist/list-prompt-tags-6LY3ZPYI.js +23 -0
- package/mcp-server/dist/list-prompts-VWEZ4CDE.js +32 -0
- package/mcp-server/dist/list-scenarios-TXD4W2ZJ.js +40 -0
- package/mcp-server/dist/list-simulation-runs-RHPOLMFI.js +43 -0
- package/mcp-server/dist/list-suites-FSGBX27Z.js +42 -0
- package/mcp-server/dist/list-workflows-VRGEZ3EN.js +35 -0
- package/mcp-server/dist/rename-prompt-tag-VOJJLX4M.js +18 -0
- package/mcp-server/dist/run-agent-KTCC7TB7.js +36 -0
- package/mcp-server/dist/run-evaluation-2X3V3Q6L.js +64 -0
- package/mcp-server/dist/run-suite-BTMHGI2D.js +29 -0
- package/mcp-server/dist/run-workflow-IGAYGKJL.js +36 -0
- package/mcp-server/dist/search-traces-VYFUIMXH.js +72 -0
- package/mcp-server/dist/set-model-provider-W5IUI326.js +33 -0
- package/mcp-server/dist/update-agent-4BB7EYLR.js +20 -0
- package/mcp-server/dist/update-dataset-CXBKZ4W3.js +22 -0
- package/mcp-server/dist/update-dataset-record-HOHAMHXG.js +19 -0
- package/mcp-server/dist/update-evaluator-IVOR6FTR.js +24 -0
- package/mcp-server/dist/update-prompt-OWQAKE7K.js +24 -0
- package/mcp-server/dist/update-scenario-GDFVILPN.js +27 -0
- package/mcp-server/dist/update-suite-BXYUYSPT.js +39 -0
- package/mcp-server/package.json +79 -0
- package/mcp-server/pnpm-lock.yaml +6103 -0
- package/mcp-server/pnpm-workspace.yaml +2 -0
- package/mcp-server/pyproject.toml +17 -0
- package/mcp-server/src/__tests__/all-tools.integration.test.ts +1681 -0
- package/mcp-server/src/__tests__/config.unit.test.ts +169 -0
- package/mcp-server/src/__tests__/datasets.integration.test.ts +603 -0
- package/mcp-server/src/__tests__/datasets.unit.test.ts +240 -0
- package/mcp-server/src/__tests__/date-parsing.unit.test.ts +78 -0
- package/mcp-server/src/__tests__/discover-evaluator-schema.unit.test.ts +89 -0
- package/mcp-server/src/__tests__/discover-schema.unit.test.ts +118 -0
- package/mcp-server/src/__tests__/docker.integration.test.ts +234 -0
- package/mcp-server/src/__tests__/evaluator-tools.unit.test.ts +262 -0
- package/mcp-server/src/__tests__/http-transport.integration.test.ts +397 -0
- package/mcp-server/src/__tests__/integration.integration.test.ts +288 -0
- package/mcp-server/src/__tests__/langwatch-api.unit.test.ts +455 -0
- package/mcp-server/src/__tests__/model-provider-tools.unit.test.ts +190 -0
- package/mcp-server/src/__tests__/scenario-tools.integration.test.ts +286 -0
- package/mcp-server/src/__tests__/scenario-tools.unit.test.ts +185 -0
- package/mcp-server/src/__tests__/schemas.unit.test.ts +85 -0
- package/mcp-server/src/__tests__/tools.unit.test.ts +900 -0
- package/mcp-server/src/config.d.ts +15 -0
- package/mcp-server/src/config.ts +107 -0
- package/mcp-server/src/create-mcp-server.d.ts +6 -0
- package/mcp-server/src/create-mcp-server.ts +1799 -0
- package/mcp-server/src/http-server.ts +329 -0
- package/mcp-server/src/index.ts +46 -0
- package/mcp-server/src/langwatch-api-agents.ts +108 -0
- package/mcp-server/src/langwatch-api-annotations.ts +49 -0
- package/mcp-server/src/langwatch-api-dashboards.ts +48 -0
- package/mcp-server/src/langwatch-api-datasets.ts +191 -0
- package/mcp-server/src/langwatch-api-evaluators.ts +80 -0
- package/mcp-server/src/langwatch-api-model-providers.ts +41 -0
- package/mcp-server/src/langwatch-api-monitors.ts +82 -0
- package/mcp-server/src/langwatch-api-scenarios.ts +67 -0
- package/mcp-server/src/langwatch-api-secrets.ts +48 -0
- package/mcp-server/src/langwatch-api-simulation-runs.ts +51 -0
- package/mcp-server/src/langwatch-api-suites.ts +118 -0
- package/mcp-server/src/langwatch-api-triggers.ts +48 -0
- package/mcp-server/src/langwatch-api-workflows.ts +41 -0
- package/mcp-server/src/langwatch-api.ts +299 -0
- package/mcp-server/src/schemas/analytics-groups.ts +78 -0
- package/mcp-server/src/schemas/analytics-metrics.ts +179 -0
- package/mcp-server/src/schemas/create-dataset.ts +48 -0
- package/mcp-server/src/schemas/filter-fields.ts +119 -0
- package/mcp-server/src/schemas/index.ts +4 -0
- package/mcp-server/src/tools/archive-scenario.ts +19 -0
- package/mcp-server/src/tools/archive-suite.ts +12 -0
- package/mcp-server/src/tools/assign-prompt-tag.ts +16 -0
- package/mcp-server/src/tools/create-agent.ts +15 -0
- package/mcp-server/src/tools/create-annotation.ts +18 -0
- package/mcp-server/src/tools/create-dashboard.ts +7 -0
- package/mcp-server/src/tools/create-dataset-records.ts +23 -0
- package/mcp-server/src/tools/create-dataset.ts +22 -0
- package/mcp-server/src/tools/create-evaluator.ts +33 -0
- package/mcp-server/src/tools/create-prompt-tag.ts +12 -0
- package/mcp-server/src/tools/create-prompt.ts +58 -0
- package/mcp-server/src/tools/create-scenario.ts +30 -0
- package/mcp-server/src/tools/create-suite.ts +42 -0
- package/mcp-server/src/tools/delete-agent.ts +7 -0
- package/mcp-server/src/tools/delete-annotation.ts +7 -0
- package/mcp-server/src/tools/delete-dashboard.ts +7 -0
- package/mcp-server/src/tools/delete-dataset-records.ts +22 -0
- package/mcp-server/src/tools/delete-dataset.ts +20 -0
- package/mcp-server/src/tools/delete-evaluator.ts +12 -0
- package/mcp-server/src/tools/delete-prompt-tag.ts +12 -0
- package/mcp-server/src/tools/delete-workflow.ts +7 -0
- package/mcp-server/src/tools/discover-evaluator-schema.ts +143 -0
- package/mcp-server/src/tools/discover-scenario-schema.ts +71 -0
- package/mcp-server/src/tools/discover-schema.ts +106 -0
- package/mcp-server/src/tools/format-dataset-mutation.ts +25 -0
- package/mcp-server/src/tools/get-agent.ts +21 -0
- package/mcp-server/src/tools/get-analytics.ts +98 -0
- package/mcp-server/src/tools/get-dashboard.ts +22 -0
- package/mcp-server/src/tools/get-dataset.ts +63 -0
- package/mcp-server/src/tools/get-evaluator.ts +53 -0
- package/mcp-server/src/tools/get-prompt.ts +54 -0
- package/mcp-server/src/tools/get-scenario.ts +36 -0
- package/mcp-server/src/tools/get-simulation-run.ts +60 -0
- package/mcp-server/src/tools/get-suite.ts +47 -0
- package/mcp-server/src/tools/get-trace.ts +61 -0
- package/mcp-server/src/tools/get-workflow.ts +17 -0
- package/mcp-server/src/tools/list-agents.ts +27 -0
- package/mcp-server/src/tools/list-annotations.ts +33 -0
- package/mcp-server/src/tools/list-dashboards.ts +27 -0
- package/mcp-server/src/tools/list-dataset-records.ts +46 -0
- package/mcp-server/src/tools/list-datasets.ts +80 -0
- package/mcp-server/src/tools/list-evaluators.ts +37 -0
- package/mcp-server/src/tools/list-model-providers.ts +40 -0
- package/mcp-server/src/tools/list-prompt-tags.ts +21 -0
- package/mcp-server/src/tools/list-prompts.ts +34 -0
- package/mcp-server/src/tools/list-scenarios.ts +47 -0
- package/mcp-server/src/tools/list-simulation-runs.ts +49 -0
- package/mcp-server/src/tools/list-suites.ts +43 -0
- package/mcp-server/src/tools/list-workflows.ts +31 -0
- package/mcp-server/src/tools/rename-prompt-tag.ts +14 -0
- package/mcp-server/src/tools/run-agent.ts +36 -0
- package/mcp-server/src/tools/run-evaluation.ts +87 -0
- package/mcp-server/src/tools/run-suite.ts +28 -0
- package/mcp-server/src/tools/run-workflow.ts +36 -0
- package/mcp-server/src/tools/search-traces.ts +91 -0
- package/mcp-server/src/tools/set-model-provider.ts +46 -0
- package/mcp-server/src/tools/update-agent.ts +13 -0
- package/mcp-server/src/tools/update-dataset-record.ts +21 -0
- package/mcp-server/src/tools/update-dataset.ts +23 -0
- package/mcp-server/src/tools/update-evaluator.ts +30 -0
- package/mcp-server/src/tools/update-prompt.ts +31 -0
- package/mcp-server/src/tools/update-scenario.ts +32 -0
- package/mcp-server/src/tools/update-suite.ts +44 -0
- package/mcp-server/src/utils/date-parsing.ts +31 -0
- package/mcp-server/src/utils/escape-markdown.ts +12 -0
- package/mcp-server/tsconfig.json +27 -0
- package/mcp-server/uv.lock +2731 -0
- package/package.json +2 -1
- package/packages/server/dist/cli.cjs +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
fireActivityTrackingNurturing,
|
|
4
|
+
resetActivityTrackingCache,
|
|
5
|
+
getActivityTrackingCacheSize,
|
|
6
|
+
} from "./activityTracking";
|
|
7
|
+
|
|
8
|
+
// Suppress logger output
|
|
9
|
+
vi.mock("../../../../src/utils/logger/server", () => ({
|
|
10
|
+
createLogger: () => ({
|
|
11
|
+
info: vi.fn(),
|
|
12
|
+
warn: vi.fn(),
|
|
13
|
+
error: vi.fn(),
|
|
14
|
+
debug: vi.fn(),
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
vi.mock("../../../../src/utils/posthogErrorCapture", () => ({
|
|
18
|
+
captureException: vi.fn(),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const mockNurturing = {
|
|
22
|
+
identifyUser: vi.fn().mockResolvedValue(undefined),
|
|
23
|
+
trackEvent: vi.fn().mockResolvedValue(undefined),
|
|
24
|
+
groupUser: vi.fn().mockResolvedValue(undefined),
|
|
25
|
+
batch: vi.fn().mockResolvedValue(undefined),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let currentNurturing: typeof mockNurturing | undefined = mockNurturing;
|
|
29
|
+
|
|
30
|
+
vi.mock("../../../../src/server/app-layer/app", () => ({
|
|
31
|
+
getApp: () => ({
|
|
32
|
+
get nurturing() {
|
|
33
|
+
return currentNurturing;
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
describe("Activity tracking hook", () => {
|
|
39
|
+
describe("given an active NurturingService", () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
vi.clearAllMocks();
|
|
42
|
+
currentNurturing = mockNurturing;
|
|
43
|
+
resetActivityTrackingCache();
|
|
44
|
+
vi.useRealTimers();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("when the auth session callback fires", () => {
|
|
48
|
+
it("identifies user with last_active_at set to the current time", () => {
|
|
49
|
+
const now = new Date("2026-03-15T12:00:00.000Z");
|
|
50
|
+
vi.setSystemTime(now);
|
|
51
|
+
|
|
52
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
53
|
+
|
|
54
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledWith({
|
|
55
|
+
userId: "user-1",
|
|
56
|
+
traits: { last_active_at: "2026-03-15T12:00:00.000Z" },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
vi.useRealTimers();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("when a user refreshes their session multiple times within one hour", () => {
|
|
64
|
+
it("makes at most one Customer.io identify call per hour", () => {
|
|
65
|
+
vi.useFakeTimers();
|
|
66
|
+
vi.setSystemTime(new Date("2026-03-15T12:00:00.000Z"));
|
|
67
|
+
|
|
68
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
69
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
70
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
71
|
+
|
|
72
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledTimes(1);
|
|
73
|
+
|
|
74
|
+
vi.useRealTimers();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("allows a new call after one hour has passed", () => {
|
|
78
|
+
vi.useFakeTimers();
|
|
79
|
+
vi.setSystemTime(new Date("2026-03-15T12:00:00.000Z"));
|
|
80
|
+
|
|
81
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
82
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledTimes(1);
|
|
83
|
+
|
|
84
|
+
// Advance past the 1-hour debounce window
|
|
85
|
+
vi.advanceTimersByTime(60 * 60 * 1000 + 1);
|
|
86
|
+
|
|
87
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
88
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledTimes(2);
|
|
89
|
+
|
|
90
|
+
vi.useRealTimers();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("tracks separate users independently", () => {
|
|
94
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
95
|
+
fireActivityTrackingNurturing({ userId: "user-2" });
|
|
96
|
+
|
|
97
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledTimes(2);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("when expired entries accumulate in the debounce cache", () => {
|
|
102
|
+
it("evicts entries older than one hour during the next call", () => {
|
|
103
|
+
vi.useFakeTimers();
|
|
104
|
+
vi.setSystemTime(new Date("2026-03-15T12:00:00.000Z"));
|
|
105
|
+
|
|
106
|
+
// Populate cache with multiple users
|
|
107
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
108
|
+
fireActivityTrackingNurturing({ userId: "user-2" });
|
|
109
|
+
fireActivityTrackingNurturing({ userId: "user-3" });
|
|
110
|
+
expect(getActivityTrackingCacheSize()).toBe(3);
|
|
111
|
+
|
|
112
|
+
// Advance past the 1-hour window so entries are expired
|
|
113
|
+
vi.advanceTimersByTime(60 * 60 * 1000 + 1);
|
|
114
|
+
|
|
115
|
+
// Next call triggers sweep and evicts expired entries
|
|
116
|
+
fireActivityTrackingNurturing({ userId: "user-4" });
|
|
117
|
+
|
|
118
|
+
// Only user-4 remains (user-1..3 were evicted by sweep)
|
|
119
|
+
expect(getActivityTrackingCacheSize()).toBe(1);
|
|
120
|
+
|
|
121
|
+
vi.useRealTimers();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("does not sweep more than once per hour", () => {
|
|
125
|
+
vi.useFakeTimers();
|
|
126
|
+
vi.setSystemTime(new Date("2026-03-15T12:00:00.000Z"));
|
|
127
|
+
|
|
128
|
+
// First call triggers sweep (lastSweepAt is 0)
|
|
129
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
130
|
+
expect(getActivityTrackingCacheSize()).toBe(1);
|
|
131
|
+
|
|
132
|
+
// Advance 30 minutes — not enough for another sweep
|
|
133
|
+
vi.advanceTimersByTime(30 * 60 * 1000);
|
|
134
|
+
fireActivityTrackingNurturing({ userId: "user-2" });
|
|
135
|
+
expect(getActivityTrackingCacheSize()).toBe(2);
|
|
136
|
+
|
|
137
|
+
// Advance another 31 minutes (total 61 min from start)
|
|
138
|
+
// user-1 is now expired but sweep hasn't run since 30min mark
|
|
139
|
+
vi.advanceTimersByTime(31 * 60 * 1000);
|
|
140
|
+
fireActivityTrackingNurturing({ userId: "user-3" });
|
|
141
|
+
|
|
142
|
+
// Sweep should have run: user-1 expired (61 min old), user-2 still valid (31 min old)
|
|
143
|
+
// user-3 just added. So cache = user-2 + user-3 = 2
|
|
144
|
+
expect(getActivityTrackingCacheSize()).toBe(2);
|
|
145
|
+
|
|
146
|
+
vi.useRealTimers();
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("when Customer.io API is unavailable", () => {
|
|
151
|
+
it("does not throw (fire-and-forget)", async () => {
|
|
152
|
+
const { captureException } = await import(
|
|
153
|
+
"../../../../src/utils/posthogErrorCapture"
|
|
154
|
+
);
|
|
155
|
+
mockNurturing.identifyUser.mockRejectedValueOnce(
|
|
156
|
+
new Error("CIO unavailable"),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
expect(() =>
|
|
160
|
+
fireActivityTrackingNurturing({ userId: "user-1" }),
|
|
161
|
+
).not.toThrow();
|
|
162
|
+
|
|
163
|
+
await vi.waitFor(() => {
|
|
164
|
+
expect(captureException).toHaveBeenCalled();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("clears the cache entry on rejection so the next call can retry", async () => {
|
|
169
|
+
mockNurturing.identifyUser.mockRejectedValueOnce(
|
|
170
|
+
new Error("CIO unavailable"),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
174
|
+
expect(getActivityTrackingCacheSize()).toBe(1);
|
|
175
|
+
|
|
176
|
+
await vi.waitFor(() => {
|
|
177
|
+
expect(getActivityTrackingCacheSize()).toBe(0);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Next call should succeed and re-add to cache
|
|
181
|
+
mockNurturing.identifyUser.mockResolvedValueOnce(undefined);
|
|
182
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
183
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledTimes(2);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("given a user who has not completed onboarding (no organization)", () => {
|
|
189
|
+
beforeEach(() => {
|
|
190
|
+
vi.clearAllMocks();
|
|
191
|
+
currentNurturing = mockNurturing;
|
|
192
|
+
resetActivityTrackingCache();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
describe("when the auth session callback fires", () => {
|
|
196
|
+
it("does not call identifyUser to avoid creating ghost people in Customer.io", () => {
|
|
197
|
+
fireActivityTrackingNurturing({
|
|
198
|
+
userId: "user-no-org",
|
|
199
|
+
hasOrganization: false,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("does not populate the debounce cache", () => {
|
|
206
|
+
fireActivityTrackingNurturing({
|
|
207
|
+
userId: "user-no-org",
|
|
208
|
+
hasOrganization: false,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(getActivityTrackingCacheSize()).toBe(0);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe("given nurturing is undefined", () => {
|
|
217
|
+
beforeEach(() => {
|
|
218
|
+
vi.clearAllMocks();
|
|
219
|
+
currentNurturing = undefined;
|
|
220
|
+
resetActivityTrackingCache();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe("when the auth session callback fires", () => {
|
|
224
|
+
it("silently skips without calling any nurturing methods", () => {
|
|
225
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
226
|
+
|
|
227
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("does not populate the debounce cache", () => {
|
|
231
|
+
fireActivityTrackingNurturing({ userId: "user-1" });
|
|
232
|
+
|
|
233
|
+
expect(getActivityTrackingCacheSize()).toBe(0);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { getApp } from "../../../../src/server/app-layer/app";
|
|
2
|
+
import { captureException } from "../../../../src/utils/posthogErrorCapture";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fires nurturing calls when a team member is invited.
|
|
6
|
+
*
|
|
7
|
+
* Updates the user's team_member_count trait and tracks the event.
|
|
8
|
+
* All calls are fire-and-forget.
|
|
9
|
+
*/
|
|
10
|
+
export function fireTeamMemberInvitedNurturing({
|
|
11
|
+
userId,
|
|
12
|
+
teamMemberCount,
|
|
13
|
+
role,
|
|
14
|
+
}: {
|
|
15
|
+
userId: string;
|
|
16
|
+
teamMemberCount: number;
|
|
17
|
+
role: string;
|
|
18
|
+
}): void {
|
|
19
|
+
const nurturing = getApp().nurturing;
|
|
20
|
+
if (!nurturing) return;
|
|
21
|
+
|
|
22
|
+
void nurturing
|
|
23
|
+
.identifyUser({ userId, traits: { team_member_count: teamMemberCount } })
|
|
24
|
+
.catch(captureException);
|
|
25
|
+
|
|
26
|
+
void nurturing
|
|
27
|
+
.trackEvent({ userId, event: "team_member_invited", properties: {
|
|
28
|
+
role,
|
|
29
|
+
}})
|
|
30
|
+
.catch(captureException);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Fires nurturing calls when a workflow is created.
|
|
35
|
+
*
|
|
36
|
+
* Updates the user's workflow_count trait and tracks the event.
|
|
37
|
+
* All calls are fire-and-forget.
|
|
38
|
+
*/
|
|
39
|
+
export function fireWorkflowCreatedNurturing({
|
|
40
|
+
userId,
|
|
41
|
+
workflowCount,
|
|
42
|
+
workflowId,
|
|
43
|
+
projectId,
|
|
44
|
+
}: {
|
|
45
|
+
userId: string;
|
|
46
|
+
workflowCount: number;
|
|
47
|
+
workflowId: string;
|
|
48
|
+
projectId: string;
|
|
49
|
+
}): void {
|
|
50
|
+
const nurturing = getApp().nurturing;
|
|
51
|
+
if (!nurturing) return;
|
|
52
|
+
|
|
53
|
+
void nurturing
|
|
54
|
+
.identifyUser({ userId, traits: { workflow_count: workflowCount } })
|
|
55
|
+
.catch(captureException);
|
|
56
|
+
|
|
57
|
+
void nurturing
|
|
58
|
+
.trackEvent({ userId, event: "workflow_created", properties: {
|
|
59
|
+
workflow_id: workflowId,
|
|
60
|
+
project_id: projectId,
|
|
61
|
+
}})
|
|
62
|
+
.catch(captureException);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Fires nurturing calls when a scenario is created.
|
|
67
|
+
*
|
|
68
|
+
* Updates the user's scenario_count trait and tracks the event.
|
|
69
|
+
* All calls are fire-and-forget.
|
|
70
|
+
*/
|
|
71
|
+
export function fireScenarioCreatedNurturing({
|
|
72
|
+
userId,
|
|
73
|
+
scenarioCount,
|
|
74
|
+
scenarioId,
|
|
75
|
+
projectId,
|
|
76
|
+
}: {
|
|
77
|
+
userId: string;
|
|
78
|
+
scenarioCount: number;
|
|
79
|
+
scenarioId: string;
|
|
80
|
+
projectId: string;
|
|
81
|
+
}): void {
|
|
82
|
+
const nurturing = getApp().nurturing;
|
|
83
|
+
if (!nurturing) return;
|
|
84
|
+
|
|
85
|
+
void nurturing
|
|
86
|
+
.identifyUser({ userId, traits: { scenario_count: scenarioCount } })
|
|
87
|
+
.catch(captureException);
|
|
88
|
+
|
|
89
|
+
void nurturing
|
|
90
|
+
.trackEvent({ userId, event: "scenario_created", properties: {
|
|
91
|
+
scenario_id: scenarioId,
|
|
92
|
+
project_id: projectId,
|
|
93
|
+
}})
|
|
94
|
+
.catch(captureException);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Fires nurturing event when an experiment is run.
|
|
99
|
+
*
|
|
100
|
+
* Fire-and-forget.
|
|
101
|
+
*/
|
|
102
|
+
export function fireExperimentRanNurturing({
|
|
103
|
+
userId,
|
|
104
|
+
experimentId,
|
|
105
|
+
projectId,
|
|
106
|
+
}: {
|
|
107
|
+
userId: string;
|
|
108
|
+
experimentId?: string;
|
|
109
|
+
projectId: string;
|
|
110
|
+
}): void {
|
|
111
|
+
const nurturing = getApp().nurturing;
|
|
112
|
+
if (!nurturing) return;
|
|
113
|
+
|
|
114
|
+
void nurturing
|
|
115
|
+
.trackEvent({ userId, event: "experiment_ran", properties: {
|
|
116
|
+
experiment_id: experimentId,
|
|
117
|
+
project_id: projectId,
|
|
118
|
+
}})
|
|
119
|
+
.catch(captureException);
|
|
120
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
fireTeamMemberInvitedNurturing,
|
|
4
|
+
fireWorkflowCreatedNurturing,
|
|
5
|
+
fireScenarioCreatedNurturing,
|
|
6
|
+
fireExperimentRanNurturing,
|
|
7
|
+
} from "./featureAdoption";
|
|
8
|
+
|
|
9
|
+
// Suppress logger output
|
|
10
|
+
vi.mock("../../../../src/utils/logger/server", () => ({
|
|
11
|
+
createLogger: () => ({
|
|
12
|
+
info: vi.fn(),
|
|
13
|
+
warn: vi.fn(),
|
|
14
|
+
error: vi.fn(),
|
|
15
|
+
debug: vi.fn(),
|
|
16
|
+
}),
|
|
17
|
+
}));
|
|
18
|
+
vi.mock("../../../../src/utils/posthogErrorCapture", () => ({
|
|
19
|
+
captureException: vi.fn(),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const mockNurturing = {
|
|
23
|
+
identifyUser: vi.fn().mockResolvedValue(undefined),
|
|
24
|
+
trackEvent: vi.fn().mockResolvedValue(undefined),
|
|
25
|
+
groupUser: vi.fn().mockResolvedValue(undefined),
|
|
26
|
+
batch: vi.fn().mockResolvedValue(undefined),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let currentNurturing: typeof mockNurturing | undefined = mockNurturing;
|
|
30
|
+
|
|
31
|
+
vi.mock("../../../../src/server/app-layer/app", () => ({
|
|
32
|
+
getApp: () => ({
|
|
33
|
+
get nurturing() {
|
|
34
|
+
return currentNurturing;
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
describe("Feature adoption hooks", () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
vi.clearAllMocks();
|
|
42
|
+
currentNurturing = mockNurturing;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("fireTeamMemberInvitedNurturing()", () => {
|
|
46
|
+
describe("when an invite is sent", () => {
|
|
47
|
+
it("identifies user with updated team_member_count", () => {
|
|
48
|
+
fireTeamMemberInvitedNurturing({
|
|
49
|
+
userId: "user-1",
|
|
50
|
+
teamMemberCount: 5,
|
|
51
|
+
role: "member",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledWith({
|
|
55
|
+
userId: "user-1",
|
|
56
|
+
traits: { team_member_count: 5 },
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("tracks team_member_invited event with role", () => {
|
|
61
|
+
fireTeamMemberInvitedNurturing({
|
|
62
|
+
userId: "user-1",
|
|
63
|
+
teamMemberCount: 5,
|
|
64
|
+
role: "member",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(mockNurturing.trackEvent).toHaveBeenCalledWith({
|
|
68
|
+
userId: "user-1",
|
|
69
|
+
event: "team_member_invited",
|
|
70
|
+
properties: { role: "member" },
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("when nurturing is undefined", () => {
|
|
76
|
+
it("silently skips without calling any nurturing methods", () => {
|
|
77
|
+
currentNurturing = undefined;
|
|
78
|
+
|
|
79
|
+
fireTeamMemberInvitedNurturing({
|
|
80
|
+
userId: "user-1",
|
|
81
|
+
teamMemberCount: 5,
|
|
82
|
+
role: "member",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
86
|
+
expect(mockNurturing.trackEvent).not.toHaveBeenCalled();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("when Customer.io API is unavailable", () => {
|
|
91
|
+
it("does not throw (fire-and-forget)", async () => {
|
|
92
|
+
const { captureException } = await import(
|
|
93
|
+
"../../../../src/utils/posthogErrorCapture"
|
|
94
|
+
);
|
|
95
|
+
mockNurturing.identifyUser.mockRejectedValueOnce(
|
|
96
|
+
new Error("CIO unavailable"),
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(() =>
|
|
100
|
+
fireTeamMemberInvitedNurturing({
|
|
101
|
+
userId: "user-1",
|
|
102
|
+
teamMemberCount: 5,
|
|
103
|
+
role: "member",
|
|
104
|
+
}),
|
|
105
|
+
).not.toThrow();
|
|
106
|
+
|
|
107
|
+
await vi.waitFor(() => {
|
|
108
|
+
expect(captureException).toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("fireWorkflowCreatedNurturing()", () => {
|
|
115
|
+
describe("when the workflow is saved", () => {
|
|
116
|
+
it("identifies user with updated workflow_count", () => {
|
|
117
|
+
fireWorkflowCreatedNurturing({
|
|
118
|
+
userId: "user-1",
|
|
119
|
+
workflowCount: 3,
|
|
120
|
+
workflowId: "wf-1",
|
|
121
|
+
projectId: "proj-1",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledWith({
|
|
125
|
+
userId: "user-1",
|
|
126
|
+
traits: { workflow_count: 3 },
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("tracks workflow_created event with workflow_id and project_id", () => {
|
|
131
|
+
fireWorkflowCreatedNurturing({
|
|
132
|
+
userId: "user-1",
|
|
133
|
+
workflowCount: 3,
|
|
134
|
+
workflowId: "wf-1",
|
|
135
|
+
projectId: "proj-1",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
expect(mockNurturing.trackEvent).toHaveBeenCalledWith({
|
|
139
|
+
userId: "user-1",
|
|
140
|
+
event: "workflow_created",
|
|
141
|
+
properties: { workflow_id: "wf-1", project_id: "proj-1" },
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe("when nurturing is undefined", () => {
|
|
147
|
+
it("silently skips without calling any nurturing methods", () => {
|
|
148
|
+
currentNurturing = undefined;
|
|
149
|
+
|
|
150
|
+
fireWorkflowCreatedNurturing({
|
|
151
|
+
userId: "user-1",
|
|
152
|
+
workflowCount: 3,
|
|
153
|
+
workflowId: "wf-1",
|
|
154
|
+
projectId: "proj-1",
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
158
|
+
expect(mockNurturing.trackEvent).not.toHaveBeenCalled();
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
describe("when Customer.io API is unavailable", () => {
|
|
163
|
+
it("does not throw (fire-and-forget)", async () => {
|
|
164
|
+
const { captureException } = await import(
|
|
165
|
+
"../../../../src/utils/posthogErrorCapture"
|
|
166
|
+
);
|
|
167
|
+
mockNurturing.identifyUser.mockRejectedValueOnce(
|
|
168
|
+
new Error("CIO unavailable"),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(() =>
|
|
172
|
+
fireWorkflowCreatedNurturing({
|
|
173
|
+
userId: "user-1",
|
|
174
|
+
workflowCount: 3,
|
|
175
|
+
workflowId: "wf-1",
|
|
176
|
+
projectId: "proj-1",
|
|
177
|
+
}),
|
|
178
|
+
).not.toThrow();
|
|
179
|
+
|
|
180
|
+
await vi.waitFor(() => {
|
|
181
|
+
expect(captureException).toHaveBeenCalled();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("fireScenarioCreatedNurturing()", () => {
|
|
188
|
+
describe("when the scenario is saved", () => {
|
|
189
|
+
it("identifies user with updated scenario_count", () => {
|
|
190
|
+
fireScenarioCreatedNurturing({
|
|
191
|
+
userId: "user-1",
|
|
192
|
+
scenarioCount: 7,
|
|
193
|
+
scenarioId: "sc-1",
|
|
194
|
+
projectId: "proj-1",
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(mockNurturing.identifyUser).toHaveBeenCalledWith({
|
|
198
|
+
userId: "user-1",
|
|
199
|
+
traits: { scenario_count: 7 },
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("tracks scenario_created event with scenario_id and project_id", () => {
|
|
204
|
+
fireScenarioCreatedNurturing({
|
|
205
|
+
userId: "user-1",
|
|
206
|
+
scenarioCount: 7,
|
|
207
|
+
scenarioId: "sc-1",
|
|
208
|
+
projectId: "proj-1",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(mockNurturing.trackEvent).toHaveBeenCalledWith({
|
|
212
|
+
userId: "user-1",
|
|
213
|
+
event: "scenario_created",
|
|
214
|
+
properties: { scenario_id: "sc-1", project_id: "proj-1" },
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe("when nurturing is undefined", () => {
|
|
220
|
+
it("silently skips without calling any nurturing methods", () => {
|
|
221
|
+
currentNurturing = undefined;
|
|
222
|
+
|
|
223
|
+
fireScenarioCreatedNurturing({
|
|
224
|
+
userId: "user-1",
|
|
225
|
+
scenarioCount: 7,
|
|
226
|
+
scenarioId: "sc-1",
|
|
227
|
+
projectId: "proj-1",
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
231
|
+
expect(mockNurturing.trackEvent).not.toHaveBeenCalled();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
describe("when Customer.io API is unavailable", () => {
|
|
236
|
+
it("does not throw (fire-and-forget)", async () => {
|
|
237
|
+
const { captureException } = await import(
|
|
238
|
+
"../../../../src/utils/posthogErrorCapture"
|
|
239
|
+
);
|
|
240
|
+
mockNurturing.identifyUser.mockRejectedValueOnce(
|
|
241
|
+
new Error("CIO unavailable"),
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
expect(() =>
|
|
245
|
+
fireScenarioCreatedNurturing({
|
|
246
|
+
userId: "user-1",
|
|
247
|
+
scenarioCount: 7,
|
|
248
|
+
scenarioId: "sc-1",
|
|
249
|
+
projectId: "proj-1",
|
|
250
|
+
}),
|
|
251
|
+
).not.toThrow();
|
|
252
|
+
|
|
253
|
+
await vi.waitFor(() => {
|
|
254
|
+
expect(captureException).toHaveBeenCalled();
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
describe("fireExperimentRanNurturing()", () => {
|
|
261
|
+
describe("when the experiment completes", () => {
|
|
262
|
+
it("tracks experiment_ran event with experiment_id and project_id", () => {
|
|
263
|
+
fireExperimentRanNurturing({
|
|
264
|
+
userId: "user-1",
|
|
265
|
+
experimentId: "exp-1",
|
|
266
|
+
projectId: "proj-1",
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
expect(mockNurturing.trackEvent).toHaveBeenCalledWith({
|
|
270
|
+
userId: "user-1",
|
|
271
|
+
event: "experiment_ran",
|
|
272
|
+
properties: { experiment_id: "exp-1", project_id: "proj-1" },
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("does not call identifyUser (no count trait for experiments)", () => {
|
|
277
|
+
fireExperimentRanNurturing({
|
|
278
|
+
userId: "user-1",
|
|
279
|
+
experimentId: "exp-1",
|
|
280
|
+
projectId: "proj-1",
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
expect(mockNurturing.identifyUser).not.toHaveBeenCalled();
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe("when nurturing is undefined", () => {
|
|
288
|
+
it("silently skips without calling any nurturing methods", () => {
|
|
289
|
+
currentNurturing = undefined;
|
|
290
|
+
|
|
291
|
+
fireExperimentRanNurturing({
|
|
292
|
+
userId: "user-1",
|
|
293
|
+
experimentId: "exp-1",
|
|
294
|
+
projectId: "proj-1",
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
expect(mockNurturing.trackEvent).not.toHaveBeenCalled();
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe("when Customer.io API is unavailable", () => {
|
|
302
|
+
it("does not throw (fire-and-forget)", async () => {
|
|
303
|
+
const { captureException } = await import(
|
|
304
|
+
"../../../../src/utils/posthogErrorCapture"
|
|
305
|
+
);
|
|
306
|
+
mockNurturing.trackEvent.mockRejectedValueOnce(
|
|
307
|
+
new Error("CIO unavailable"),
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
expect(() =>
|
|
311
|
+
fireExperimentRanNurturing({
|
|
312
|
+
userId: "user-1",
|
|
313
|
+
experimentId: "exp-1",
|
|
314
|
+
projectId: "proj-1",
|
|
315
|
+
}),
|
|
316
|
+
).not.toThrow();
|
|
317
|
+
|
|
318
|
+
await vi.waitFor(() => {
|
|
319
|
+
expect(captureException).toHaveBeenCalled();
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { fireSignupNurturingCalls } from "./signupIdentification";
|
|
2
|
+
export {
|
|
3
|
+
fireTeamMemberInvitedNurturing,
|
|
4
|
+
fireWorkflowCreatedNurturing,
|
|
5
|
+
fireScenarioCreatedNurturing,
|
|
6
|
+
fireExperimentRanNurturing,
|
|
7
|
+
} from "./featureAdoption";
|
|
8
|
+
export {
|
|
9
|
+
fireActivityTrackingNurturing,
|
|
10
|
+
resetActivityTrackingCache,
|
|
11
|
+
} from "./activityTracking";
|
|
12
|
+
export { ensureUserSyncedToCio, resetUserSyncCache } from "./userSync";
|
|
13
|
+
export {
|
|
14
|
+
fireIntegrationMethodNurturing,
|
|
15
|
+
mapProductSelectionToIntegrationMethod,
|
|
16
|
+
} from "./productInterest";
|
|
17
|
+
export type { IntegrationMethodValue } from "./productInterest";
|