mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
fa84808048
no issue Since `ember-moment@10.0` it's not been necessary to use the `ember-cli-moment-shim` package, with `moment` instead being usable directly via `ember-auto-import`. Getting rid of the shim package is necessary for compatibility with `embroider`, Ember's new build tooling. - dropped `ember-cli-moment-shim` dependency - added `moment-timezone` dependency and updated all imports to reflect the different package - worked around `ember-power-calendar` having `ember-cli-moment-shim` as a sub-dependency - added empty in-repo-addon `ember-power-calendar-moment` to avoid `ember-power-calendar` complaining about a missing package - added `ember-power-calendar-utils` in-repo-addon that is a copy of `ember-power-calendar-moment` but without the build-time renaming of the tree for better compatibility with embroider
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import faker from 'faker';
|
|
import moment from 'moment-timezone';
|
|
import {Factory} from 'miragejs';
|
|
|
|
const EVENT_TYPES = [
|
|
'newsletter_event',
|
|
'login_event',
|
|
'subscription_event',
|
|
'payment_event',
|
|
'login_event',
|
|
'signup_event',
|
|
'email_delivered_event',
|
|
'email_opened_event',
|
|
'email_failed_event'
|
|
];
|
|
|
|
/* eslint-disable camelcase */
|
|
export default Factory.extend({
|
|
type() { return faker.random.arrayElement([EVENT_TYPES]); },
|
|
createdAt() { return moment.utc().format(); },
|
|
|
|
afterCreate(event, server) {
|
|
if (!event.member) {
|
|
event.update({member: server.create('member')});
|
|
}
|
|
|
|
if (event.type === 'newsletter_event') {
|
|
event.update({
|
|
data: {
|
|
source: 'member',
|
|
subscribed: event.subscribed !== undefined ? event.subscribed : faker.datatype.boolean()
|
|
}
|
|
});
|
|
}
|
|
|
|
if (event.type === 'subscription_event') {
|
|
event.update({
|
|
data: {
|
|
source: 'stripe'
|
|
// TODO: add from_plan, to_plan, currency, mrr_delta
|
|
}
|
|
});
|
|
}
|
|
|
|
if (event.type === 'payment_event') {
|
|
// TODO: add data attributes
|
|
}
|
|
|
|
if (event.type === 'signup_event') {
|
|
// TODO: add data attributes
|
|
}
|
|
}
|
|
});
|