diff --git a/.github/workflows/trigger-deploy.yml b/.github/workflows/trigger-deploy.yml index d8ddff0..abd335b 100644 --- a/.github/workflows/trigger-deploy.yml +++ b/.github/workflows/trigger-deploy.yml @@ -14,8 +14,7 @@ on: jobs: trigger-zpm-deployment: name: Trigger zpm-registry-deployment via REST API - runs-on: ubuntu-latest - + runs-on: ubuntu-22.04 steps: - name: REST POST call run: |- diff --git a/src/cls/ZPM/Analytics/AbstractEventProcessor.cls b/src/cls/ZPM/Analytics/AbstractEventProcessor.cls new file mode 100644 index 0000000..6b41101 --- /dev/null +++ b/src/cls/ZPM/Analytics/AbstractEventProcessor.cls @@ -0,0 +1,29 @@ +/// To execute your code immediately after the event occurs, +/// you need to create a subclass of this class and override the Process() method in it. +Class ZPM.Analytics.AbstractEventProcessor [ Abstract ] +{ + +Parameter SubClasses As CONFIGVALUE; + +/// Override this method to run your code when event occurs +ClassMethod Process(event as ZPM.Analytics.Event) As %Status [ Abstract ] +{ + Return $$$OK +} + +/// Do not change or override this method +ClassMethod getSubClasses() As %String [ CodeMode = objectgenerator ] +{ + Set list = "" + + Set rs = ##class(%Dictionary.ClassDefinitionQuery).SubclassOfFunc("ZPM.Analytics.AbstractEventProcessor") + While (rs.%Next()) { + Set list = list _ $listbuild( rs.%GetData(1) ) + } + + Do $system.OBJ.UpdateConfigParam("ZPM.Analytics.AbstractEventProcessor","SubClasses",$listtostring(list,",")) + Do %code.WriteLine(" return $PARAMETER(""ZPM.Analytics.AbstractEventProcessor"",""SubClasses"") ") + Return $$$OK +} + +} diff --git a/src/cls/ZPM/Analytics/Event.cls b/src/cls/ZPM/Analytics/Event.cls index e04f4c9..7c50398 100644 --- a/src/cls/ZPM/Analytics/Event.cls +++ b/src/cls/ZPM/Analytics/Event.cls @@ -3,7 +3,7 @@ Class ZPM.Analytics.Event Extends (%Persistent, %JSON.Adaptor) Parameter DSTIME = "AUTO"; -/// Server date and time, saving the data +/// Server date and time, saving the data Property TS As %PosixTime(%JSONINCLUDE = "none") [ SqlComputeCode = {set {*}=##class(%Library.PosixTime).CurrentTimeStamp()}, SqlComputed, SqlComputeOnChange = %%INSERT ]; /// Event type: download, install, uninstall @@ -40,6 +40,22 @@ Property Region As %String(%JSONINCLUDE = "none"); Property City As %String(%JSONINCLUDE = "none"); +ClassMethod ExecuteEventProcessors(event As ZPM.Analytics.Event) As %Status +{ + Set subclasses = $PARAMETER("ZPM.Analytics.AbstractEventProcessor","SubClasses") + Set list = $ListFromString(subclasses,",") + For i=1:1:$listlength(list){ + Try { + $$$ThrowOnError($Classmethod($listget(list,i), "Process", event)) + } Catch ex { + If (ex.Name '= "") { + Throw ex + } + } + } + return $$$OK +} + ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObject) As %Status { Try { @@ -48,10 +64,7 @@ ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObj Set event.IP = ip Do event.%JSONImport(json) $$$ThrowOnError(event.%Save()) - If ##class(%Dictionary.CompiledClass).%ExistsId("ZPM.Analytics.IP") { - Do ##class(ZPM.Analytics.IP).SetGeo(event, ip) - } - $$$ThrowOnError(event.%Save()) + $$$ThrowOnError(..ExecuteEventProcessors(event)) Return $$$OK } Catch ex { Do ex.Log()