@@ -19,12 +19,12 @@ private class PhContainer {
19
19
private string _event ;
20
20
21
21
[ JsonProperty ( "properties" ) ]
22
- private Dictionary < string , object > _properties ;
22
+ private IDictionary < string , object > _properties ;
23
23
24
24
[ JsonProperty ( "timestamp" ) ]
25
25
private DateTime _timestamp ;
26
26
27
- public PhContainer ( string apiKey , string eventName , Dictionary < string , object > properties ) {
27
+ public PhContainer ( string apiKey , string eventName , IDictionary < string , object > properties ) {
28
28
_apiKey = apiKey ;
29
29
_event = eventName ;
30
30
_properties = properties ;
@@ -84,16 +84,20 @@ public static void RemovedFromDocument(GH_Component component, OasysPluginInfo p
84
84
}
85
85
}
86
86
87
- public static async Task < HttpResponseMessage > SendToPostHog ( OasysPluginInfo pluginInfo , string eventName , Dictionary < string , object > additionalProperties = null ) {
87
+ public static async Task < HttpResponseMessage > SendToPostHog ( OasysPluginInfo pluginInfo , string eventName , IDictionary < string , object > additionalProperties = null ) {
88
+ return await SendToPostHog ( pluginInfo . PostHogApiKey , pluginInfo . PluginName , pluginInfo . Version , pluginInfo . IsBeta , eventName , additionalProperties ) ;
89
+ }
90
+
91
+ public static async Task < HttpResponseMessage > SendToPostHog ( string postHogApiKey , string pluginName , string version , bool isBeta , string eventName , IDictionary < string , object > additionalProperties = null ) {
88
92
// posthog ADS plugin requires a user object
89
93
User user = currentUser ;
90
94
91
95
var properties = new Dictionary < string , object > ( ) {
92
96
{ "distinct_id" , user . UserName } ,
93
97
{ "user" , user } ,
94
- { "pluginName" , pluginInfo . PluginName } ,
95
- { "version" , pluginInfo . Version } ,
96
- { "isBeta" , pluginInfo . IsBeta } ,
98
+ { "pluginName" , pluginName } ,
99
+ { "version" , version } ,
100
+ { "isBeta" , isBeta } ,
97
101
} ;
98
102
99
103
if ( additionalProperties != null ) {
@@ -102,7 +106,11 @@ public static async Task<HttpResponseMessage> SendToPostHog(OasysPluginInfo plug
102
106
}
103
107
}
104
108
105
- var container = new PhContainer ( pluginInfo . PostHogApiKey , eventName , properties ) ;
109
+ return await SendToPostHog ( postHogApiKey , eventName , properties ) ;
110
+ }
111
+
112
+ public static async Task < HttpResponseMessage > SendToPostHog ( string postHogApiKey , string eventName , IDictionary < string , object > properties ) {
113
+ var container = new PhContainer ( postHogApiKey , eventName , properties ) ;
106
114
string body = JsonConvert . SerializeObject ( container ) ;
107
115
var content = new StringContent ( body , Encoding . UTF8 , "application/json" ) ;
108
116
HttpResponseMessage response = await phClient . PostAsync ( "https://eu.posthog.com/capture/" , content ) ;
0 commit comments