Skip to main content

Friend-source Tracking

Overview

This domain has three tables: friend_track_campaign (campaigns that track where new friends come from, each with its own token for the invite link), friend_track_event (follow/unfollow events that arrived through such a campaign), and friend_track_ref (sub-reference codes, ref_id, pre-issued under a single campaign).

Table friend_track_campaign

ColumnTypeNullableDefaultDescription
idSERIAL (INTEGER)NOnextval(...)Primary key of the friend-track campaign
nameTEXTNO-Campaign name
tokenTEXTNO-Campaign token embedded in the invite link (unique table-wide)
descriptionTEXTYES-Campaign description
statusTEXTNO'active'Campaign status
attribute_configJSONBYES{}Attribute values applied to users who arrive through this campaign
line_oa_idINTEGERNO-Owning LINE OA (FK to line_oa.id)
organization_idINTEGERNO-Owning organization (FK to organization.id)
created_byINTEGERNO0User who created the record
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp
updated_byINTEGERYES0User who last updated the record
updated_dateTIMESTAMPTZ(3)YES-Last update timestamp
deleted_dateTIMESTAMPTZ(3)YES-Soft-delete timestamp
ref_attribute_keyVARCHAR(255)YES-Attribute name used to store the ref_id on the user profile
ref_upload_statusJSONBYES-Status of the ref_id bulk upload into the campaign (progress/result)

Table friend_track_event

ColumnTypeNullableDefaultDescription
idSERIAL (INTEGER)NOnextval(...)Primary key of the event
campaign_idINTEGERNO-Campaign the event belongs to (FK to friend_track_campaign.id)
line_user_idTEXTNO-LINE user ID of the person the event is about
event_typeTEXTNO-Event kind, e.g. follow or unfollow
display_nameTEXTYES-User's display name at the time of the event
picture_urlTEXTYES-User's profile picture URL at the time of the event
line_oa_idINTEGERNO-LINE OA where the event occurred
organization_idINTEGERNO-Owning organization
created_dateTIMESTAMPTZ(3)NOnow()When the event occurred
ref_idVARCHAR(255)YES-Sub-reference code carried by the link, identifying the individual channel or referrer

Table friend_track_ref

ColumnTypeNullableDefaultDescription
idSERIAL (INTEGER)NOnextval(...)Primary key of the ref record
campaign_idINTEGERNO-Campaign the ref belongs to (FK to friend_track_campaign.id)
ref_idVARCHAR(255)NO-Issued sub-reference code (unique within the campaign)
line_oa_idINTEGERNO-Owning LINE OA
organization_idINTEGERNO-Owning organization
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp

Notes

  • friend_track_campaign has FKs to line_oa.id and organization.id with ON DELETE RESTRICT, so a LINE OA or organization with campaigns still attached cannot be deleted.
  • friend_track_event.campaign_id and friend_track_ref.campaign_id are FKs to friend_track_campaign.id with ON DELETE CASCADE — deleting a campaign removes its events and refs.
  • friend_track_campaign.token carries a table-wide unique constraint.
  • friend_track_ref has a unique constraint on (campaign_id, ref_id): a ref_id cannot repeat within one campaign, but the same value may be reused across campaigns.
  • friend_track_campaign is also referenced by content_page, linking content pages to a friend-track campaign.
  • Indexes: friend_track_campaign on line_oa_id and deleted_date; friend_track_event on campaign_id, (line_user_id, line_oa_id) and (event_type, campaign_id); friend_track_ref on campaign_id.
  • friend_track_event and friend_track_ref have no soft-delete column.