Ghost/ghost/admin/app/components/settings/analytics.js
Fabien "egg" O'Carroll c99016fd2f Limited post export size to 1000 posts
refs https://github.com/TryGhost/Team/issues/2936

We want to make sure that downloads complete in a reasonable number of
time, and the simplest way to do that is to cap the size of the file.
2023-04-07 14:44:28 +07:00

55 lines
1.4 KiB
JavaScript

import Component from '@glimmer/component';
import ghostPaths from 'ghost-admin/utils/ghost-paths';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default class Analytics extends Component {
@service settings;
@service feature;
@service utils;
@action
toggleEmailTrackOpens(event) {
if (event) {
event.preventDefault();
}
this.settings.emailTrackOpens = !this.settings.emailTrackOpens;
}
@task
*exportPostsTask() {
let exportUrl = ghostPaths().url.api('posts/export');
let downloadParams = new URLSearchParams();
downloadParams.set('limit', 1000);
yield this.utils.fetchAndDownloadFile(`${exportUrl}?${downloadParams.toString()}`);
return true;
}
@action
toggleEmailTrackClicks(event) {
if (event) {
event.preventDefault();
}
this.settings.emailTrackClicks = !this.settings.emailTrackClicks;
}
@action
toggleMembersTrackSources(event) {
if (event) {
event.preventDefault();
}
this.settings.membersTrackSources = !this.settings.membersTrackSources;
}
@action
toggleOutboundLinkTagging(event) {
if (event) {
event.preventDefault();
}
this.settings.outboundLinkTagging = !this.settings.outboundLinkTagging;
}
}