Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(cloud): switch from crisp to plain for in-app chat support (#6433)

Marc Klingen3ca321d9f8bd
diff --git a/.env.prod.example b/.env.prod.example
index 318371bd11..8d5313ce60 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -250,8 +250,9 @@ OTEL_SERVICE_NAME="langfuse"
# NEXT_PUBLIC_DEMO_ORG_ID=
# NEXT_PUBLIC_DEMO_PROJECT_ID=
-# Crisp chat
-# NEXT_PUBLIC_CRISP_WEBSITE_ID=
+# Plain Chat
+# NEXT_PUBLIC_PLAIN_APP_ID=
+# PLAIN_AUTHENTICATION_SECRET=
# Admin API
# ADMIN_API_KEY=
diff --git a/.github/workflows/_deploy_ecs_service.yml b/.github/workflows/_deploy_ecs_service.yml
index b6e50a61d8..8eb64a4bf3 100644
--- a/.github/workflows/_deploy_ecs_service.yml
+++ b/.github/workflows/_deploy_ecs_service.yml
@@ -52,7 +52,7 @@ jobs:
--build-arg NEXT_PUBLIC_BUILD_ID=${{ github.sha }} \
--build-arg NEXT_PUBLIC_POSTHOG_KEY=${{ vars.NEXT_PUBLIC_POSTHOG_KEY }} \
--build-arg NEXT_PUBLIC_POSTHOG_HOST=${{ vars.NEXT_PUBLIC_POSTHOG_HOST }} \
- --build-arg NEXT_PUBLIC_CRISP_WEBSITE_ID=${{ vars.NEXT_PUBLIC_CRISP_WEBSITE_ID }} \
+ --build-arg NEXT_PUBLIC_PLAIN_APP_ID=${{ vars.NEXT_PUBLIC_PLAIN_APP_ID }} \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
--build-arg SENTRY_ORG=${{ vars.SENTRY_ORG }} \
--build-arg SENTRY_PROJECT=${{ vars.SENTRY_PROJECT }} \
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6d9dd4e7f2..e28e2c52e2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -58,7 +58,7 @@ importers:
next-auth:
specifier: ^4.24.11
zod:
specifier: ^3.23.8
version: 3.23.8
@@ -232,7 +232,7 @@ importers:
version: 4.0.2
next-auth:
specifier: ^4.24.11
nodemailer:
specifier: ^6.9.15
version: 6.9.15
@@ -537,6 +537,9 @@ importers:
'@tanstack/react-table':
specifier: ^8.20.5
+ '@team-plain/typescript-sdk':
+ specifier: ^5.8.0
+ version: 5.8.0
'@tremor/react':
specifier: 3.16.2
@@ -738,10 +741,6 @@ importers:
zod:
specifier: ^3.23.8
version: 3.23.8
- optionalDependencies:
- crisp-sdk-web:
- specifier: ^1.0.25
- version: 1.0.25
devDependencies:
'@jedmao/location':
specifier: ^3.0.0
@@ -2273,6 +2272,11 @@ packages:
resolution: {integrity: sha512-7XhUbtnlkSEZK15kN3t+tzIMxsbKm/dSkKBFalj+20NvPKe1kBY7mR2P7vuijEn+f06z5+A8bVGKO0v39cr6Wg==}
engines: {node: '>=18.0.0'}
+ '@graphql-typed-document-node/[email protected]':
+ resolution: {integrity: sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==}
+ peerDependencies:
+ graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
+
resolution: {integrity: sha512-gyt/WayZrVPH2w/UTLansS7F9Nwld472JxxaETamrM8HNlsa+jSLNyKAZmhxI2Me4c3mQHFiS1wWHDY1g1Kthw==}
engines: {node: '>=12.10.0'}
@@ -4841,6 +4845,9 @@ packages:
'@tanstack/[email protected]':
resolution: {integrity: sha512-PBu00mtt95jbKFi6Llk9aik8bnR3tR/oQP1o3TSi+iG//+Q2RTIzCEgKkHG8BB86kxMNW6O8wku+Lmi+QFR6jA==}
+ '@team-plain/[email protected]':
+ resolution: {integrity: sha512-qgDGX96yDsdTo5+Yh8R+rhtInmAm90w17607B2Ugik8Ij0H1wocjjp8xtMxHruSmms5ani43Y5xRxVFPSxYVeg==}
+
'@testing-library/[email protected]':
resolution: {integrity: sha512-PmJPnogldqoVFf+EwbHvbBJ98MmqASV8kLrBYgsDNxQcFMeIS7JFL48sfyXvuMtgmWO/wMhh25odr+8VhDmn4g==}
engines: {node: '>=18'}
@@ -6362,9 +6369,6 @@ packages:
resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==}
- resolution: {integrity: sha512-CWTHFFeHRV0oqiXoPh/aIAKhFs6xcIM4NenGPnClAMCZUDQgQsF1OWmZWmnVNjJriXUmWRgDfeUxcxygS0dCRA==}
-
resolution: {integrity: sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==}
engines: {node: '>=12.0.0'}
@@ -8937,6 +8941,10 @@ packages:
resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==}
+ resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==}
+ deprecated: This package is deprecated. Use the optional chaining (?.) operator instead.
+
resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==}
@@ -12040,6 +12048,9 @@ packages:
peerDependencies:
zod: ^3.23.3
+ resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==}
+
resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}
@@ -12198,13 +12209,13 @@ snapshots:
'@aws-sdk/types': 3.679.0
'@aws-sdk/util-locate-window': 3.568.0
'@smithy/util-utf8': 2.3.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-crypto/[email protected]':
dependencies:
'@aws-crypto/util': 5.2.0
'@aws-sdk/types': 3.679.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-crypto/[email protected]':
dependencies:
@@ -12261,7 +12272,7 @@ snapshots:
'@smithy/util-middleware': 3.0.7
'@smithy/util-retry': 3.0.7
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -12311,7 +12322,7 @@ snapshots:
'@smithy/util-retry': 3.0.7
'@smithy/util-stream': 3.1.9
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
transitivePeerDependencies:
- aws-crt
@@ -12405,7 +12416,7 @@ snapshots:
'@smithy/util-middleware': 3.0.7
'@smithy/util-retry': 3.0.7
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
uuid: 9.0.1
transitivePeerDependencies:
- aws-crt
@@ -12751,7 +12762,7 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/util-middleware': 3.0.7
fast-xml-parser: 4.4.1
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -12807,6 +12818,25 @@ snapshots:
- '@aws-sdk/client-sso-oidc'
- aws-crt
+ '@aws-sdk/[email protected]':
+ dependencies:
+ '@aws-sdk/core': 3.667.0
+ '@aws-sdk/credential-provider-env': 3.667.0
+ '@aws-sdk/credential-provider-http': 3.667.0
+ '@aws-sdk/credential-provider-process': 3.667.0
+ '@aws-sdk/credential-provider-sso': 3.675.0
+ '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])
+ '@aws-sdk/types': 3.667.0
+ '@smithy/credential-provider-imds': 3.2.4
+ '@smithy/property-provider': 3.1.7
+ '@smithy/shared-ini-file-loader': 3.1.8
+ '@smithy/types': 3.5.0
+ tslib: 2.8.1
+ transitivePeerDependencies:
+ - '@aws-sdk/client-sso-oidc'
+ - aws-crt
+ optional: true
+
dependencies:
'@aws-sdk/client-sts': 3.668.0
@@ -12864,6 +12894,26 @@ snapshots:
- '@aws-sdk/client-sts'
- aws-crt
+ '@aws-sdk/[email protected]':
+ dependencies:
+ '@aws-sdk/credential-provider-env': 3.667.0
+ '@aws-sdk/credential-provider-http': 3.667.0
+ '@aws-sdk/credential-provider-ini': 3.675.0
+ '@aws-sdk/credential-provider-process': 3.667.0
+ '@aws-sdk/credential-provider-sso': 3.675.0
+ '@aws-sdk/credential-provider-web-identity': 3.667.0(@aws-sdk/[email protected])
+ '@aws-sdk/types': 3.667.0
+ '@smithy/credential-provider-imds': 3.2.4
+ '@smithy/property-provider': 3.1.7
+ '@smithy/shared-ini-file-loader': 3.1.8
+ '@smithy/types': 3.5.0
+ tslib: 2.8.1
+ transitivePeerDependencies:
+ - '@aws-sdk/client-sso-oidc'
+ - '@aws-sdk/client-sts'
+ - aws-crt
+ optional: true
+
dependencies:
'@aws-sdk/credential-provider-env': 3.667.0
@@ -12925,6 +12975,21 @@ snapshots:
- '@aws-sdk/client-sso-oidc'
- aws-crt
+ '@aws-sdk/[email protected]':
+ dependencies:
+ '@aws-sdk/client-sso': 3.675.0
+ '@aws-sdk/core': 3.667.0
+ '@aws-sdk/token-providers': 3.667.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))
+ '@aws-sdk/types': 3.667.0
+ '@smithy/property-provider': 3.1.7
+ '@smithy/shared-ini-file-loader': 3.1.8
+ '@smithy/types': 3.5.0
+ tslib: 2.8.1
+ transitivePeerDependencies:
+ - '@aws-sdk/client-sso-oidc'
+ - aws-crt
+ optional: true
+
dependencies:
'@aws-sdk/client-sso': 3.675.0
@@ -13018,7 +13083,7 @@ snapshots:
'@aws-sdk/types': 3.667.0
'@smithy/protocol-http': 4.1.4
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13030,14 +13095,14 @@ snapshots:
dependencies:
'@aws-sdk/types': 3.667.0
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
'@aws-sdk/types': 3.667.0
'@smithy/protocol-http': 4.1.4
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13097,7 +13162,7 @@ snapshots:
'@smithy/core': 2.4.8
'@smithy/protocol-http': 4.1.4
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13106,7 +13171,7 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/util-config-provider': 3.0.0
'@smithy/util-middleware': 3.0.7
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13158,12 +13223,12 @@ snapshots:
'@aws-sdk/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13178,7 +13243,7 @@ snapshots:
'@aws-sdk/types': 3.667.0
'@smithy/types': 3.5.0
'@smithy/util-endpoints': 2.1.3
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13203,7 +13268,7 @@ snapshots:
'@aws-sdk/types': 3.667.0
'@smithy/types': 3.5.0
bowser: 2.11.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13219,7 +13284,7 @@ snapshots:
'@aws-sdk/types': 3.667.0
'@smithy/node-config-provider': 3.1.8
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@aws-sdk/[email protected]':
dependencies:
@@ -13342,7 +13407,7 @@ snapshots:
'@babel/traverse': 7.24.1
'@babel/types': 7.24.0
convert-source-map: 2.0.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -13569,7 +13634,7 @@ snapshots:
'@babel/helper-split-export-declaration': 7.22.6
'@babel/parser': 7.24.1
'@babel/types': 7.24.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -14077,7 +14142,7 @@ snapshots:
'@eslint/[email protected]':
dependencies:
ajv: 6.12.6
- debug: 4.3.7([email protected])
+ debug: 4.3.7
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.1
@@ -14170,6 +14235,10 @@ snapshots:
'@google/[email protected]': {}
+ '@graphql-typed-document-node/[email protected]([email protected])':
+ dependencies:
+ graphql: 16.9.0
+
dependencies:
'@grpc/proto-loader': 0.7.13
@@ -14213,7 +14282,7 @@ snapshots:
'@humanwhocodes/[email protected]':
dependencies:
'@humanwhocodes/object-schema': 2.0.2
- debug: 4.3.7([email protected])
+ debug: 4.3.7
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -14651,7 +14720,7 @@ snapshots:
'@aws-sdk/client-bedrock-agent-runtime': 3.668.0
'@aws-sdk/client-bedrock-runtime': 3.668.0
'@aws-sdk/client-kendra': 3.668.0
- '@aws-sdk/credential-provider-node': 3.675.0(@aws-sdk/[email protected](@aws-sdk/[email protected]))(@aws-sdk/[email protected])
+ '@aws-sdk/credential-provider-node': 3.675.0
'@langchain/core': 0.3.18([email protected]([email protected]))
zod: 3.23.8
zod-to-json-schema: 3.23.5([email protected])
@@ -16970,7 +17039,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -16987,7 +17056,7 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/util-config-provider': 3.0.0
'@smithy/util-middleware': 3.0.7
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17000,7 +17069,7 @@ snapshots:
'@smithy/util-body-length-browser': 3.0.0
'@smithy/util-middleware': 3.0.7
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17021,18 +17090,18 @@ snapshots:
dependencies:
'@smithy/eventstream-serde-universal': 3.0.9
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/eventstream-serde-universal': 3.0.9
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17046,7 +17115,7 @@ snapshots:
'@smithy/querystring-builder': 3.0.7
'@smithy/types': 3.5.0
'@smithy/util-base64': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17060,7 +17129,7 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/util-buffer-from': 3.0.0
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17071,7 +17140,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17103,7 +17172,7 @@ snapshots:
dependencies:
'@smithy/protocol-http': 4.1.4
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17113,7 +17182,7 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/url-parser': 3.0.7
'@smithy/util-middleware': 3.0.7
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17124,25 +17193,25 @@ snapshots:
'@smithy/types': 3.5.0
'@smithy/util-middleware': 3.0.7
'@smithy/util-retry': 3.0.7
- tslib: 2.6.3
+ tslib: 2.8.1
uuid: 9.0.1
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/property-provider': 3.1.7
'@smithy/shared-ini-file-loader': 3.1.8
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17150,7 +17219,7 @@ snapshots:
'@smithy/protocol-http': 4.1.4
'@smithy/querystring-builder': 3.0.7
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17160,7 +17229,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17200,31 +17269,31 @@ snapshots:
'@smithy/protocol-http': 4.1.4
'@smithy/types': 3.5.0
'@smithy/util-stream': 3.1.9
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/querystring-parser': 3.0.7
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/util-buffer-from': 3.0.0
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17246,7 +17315,7 @@ snapshots:
'@smithy/smithy-client': 3.4.0
'@smithy/types': 3.5.0
bowser: 2.11.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17256,13 +17325,13 @@ snapshots:
'@smithy/property-provider': 3.1.7
'@smithy/smithy-client': 3.4.0
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/node-config-provider': 3.1.8
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17271,13 +17340,13 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
'@smithy/service-error-classification': 3.0.7
'@smithy/types': 3.5.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17288,7 +17357,7 @@ snapshots:
'@smithy/util-buffer-from': 3.0.0
'@smithy/util-hex-encoding': 3.0.0
'@smithy/util-utf8': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17302,7 +17371,7 @@ snapshots:
'@smithy/[email protected]':
dependencies:
'@smithy/util-buffer-from': 3.0.0
- tslib: 2.6.3
+ tslib: 2.8.1
'@smithy/[email protected]':
dependencies:
@@ -17369,6 +17438,15 @@ snapshots:
'@tanstack/[email protected]': {}
+ '@team-plain/[email protected]':
+ dependencies:
+ '@graphql-typed-document-node/core': 3.2.0([email protected])
+ ajv: 8.17.1
+ ajv-formats: 2.1.1([email protected])
+ graphql: 16.9.0
+ lodash.get: 4.4.2
+ zod: 3.22.4
+
'@testing-library/[email protected]':
dependencies:
'@babel/code-frame': 7.24.2
@@ -17791,7 +17869,7 @@ snapshots:
dependencies:
- '@types/node': 20.14.8
+ '@types/node': 20.10.5
optional: true
@@ -17871,7 +17949,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 6.21.0([email protected])
'@typescript-eslint/utils': 6.21.0([email protected])([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.0
ts-api-utils: 1.3.0([email protected])
optionalDependencies:
@@ -17883,7 +17961,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 7.3.1([email protected])
'@typescript-eslint/utils': 7.3.1([email protected])([email protected])
- debug: 4.3.7([email protected])
+ debug: 4.3.7
eslint: 8.57.0
ts-api-utils: 1.3.0([email protected])
optionalDependencies:
@@ -17932,7 +18010,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 7.12.0
'@typescript-eslint/visitor-keys': 7.12.0
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.5
@@ -17947,7 +18025,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 7.3.1
'@typescript-eslint/visitor-keys': 7.3.1
- debug: 4.3.7([email protected])
+ debug: 4.3.7
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.3
@@ -18064,7 +18142,7 @@ snapshots:
'@typescript-eslint/eslint-plugin': 7.3.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
'@typescript-eslint/parser': 7.12.0([email protected])([email protected])
eslint-config-prettier: 9.1.0([email protected])
+ eslint-import-resolver-alias: 1.1.2([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])
eslint-plugin-eslint-comments: 3.2.0([email protected])
@@ -18110,7 +18188,7 @@ snapshots:
dependencies:
'@vitest/spy': 2.1.2
estree-walker: 3.0.3
- magic-string: 0.30.11
+ magic-string: 0.30.17
optionalDependencies:
vite: 5.2.14(@types/[email protected])
optional: true
@@ -19241,9 +19319,6 @@ snapshots:
- optional: true
-
dependencies:
luxon: 3.4.4
@@ -19580,6 +19655,10 @@ snapshots:
dependencies:
ms: 2.1.2
+ dependencies:
+ ms: 2.1.3
+
dependencies:
ms: 2.1.3
@@ -20069,7 +20148,7 @@ snapshots:
eslint: 8.57.0
eslint-plugin-turbo: 1.13.4([email protected])
dependencies:
@@ -20083,7 +20162,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
enhanced-resolve: 5.17.1
eslint: 8.57.0
@@ -20160,7 +20239,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.15.1
is-glob: 4.0.3
@@ -20433,7 +20512,7 @@ snapshots:
dependencies:
- '@types/estree': 1.0.6
+ '@types/estree': 1.0.7
@@ -21234,7 +21313,7 @@ snapshots:
dependencies:
agent-base: 7.1.3
- debug: 4.3.7([email protected])
+ debug: 4.3.7
transitivePeerDependencies:
- supports-color
@@ -22009,7 +22088,7 @@ snapshots:
dependencies:
- '@types/node': 20.14.8
+ '@types/node': 20.10.5
merge-stream: 2.0.0
supports-color: 8.1.1
@@ -22387,6 +22466,8 @@ snapshots:
+
@@ -23069,6 +23150,23 @@ snapshots:
optionalDependencies:
nodemailer: 6.9.15
+ dependencies:
+ '@babel/runtime': 7.26.0
+ '@panva/hkdf': 1.1.1
+ cookie: 0.7.2
+ jose: 4.15.5
+ oauth: 0.9.15
+ openid-client: 5.6.5
+ preact: 10.19.7
+ preact-render-to-string: 5.2.6([email protected])
+ react: 18.2.0
+ react-dom: 18.2.0([email protected])
+ uuid: 8.3.2
+ optionalDependencies:
+ nodemailer: 6.9.15
+
dependencies:
@@ -24321,7 +24419,7 @@ snapshots:
dependencies:
- debug: 4.3.7([email protected])
+ debug: 4.3.7
module-details-from-path: 1.0.3
resolve: 1.22.8
transitivePeerDependencies:
@@ -25541,7 +25639,7 @@ snapshots:
dependencies:
cac: 6.7.14
- debug: 4.3.7([email protected])
+ debug: 4.4.0
pathe: 1.1.2
vite: 5.2.14(@types/[email protected])
transitivePeerDependencies:
@@ -25628,8 +25726,8 @@ snapshots:
'@vitest/spy': 2.1.2
'@vitest/utils': 2.1.2
chai: 5.1.1
- debug: 4.3.7([email protected])
- magic-string: 0.30.11
+ debug: 4.4.0
+ magic-string: 0.30.17
pathe: 1.1.2
std-env: 3.7.0
tinybench: 2.9.0
@@ -26012,6 +26110,8 @@ snapshots:
dependencies:
zod: 3.23.8
+
diff --git a/web/Dockerfile b/web/Dockerfile
index d0279b7a87..fafda70e0c 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -33,8 +33,7 @@ ENV DOCKER_BUILD 1
ENV NEXT_MANUAL_SIG_HANDLE true
# pass public variables in build step
-ARG NEXT_PUBLIC_CRISP_WEBSITE_ID
-
+ARG NEXT_PUBLIC_PLAIN_APP_ID
ARG NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
ENV NEXT_PUBLIC_LANGFUSE_CLOUD_REGION=$NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
ARG NEXT_PUBLIC_DEMO_ORG_ID
diff --git a/web/next.config.mjs b/web/next.config.mjs
index c69b74f8f2..437c163a6e 100644
--- a/web/next.config.mjs
+++ b/web/next.config.mjs
@@ -11,19 +11,19 @@ import { env } from "./src/env.mjs";
* img-src https to allow loading images from SSO providers
*/
const cspHeader = `
- default-src 'self' https://*.langfuse.com https://*.langfuse.dev https://*.posthog.com https://*.sentry.io wss://*.crisp.chat https://*.crisp.chat;
- script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.langfuse.com https://*.langfuse.dev https://client.crisp.chat https://settings.crisp.chat https://challenges.cloudflare.com https://*.sentry.io https://static.cloudflareinsights.com https://*.stripe.com https://uptime.betterstack.com;
- style-src 'self' 'unsafe-inline' https://client.crisp.chat https://uptime.betterstack.com;
- img-src 'self' https: blob: data: http://localhost:* https://client.crisp.chat https://image.crisp.chat https://storage.crisp.chat;
- font-src 'self' https://client.crisp.chat;
- frame-src 'self' https://challenges.cloudflare.com https://*.stripe.com https://game.crisp.chat;
+ default-src 'self' https://*.langfuse.com https://*.langfuse.dev https://*.posthog.com https://*.sentry.io;
+ script-src 'self' 'unsafe-eval' 'unsafe-inline' https://*.langfuse.com https://*.langfuse.dev https://challenges.cloudflare.com https://*.sentry.io https://static.cloudflareinsights.com https://*.stripe.com https://uptime.betterstack.com https://chat.cdn-plain.com;
+ style-src 'self' 'unsafe-inline' https://uptime.betterstack.com https://fonts.googleapis.com;
+ img-src 'self' https: blob: data: http://localhost:*;
+ font-src 'self';
+ frame-src 'self' https://challenges.cloudflare.com https://*.stripe.com;
worker-src 'self' blob:;
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
- connect-src 'self' https://*.langfuse.com https://*.langfuse.dev https://client.crisp.chat https://storage.crisp.chat wss://client.relay.crisp.chat wss://stream.relay.crisp.chat https://*.ingest.us.sentry.io https://*.sentry.io https://uptime.betterstack.com;
- media-src 'self' https: http://localhost:* https://client.crisp.chat;
+ connect-src 'self' https://*.langfuse.com https://*.langfuse.dev https://*.ingest.us.sentry.io https://*.sentry.io https://uptime.betterstack.com https://chat.uk.plain.com;
+ media-src 'self' https: http://localhost:*;
${env.LANGFUSE_CSP_ENFORCE_HTTPS === "true" ? "upgrade-insecure-requests; block-all-mixed-content;" : ""}
${env.SENTRY_CSP_REPORT_URI ? `report-uri ${env.SENTRY_CSP_REPORT_URI}; report-to csp-endpoint;` : ""}
`;
@@ -139,22 +139,22 @@ const nextConfig = {
// Required to check authentication status from langfuse.com
...(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined
? [
- {
- source: "/api/auth/session",
- headers: [
- {
- key: "Access-Control-Allow-Origin",
- value: "https://langfuse.com",
- },
- { key: "Access-Control-Allow-Credentials", value: "true" },
- { key: "Access-Control-Allow-Methods", value: "GET,POST" },
- {
- key: "Access-Control-Allow-Headers",
- value: "Content-Type, Authorization",
- },
- ],
- },
- ]
+ {
+ source: "/api/auth/session",
+ headers: [
+ {
+ key: "Access-Control-Allow-Origin",
+ value: "https://langfuse.com",
+ },
+ { key: "Access-Control-Allow-Credentials", value: "true" },
+ { key: "Access-Control-Allow-Methods", value: "GET,POST" },
+ {
+ key: "Access-Control-Allow-Headers",
+ value: "Content-Type, Authorization",
+ },
+ ],
+ },
+ ]
: []),
// all files in /public/generated are public and can be accessed from any origin, e.g. to render an API reference based on our openapi schema
{
diff --git a/web/package.json b/web/package.json
index 78358ad9ec..5f01db71a9 100644
--- a/web/package.json
+++ b/web/package.json
@@ -92,6 +92,7 @@
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^4.36.1",
"@tanstack/react-table": "^8.20.5",
+ "@team-plain/typescript-sdk": "^5.8.0",
"@tremor/react": "3.16.2",
"@trpc/client": "^10.45.0",
"@trpc/next": "^10.45.0",
@@ -201,9 +202,6 @@
"ct3aMetadata": {
"initVersion": "7.13.0"
},
- "optionalDependencies": {
- "crisp-sdk-web": "^1.0.25"
- },
"pnpm": {
"overrides": {
"nanoid": "^3.3.8",
diff --git a/web/src/components/nav/support-menu-dropdown.tsx b/web/src/components/nav/support-menu-dropdown.tsx
index 3ab703d9db..931abf9aba 100644
--- a/web/src/components/nav/support-menu-dropdown.tsx
+++ b/web/src/components/nav/support-menu-dropdown.tsx
@@ -24,15 +24,9 @@ import {
useUiCustomization,
} from "@/src/ee/features/ui-customization/useUiCustomization";
import { SidebarMenuButton, useSidebar } from "@/src/components/ui/sidebar";
-import {
- chatAvailable,
- chatIsVisible,
- showChat,
- hideChat,
-} from "@/src/features/support-chat/chat";
-import { Switch } from "@/src/components/ui/switch";
import { SiDiscord } from "react-icons/si";
import { env } from "@/src/env.mjs";
+import { chatAvailable, openChat } from "@/src/features/support-chat/PlainChat";
type SupportMenuItem = {
title: string;
@@ -54,7 +48,6 @@ export const SupportMenuDropdown = () => {
},
];
- const chatVisible = chatIsVisible();
if (uiCustomization?.supportHref) {
items.push({
title: "Support",
@@ -67,21 +60,9 @@ export const SupportMenuDropdown = () => {
title: "Chat",
pathname: "#",
menuNode: (
- <div className="flex items-center gap-2">
+ <div className="flex items-center gap-2" onClick={() => openChat()}>
<MessageCircle className="h-4 w-4" />
- <span>Chat</span>
- <Switch
- defaultChecked={chatVisible}
- onClick={(e) => e.stopPropagation()}
- onCheckedChange={(checked) => {
- if (checked) {
- showChat();
- } else {
- hideChat();
- }
- }}
- className="ml-auto"
- />
+ <span>Open Chat</span>
</div>
),
icon: MessageCircle,
diff --git a/web/src/ee/features/billing/components/BillingSettings.tsx b/web/src/ee/features/billing/components/BillingSettings.tsx
index 454937d21a..98e18acec3 100644
--- a/web/src/ee/features/billing/components/BillingSettings.tsx
+++ b/web/src/ee/features/billing/components/BillingSettings.tsx
@@ -11,11 +11,6 @@ import { numberFormatter, compactNumberFormatter } from "@/src/utils/numbers";
import { useHasEntitlement } from "@/src/features/entitlements/hooks";
import { type Plan, planLabels } from "@langfuse/shared";
import { useRouter } from "next/router";
-import {
- chatAvailable,
- sendUserChatMessage,
-} from "@/src/features/support-chat/chat";
-import { env } from "@/src/env.mjs";
import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";
import { MAX_EVENTS_FREE_PLAN } from "@/src/ee/features/billing/constants";
@@ -34,6 +29,7 @@ import { stripeProducts } from "@/src/ee/features/billing/utils/stripeProducts";
import { toast } from "sonner";
import { ActionButton } from "@/src/components/ActionButton";
import { useState } from "react";
+import { chatAvailable, openChat } from "@/src/features/support-chat/PlainChat";
export const BillingSettings = () => {
const router = useRouter();
@@ -198,12 +194,13 @@ const BillingPortalOrPricingPageButton = () => {
<Button
variant="secondary"
onClick={() =>
- sendUserChatMessage(
- `I'd like to change my current plan, region ${env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}, organization id ${organization.id}`,
- )
+ // sendUserChatMessage(
+ // `I'd like to change my current plan, region ${env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}, organization id ${organization.id}`,
+ // )
+ openChat()
}
>
- Change plan
+ Change plan (via support)
</Button>
);
else return null;
diff --git a/web/src/env.mjs b/web/src/env.mjs
index 3c3ae62931..015e2f38c9 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -291,6 +291,7 @@ export const env = createEnv({
.number()
.positive()
.default(50_000),
+ PLAIN_AUTHENTICATION_SECRET: z.string().optional(),
},
/**
@@ -313,7 +314,7 @@ export const env = createEnv({
NEXT_PUBLIC_TURNSTILE_SITE_KEY: z.string().optional(),
NEXT_PUBLIC_POSTHOG_KEY: z.string().optional(),
NEXT_PUBLIC_POSTHOG_HOST: z.string().optional(),
- NEXT_PUBLIC_CRISP_WEBSITE_ID: z.string().optional(),
+ NEXT_PUBLIC_PLAIN_APP_ID: z.string().optional(),
NEXT_PUBLIC_BUILD_ID: z.string().optional(),
NEXT_PUBLIC_BASE_PATH: z.string().optional(),
},
@@ -502,7 +503,8 @@ export const env = createEnv({
NEXT_PUBLIC_POSTHOG_KEY: process.env.NEXT_PUBLIC_POSTHOG_KEY,
NEXT_PUBLIC_POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST,
// Other
- NEXT_PUBLIC_CRISP_WEBSITE_ID: process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID,
+ NEXT_PUBLIC_PLAIN_APP_ID: process.env.NEXT_PUBLIC_PLAIN_APP_ID,
+ PLAIN_AUTHENTICATION_SECRET: process.env.PLAIN_AUTHENTICATION_SECRET,
// clickhouse
CLICKHOUSE_URL: process.env.CLICKHOUSE_URL,
CLICKHOUSE_CLUSTER_NAME: process.env.CLICKHOUSE_CLUSTER_NAME,
diff --git a/web/src/features/notifications/ErrorNotification.tsx b/web/src/features/notifications/ErrorNotification.tsx
index 83d78795f0..fe580dd5fb 100644
--- a/web/src/features/notifications/ErrorNotification.tsx
+++ b/web/src/features/notifications/ErrorNotification.tsx
@@ -1,9 +1,6 @@
import { Button } from "@/src/components/ui/button";
+import { chatAvailable, openChat } from "@/src/features/support-chat/PlainChat";
import { AlertTriangle, X } from "lucide-react";
-import {
- chatAvailable,
- sendUserChatMessage,
-} from "@/src/features/support-chat/chat";
interface ErrorNotificationProps {
error: string;
@@ -27,14 +24,14 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
? "text-destructive-foreground"
: "text-dark-yellow";
- const handleReportIssueClick = () => {
- if (chatAvailable) {
- const currentUrl = window.location.href;
- const message = `I received the following error:\n\nError: ${error}\nDescription: ${description}\n ${path ? `Path: ${path}\n` : ""}URL: ${currentUrl}`;
- sendUserChatMessage(message);
- dismissToast(toast);
- }
- };
+ // const handleReportIssueClick = () => {
+ // if (chatAvailable) {
+ // const currentUrl = window.location.href;
+ // const message = `I received the following error:\n\nError: ${error}\nDescription: ${description}\n ${path ? `Path: ${path}\n` : ""}URL: ${currentUrl}`;
+ // sendUserChatMessage(message);
+ // dismissToast(toast);
+ // }
+ // };
return (
<div className="flex justify-between">
@@ -63,7 +60,7 @@ export const ErrorNotification: React.FC<ErrorNotificationProps> = ({
variant="errorNotification"
size={"sm"}
onClick={() => {
- handleReportIssueClick();
+ openChat();
}}
>
Report issue to Langfuse team
diff --git a/web/src/features/projects/components/NewProjectForm.tsx b/web/src/features/projects/components/NewProjectForm.tsx
index a24d1036f8..5ec3d74027 100644
--- a/web/src/features/projects/components/NewProjectForm.tsx
+++ b/web/src/features/projects/components/NewProjectForm.tsx
@@ -14,9 +14,9 @@ import { Input } from "@/src/components/ui/input";
import { api } from "@/src/utils/api";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
-import { chatRunTrigger } from "@/src/features/support-chat/chat";
import { projectNameSchema } from "@/src/features/auth/lib/projectNameSchema";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
+import { showChat } from "@/src/features/support-chat/PlainChat";
export const NewProjectForm = ({
orgId,
@@ -57,7 +57,7 @@ export const NewProjectForm = ({
.catch((error) => {
console.error(error);
});
- chatRunTrigger("after-project-creation");
+ showChat();
}
return (
<Form {...form}>
diff --git a/web/src/features/setup/components/SetupPage.tsx b/web/src/features/setup/components/SetupPage.tsx
index 9ead03e346..7d4fda572a 100644
--- a/web/src/features/setup/components/SetupPage.tsx
+++ b/web/src/features/setup/components/SetupPage.tsx
@@ -22,7 +22,7 @@ import {
inviteMembersRoute,
setupTracingRoute,
} from "@/src/features/setup/setupRoutes";
-import { showChat } from "@/src/features/support-chat/chat";
+import { showChat } from "@/src/features/support-chat/PlainChat";
import { api } from "@/src/utils/api";
import { cn } from "@/src/utils/tailwind";
import { type RouterOutput } from "@/src/utils/types";
diff --git a/web/src/features/support-chat/PlainChat.tsx b/web/src/features/support-chat/PlainChat.tsx
new file mode 100644
index 0000000000..d69bd04e2d
--- /dev/null
+++ b/web/src/features/support-chat/PlainChat.tsx
@@ -0,0 +1,147 @@
+import { env } from "@/src/env.mjs";
+import { type Plan } from "@langfuse/shared";
+import { useEffect, useRef } from "react";
+
+declare global {
+ interface Window {
+ Plain: any;
+ }
+}
+
+const PlainChat = () => {
+ const scriptRef = useRef<HTMLScriptElement | null>(null);
+
+ useEffect(() => {
+ if (!env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) return;
+ if (!env.NEXT_PUBLIC_PLAIN_APP_ID) {
+ console.error("NEXT_PUBLIC_PLAIN_APP_ID is not set");
+ return;
+ }
+
+ // Check if URL contains supportChat parameter
+ const shouldShowChat =
+ typeof window !== "undefined" &&
+ new URLSearchParams(window.location.search).get("supportChat") === "1";
+
+ // Load the script only once
+ if (!scriptRef.current) {
+ const script = document.createElement("script");
+ script.async = false;
+ script.src = "https://chat.cdn-plain.com/index.js";
+ script.onload = () => {
+ window.Plain.init({
+ appId: env.NEXT_PUBLIC_PLAIN_APP_ID,
+ hideLauncher: !shouldShowChat,
+ hideBranding: true,
+ logo: {
+ url: "/icon256.png",
+ alt: "Langfuse logo",
+ },
+ style: {
+ brandColor: "#000000", // This will be used in various places in the chat widget such as the primary chat button and send message button
+ brandBackgroundColor: "#0A60B5", // Used for the background of the chat widget on the intro screen
+ launcherBackgroundColor: "#666666", // These can also be passed in this format { light: '#FFFFFF', dark: '#000000' }
+ launcherIconColor: "#FFFFFF",
+ },
+ links: [
+ {
+ icon: "book",
+ text: "View Langfuse docs",
+ url: "https://langfuse.com/docs",
+ },
+ ],
+ });
+
+ // If URL parameter is present, open the chat immediately
+ if (shouldShowChat) {
+ window.Plain.open();
+ }
+ };
+
+ document.head.appendChild(script);
+ scriptRef.current = script;
+
+ // Cleanup function to remove the script when the component unmounts
+ return () => {
+ if (scriptRef.current && document.head.contains(scriptRef.current)) {
+ document.head.removeChild(scriptRef.current);
+ }
+ };
+ }
+ }, []);
+
+ return null;
+};
+
+export default PlainChat;
+
+export const chatAvailable = !!env.NEXT_PUBLIC_PLAIN_APP_ID;
+
+export const showChat = (): void => {
+ if (chatAvailable) {
+ window.Plain.update({
+ hideLauncher: false,
+ });
+ }
+};
+
+export const hideChat = (): void => {
+ if (chatAvailable) {
+ window.Plain.update({
+ hideLauncher: true,
+ });
+ }
+};
+
+export const closeChat = (): void => {
+ if (chatAvailable) {
+ window.Plain.close();
+ }
+};
+
+export const openChat = (): void => {
+ if (chatAvailable) {
+ showChat();
+ window.Plain.open();
+ }
+};
+
+export const getUnreadMessageCount = (): number | null => {
+ if (chatAvailable) {
+ return window.Plain.getUnreadMessageCount();
+ }
+ return null;
+};
+
+export const chatSetCustomer = (customer: {
+ email?: string;
+ fullName?: string;
+ emailHash?: string;
+ chatAvatarUrl?: string;
+}) => {
+ if (chatAvailable) {
+ window.Plain.update({
+ customerDetails: customer,
+ });
+ }
+};
+
+export const chatSetThreadDetails = (p: { orgId?: string; plan?: Plan }) => {
+ if (chatAvailable) {
+ window.Plain.update({
+ threadDetails: {
+ ...(p.orgId && {
+ tenantIdentifier: {
+ externalId: `cloud_${env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}_org_${p.orgId}`,
+ },
+ }),
+ ...(p.plan && {
+ tierIdentifier: {
+ externalId: p.plan,
+ },
+ }),
+ // project_id: `cloud_${env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION}_project_${project?.id}`,
+ },
+ });
+ }
+};
diff --git a/web/src/features/support-chat/chat.tsx b/web/src/features/support-chat/chat.tsx
deleted file mode 100644
index cfe0c89224..0000000000
--- a/web/src/features/support-chat/chat.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-"use client";
-
-import { useEffect } from "react";
-import { Crisp } from "crisp-sdk-web";
-import { env } from "@/src/env.mjs";
-import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-
-const CrispChat = () => {
- const capture = usePostHogClientCapture();
-
- useEffect(() => {
- if (env.NEXT_PUBLIC_CRISP_WEBSITE_ID) {
- Crisp.configure(env.NEXT_PUBLIC_CRISP_WEBSITE_ID);
-
- // Check session storage for chat visibility
- // Expires at end of session
- const shouldShowChat =
- sessionStorage.getItem("supportChatVisible") === "true";
- if (!shouldShowChat) {
- Crisp.chat.hide();
- }
- Crisp.chat.onChatInitiated(() => {
- capture("support_chat:initiated");
- });
- Crisp.chat.onChatOpened(() => {
- capture("support_chat:opened");
- });
- Crisp.message.onMessageSent(() => {
- capture("support_chat:message_sent");
- });
- Crisp.message.onMessageReceived(() => {
- showChat();
- });
- try {
- if (Crisp.chat.unreadCount() > 0) {
- showChat();
- }
- } catch (e) {
- // do nothing, this throws unnecessary errors that cannot be fixed
- }
- return () => {
- Crisp.chat.offChatInitiated();
- Crisp.chat.offChatOpened();
- Crisp.message.offMessageSent();
- };
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
-
- return null;
-};
-
-export default CrispChat;
-
-export const chatSetUser = ({
- name,
- email,
- avatar,
- data,
- segments,
-}: {
- name?: string;
- email?: string;
- avatar?: string;
- data?: object;
- segments?: string[];
-}) => {
- if (chatAvailable) {
- if (email) Crisp.user.setEmail(email);
- if (name) Crisp.user.setNickname(name);
- if (avatar) Crisp.user.setAvatar(avatar);
- if (data) Crisp.session.setData(data);
- if (segments) Crisp.session.setSegments(segments, true);
- }
-};
-
-type Trigger = "after-project-creation";
-
-export const chatRunTrigger = (trigger: Trigger) => {
- if (chatAvailable) {
- try {
- Crisp.trigger.run(trigger);
- } catch (e) {
- console.error("Failed to run Crisp trigger", e);
- }
- }
-};
-
-export const sendUserChatMessage = (message: string) => {
- openChat();
- if (chatAvailable) Crisp.message.send("text", message);
-};
-
-export const showAgentChatMessage = (message: string) => {
- openChat();
- if (chatAvailable) Crisp.message.show("text", message);
-};
-
-export const openChat = () => {
- showChat();
- if (chatAvailable) Crisp.chat.open();
-};
-
-export const hideChat = () => {
- if (chatAvailable) {
- sessionStorage.setItem("supportChatVisible", "false");
- Crisp.chat.hide();
- }
-};
-
-export const showChat = () => {
- if (chatAvailable) {
- sessionStorage.setItem("supportChatVisible", "true");
- Crisp.chat.show();
- }
-};
-
-export const chatIsVisible = () => {
- if (!chatAvailable) return false;
- return sessionStorage.getItem("supportChatVisible") === "true";
-};
-
-export const chatAvailable = !!process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID;
diff --git a/web/src/features/support-chat/createSupportEmailHash.ts b/web/src/features/support-chat/createSupportEmailHash.ts
new file mode 100644
index 0000000000..ece887bfa1
--- /dev/null
+++ b/web/src/features/support-chat/createSupportEmailHash.ts
@@ -0,0 +1,16 @@
+import { env } from "@/src/env.mjs";
+import { logger } from "@langfuse/shared/src/server";
+import * as crypto from "node:crypto";
+
+export const createSupportEmailHash = (email: string): string | undefined => {
+ if (!env.PLAIN_AUTHENTICATION_SECRET) {
+ if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) {
+ logger.error("PLAIN_AUTHENTICATION_SECRET is not set");
+ }
+ return undefined;
+ }
+ const hmac = crypto.createHmac("sha256", env.PLAIN_AUTHENTICATION_SECRET);
+ hmac.update(email);
+ const hash = hmac.digest("hex");
+ return hash;
+};
diff --git a/web/src/features/support-chat/index.tsx b/web/src/features/support-chat/index.tsx
deleted file mode 100644
index e90e0b53c8..0000000000
--- a/web/src/features/support-chat/index.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import dynamic from "next/dynamic";
-
-export { chatSetUser } from "./chat";
-
-export const CrispWidget = dynamic(() => import("./chat"), {
- ssr: false,
-});
diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsx
index f02fb9623f..08b5ea370f 100644
--- a/web/src/pages/_app.tsx
+++ b/web/src/pages/_app.tsx
@@ -18,7 +18,6 @@ import { useRouter } from "next/router";
import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";
-import { CrispWidget, chatSetUser } from "@/src/features/support-chat";
import prexit from "prexit";
// Custom polyfills not yet available in `next-core`:
@@ -35,6 +34,10 @@ import { env } from "@/src/env.mjs";
import { ThemeProvider } from "@/src/features/theming/ThemeProvider";
import { MarkdownContextProvider } from "@/src/features/theming/useMarkdownContext";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
+import PlainChat, {
+ chatSetCustomer,
+ chatSetThreadDetails,
+} from "@/src/features/support-chat/PlainChat";
// Check that PostHog is client-side (used to handle Next.js SSR) and that env vars are set
if (
@@ -105,9 +108,9 @@ const MyApp: AppType<{ session: Session | null }> = ({
<UserTracking />
</Layout>
<BetterStackUptimeStatusMessage />
- </ThemeProvider>{" "}
+ </ThemeProvider>
</MarkdownContextProvider>
- <CrispWidget />
+ <PlainChat />
</DetailPageListsProvider>
</SessionProvider>
</PostHogProvider>
@@ -163,19 +166,11 @@ function UserTracking() {
});
// Chat
- chatSetUser({
- name: sessionUser.name ?? "undefined",
- email: sessionUser.email ?? "undefined",
- avatar: sessionUser.image ?? undefined,
- data: {
- userId: sessionUser.id ?? "undefined",
- organizations: sessionUser.organizations
- ? JSON.stringify(sessionUser.organizations)
- : "undefined",
- featureFlags: sessionUser.featureFlags
- ? JSON.stringify(sessionUser.featureFlags)
- : "undefined",
- },
+ chatSetCustomer({
+ email: sessionUser.email ?? undefined,
+ fullName: sessionUser.name ?? undefined,
+ emailHash: sessionUser.emailSupportHash ?? undefined,
+ chatAvatarUrl: sessionUser.image ?? undefined,
});
} else if (session.status === "unauthenticated") {
lastIdentifiedUser.current = null;
@@ -233,48 +228,35 @@ function UserTracking() {
}
}, [project, organization]);
- // update crisp segments
+ // update chat thread details
const plan = organization?.plan;
- const currentOrgIsDemoOrg =
- env.NEXT_PUBLIC_DEMO_ORG_ID &&
- organization?.id &&
- organization.id === env.NEXT_PUBLIC_DEMO_ORG_ID;
- const projectRole = project?.role;
- const organizationRole = organization?.role;
+ // const currentOrgIsDemoOrg =
+ // env.NEXT_PUBLIC_DEMO_ORG_ID &&
+ // organization?.id &&
+ // organization.id === env.NEXT_PUBLIC_DEMO_ORG_ID;
+ // const projectRole = project?.role;
+ // const organizationRole = organization?.role;
+ const organizationId = organization?.id;
useEffect(() => {
- let segments = [];
- if (plan && !currentOrgIsDemoOrg) {
- segments.push("plan:" + plan);
- }
- if (currentOrgIsDemoOrg) {
- segments.push("demo");
- }
- if (projectRole) {
- segments.push("p_role:" + projectRole);
- }
- if (organizationRole) {
- segments.push("o_role:" + organizationRole);
- }
- if (segments.length > 0) {
- chatSetUser({
- segments,
- });
- }
- }, [plan, currentOrgIsDemoOrg, projectRole, organizationRole]);
+ chatSetThreadDetails({
+ orgId: organizationId ?? undefined,
+ plan: plan ?? undefined,
+ });
+ }, [plan, organizationId]);
// add stripe link to chat
- const orgStripeLink = organization?.cloudConfig?.stripe?.customerId
- ? `https://dashboard.stripe.com/customers/${organization.cloudConfig.stripe.customerId}`
- : undefined;
- useEffect(() => {
- if (orgStripeLink) {
- chatSetUser({
- data: {
- stripe: orgStripeLink,
- },
- });
- }
- }, [orgStripeLink]);
+ // const orgStripeLink = organization?.cloudConfig?.stripe?.customerId
+ // ? `https://dashboard.stripe.com/customers/${organization.cloudConfig.stripe.customerId}`
+ // : undefined;
+ // useEffect(() => {
+ // if (orgStripeLink) {
+ // chatSetUser({
+ // data: {
+ // stripe: orgStripeLink,
+ // },
+ // });
+ // }
+ // }, [orgStripeLink]);
return null;
}
diff --git a/web/src/pages/auth/sign-in.tsx b/web/src/pages/auth/sign-in.tsx
index 671e4f367a..2227779a91 100644
--- a/web/src/pages/auth/sign-in.tsx
+++ b/web/src/pages/auth/sign-in.tsx
@@ -32,7 +32,7 @@ import { Shield, Code } from "lucide-react";
import { useRouter } from "next/router";
import { captureException } from "@sentry/nextjs";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-import { openChat } from "@/src/features/support-chat/chat";
+import { openChat } from "@/src/features/support-chat/PlainChat";
const credentialAuthForm = z.object({
email: z.string().email(),
@@ -532,7 +532,7 @@ export default function SignIn({
on a solution.{" "}
<span
className="cursor-pointer whitespace-nowrap text-xs font-medium text-primary-accent hover:text-hover-primary-accent"
- onClick={openChat}
+ onClick={() => openChat()}
>
(contact us)
</span>
diff --git a/web/src/server/auth.ts b/web/src/server/auth.ts
index 8c8fc001f3..07fba4dbf6 100644
--- a/web/src/server/auth.ts
+++ b/web/src/server/auth.ts
@@ -52,6 +52,7 @@ import {
import { projectRoleAccessRights } from "@/src/features/rbac/constants/projectAccessRights";
import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";
import { getSSOBlockedDomains } from "@/src/features/auth-credentials/server/signupApiHandler";
+import { createSupportEmailHash } from "@/src/features/support-chat/createSupportEmailHash";
function canCreateOrganizations(userEmail: string | null): boolean {
const instancePlan = getSelfHostedInstancePlanServerSide();
@@ -503,6 +504,9 @@ export async function getAuthOptions(): Promise<NextAuthOptions> {
id: dbUser.id,
name: dbUser.name,
email: dbUser.email,
+ emailSupportHash: dbUser.email
+ ? createSupportEmailHash(dbUser.email)
+ : undefined,
image: dbUser.image,
admin: dbUser.admin,
canCreateOrganizations: canCreateOrganizations(
diff --git a/web/types/next-auth.d.ts b/web/types/next-auth.d.ts
index 2b92c98174..36d89a77d1 100644
--- a/web/types/next-auth.d.ts
+++ b/web/types/next-auth.d.ts
@@ -30,6 +30,7 @@ declare module "next-auth" {
id: PrismaUser["id"];
name?: PrismaUser["name"];
email?: PrismaUser["email"];
+ emailSupportHash?: string | null;
image?: PrismaUser["image"];
admin?: PrismaUser["admin"];
emailVerified?: string | null; // iso datetime string, need to stringify as JWT & useSession do not support Date objects