Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow domain change #2803

Merged
merged 20 commits into from
Apr 4, 2023
Merged

Allow domain change #2803

merged 20 commits into from
Apr 4, 2023

Conversation

aerosol
Copy link
Member

@aerosol aerosol commented Mar 29, 2023

Changes

Ref #1080

This PR implements the ability to change a site's domain keeping the collected stats intact.

We grant users with 72 hours transition period in which they're expected to update their API credentials and tracker scripts to point at the new domain. During that time, both old and new domains are accepted within incoming traffic and are made unavailable for registration.

This change will be only live after V2 migration is done (Ref #2762 #2780) hence the "feature flag" required for it is V2_MIGRATION_DONE=1 variable set.

change-domain-light.mp4
change-domain-dark.mp4

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

Updated

Documentation

plausible/docs#380

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@bundlemon
Copy link

bundlemon bot commented Mar 29, 2023

BundleMon

Unchanged files (7)
Status Path Size Limits
static/css/app.css
492.34KB -
static/js/dashboard.js
295.28KB -
static/js/app.js
12.13KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.06KB -
tracker/js/plausible.js
733B -
static/js/applyTheme.js
314B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@aerosol aerosol marked this pull request as ready for review March 29, 2023 13:06
@aerosol aerosol changed the title [wip] Allow domain change Allow domain change Mar 29, 2023
lib/plausible/site.ex Outdated Show resolved Hide resolved
aerosol and others added 3 commits March 29, 2023 17:57
@aerosol
Copy link
Member Author

aerosol commented Mar 30, 2023

I've added a note to CHANGELOG via e6a56b4

Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

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

All looks good to me.

test/plausible/site/cache_test.exs Show resolved Hide resolved
@rphlo
Copy link

rphlo commented Mar 30, 2023

Could a API endpoint be added to change a domain?

@aerosol
Copy link
Member Author

aerosol commented Mar 30, 2023

@rphlo sure, we could add that. Do you mind describing your use case?

@rphlo
Copy link

rphlo commented Mar 31, 2023

@rphlo sure, we could add that. Do you mind describing your use case?

I use the self hosted version,
I my case I provide subdomain to my clients. I auto create through the API an analytics page for that subdomain and provide a shared link for the client to see it.
However if they decide to change their subdomain at the moment I am forced to create a fresh analytics page and they lose their history.
If the API would let me change the domain in the future it be great.

@rphlo
Copy link

rphlo commented Mar 31, 2023

I believe it should be possible for the owner to switch back to its previous domain within the 72 hours period.
I can imagine cases were a user would change his mind.
Actually as I understand the current implementation allow this by using a third domain.

Site goes domain1.site > domain2.site > domain3.site > domain1.site, Would work
Site goes domain1.site > domain2.site > domain1.site, Wouldn't work

@aerosol
Copy link
Member Author

aerosol commented Mar 31, 2023

@rphlo Thanks for sharing your use case. I've added the API endpoint. Please note however that this feature requires a complex database migration to work, it is still in experimental phase and we don't have this documented for self-hosters yet.

And you are correct, in this implementation it's impossible to undo domain change without setting a temporary domain first, unless the 72h transition period ends.

@aerosol
Copy link
Member Author

aerosol commented Apr 3, 2023

With 67317b2 repeated changes within the same site are allowed, no need for a temporary rename anymore.

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.

None yet

4 participants