Skip to content

Prevent special goal renames#6468

Merged
aerosol merged 4 commits into
masterfrom
prevent-special-goal-renames
Jun 30, 2026
Merged

Prevent special goal renames#6468
aerosol merged 4 commits into
masterfrom
prevent-special-goal-renames

Conversation

@aerosol

@aerosol aerosol commented Jun 29, 2026

Copy link
Copy Markdown
Member

This PR locks special goal renames so they don't lose their front-end meaning.
In case of goals whose display names fall within the special set, but their corresponding event names don't, we allow the rename in case a manual status regain is needed.

Ref https://app.basecamp.com/5308029/buckets/36789884/card_tables/cards/9834018285
Ref #6464

@aerosol aerosol requested a review from a team June 29, 2026 12:27
Comment on lines +566 to +578
test "update/2 allows updating non-name fields of a special goal" do
site = new_site()
{:ok, goal} = Goals.create(site, %{"event_name" => "File Download"})

assert {:ok, updated} =
Goals.update(goal, %{
"event_name" => "File Download",
"display_name" => "File Download",
"custom_props" => %{"0" => "path"}
})

assert updated.custom_props == %{"0" => "path"}
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question, non-blocking: I know it's allowed right now, but now that we're looking into special goals, should we keep allowing this? Special goals with some user-defined properties seem likely to bite us in the future.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bite us how?

@apata apata Jun 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say we want to make File Download dashboard component more special. Instead of relying on the system-defined setup for the goal that's the same for everyone, we need to take into account variants where the otherwise system-defined goal has arbitrary custom props defined.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or ignore any unrecognizable configuration. Nothing prevents you from sending ANY goal data. There is no way to tell whether this is legitimate event from the tracker, matching an auto-created goal or just random payload that happens to be named "File Download" with any custom props attached. We are relying on display names to recognize special goals, nothing is guaranteed in such setup.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, special goals with custom props work fine, granted there's data. If you use the seeded db and attach logged_in: true to "Outbound Link: Click", the report will render narrowed down to that. I don't see why should we prevent that based on pure speculation.

Comment thread test/plausible/goals_test.exs Outdated
assert render(lv) =~ "cannot be changed for an automated goal"
end

test "renders error when goal is invalid", %{conn: conn, site: site} do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meganitpick, non-blocking: I see now that there's several ways for the goal to be invalid, this test could be renamed to something like "renders error when renaming goal to be the same as an existing goal name"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO at the form level, it does not matter, we only care if the changeset error shows up, whatever that might be. The test is fine. Lower level tests can go into details.

@aerosol aerosol added this pull request to the merge queue Jun 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 30, 2026
@aerosol aerosol added this pull request to the merge queue Jun 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 30, 2026
@aerosol aerosol enabled auto-merge June 30, 2026 05:33
@aerosol aerosol added this pull request to the merge queue Jun 30, 2026
Merged via the queue into master with commit 55c625e Jun 30, 2026
22 checks passed
@aerosol aerosol deleted the prevent-special-goal-renames branch June 30, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants