|
1 | 1 | import { isCloud } from '@/platform/distribution/types' |
2 | 2 |
|
3 | 3 | /** |
4 | | - * Zendesk ticket form field ID for the distribution tag. |
5 | | - * This field is used to categorize support requests by their source (cloud vs OSS). |
| 4 | + * Zendesk ticket form field IDs. |
6 | 5 | */ |
7 | | -const DISTRIBUTION_FIELD_ID = 'tf_42243568391700' |
| 6 | +const ZENDESK_FIELDS = { |
| 7 | + /** Distribution tag (cloud vs OSS) */ |
| 8 | + DISTRIBUTION: 'tf_42243568391700', |
| 9 | + /** User email (anonymous requester) */ |
| 10 | + ANONYMOUS_EMAIL: 'tf_anonymous_requester_email', |
| 11 | + /** User email (authenticated) */ |
| 12 | + EMAIL: 'tf_40029135130388', |
| 13 | + /** User ID */ |
| 14 | + USER_ID: 'tf_42515251051412' |
| 15 | +} as const |
| 16 | + |
| 17 | +const SUPPORT_BASE_URL = 'https://support.comfy.org/hc/en-us/requests/new' |
8 | 18 |
|
9 | 19 | /** |
10 | | - * Support URLs for the ComfyUI platform. |
11 | | - * The URL varies based on whether the application is running in Cloud or OSS distribution. |
| 20 | + * Builds the support URL with optional user information for pre-filling. |
| 21 | + * Users without login information will still get a valid support URL without pre-fill. |
12 | 22 | * |
13 | | - * - Cloud: Includes 'ccloud' tag for identifying cloud-based support requests |
14 | | - * - OSS: Includes 'oss' tag for identifying open-source support requests |
| 23 | + * @param params - User information to pre-fill in the support form |
| 24 | + * @returns Complete Zendesk support URL with query parameters |
15 | 25 | */ |
16 | | -const TAG = isCloud ? 'ccloud' : 'oss' |
17 | | -export const SUPPORT_URL = `https://support.comfy.org/hc/en-us/requests/new?${DISTRIBUTION_FIELD_ID}=${TAG}` |
| 26 | +export function buildSupportUrl(params?: { |
| 27 | + userEmail?: string | null |
| 28 | + userId?: string | null |
| 29 | +}): string { |
| 30 | + const searchParams = new URLSearchParams({ |
| 31 | + [ZENDESK_FIELDS.DISTRIBUTION]: isCloud ? 'ccloud' : 'oss' |
| 32 | + }) |
| 33 | + |
| 34 | + if (params?.userEmail) { |
| 35 | + searchParams.append(ZENDESK_FIELDS.ANONYMOUS_EMAIL, params.userEmail) |
| 36 | + searchParams.append(ZENDESK_FIELDS.EMAIL, params.userEmail) |
| 37 | + } |
| 38 | + if (params?.userId) { |
| 39 | + searchParams.append(ZENDESK_FIELDS.USER_ID, params.userId) |
| 40 | + } |
| 41 | + |
| 42 | + return `${SUPPORT_BASE_URL}?${searchParams.toString()}` |
| 43 | +} |
0 commit comments