Thrift model for auditing updates
in build.sbt
libraryDependencies ++= Seq(
"com.gu" %% "auditing-thrift-model" % "0.4.0"
)somewhere in your code
import com.gu.auditing.model.v1.{App, Notification}
Notification(
app = App.YourAppHere,
operation = "EatFruit",
userEmail = "[email protected]",
date = new DateTime().toString(),
resourceId = Some("apple"),
message = Some("{json}")
)))You'll probably want to use thrift-serializer to handle the messages.
var Notification = require('auditing-thrift-model').Notification;
var App = require('auditing-thrift-model').App;
var message = new Notification({
app = App.YourAppHere,
operation = "EatFruit",
userEmail = "[email protected]",
date = (new Date()).toISOString(),
resourceId = "apple",
message = JSON.stringify({json})
});
serializer.write(message, serializer.Compression.Gzip, function (err, bytes) {
// use the buffer somehow
});var serializer = require('thrift-serialize');
var Notification = require('auditing-thrift-model').Notification;
serializer.read(Notification, data, function (err, message) {
console.log(message.operation, message.date);
// You can have the full name of the source app calling
console.log(message.getAppName());
});- Install
thriftusingbrew install thrift
The list of allowed applications is kept as an enum, add new ones in App.
The model is used both by Scala applications and node.js lambda.
sbt releaseto publish a new version on Sonatypenpm run compileto compile the model for node.js- update the version of
package.jsonit should match the one you just released on Sonatype npm publish ./to publish the new version on npm