Skip to content

Commit 1edbde9

Browse files
committed
abstract event proc
1 parent 804d04b commit 1edbde9

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Class ZPM.Analytics.AbstractEventProcessor [ Abstract ]
2+
{
3+
4+
Parameter SubClasses As CONFIGVALUE;
5+
6+
ClassMethod Process(event) As %Status [ Abstract ]
7+
{
8+
Return $$$OK
9+
}
10+
11+
ClassMethod getSubClasses() As %String [ CodeMode = objectgenerator ]
12+
{
13+
Set list = ""
14+
15+
Set rs = ##class(%Dictionary.ClassDefinitionQuery).SubclassOfFunc("ZPM.Analytics.AbstractEventProcessor")
16+
While (rs.%Next()) {
17+
Set list = list _ $listbuild( rs.%GetData(1) )
18+
}
19+
20+
Do $system.OBJ.UpdateConfigParam("ZPM.Analytics.AbstractEventProcessor","SubClasses",$listtostring(list,","))
21+
Do %code.WriteLine(" return $PARAMETER(""ZPM.Analytics.AbstractEventProcessor"",""SubClasses"") ")
22+
Return $$$OK
23+
}
24+
25+
}

src/cls/ZPM/Analytics/Event.cls

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Class ZPM.Analytics.Event Extends (%Persistent, %JSON.Adaptor)
33

44
Parameter DSTIME = "AUTO";
55

6-
/// Server date and time, saving the data
6+
/// Server date and time, saving the data
77
Property TS As %PosixTime(%JSONINCLUDE = "none") [ SqlComputeCode = {set {*}=##class(%Library.PosixTime).CurrentTimeStamp()}, SqlComputed, SqlComputeOnChange = %%INSERT ];
88

99
/// Event type: download, install, uninstall
@@ -40,6 +40,22 @@ Property Region As %String(%JSONINCLUDE = "none");
4040

4141
Property City As %String(%JSONINCLUDE = "none");
4242

43+
ClassMethod ExecuteEventProcessors(event As ZPM.Analytics.Event) As %Status
44+
{
45+
Set subclasses = $PARAMETER("ZPM.Analytics.AbstractEventProcessor","SubClasses")
46+
Set list = $ListFromString(subclasses,",")
47+
For i=1:1:$listlength(list){
48+
Try {
49+
$$$ThrowOnError($Classmethod($listget(list,i), "Process", event))
50+
} Catch ex {
51+
If (ex.Name '= "<CLASS DOES NOT EXIST>") {
52+
Throw ex
53+
}
54+
}
55+
}
56+
return $$$OK
57+
}
58+
4359
ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObject) As %Status
4460
{
4561
Try {
@@ -48,10 +64,7 @@ ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObj
4864
Set event.IP = ip
4965
Do event.%JSONImport(json)
5066
$$$ThrowOnError(event.%Save())
51-
If ##class(%Dictionary.CompiledClass).%ExistsId("ZPM.Analytics.IP") {
52-
Do ##class(ZPM.Analytics.IP).SetGeo(event, ip)
53-
}
54-
$$$ThrowOnError(event.%Save())
67+
$$$ThrowOnError(..ExecuteEventProcessors(event))
5568
Return $$$OK
5669
} Catch ex {
5770
Do ex.Log()

0 commit comments

Comments
 (0)