@@ -255,22 +255,20 @@ desktop or run `docker logs service-bus` to verify the service is up before laun
255
255
256
256
1. Add the following to your `secrets.json` in `dev` to configure the service bus:
257
257
258
- ```json
259
- "eventLogging": {
260
- "azureServiceBus": {
261
- "connectionString": "\"Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;\"",
262
- "topicName": "event-logging",
263
- "eventRepositorySubscriptionName": "events-write-subscription",
264
- "slackSubscriptionName": "events-slack-subscription",
265
- "webhookSubscriptionName": "events-webhook-subscription",
266
- }
267
- },
268
- ```
269
-
270
- :::info
271
- (optional) The `slackSubscriptionName` and `webhookSubscriptionName` specified above are optional. If
272
- they are not defined, the system will use the above default names.
273
- :::
258
+ ```json
259
+ "eventLogging": {
260
+ "azureServiceBus": {
261
+ "connectionString": "\"Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;\"",
262
+ "topicName": "event-logging",
263
+ "eventRepositorySubscriptionName": "events-write-subscription",
264
+ "slackSubscriptionName": "events-slack-subscription",
265
+ "webhookSubscriptionName": "events-webhook-subscription",
266
+ }
267
+ },
268
+ ```
269
+
270
+ :::info (optional) The `slackSubscriptionName` and `webhookSubscriptionName` specified above are
271
+ optional. If they are not defined, the system will use the above default names. :::
274
272
275
273
2. Re-run the secrets script to publish the new secrets
276
274
@@ -279,3 +277,66 @@ pwsh setup_secrets.ps1 -clear
279
277
```
280
278
281
279
3. Start or re-start all services, including `EventsProcessor`.
280
+
281
+ ### Integrations and IntegrationConfigurations
282
+
283
+ Organizations can configure Integrations and IntegrationConfigurations to send events to different
284
+ endpoints. Each handler maps to a specific integration and checks for the configuration when it
285
+ receives an event. Currently, there are integrations/handlers for Slack and webhooks (as mentioned
286
+ above).
287
+
288
+ **OrganizationIntegration**
289
+
290
+ - This is the top level object that enables a specific integration for the Organization
291
+ - It includes any properties that apply to the entire integration across all events
292
+
293
+ - For slack, it consists of the token:
294
+
295
+ ```json
296
+ { "token": "xoxb-token-from-slack" }
297
+ ```
298
+
299
+ - For webhooks, it is `null`. However, even though there is no configuration, an organization must
300
+ have a webhook `OrganizationIntegration` to enable configuration via
301
+ `OrganizationIntegrationConfiguration`
302
+
303
+ **OrganizationIntegrationConfiguration**
304
+
305
+ - This contains the configurations specific to each `EventType` for the integration.
306
+ - `Configuration` contains the event-specific configuration
307
+
308
+ - For Slack, this would contain what channel to send the message to:
309
+
310
+ ```json
311
+ { "channelId": "C123456" }
312
+ ```
313
+
314
+ - For Webhook, this is the URL the request should be sent to:
315
+
316
+ ```json
317
+ { "url": "https://api.example.com" }
318
+ ```
319
+
320
+ - `Template` contains a template string the is expected to be filled in with the contents of the
321
+ actual event.
322
+ - The tokens in the string are wrapped in `#` characters. For instance, the UserId would be
323
+ `#UserId#`
324
+ - The `IntegrationTemplateProcessor` does the actual work of replacing these tokens with
325
+ introspected values from the provided `EventMessage`.
326
+ - Note that the template does not enforce any structure - it could be a freeform text message to
327
+ send via Slack, or a JSON body to send via webhook. We simply store and use it as a string for
328
+ the most flexibility.
329
+
330
+ **OrganizationIntegrationConfigurationDetails**
331
+
332
+ - The database has a view - `OrganizationIntegrationConfigurationDetailsView` - which is a join of
333
+ `OrganizationIntegration` and `OrganizationIntegrationConfiguration` on the
334
+ `OrganizationIntegration.Id`.
335
+ - This is represented in code as an array of `OrganizationIntegrationConfigurationDetails` objects
336
+ returned to the handler, with the combined configuration details in `MergedConfiguration` and the
337
+ `Template` that defines the contents to send to the specific service.
338
+ - This allows us to query for a specific Organization (by id) and an `IntegrationType` for an
339
+ `EventType` and return a combined object with the configuration details of both tables.
340
+ - The job of the handler is to iterate over these detail objects, fill in the Template with values
341
+ from the actual EventMessage, and send the message to the integration using the
342
+ `MergedConfiguration` details.
0 commit comments