15 Commits

Author SHA1 Message Date
Klaas van Schelven
bd35c1efdb Installation quota: pick up on settings-changes
like 7b7cd66dfb but at the installation-level
2026-01-07 15:18:29 +01:00
Klaas van Schelven
1d261b4b7c Setting & check for site-wide per-month event ingestion maximum 2026-01-07 11:29:49 +01:00
Klaas van Schelven
7f831f52d4 Remove DIGEST_IMMEDIATELY option
Although DIGEST_IMMEDIATELY=True is theoretically a nice thing to
have, the upkeep is not worth it now that we're about to introduce
minidump ingestion.

The only thing that you're saving is the round-trip via the filesystem,
but performance of that is negligable, and if you're configuring
DIGEST_IMMEDIATELY you're actually _not_ in the performance-critical path
anyway.

Getting rid of it _also_ harmonizes/reduces the number of paths to test.

It's approximately 1% of our installed base.
2025-11-05 09:03:17 +01:00
Klaas van Schelven
d8fef759ca Add database vendor, version and machine arch to phonehome message
See #226, in the context of which having some idea of the number of
installations on 2.x w/ mariadb would have been very useful
2025-10-10 09:41:57 +02:00
Klaas van Schelven
e363917e9c Per-month quota for email-sending
Fix #34
2025-07-28 14:41:32 +02:00
Klaas van Schelven
d400d98a02 Add setting to enable opting out of PHONEHOME
Fixes #52
2025-03-03 09:26:06 +01:00
Klaas van Schelven
615d2da4c8 Chache stored_event_count (on Issue and Projet)
"possibly expensive" turned out to be "actually expensive". On 'emu', with 1.5M
events, the counts take 85 and 154 ms for Project and Issue respectively;
bottlenecking our digestion to ~3 events/s.

Note: this is single-issue, single-project (presumably, the cost would be lower
for more spread-out cases)

Note on indexes: Event already has indexes for both Project & Issue (though as
the first item in a multi-column index). Without checking further: that appears
to not "magically solve counting".

This commit also optimizes the .count() on the issue-detail event list (via
Paginator).

This commit also slightly changes the value passed as `stored_event_count` to
be used for `get_random_irrelevance` to be the post-evication value. That won't
matter much in practice, but is slightly more correct IMHO.
2025-02-06 16:24:25 +01:00
Klaas van Schelven
0b42d3ff1e Semi-manual squash-migrations
## Goal

Reduce the number of migrations for _fresh installs_ of Bugsink. This implies: squash as
broadly as possible.

## How?

"throw-away-and-rerun". In particular, for a given app:

* throw away the migrations from some starting point up until and including the last one.
* run "makemigrations" for that app. Django will see what's missing and just redo it
* rename to 000n_b_squashed or similar.
* manually set a `replaces` list on the migration to the just-removed migrations
* manually check dependencies; check that they are:
    * as low as possible, e.g. an FK should only depend on existence. this reduces the
      risk of circular dependencies.
    * pointing to "original migrations", i.e. not to a just-created squashed migration.
      because the squashed migrations "contain a lot" they increase the risk of circular
      dependencies.
* restore (git checkout) the thrown-away migration

## Further tips:

* "Some starting point" is often not 0000, but some higher number (see e.g. the outcome
  in the present commit). Leaving the migrations for creation of base models (Event,
  Issue, Project) in place saves you from a lot of circular dependency problems.
* Move db.sqlite3 out of the way to avoid superfluous warnings.

## RunPython worries

I grepped for RunPython in the replaced migrations, with the following results:

* phonehome's create_installation_id was copied-over to the squashed migration.
* all others where ignored, because:
    * they "do something with events", i.e. only when events are present will they have
      an effect. This means they are no-ops for _new installs_.
    * for existing installs, for any given app, they will only be missed (replaced) when
      the first replaced migration is not yet executed.

I used the following command (reading from the bottom) to establish that this means only
people that did a fresh install after 8ad6059722 (June 14, 2024), but before
c01d332e18 (July 16) _and then never did any upgrades_ would be affected. There are no
such people.

git log --name-only \
    events/migrations/0004_event_irrelevance_for_retention.py \
    issues/migrations/0004_rename_event_count_issue_digested_event_count.py \
    phonehome/migrations/0001_initial.py \
    projects/migrations/0002_initial.py \
    teams/migrations/0001_initial.py

Note that the above observation still be true for the next squashmigration (assuming
squashing starting at the same starting migrations).

## Cleanup of the replaced migrations

Django says:

> Once you’ve squashed your migration, you should then commit it alongside the
> migrations it replaces and distribute this change to all running instances of your
> application, making sure that they run migrate to store the change in their database.

Given that I'm not in control of all running instances of my application, this means the
cleanup must not happen "too soon", and only after announcing a migration path ("update
to version X before updating to version Y").

## Roads not taken

Q: Why not just do squashmigrations? A: It didn't work reliably (for me), presumably b/c
of the high number of strongly interdependant apps in combination with some RunPython.

Seen after I was mostly done, not explored seriously (yet):

* https://github.com/3YOURMIND/django-replace-migrations
* https://pypi.org/project/django-squash/
* https://django-extensions.readthedocs.io/en/latest/delete_squashed_migrations.html
2025-02-03 16:06:17 +01:00
Klaas van Schelven
9ae6233965 Wrap 2 more BASE_URL usages with str()
In 59372aba33 a lazily evaluated BASE_URL tool was introduced.
I found 2 more cases in which BASE_URL was not "collapsed into a
string" magically by `__add__`, one of which actually causing
an `Object of type TenantBaseURL is not JSON serializable`
2025-01-30 08:52:38 +01:00
Klaas van Schelven
01578d7829 Add print_phonehome management command
useful for:

* figuring out what phonehome will report
* getting some stats on-screen locally
2025-01-29 10:06:41 +01:00
Klaas van Schelven
8cf7b006ed Phonehome comments updated: the reasons have changed
detecting production-use is no longer a reason since that's fine
2025-01-15 14:21:46 +01:00
Klaas van Schelven
3f432727d9 Warn about lack of EMAIL_BACKEND in the interface 2024-11-29 15:59:14 +01:00
Klaas van Schelven
78bceaaf43 phone-home 'EMAIL_BACKEND' (a signal about production-use) 2024-11-11 14:43:26 +01:00
Klaas van Schelven
47bf207db5 Nudge non-paying users to paid (yellow banner, site-title) 2024-11-11 14:05:02 +01:00
Klaas van Schelven
0f5ac46362 Add first version of 'phone home' 2024-11-07 22:08:53 +01:00