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

Log (history) for entity changes #118

Closed
michaelbromley opened this issue Jun 24, 2019 · 1 comment
Closed

Log (history) for entity changes #118

michaelbromley opened this issue Jun 24, 2019 · 1 comment

Comments

@michaelbromley
Copy link
Member

Is your feature request related to a problem? Please describe.
An Order changes state during processing. We need a log of these changes so for auditing purposes, including date, administrator, and other contextual information. E.g.

  • Order transitioned to PaymentAuthorized state on xxxxx date
  • Order transitioned to PaymentSettled state one xxxx date by administrator Joe.

This would allow us to implement an Order History like Shopify do:

order-timeline-overview-961c27c0d0f94f8ffd3a5e25093ca55f5baa3d7ca030715cf570c51f59e98d05

Same also goes for Payment entities. Generalizing this, it might also be useful to log changes to other entities such as Customer or ProductVariant. We'd need to strike a balance here because for certain frequently-changing entities this could generate a log of only marginally-useful noise.

Describe the solution you'd like
A new entity, LogEntry which contains things like date, user, event type, contextual info. An interface Loggable could be implemented by entities which should be logged:

interface Loggable {
  log: LogEntry[]
}

Need to figure out whether a single entity would work with the various types of log message that might be needed, or whether inheritance would be better.

@michaelbromley
Copy link
Member Author

What to log?

Some of the things that should be logged to the history for an Order:

  • State transitions
  • Payment authorized
  • Payment settled
  • Fulfillment created
  • Cancellation
  • Refund created
  • Refund settled
  • Notes by admin

Common fields

  • id
  • createdAt
  • updatedAt
  • Administrator (who instigated the action, get from the RequestContext)

Since each type of log entry would have other different fields, it might make sense to just dump related data (refundId for refunds, fulfillmentId for fulfillments etc) into a stringified JSON field and use a discriminator + unions for the purposes of type safety. Also the GraphQL type could also just use the JSON type to expose whatever data is needed.

michaelbromley added a commit that referenced this issue Jul 3, 2019
michaelbromley added a commit that referenced this issue Jul 3, 2019
michaelbromley added a commit that referenced this issue Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant