@lobehub/chat 0.141.0 → 0.141.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +5 -1
- package/README.zh-CN.md +4 -1
- package/docs/self-hosting/advanced/analytics.mdx +1 -1
- package/docs/self-hosting/advanced/analytics.zh-CN.mdx +1 -1
- package/docs/self-hosting/environment-variables/analytics.mdx +91 -0
- package/docs/self-hosting/environment-variables/analytics.zh-CN.mdx +91 -0
- package/docs/self-hosting/environment-variables/basic.mdx +16 -89
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +17 -88
- package/package.json +3 -1
- package/src/app/chat/(desktop)/features/SideBar/index.tsx +0 -1
- package/src/app/layout.tsx +2 -0
- package/src/app/settings/sync/components/SystemIcon.tsx +11 -6
- package/src/components/Analytics/Google.tsx +14 -0
- package/src/components/Analytics/Vercel.tsx +2 -4
- package/src/components/Analytics/index.tsx +9 -4
- package/src/config/__tests__/client.test.ts +1 -8
- package/src/config/client.ts +0 -7
- package/src/config/server/analytics.ts +32 -0
- package/src/config/server/index.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.141.2](https://github.com/lobehub/lobe-chat/compare/v0.141.1...v0.141.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-03-22**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix window icon and scrollbar style.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix window icon and scrollbar style, closes [#1691](https://github.com/lobehub/lobe-chat/issues/1691) ([4f46845](https://github.com/lobehub/lobe-chat/commit/4f46845))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.141.1](https://github.com/lobehub/lobe-chat/compare/v0.141.0...v0.141.1)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-03-22**</sup>
|
|
33
|
+
|
|
34
|
+
#### ♻ Code Refactoring
|
|
35
|
+
|
|
36
|
+
- **misc**: Refactor the Vercel Aanlytics and support Google Aanlytics.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### Code refactoring
|
|
44
|
+
|
|
45
|
+
- **misc**: Refactor the Vercel Aanlytics and support Google Aanlytics, closes [#1688](https://github.com/lobehub/lobe-chat/issues/1688) ([e07e9cf](https://github.com/lobehub/lobe-chat/commit/e07e9cf))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 0.141.0](https://github.com/lobehub/lobe-chat/compare/v0.140.1...v0.141.0)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2024-03-22**</sup>
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
An open-source, modern-design ChatGPT/LLMs UI/Framework.<br/>
|
|
8
8
|
Supports speech-synthesis, multi-modal, and extensible ([function call][docs-functionc-call]) plugin system.<br/>
|
|
9
|
-
One-click **FREE** deployment of your private ChatGPT/Gemini/Ollama chat application.
|
|
9
|
+
One-click **FREE** deployment of your private OpenAI ChatGPT/Claude/Gemini/Groq/Ollama chat application.
|
|
10
10
|
|
|
11
11
|
**English** · [简体中文](./README.zh-CN.md) · [Changelog](./CHANGELOG.md) · [Documents][docs] · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
|
|
12
12
|
|
|
@@ -121,9 +121,13 @@ In this way, LobeChat can more flexibly adapt to the needs of different users, w
|
|
|
121
121
|
We have implemented support for the following model service providers:
|
|
122
122
|
|
|
123
123
|
- **AWS Bedrock**: Integrated with AWS Bedrock service, supporting models such as **Claude / LLama2**, providing powerful natural language processing capabilities. [Learn more](https://aws.amazon.com/cn/bedrock)
|
|
124
|
+
- **Anthropic (Claude)**: Accessed Anthropic's **Claude** series models, including Claude 3 and Claude 2, with breakthroughs in multi-modal capabilities and extended context, setting a new industry benchmark. [Learn more](https://www.anthropic.com/claude)
|
|
124
125
|
- **Google AI (Gemini Pro, Gemini Vision)**: Access to Google's **Gemini** series models, including Gemini and Gemini Pro, to support advanced language understanding and generation. [Learn more](https://deepmind.google/technologies/gemini/)
|
|
125
126
|
- **ChatGLM**: Added the **ChatGLM** series models from Zhipuai (GLM-4/GLM-4-vision/GLM-3-turbo), providing users with another efficient conversation model choice. [Learn more](https://www.zhipuai.cn/)
|
|
126
127
|
- **Moonshot AI (Dark Side of the Moon)**: Integrated with the Moonshot series models, an innovative AI startup from China, aiming to provide deeper conversation understanding. [Learn more](https://www.moonshot.cn/)
|
|
128
|
+
- **Groq**: Accessed Groq's AI models, efficiently processing message sequences and generating responses, capable of multi-turn dialogues and single-interaction tasks. [Learn more](https://groq.com/)
|
|
129
|
+
- **OpenRouter**: Supports routing of models including **Claude 3**, **Gemma**, **Mistral**, **Llama2** and **Cohere**, with intelligent routing optimization to improve usage efficiency, open and flexible. [Learn more](https://openrouter.ai/)
|
|
130
|
+
- **01.AI (Yi Model)**: Integrated the 01.AI models, with series of APIs featuring fast inference speed, which not only shortened the processing time, but also maintained excellent model performance. [Learn more](https://01.ai/)
|
|
127
131
|
|
|
128
132
|
At the same time, we are also planning to support more model service providers, such as Replicate and Perplexity, to further enrich our service provider library. If you would like LobeChat to support your favorite service provider, feel free to join our [community discussion](https://github.com/lobehub/lobe-chat/discussions/1284).
|
|
129
133
|
|
package/README.zh-CN.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
开源、现代化设计的 ChatGPT/LLMs 聊天应用与开发框架<br/>
|
|
8
8
|
支持语音合成、多模态、可扩展的([function call][docs-functionc-call])插件系统<br/>
|
|
9
|
-
一键**免费**拥有你自己的 ChatGPT/Gemini/Ollama 应用
|
|
9
|
+
一键**免费**拥有你自己的 ChatGPT/Gemini/Claude/Ollama 应用
|
|
10
10
|
|
|
11
11
|
[English](./README.md) · **简体中文** · [更新日志](./CHANGELOG.md) · [文档][github-document-link] · [报告问题][github-issues-link] · [请求功能][github-issues-link]
|
|
12
12
|
|
|
@@ -121,8 +121,11 @@
|
|
|
121
121
|
|
|
122
122
|
- **AWS Bedrock**:集成了 AWS Bedrock 服务,支持了 **Claude / LLama2** 等模型,提供了强大的自然语言处理能力。[了解更多](https://aws.amazon.com/cn/bedrock)
|
|
123
123
|
- **Google AI (Gemini Pro、Gemini Vision)**:接入了 Google 的 **Gemini** 系列模型,包括 Gemini 和 Gemini Pro,以支持更高级的语言理解和生成。[了解更多](https://deepmind.google/technologies/gemini/)
|
|
124
|
+
- **Anthropic (Claude)**:接入了 Anthropic 的 **Claude** 系列模型,包括 Claude 3 和 Claude 2,多模态突破,超长上下文,树立行业新基准。[了解更多](https://www.anthropic.com/claude)
|
|
124
125
|
- **ChatGLM**:加入了智谱的 **ChatGLM** 系列模型(GLM-4/GLM-4-vision/GLM-3-turbo),为用户提供了另一种高效的会话模型选择。[了解更多](https://www.zhipuai.cn/)
|
|
125
126
|
- **Moonshot AI (月之暗面)**:集成了 Moonshot 系列模型,这是一家来自中国的创新性 AI 创业公司,旨在提供更深层次的会话理解。[了解更多](https://www.moonshot.cn/)
|
|
127
|
+
- **Groq**:接入了 Groq 的 AI 模型,高效处理消息序列,生成回应,胜任多轮对话及单次交互任务。[了解更多](https://groq.com/)
|
|
128
|
+
- **OpenRouter**:其支持包括 **Claude 3**,**Gemma**,**Mistral**,**Llama2**和**Cohere**等模型路由,支持智能路由优化,提升使用效率,开放且灵活。[了解更多](https://openrouter.ai/)
|
|
126
129
|
|
|
127
130
|
同时,我们也在计划支持更多的模型服务商,如 Replicate 和 Perplexity 等,以进一步丰富我们的服务商库。如果你希望让 LobeChat 支持你喜爱的服务商,欢迎加入我们的[社区讨论](https://github.com/lobehub/lobe-chat/discussions/1284)。
|
|
128
131
|
|
|
@@ -11,7 +11,7 @@ To better help analyze the usage of LobeChat users, we have integrated several f
|
|
|
11
11
|
|
|
12
12
|
[Vercel Analytics](https://vercel.com/analytics) is a data analytics service launched by Vercel, which can help you collect website visit data, including traffic, sources, and devices used for access.
|
|
13
13
|
|
|
14
|
-
We have integrated Vercel Analytics into the code, and you can enable it by setting the environment variable `
|
|
14
|
+
We have integrated Vercel Analytics into the code, and you can enable it by setting the environment variable `ENABLE_VERCEL_ANALYTICS=1`, and then open the Analytics tab in your Vercel deployment project to view your app's visit data.
|
|
15
15
|
|
|
16
16
|
Vercel Analytics provides 2500 free Web Analytics Events per month (which can be understood as page views), which is generally sufficient for personal deployment and self-use products.
|
|
17
17
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[Vercel Analytics](https://vercel.com/analytics) 是 Vercel 推出的一款数据分析服务,它可以帮助你收集网站的访问情况,包括访问量、访问来源、访问设备等等。
|
|
12
12
|
|
|
13
|
-
我们在代码中集成了 Vercel Analytics,你可以通过设置环境变量 `
|
|
13
|
+
我们在代码中集成了 Vercel Analytics,你可以通过设置环境变量 `ENABLE_VERCEL_ANALYTICS=1` 来开启它,并打开 Vercel 部署项目中 Analytics tab 查看你的应用访问情况。
|
|
14
14
|
|
|
15
15
|
Vercel Analytics 提供了 2500 次 / 月的免费 Web Analytics Events (可以理解为 PV),对于个人部署自用的产品来说基本够用。
|
|
16
16
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Data Statistics
|
|
2
|
+
|
|
3
|
+
We have integrated several free/open-source data analytics services in LobeChat for collecting user usage data. Here are environment variables that you can use.
|
|
4
|
+
|
|
5
|
+
## Vercel Analytics
|
|
6
|
+
|
|
7
|
+
### `ENABLE_VERCEL_ANALYTICS`
|
|
8
|
+
|
|
9
|
+
- Type: Optional
|
|
10
|
+
- Description: Used to configure the environment variable for Vercel Analytics. Set to `1` to enable Vercel Analytics.
|
|
11
|
+
- Default: `-`
|
|
12
|
+
- Example: `1`
|
|
13
|
+
|
|
14
|
+
### `DEBUG_VERCEL_ANALYTICS`
|
|
15
|
+
|
|
16
|
+
- Type: Optional
|
|
17
|
+
- Description: Used to enable the debug mode for Vercel Analytics.
|
|
18
|
+
- Default: `-`
|
|
19
|
+
- Example: `1`
|
|
20
|
+
|
|
21
|
+
## Google Analytics
|
|
22
|
+
|
|
23
|
+
### `ENABLE_GOOGLE_ANALYTICS`
|
|
24
|
+
|
|
25
|
+
- Type: Optional
|
|
26
|
+
- Description: Used to configure the environment variable for Google Analytics. Set to `1` to enable Google Analytics.
|
|
27
|
+
- Default: `-`
|
|
28
|
+
- Example: `1`
|
|
29
|
+
|
|
30
|
+
### `GOOGLE_ANALYTICS_MEASUREMENT_ID`
|
|
31
|
+
|
|
32
|
+
- Type: Required
|
|
33
|
+
- Description: Google Analytics Measurement ID,you can get it from the Google Analytics dashboard.
|
|
34
|
+
- Default: `-`
|
|
35
|
+
- Example: `G-63LP2TV03T`
|
|
36
|
+
|
|
37
|
+
## Posthog Analytics
|
|
38
|
+
|
|
39
|
+
### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
|
|
40
|
+
|
|
41
|
+
- Type: Optional
|
|
42
|
+
- Description: Used to enable the environment variable for [PostHog Analytics][posthog-analytics-url]. Set to `1` to enable PostHog Analytics.
|
|
43
|
+
- Default: `-`
|
|
44
|
+
- Example: `1`
|
|
45
|
+
|
|
46
|
+
### `NEXT_PUBLIC_POSTHOG_KEY`
|
|
47
|
+
|
|
48
|
+
- Type: Optional
|
|
49
|
+
- Description: Set the PostHog project Key.
|
|
50
|
+
- Default: `-`
|
|
51
|
+
- Example: `phc_xxxxxxxx`
|
|
52
|
+
|
|
53
|
+
### `NEXT_PUBLIC_POSTHOG_HOST`
|
|
54
|
+
|
|
55
|
+
- Type: Optional
|
|
56
|
+
- Description: Set the deployment address of the PostHog service, defaulting to the official SAAS address.
|
|
57
|
+
- Default: `https://app.posthog.com`
|
|
58
|
+
- Example: `https://example.com`
|
|
59
|
+
|
|
60
|
+
### `NEXT_PUBLIC_POSTHOG_DEBUG`
|
|
61
|
+
|
|
62
|
+
- Type: Optional
|
|
63
|
+
- Description: Enable the debug mode for PostHog.
|
|
64
|
+
- Default: `-`
|
|
65
|
+
- Example: `1`
|
|
66
|
+
|
|
67
|
+
## Umami Analytics
|
|
68
|
+
|
|
69
|
+
### `NEXT_PUBLIC_ANALYTICS_UMAMI`
|
|
70
|
+
|
|
71
|
+
- Type: Optional
|
|
72
|
+
- Description: Used to enable the environment variable for [Umami Analytics][umami-analytics-url]. Set to `1` to enable Umami Analytics.
|
|
73
|
+
- Default: `-`
|
|
74
|
+
- Example: `1`
|
|
75
|
+
|
|
76
|
+
### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
|
|
77
|
+
|
|
78
|
+
- Type: Optional
|
|
79
|
+
- Description: The URL of the Umami script, defaulting to the script URL provided by Umami Cloud.
|
|
80
|
+
- Default: `https://analytics.umami.is/script.js`
|
|
81
|
+
- Example: `https://umami.your-site.com/script.js`
|
|
82
|
+
|
|
83
|
+
### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
|
|
84
|
+
|
|
85
|
+
- Type: Required
|
|
86
|
+
- Description: Your Umami Website ID.
|
|
87
|
+
- Default: `-`
|
|
88
|
+
- Example: `E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
|
|
89
|
+
|
|
90
|
+
[posthog-analytics-url]: https://posthog.com
|
|
91
|
+
[umami-analytics-url]: https://umami.is
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# 数据统计
|
|
2
|
+
|
|
3
|
+
我们在 LobeChat 中集成了若干免费 / 开源的数据统计服务,用于了解用户的使用情况,以下是相关环境变量。
|
|
4
|
+
|
|
5
|
+
## Vercel Analytics
|
|
6
|
+
|
|
7
|
+
### `ENABLE_VERCEL_ANALYTICS`
|
|
8
|
+
|
|
9
|
+
- 类型:可选
|
|
10
|
+
- 描述:用于配置 Vercel Analytics 的环境变量,当设为 `1` 时开启 Vercel Analytics
|
|
11
|
+
- 默认值: `-`
|
|
12
|
+
- 示例:`1`
|
|
13
|
+
|
|
14
|
+
### `DEBUG_VERCEL_ANALYTICS`
|
|
15
|
+
|
|
16
|
+
- 类型:可选
|
|
17
|
+
- 描述:用于开启 Vercel Analytics 的调试模式
|
|
18
|
+
- 默认值: `-`
|
|
19
|
+
- 示例:`1`
|
|
20
|
+
|
|
21
|
+
## Google Analytics
|
|
22
|
+
|
|
23
|
+
### `ENABLE_GOOGLE_ANALYTICS`
|
|
24
|
+
|
|
25
|
+
- 类型:必选
|
|
26
|
+
- 描述:用于配置 Google Analytics 的环境变量,当设为 `1` 时开启 Google Analytics
|
|
27
|
+
- 默认值: `-`
|
|
28
|
+
- 示例:`1`
|
|
29
|
+
|
|
30
|
+
### `GOOGLE_ANALYTICS_MEASUREMENT_ID`
|
|
31
|
+
|
|
32
|
+
- 类型:必选
|
|
33
|
+
- 描述:Google Analytics 的 Measurement ID,如果开启了 Google Analytics,此项必填
|
|
34
|
+
- 默认值: `-`
|
|
35
|
+
- 示例:`G-63LP2TV03T`
|
|
36
|
+
|
|
37
|
+
## Posthog Analytics
|
|
38
|
+
|
|
39
|
+
### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
|
|
40
|
+
|
|
41
|
+
- 类型:可选
|
|
42
|
+
- 描述:用于开启 [PostHog Analytics][posthog-analytics-url] 的环境变量,设为 `1` 时开启 PostHog Analytics
|
|
43
|
+
- 默认值: `-`
|
|
44
|
+
- 示例:`1`
|
|
45
|
+
|
|
46
|
+
### `NEXT_PUBLIC_POSTHOG_KEY`
|
|
47
|
+
|
|
48
|
+
- 类型:可选
|
|
49
|
+
- 描述:设置 PostHog 项目 Key
|
|
50
|
+
- 默认值: `-`
|
|
51
|
+
- 示例:`phc_xxxxxxxx`
|
|
52
|
+
|
|
53
|
+
### `NEXT_PUBLIC_POSTHOG_HOST`
|
|
54
|
+
|
|
55
|
+
- 类型:可选
|
|
56
|
+
- 描述:设置 PostHog 服务的部署地址,默认为官方的 SAAS 地址
|
|
57
|
+
- 默认值:`https://app.posthog.com`
|
|
58
|
+
- 示例:`https://example.com`
|
|
59
|
+
|
|
60
|
+
### `NEXT_PUBLIC_POSTHOG_DEBUG`
|
|
61
|
+
|
|
62
|
+
- 类型:可选
|
|
63
|
+
- 描述:开启 PostHog 的调试模式
|
|
64
|
+
- 默认值: `-`
|
|
65
|
+
- 示例:`1`
|
|
66
|
+
|
|
67
|
+
## Umami Analytics
|
|
68
|
+
|
|
69
|
+
### `NEXT_PUBLIC_ANALYTICS_UMAMI`
|
|
70
|
+
|
|
71
|
+
- 类型:可选
|
|
72
|
+
- 描述:用于开启 [Umami Analytics][umami-analytics-url] 的环境变量,设为 `1` 时开启 Umami Analytics
|
|
73
|
+
- 默认值: `-`
|
|
74
|
+
- 示例:`1`
|
|
75
|
+
|
|
76
|
+
### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
|
|
77
|
+
|
|
78
|
+
- 类型:可选
|
|
79
|
+
- 描述:Umami 脚本的网址,默认为 Umami Cloud 提供的脚本网址
|
|
80
|
+
- 默认值:`https://analytics.umami.is/script.js`
|
|
81
|
+
- 示例:`https://umami.your-site.com/script.js`
|
|
82
|
+
|
|
83
|
+
### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
|
|
84
|
+
|
|
85
|
+
- 类型:必选
|
|
86
|
+
- 描述:你的 Umami 的 Website ID
|
|
87
|
+
- 默认值:`-`
|
|
88
|
+
- 示例:`E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
|
|
89
|
+
|
|
90
|
+
[posthog-analytics-url]: https://posthog.com
|
|
91
|
+
[umami-analytics-url]: https://umami.is
|
|
@@ -34,18 +34,18 @@ LobeChat provides some additional configuration options during deployment, which
|
|
|
34
34
|
|
|
35
35
|
The `DEFAULT_AGENT_CONFIG` is used to configure the default settings for the LobeChat default agent. It supports various data types and structures, including key-value pairs, nested fields, array values, and more. The table below provides detailed information on the configuration options, examples, and corresponding explanations for the `DEFAULT_AGENT_CONFIG` environment variable:
|
|
36
36
|
|
|
37
|
-
| Configuration Type
|
|
38
|
-
|
|
|
39
|
-
| Basic Key-Value Pair
|
|
40
|
-
| Nested Field
|
|
41
|
-
| Array
|
|
42
|
-
| Chinese Comma
|
|
43
|
-
| Multiple Configurations | `model=glm-4;provider=zhipu`
|
|
44
|
-
| Numeric Value
|
|
45
|
-
| Boolean Value
|
|
46
|
-
| Special Characters
|
|
47
|
-
| Error Handling
|
|
48
|
-
| Value Override
|
|
37
|
+
| Configuration Type | Example | Explanation |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| Basic Key-Value Pair | `model=gpt-4` | Set the model to `gpt-4`. |
|
|
40
|
+
| Nested Field | `tts.sttLocale=en-US` | Set the language locale for the text-to-speech service to `en-US`. |
|
|
41
|
+
| Array | `plugins=search-engine,lobe-image-designer` | Enable the `search-engine` and `lobe-image-designer` plugins. |
|
|
42
|
+
| Chinese Comma | `plugins=search-engine,lobe-image-designer` | Same as above, demonstrating support for Chinese comma separation. |
|
|
43
|
+
| Multiple Configurations | `model=glm-4;provider=zhipu` | Set the model to `glm-4` and the model provider to `zhipu`. |
|
|
44
|
+
| Numeric Value | `params.max_tokens=300` | Set the maximum tokens to `300`. |
|
|
45
|
+
| Boolean Value | `enableAutoCreateTopic=true` | Enable automatic topic creation. |
|
|
46
|
+
| Special Characters | `inputTemplate="Hello; I am a bot;"` | Set the input template to `Hello; I am a bot;`. |
|
|
47
|
+
| Error Handling | `model=gpt-4;maxToken` | Ignore invalid entry `maxToken` and only parse `model=gpt-4`. |
|
|
48
|
+
| Value Override | `model=gpt-4;model=gpt-4-1106-preview` | If a key is repeated, use the value that appears last; in this case, the value of `model` is `gpt-4-1106-preview`. |
|
|
49
49
|
|
|
50
50
|
Further reading:
|
|
51
51
|
|
|
@@ -86,8 +86,8 @@ Further reading:
|
|
|
86
86
|
### Auth0
|
|
87
87
|
|
|
88
88
|
<Callout>
|
|
89
|
-
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
90
|
-
other identity verification service providers, you can submit a [feature
|
|
89
|
+
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
90
|
+
If you need to use other identity verification service providers, you can submit a [feature
|
|
91
91
|
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
92
92
|
</Callout>
|
|
93
93
|
|
|
@@ -115,8 +115,8 @@ Further reading:
|
|
|
115
115
|
### Microsoft Entra ID
|
|
116
116
|
|
|
117
117
|
<Callout>
|
|
118
|
-
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
119
|
-
other identity verification service providers, you can submit a [feature
|
|
118
|
+
Currently, we only support the Auth0, Microsoft Entra ID identity verification service providers.
|
|
119
|
+
If you need to use other identity verification service providers, you can submit a [feature
|
|
120
120
|
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
|
|
121
121
|
</Callout>
|
|
122
122
|
|
|
@@ -178,77 +178,4 @@ The above example sets the `SERPAPI_API_KEY` of the `search-engine` plugin to `x
|
|
|
178
178
|
- Description: Index address of the LobeChat assistant market. If you have deployed the assistant market service on your own, you can use this variable to override the default market address.
|
|
179
179
|
- Default: `https://chat-agents.lobehub.com`
|
|
180
180
|
|
|
181
|
-
## Data Statistics
|
|
182
|
-
|
|
183
|
-
### Vercel Analytics
|
|
184
|
-
|
|
185
|
-
#### `NEXT_PUBLIC_ANALYTICS_VERCEL`
|
|
186
|
-
|
|
187
|
-
- Type: Optional
|
|
188
|
-
- Description: Used to configure the environment variable for Vercel Analytics. Set to `1` to enable Vercel Analytics.
|
|
189
|
-
- Default: `-`
|
|
190
|
-
- Example: `1`
|
|
191
|
-
|
|
192
|
-
#### `NEXT_PUBLIC_VERCEL_DEBUG`
|
|
193
|
-
|
|
194
|
-
- Type: Optional
|
|
195
|
-
- Description: Used to enable the debug mode for Vercel Analytics.
|
|
196
|
-
- Default: `-`
|
|
197
|
-
- Example: `1`
|
|
198
|
-
|
|
199
|
-
### Posthog Analytics
|
|
200
|
-
|
|
201
|
-
#### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
|
|
202
|
-
|
|
203
|
-
- Type: Optional
|
|
204
|
-
- Description: Used to enable the environment variable for [PostHog Analytics][posthog-analytics-url]. Set to `1` to enable PostHog Analytics.
|
|
205
|
-
- Default: `-`
|
|
206
|
-
- Example: `1`
|
|
207
|
-
|
|
208
|
-
#### `NEXT_PUBLIC_POSTHOG_KEY`
|
|
209
|
-
|
|
210
|
-
- Type: Optional
|
|
211
|
-
- Description: Set the PostHog project Key.
|
|
212
|
-
- Default: `-`
|
|
213
|
-
- Example: `phc_xxxxxxxx`
|
|
214
|
-
|
|
215
|
-
#### `NEXT_PUBLIC_POSTHOG_HOST`
|
|
216
|
-
|
|
217
|
-
- Type: Optional
|
|
218
|
-
- Description: Set the deployment address of the PostHog service, defaulting to the official SAAS address.
|
|
219
|
-
- Default: `https://app.posthog.com`
|
|
220
|
-
- Example: `https://example.com`
|
|
221
|
-
|
|
222
|
-
#### `NEXT_PUBLIC_POSTHOG_DEBUG`
|
|
223
|
-
|
|
224
|
-
- Type: Optional
|
|
225
|
-
- Description: Enable the debug mode for PostHog.
|
|
226
|
-
- Default: `-`
|
|
227
|
-
- Example: `1`
|
|
228
|
-
|
|
229
|
-
### Umami Analytics
|
|
230
|
-
|
|
231
|
-
#### `NEXT_PUBLIC_ANALYTICS_UMAMI`
|
|
232
|
-
|
|
233
|
-
- Type: Optional
|
|
234
|
-
- Description: Used to enable the environment variable for [Umami Analytics][umami-analytics-url]. Set to `1` to enable Umami Analytics.
|
|
235
|
-
- Default: `-`
|
|
236
|
-
- Example: `1`
|
|
237
|
-
|
|
238
|
-
#### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
|
|
239
|
-
|
|
240
|
-
- Type: Optional
|
|
241
|
-
- Description: The URL of the Umami script, defaulting to the script URL provided by Umami Cloud.
|
|
242
|
-
- Default: `https://analytics.umami.is/script.js`
|
|
243
|
-
- Example: `https://umami.your-site.com/script.js`
|
|
244
|
-
|
|
245
|
-
#### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
|
|
246
|
-
|
|
247
|
-
- Type: Required
|
|
248
|
-
- Description: Your Umami Website ID.
|
|
249
|
-
- Default: `-`
|
|
250
|
-
- Example: `E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
|
|
251
|
-
|
|
252
181
|
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
253
|
-
[posthog-analytics-url]: https://posthog.com
|
|
254
|
-
[umami-analytics-url]: https://umami.is
|
|
@@ -25,7 +25,7 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
25
25
|
- 默认值: `-`
|
|
26
26
|
- 示例: `/test`
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
### `DEFAULT_AGENT_CONFIG`
|
|
29
29
|
|
|
30
30
|
- 类型:可选
|
|
31
31
|
- 描述:用于配置 LobeChat 默认助理的默认配置。它支持多种数据类型和结构,包括键值对、嵌套字段、数组值等。
|
|
@@ -34,18 +34,18 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
34
34
|
|
|
35
35
|
`DEFAULT_AGENT_CONFIG` 用于配置 LobeChat 默认助理的默认配置。它支持多种数据类型和结构,包括键值对、嵌套字段、数组值等。下表详细说明了 `DEFAULT_AGENT_CONFIG` 环境变量的配置项、示例以及相应解释:
|
|
36
36
|
|
|
37
|
-
| 配置项类型 | 示例
|
|
38
|
-
|
|
|
39
|
-
| 基本键值对 | `model=gpt-4`
|
|
40
|
-
| 嵌套字段
|
|
41
|
-
| 数组
|
|
42
|
-
| 中文逗号
|
|
43
|
-
| 多个配置项 | `model=glm-4;provider=zhipu`
|
|
44
|
-
| 数字值
|
|
45
|
-
| 布尔值
|
|
46
|
-
| 特殊字符
|
|
47
|
-
| 错误处理
|
|
48
|
-
| 值覆盖
|
|
37
|
+
| 配置项类型 | 示例 | 解释 |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| 基本键值对 | `model=gpt-4` | 设置模型为 `gpt-4`。 |
|
|
40
|
+
| 嵌套字段 | `tts.sttLocale=en-US` | 设置文本到语音服务的语言区域为 `en-US`。 |
|
|
41
|
+
| 数组 | `plugins=search-engine,lobe-image-designer` | 启用 `search-engine` 和 `lobe-image-designer` 插件。 |
|
|
42
|
+
| 中文逗号 | `plugins=search-engine,lobe-image-designer` | 同上,演示支持中文逗号分隔。 |
|
|
43
|
+
| 多个配置项 | `model=glm-4;provider=zhipu` | 设置模型为 `glm-4` 且模型服务商为 `zhipu`。 |
|
|
44
|
+
| 数字值 | `params.max_tokens=300` | 设置最大令牌数为 `300`。 |
|
|
45
|
+
| 布尔值 | `enableAutoCreateTopic=true` | 启用自动创建主题。 |
|
|
46
|
+
| 特殊字符 | `inputTemplate="Hello; I am a bot;"` | 设置输入模板为 `Hello; I am a bot;`。 |
|
|
47
|
+
| 错误处理 | `model=gpt-4;maxToken` | 忽略无效条目 `maxToken`,仅解析出 `model=gpt-4`。 |
|
|
48
|
+
| 值覆盖 | `model=gpt-4;model=gpt-4-1106-preview` | 如果键重复,使用最后一次出现的值,此处 `model` 的值为 `gpt-4-1106-preview`。 |
|
|
49
49
|
|
|
50
50
|
相关阅读:
|
|
51
51
|
|
|
@@ -86,7 +86,8 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
86
86
|
### Auth0
|
|
87
87
|
|
|
88
88
|
<Callout>
|
|
89
|
-
目前,我们仅支持 Auth0 和 Microsoft Entra ID
|
|
89
|
+
目前,我们仅支持 Auth0 和 Microsoft Entra ID
|
|
90
|
+
身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交
|
|
90
91
|
[功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
91
92
|
</Callout>
|
|
92
93
|
|
|
@@ -114,7 +115,8 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
114
115
|
### Microsoft Entra ID
|
|
115
116
|
|
|
116
117
|
<Callout>
|
|
117
|
-
目前,我们仅支持 Auth0 和 Microsoft Entra ID
|
|
118
|
+
目前,我们仅支持 Auth0 和 Microsoft Entra ID
|
|
119
|
+
身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交
|
|
118
120
|
[功能请求](https://github.com/lobehub/lobe-chat/issues/new/choose) 或 Pull Request。
|
|
119
121
|
</Callout>
|
|
120
122
|
|
|
@@ -176,77 +178,4 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
176
178
|
- 描述:LobeChat 助手市场的索引地址,如果你自行部署了助手市场的服务,可以使用该变量来覆盖默认的市场地址
|
|
177
179
|
- 默认值:`https://chat-agents.lobehub.com`
|
|
178
180
|
|
|
179
|
-
## 数据统计
|
|
180
|
-
|
|
181
|
-
### Vercel Analytics
|
|
182
|
-
|
|
183
|
-
#### `NEXT_PUBLIC_ANALYTICS_VERCEL`
|
|
184
|
-
|
|
185
|
-
- 类型:可选
|
|
186
|
-
- 描述:用于配置 Vercel Analytics 的环境变量,当设为 `1` 时开启 Vercel Analytics
|
|
187
|
-
- 默认值: `-`
|
|
188
|
-
- 示例:`1`
|
|
189
|
-
|
|
190
|
-
#### `NEXT_PUBLIC_VERCEL_DEBUG`
|
|
191
|
-
|
|
192
|
-
- 类型:可选
|
|
193
|
-
- 描述:用于开启 Vercel Analytics 的调试模式
|
|
194
|
-
- 默认值: `-`
|
|
195
|
-
- 示例:`1`
|
|
196
|
-
|
|
197
|
-
### Posthog Analytics
|
|
198
|
-
|
|
199
|
-
#### `NEXT_PUBLIC_ANALYTICS_POSTHOG`
|
|
200
|
-
|
|
201
|
-
- 类型:可选
|
|
202
|
-
- 描述:用于开启 [PostHog Analytics][posthog-analytics-url] 的环境变量,设为 `1` 时开启 PostHog Analytics
|
|
203
|
-
- 默认值: `-`
|
|
204
|
-
- 示例:`1`
|
|
205
|
-
|
|
206
|
-
#### `NEXT_PUBLIC_POSTHOG_KEY`
|
|
207
|
-
|
|
208
|
-
- 类型:可选
|
|
209
|
-
- 描述:设置 PostHog 项目 Key
|
|
210
|
-
- 默认值: `-`
|
|
211
|
-
- 示例:`phc_xxxxxxxx`
|
|
212
|
-
|
|
213
|
-
#### `NEXT_PUBLIC_POSTHOG_HOST`
|
|
214
|
-
|
|
215
|
-
- 类型:可选
|
|
216
|
-
- 描述:设置 PostHog 服务的部署地址,默认为官方的 SAAS 地址
|
|
217
|
-
- 默认值:`https://app.posthog.com`
|
|
218
|
-
- 示例:`https://example.com`
|
|
219
|
-
|
|
220
|
-
#### `NEXT_PUBLIC_POSTHOG_DEBUG`
|
|
221
|
-
|
|
222
|
-
- 类型:可选
|
|
223
|
-
- 描述:开启 PostHog 的调试模式
|
|
224
|
-
- 默认值: `-`
|
|
225
|
-
- 示例:`1`
|
|
226
|
-
|
|
227
|
-
### Umami Analytics
|
|
228
|
-
|
|
229
|
-
#### `NEXT_PUBLIC_ANALYTICS_UMAMI`
|
|
230
|
-
|
|
231
|
-
- 类型:可选
|
|
232
|
-
- 描述:用于开启 [Umami Analytics][umami-analytics-url] 的环境变量,设为 `1` 时开启 Umami Analytics
|
|
233
|
-
- 默认值: `-`
|
|
234
|
-
- 示例:`1`
|
|
235
|
-
|
|
236
|
-
#### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
|
|
237
|
-
|
|
238
|
-
- 类型:可选
|
|
239
|
-
- 描述:Umami 脚本的网址,默认为 Umami Cloud 提供的脚本网址
|
|
240
|
-
- 默认值:`https://analytics.umami.is/script.js`
|
|
241
|
-
- 示例:`https://umami.your-site.com/script.js`
|
|
242
|
-
|
|
243
|
-
#### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
|
|
244
|
-
|
|
245
|
-
- 类型:必选
|
|
246
|
-
- 描述:你的 Umami 的 Website ID
|
|
247
|
-
- 默认值:`-`
|
|
248
|
-
- 示例:`E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
|
|
249
|
-
|
|
250
181
|
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
251
|
-
[posthog-analytics-url]: https://posthog.com
|
|
252
|
-
[umami-analytics-url]: https://umami.is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.141.
|
|
3
|
+
"version": "0.141.2",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -91,7 +91,9 @@
|
|
|
91
91
|
"@lobehub/icons": "latest",
|
|
92
92
|
"@lobehub/tts": "latest",
|
|
93
93
|
"@lobehub/ui": "^1.135.4",
|
|
94
|
+
"@next/third-parties": "^14.1.4",
|
|
94
95
|
"@vercel/analytics": "^1",
|
|
96
|
+
"@vercel/speed-insights": "^1.0.10",
|
|
95
97
|
"ahooks": "^3",
|
|
96
98
|
"ai": "^3.0.0",
|
|
97
99
|
"antd": "^5",
|
package/src/app/layout.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SpeedInsights } from '@vercel/speed-insights/next';
|
|
1
2
|
import { ResolvingViewport } from 'next';
|
|
2
3
|
import { cookies } from 'next/headers';
|
|
3
4
|
import { PropsWithChildren } from 'react';
|
|
@@ -42,6 +43,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
|
|
|
42
43
|
</Layout>
|
|
43
44
|
</StyleRegistry>
|
|
44
45
|
<Analytics />
|
|
46
|
+
<SpeedInsights />
|
|
45
47
|
</body>
|
|
46
48
|
</html>
|
|
47
49
|
);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { SiApple } from '@icons-pack/react-simple-icons';
|
|
1
|
+
import { SiAndroid, SiApple, SiWindows11 } from '@icons-pack/react-simple-icons';
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
|
|
4
|
+
// TODO: 等 simple icons 修复类型,移除 ignore
|
|
5
|
+
|
|
4
6
|
const SystemIcon = memo<{ title?: string }>(({ title }) => {
|
|
5
7
|
if (!title) return;
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
if (['Mac OS', 'iOS'].includes(title)) return <SiApple size={32} />;
|
|
11
|
+
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
if (title === 'Windows') return <SiWindows11 size={32} />;
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
if (title === 'Android') return <SiAndroid size={32} />;
|
|
12
17
|
|
|
13
18
|
return null;
|
|
14
19
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GoogleAnalytics as GA } from '@next/third-parties/google';
|
|
2
|
+
|
|
3
|
+
import { getServerConfig } from '@/config/server';
|
|
4
|
+
|
|
5
|
+
const { GOOGLE_ANALYTICS_MEASUREMENT_ID, ENABLE_GOOGLE_ANALYTICS } = getServerConfig();
|
|
6
|
+
|
|
7
|
+
if (ENABLE_GOOGLE_ANALYTICS && !GOOGLE_ANALYTICS_MEASUREMENT_ID)
|
|
8
|
+
throw new Error(
|
|
9
|
+
'You have enable the google analytics but not provided the google analytics id. Please provide the google analytics id in your env',
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const GoogleAnalytics = () => <GA gaId={GOOGLE_ANALYTICS_MEASUREMENT_ID!} />;
|
|
13
|
+
|
|
14
|
+
export default GoogleAnalytics;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
1
|
import { Analytics } from '@vercel/analytics/react';
|
|
4
2
|
import { memo } from 'react';
|
|
5
3
|
|
|
6
|
-
import {
|
|
4
|
+
import { getServerConfig } from '@/config/server';
|
|
7
5
|
|
|
8
|
-
const { VERCEL_DEBUG } =
|
|
6
|
+
const { VERCEL_DEBUG } = getServerConfig();
|
|
9
7
|
|
|
10
8
|
const VercelAnalytics = memo(() => <Analytics debug={VERCEL_DEBUG} />);
|
|
11
9
|
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import dynamic from 'next/dynamic';
|
|
2
2
|
|
|
3
3
|
import { getClientConfig } from '@/config/client';
|
|
4
|
+
import { getServerConfig } from '@/config/server';
|
|
5
|
+
|
|
6
|
+
import Google from './Google';
|
|
7
|
+
import Vercel from './Vercel';
|
|
4
8
|
|
|
5
|
-
const Vercel = dynamic(() => import('./Vercel'), { ssr: false });
|
|
6
9
|
const Plausible = dynamic(() => import('./Plausible'), { ssr: false });
|
|
7
10
|
const Posthog = dynamic(() => import('./Posthog'), { ssr: false });
|
|
8
11
|
const Umami = dynamic(() => import('./Umami'), { ssr: false });
|
|
9
12
|
|
|
10
|
-
const {
|
|
11
|
-
|
|
13
|
+
const { ANALYTICS_POSTHOG, ANALYTICS_PLAUSIBLE, ANALYTICS_UMAMI } = getClientConfig();
|
|
14
|
+
|
|
15
|
+
const { ENABLE_VERCEL_ANALYTICS, ENABLE_GOOGLE_ANALYTICS } = getServerConfig();
|
|
12
16
|
|
|
13
17
|
const Analytics = () => {
|
|
14
18
|
return (
|
|
15
19
|
<>
|
|
16
|
-
{
|
|
20
|
+
{ENABLE_VERCEL_ANALYTICS && <Vercel />}
|
|
21
|
+
{ENABLE_GOOGLE_ANALYTICS && <Google />}
|
|
17
22
|
{ANALYTICS_PLAUSIBLE && <Plausible />}
|
|
18
23
|
{ANALYTICS_POSTHOG && <Posthog />}
|
|
19
24
|
{ANALYTICS_UMAMI && <Umami />}
|
|
@@ -10,8 +10,6 @@ vi.stubGlobal('process', {
|
|
|
10
10
|
|
|
11
11
|
describe('getClientConfig', () => {
|
|
12
12
|
it('should correctly reflect boolean values for analytics flags', () => {
|
|
13
|
-
process.env.NEXT_PUBLIC_ANALYTICS_VERCEL = '1';
|
|
14
|
-
process.env.NEXT_PUBLIC_VERCEL_DEBUG = '1';
|
|
15
13
|
process.env.NEXT_PUBLIC_ANALYTICS_PLAUSIBLE = '1';
|
|
16
14
|
process.env.NEXT_PUBLIC_ANALYTICS_POSTHOG = '1';
|
|
17
15
|
process.env.NEXT_PUBLIC_POSTHOG_DEBUG = '1';
|
|
@@ -20,8 +18,6 @@ describe('getClientConfig', () => {
|
|
|
20
18
|
process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER = '1';
|
|
21
19
|
|
|
22
20
|
const config = getClientConfig();
|
|
23
|
-
expect(config.ANALYTICS_VERCEL).toBe(true);
|
|
24
|
-
expect(config.VERCEL_DEBUG).toBe(true);
|
|
25
21
|
expect(config.ANALYTICS_PLAUSIBLE).toBe(true);
|
|
26
22
|
expect(config.ANALYTICS_POSTHOG).toBe(true);
|
|
27
23
|
expect(config.POSTHOG_DEBUG).toBe(true);
|
|
@@ -31,8 +27,6 @@ describe('getClientConfig', () => {
|
|
|
31
27
|
});
|
|
32
28
|
|
|
33
29
|
it('should correctly handle falsy values for analytics flags', () => {
|
|
34
|
-
process.env.NEXT_PUBLIC_ANALYTICS_VERCEL = '0';
|
|
35
|
-
process.env.NEXT_PUBLIC_VERCEL_DEBUG = '0';
|
|
36
30
|
process.env.NEXT_PUBLIC_ANALYTICS_PLAUSIBLE = '0';
|
|
37
31
|
process.env.NEXT_PUBLIC_ANALYTICS_POSTHOG = '0';
|
|
38
32
|
process.env.NEXT_PUBLIC_POSTHOG_DEBUG = '0';
|
|
@@ -41,8 +35,7 @@ describe('getClientConfig', () => {
|
|
|
41
35
|
process.env.NEXT_PUBLIC_I18N_DEBUG_SERVER = '0';
|
|
42
36
|
|
|
43
37
|
const config = getClientConfig();
|
|
44
|
-
|
|
45
|
-
expect(config.VERCEL_DEBUG).toBe(false);
|
|
38
|
+
|
|
46
39
|
expect(config.ANALYTICS_PLAUSIBLE).toBe(false);
|
|
47
40
|
expect(config.ANALYTICS_POSTHOG).toBe(false);
|
|
48
41
|
expect(config.POSTHOG_DEBUG).toBe(false);
|
package/src/config/client.ts
CHANGED
|
@@ -8,9 +8,6 @@ declare global {
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
9
9
|
namespace NodeJS {
|
|
10
10
|
interface ProcessEnv {
|
|
11
|
-
NEXT_PUBLIC_ANALYTICS_VERCEL?: string;
|
|
12
|
-
NEXT_PUBLIC_VERCEL_DEBUG?: string;
|
|
13
|
-
|
|
14
11
|
NEXT_PUBLIC_ANALYTICS_MIXPANEL?: string;
|
|
15
12
|
NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN?: string;
|
|
16
13
|
NEXT_PUBLIC_MIXPANEL_DEBUG?: string;
|
|
@@ -45,10 +42,6 @@ export const getClientConfig = () => ({
|
|
|
45
42
|
// docs
|
|
46
43
|
LOBE_CHAT_DOCS: process.env.NEXT_PUBLIC_LOBE_CHAT_DOCS,
|
|
47
44
|
|
|
48
|
-
// Vercel Analytics
|
|
49
|
-
ANALYTICS_VERCEL: process.env.NEXT_PUBLIC_ANALYTICS_VERCEL === '1',
|
|
50
|
-
VERCEL_DEBUG: process.env.NEXT_PUBLIC_VERCEL_DEBUG === '1',
|
|
51
|
-
|
|
52
45
|
// Plausible Analytics
|
|
53
46
|
ANALYTICS_PLAUSIBLE: process.env.NEXT_PUBLIC_ANALYTICS_PLAUSIBLE === '1',
|
|
54
47
|
PLAUSIBLE_DOMAIN: process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
5
|
+
namespace NodeJS {
|
|
6
|
+
interface ProcessEnv {
|
|
7
|
+
// Vercel Analytics
|
|
8
|
+
ENABLE_VERCEL_ANALYTICS?: string;
|
|
9
|
+
DEBUG_VERCEL_ANALYTICS?: string;
|
|
10
|
+
|
|
11
|
+
// Google Analytics
|
|
12
|
+
ENABLE_GOOGLE_ANALYTICS?: string;
|
|
13
|
+
GOOGLE_ANALYTICS_MEASUREMENT_ID?: string;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const getAnalyticsConfig = () => {
|
|
19
|
+
if (typeof process === 'undefined') {
|
|
20
|
+
throw new Error('[Server Config] you are importing a server-only module outside of server');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
// Vercel Analytics
|
|
25
|
+
ENABLE_VERCEL_ANALYTICS: process.env.ENABLE_VERCEL_ANALYTICS === '1',
|
|
26
|
+
VERCEL_DEBUG: process.env.DEBUG_VERCEL_ANALYTICS === '1',
|
|
27
|
+
|
|
28
|
+
// Google Analytics
|
|
29
|
+
ENABLE_GOOGLE_ANALYTICS: process.env.ENABLE_GOOGLE_ANALYTICS === '1',
|
|
30
|
+
GOOGLE_ANALYTICS_MEASUREMENT_ID: process.env.GOOGLE_ANALYTICS_MEASUREMENT_ID,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAnalyticsConfig } from './analytics';
|
|
1
2
|
import { getAppConfig } from './app';
|
|
2
3
|
import { getProviderConfig } from './provider';
|
|
3
4
|
|
|
@@ -8,6 +9,7 @@ export const getServerConfig = () => {
|
|
|
8
9
|
|
|
9
10
|
const provider = getProviderConfig();
|
|
10
11
|
const app = getAppConfig();
|
|
12
|
+
const analytics = getAnalyticsConfig();
|
|
11
13
|
|
|
12
|
-
return { ...provider, ...app };
|
|
14
|
+
return { ...provider, ...app, ...analytics };
|
|
13
15
|
};
|