| 173 | }; |
| 174 | |
| 175 | #capture(event: CaptureEvent) { |
| 176 | if (this.#posthogClient === undefined) return; |
| 177 | let groups: Record<string, string> = {}; |
| 178 | |
| 179 | if (event.organizationId) { |
| 180 | groups = { |
| 181 | ...groups, |
| 182 | organization: event.organizationId, |
| 183 | }; |
| 184 | } |
| 185 | |
| 186 | if (event.projectId) { |
| 187 | groups = { |
| 188 | ...groups, |
| 189 | project: event.projectId, |
| 190 | }; |
| 191 | } |
| 192 | |
| 193 | if (event.jobId) { |
| 194 | groups = { |
| 195 | ...groups, |
| 196 | workflow: event.jobId, |
| 197 | }; |
| 198 | } |
| 199 | |
| 200 | if (event.environmentId) { |
| 201 | groups = { |
| 202 | ...groups, |
| 203 | environment: event.environmentId, |
| 204 | }; |
| 205 | } |
| 206 | |
| 207 | let properties: Record<string, any> = {}; |
| 208 | if (event.eventProperties) { |
| 209 | properties = { |
| 210 | ...properties, |
| 211 | ...event.eventProperties, |
| 212 | }; |
| 213 | } |
| 214 | |
| 215 | if (event.userProperties) { |
| 216 | properties = { |
| 217 | ...properties, |
| 218 | $set: event.userProperties, |
| 219 | }; |
| 220 | } |
| 221 | |
| 222 | if (event.userOnceProperties) { |
| 223 | properties = { |
| 224 | ...properties, |
| 225 | $set_once: event.userOnceProperties, |
| 226 | }; |
| 227 | } |
| 228 | |
| 229 | const eventData = { |
| 230 | distinctId: event.userId, |
| 231 | event: event.event, |
| 232 | properties, |