Record custom events using the Shotgun API

What is this?

About logging to Shotgun via Shotgun API I will write about the case of intentionally leaving an arbitrary log instead of the log that is automatically left.

EventLogEntry entity

On Shotgun, the data table for logging is ** "EventLogEntry Entity" **. If someone does something on Shotgun Web (opening a page, changing status, browsing a version, etc.), it will be logged.

Feature

--Cannot be deleted --Uneditable --Recorded both from the browser and via the API

… Because it is a log, of course

Record the log [arbitrarily]

Premise

The log is recorded without doing anything, In addition, there are times when you want to log your own events as some kind of landmark.

It's a so-called "custom event".

Method used = create

There is no method for recording the event, As usual, ** create ** on the EventLogEntry entity

field

スクリーンショット 2016-03-25 2.04.57.png

By the way, speaking of "RTS" in the project column, It is serialized here> http://area.autodesk.jp/column/tutorial/road_to_stingray/ I also gave a lecture the other day> http://www.guncys.com/?p=378 I'm looking forward to the completion!

How to write event_type

Since event_type itself is just a text field, you can write it freely, Basically, it is better to match the following format

{What is the log}_{Which entity to log to}_{What kind of operation did you do}

It is an underscore that connects "who", "where", and "what". Observing from the log written as standard, it feels like the upper camel case is connected with an underscore for 3 elements.

Who

where

What happened

Example sentence

writing

Based on the contents so far, the script that leaves an arbitrary log is as follows, for example.

python


data = {}
data['project'] = PROJ
data['event_type'] = 'MyApp_Entity_SomeAction'
data['description'] = 'some action'
data['user'] = SCRIPT_USER
data['entity'] = SOME_TARGET
    
sg.create('EventLogEntry',data)

Get

The example sentence to get the written log looks like the following

python


eventType = 'MyApp_Entity_SomeAction'

log = sg.find_one(
                  'EventLogEntry',
                  [['event_type','is',eventType ],['project','is',PROJ]],
                  ['created_at','entity'],
                  order=[{'field_name':'id','direction':'desc'}]
                  )

By using the find_one method and specifying ʻorderto return in the newest order (where'desc') I have one "latest'Myscript_Shot_SomeAction'". Also, put'created_at'` in the returned field to get the timestamp.

If you enter the event type, it would be nice to make it a function so that it will be returned.

Summary

--Use create. -** Be careful as it cannot be erased **!

Remarks

Event example

Here are some examples of event types that will flow if you use them normally (= without doing anything like the above).

reference

How to write event driven triggers https://support.shotgunsoftware.com/entries/44575-How-to-write-event-driven-triggers

Event Types https://github.com/shotgunsoftware/python-api/wiki/Event-Types

There is also such a good thing

Shotgun Event Framework https://github.com/shotgunsoftware/shotgunEvents

Recommended Posts

Record custom events using the Shotgun API
Try using the PeeringDB 2.0 API
I tried using the checkio API
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Tweet using the Twitter API in Python
Create an application using the Spotify API
Image collection using Google Custom Search API
I tried using the BigQuery Storage API
I checked the library for using the Gracenote API
Hit the Web API using requests Example: Flickr
Try using the BitFlyer Ligntning API in Python
I tried using the Google Cloud Vision API
Try using the DropBox Core API in Python
Initial settings when using the foursquare API in python
Send and receive Gmail via the Gmail API using Python
Post to your account using the API on Twitter
I tried using the API of the salmon data project
Using the National Diet Library Search API in Python
A little bit from Python using the Jenkins API
Create a real-time auto-reply bot using the Twitter Streaming API
Follow the XBRL taxonomy display link using the OSS Arrele API
Obtain vulnerability information using the REST API published by NVD
Image Optimize on the server side using TinyPNG's Web API
[Python] I tried collecting data using the API of wikipedia
Tweet Now Playing to Twitter using the Spotify API. [Python]
Let's publish the super resolution API using Google Cloud Platform
For the time being, try using the docomo chat dialogue API
The story of creating a database using the Google Analytics API
I made an original program guide using the NHK program guide API.
Get the weather using the API and let the Raspberry Pi speak!
[For beginners] I tried using the Tensorflow Object Detection API
Create an application that just searches using the Google Custom Search API with Python 3.3.1 in Bottle