You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to refactor the Link → DocumentLink model to support dynamic visitor fields via JSON, provide clarity on ownership (createdByUserId), improve naming consistency, and optionally implement more robust analytics. This change will let us add extra visitor fields in the future (phone, address, etc.) without creating new columns. The server will only store the keys or minimal flags for each requested field, leaving the front end responsible for labels, input types, etc.
While not currently under development, we will also create a feature to update link preferences such as updating/removing expiry times, changing Public Link option, changing Link Name (alias), etc.
Goals & Scope
Rename the table from Link to DocumentLink, and rename some fields
Add visitorFields (JSON column) that describes which fields (e.g., name, email, phone) are requested from each visitor.
Store only the minimal structure, e.g. {"name":true,"email":true} or ["name","email"].
Adjust uniqueness constraints so alias is unique per (createdByUserId, alias) or (documentId, alias) rather than globally, if desired.
Retain or revise password, expirationTime, and isPublic logic as needed.
Add analytics structure (e.g., a separate DocumentLinkEvent table) as we need detailed download/view events.
📊 An Analytics API will be covered in a future issue to handle download/view tracking.
The server only stores the keys or booleans for which visitor fields are requested. For example:
{ "name": true, "email": true }
or
["name", "email"]
Visitor Config
Add a shared config file in src/shared/config/visitorFieldsConfig.ts containing all possible visitor fields (e.g., name, email, phoneNumber, etc.), each with a type and label.
The backend will not store labels/types in the visitorFields column—only field keys or boolean mappings.
During validation (when creating a link or at link access), the server references this config to ensure the requested fields are valid.
Example Config:
export const visitorFieldsConfig = {
name: { type: 'string', label: 'Full Name' },
email: { type: 'string', label: 'Email Address' },
expirationTime: { type: 'date', label: 'Expiration Date' }, // Optional, but included if expiration is visitor-based
};
// Export the keys separately for quick reference
export const visitorFieldKeys = Object.keys(visitorFieldsConfig);
mahid797
added
🔥Critical
Must be addressed immediately; blocking core functionality or major bug
and removed
⚡Important
High-impact issue that needs to be resolved before the next release
labels
Feb 23, 2025
We need to refactor the
Link
→DocumentLink
model to support dynamic visitor fields via JSON, provide clarity on ownership (createdByUserId
), improve naming consistency, and optionally implement more robust analytics. This change will let us add extra visitor fields in the future (phone, address, etc.) without creating new columns. The server will only store the keys or minimal flags for each requested field, leaving the front end responsible for labels, input types, etc.Goals & Scope
Link
toDocumentLink
, and rename some fieldsvisitorFields
(JSON column) that describes which fields (e.g., name, email, phone) are requested from each visitor.{"name":true,"email":true}
or["name","email"]
.alias
is unique per(createdByUserId, alias)
or(documentId, alias)
rather than globally, if desired.password
,expirationTime
, andisPublic
logic as needed.DocumentLinkEvent
table) as we need detailed download/view events.Detailed Tasks
Rename Schema Entities
schema.prisma
, renameLink
→DocumentLink
.userId
→createdByUserId
,friendlyName
→alias
).Add JSON Field for Visitor Config
Add
visitorFields Json?
toDocumentLink
.The server only stores the keys or booleans for which visitor fields are requested. For example:
or
Visitor Config
Add a shared config file in
src/shared/config/visitorFieldsConfig.ts
containing all possible visitor fields (e.g.,name
,email
,phoneNumber
, etc.), each with atype
andlabel
.The backend will not store labels/types in the
visitorFields
column—only field keys or boolean mappings.During validation (when creating a link or at link access), the server references this config to ensure the requested fields are valid.
Example Config:
export const visitorFieldsConfig = {
name: { type: 'string', label: 'Full Name' },
email: { type: 'string', label: 'Email Address' },
expirationTime: { type: 'date', label: 'Expiration Date' }, // Optional, but included if expiration is visitor-based
};
// Export the keys separately for quick reference
export const visitorFieldKeys = Object.keys(visitorFieldsConfig);
Adjust Uniqueness Constraints
If
alias
should be unique only per user or doc, add a composite unique index:Keep
linkUrl
globally unique.(Optional) Add or Sketch Analytics Table
DocumentLinkEvent
to track downloads/views with fields likeeventType
='VIEW'
or'DOWNLOAD'
.Password Protection
password
is non‐null, the server’s response should includepasswordProtected: true
so the client can handle it.Acceptance Criteria
DocumentLink
table (renamed fromLink
) with correct fields.visitorFields
JSON column is present and tested, storing minimal data (no labels/types).LinkService
, routes, etc.) updated to use new names (alias
,createdByUserId
, etc.).src/shared/config/visitorFieldsConfig.ts
exists with all valid fields and labels.visitorFieldsConfig
to validate fields at link creation (and optionally at visitor submission).The text was updated successfully, but these errors were encountered: