2022-10-27 14:58:28 +03:00
|
|
|
import Component from '@glimmer/component';
|
2023-04-03 09:35:56 +03:00
|
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
2022-10-27 14:58:28 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2023-04-07 08:54:31 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2022-10-27 14:58:28 +03:00
|
|
|
|
|
|
|
export default class Analytics extends Component {
|
|
|
|
@service settings;
|
|
|
|
@service feature;
|
2023-04-03 09:35:56 +03:00
|
|
|
@service utils;
|
2022-10-27 14:58:28 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
toggleEmailTrackOpens(event) {
|
|
|
|
if (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
this.settings.emailTrackOpens = !this.settings.emailTrackOpens;
|
|
|
|
}
|
|
|
|
|
2023-04-07 08:54:31 +03:00
|
|
|
@task
|
|
|
|
*exportPostsTask() {
|
2023-04-03 09:35:56 +03:00
|
|
|
let exportUrl = ghostPaths().url.api('posts/export');
|
|
|
|
let downloadParams = new URLSearchParams();
|
2023-04-07 09:24:59 +03:00
|
|
|
downloadParams.set('limit', 1000);
|
2023-04-03 09:35:56 +03:00
|
|
|
|
2023-04-07 08:54:31 +03:00
|
|
|
yield this.utils.fetchAndDownloadFile(`${exportUrl}?${downloadParams.toString()}`);
|
|
|
|
|
|
|
|
return true;
|
2023-04-03 09:35:56 +03:00
|
|
|
}
|
|
|
|
|
2022-10-27 14:58:28 +03:00
|
|
|
@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;
|
|
|
|
}
|
2023-01-20 15:41:36 +03:00
|
|
|
|
|
|
|
@action
|
|
|
|
toggleOutboundLinkTagging(event) {
|
|
|
|
if (event) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
this.settings.outboundLinkTagging = !this.settings.outboundLinkTagging;
|
|
|
|
}
|
2022-10-27 14:58:28 +03:00
|
|
|
}
|