Skip to content

Commit

Permalink
Cor 2290 - Webhooks Docs (#528)
Browse files Browse the repository at this point in the history
* Audit Log - Release Date Added to Docs

* Outbound Webhooks Docs V1

- Webhooks Docs
-- Creatig a Webhook
-- Example Payload
-- Testing a Webhook
-- Deleting a Webhook

* Update webhooks.md

* chore: fixed example payload section

---------

Co-authored-by: Jason Salaber <[email protected]>
  • Loading branch information
katemacfarlane and jsalaber authored Jan 16, 2024
1 parent 6813258 commit 1e47420
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 12 deletions.
20 changes: 10 additions & 10 deletions docs/extras/audit-log/audit-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ title: Audit Log
sidebar_position: 1
---

The Audit Log tracks all modifications made to a Feature. DevCycle captures the DevCycle user who made the change, a time stamp, and what was modified on each Feature save.
The Audit Log tracks all modifications made to a Feature. DevCycle captures the DevCycle user who made the change, a time stamp, and what was modified on each Feature save.

The Audit Log is located at the bottom of the Feature form in the Data & Results section.
The Audit Log is located at the bottom of the Feature form in the Data & Results section.

![Audit Log on Feature Page](/nov2023-audit-log-sidebar.png)

You can filter modfications by environment, DevCycle user, and for a particular date range.
You can filter modfications by environment, DevCycle user, and for a particular date range.

![Audit Log](/nov2023-audit-log-summary.png)

:::info

The Audit Log started to track Feature modifications on November 18, 2023. All modifications made before that date will not appear in the Audit Log.
The Audit Log feature was released in early December 2023. No Audit Log modifications were tracked before this date.

:::

The title of each modification card highlights the change that was made to the Feature upon clicking save. If multiple changes were made on a Feature save and/or there were modifications made to more than one Environment, the card will show the total number modifications made.
The title of each modification card highlights the change that was made to the Feature upon clicking save. If multiple changes were made on a Feature save and/or there were modifications made to more than one Environment, the card will show the total number modifications made.

Click the `View Details` button on each card for more information about each modification.
Click the `View Details` button on each card for more information about each modification.

Modifications are organized by Environment with each card. The color of each Environment tag corresponds to the [color selected for that Environment](/essentials/environments#from-the-dashboard-1).
Modifications are organized by Environment with each card. The color of each Environment tag corresponds to the [color selected for that Environment](/essentials/environments#from-the-dashboard-1).

Items that are added to the Feature will be highlighted in green in the left-hand column of the modification card (see below), and removals or deletions of items will be highlighted in red.
Items that are added to the Feature will be highlighted in green in the left-hand column of the modification card (see below), and removals or deletions of items will be highlighted in red.

![Audit Log Addition](/nov2023-audit-log-net-new-add.png)

For modifications to values, each card will show the orignal value on the left-hand column of the card and the updated value of on the right. If a value was added or modified, the change will be highlighted in green. If a value was deleted or removed, the change will be highlighted in red.
For modifications to values, each card will show the orignal value on the left-hand column of the card and the updated value of on the right. If a value was added or modified, the change will be highlighted in green. If a value was deleted or removed, the change will be highlighted in red.

:::info

Expand All @@ -39,6 +39,6 @@ Please note that [Self-Targeting](/extras/advanced-targeting/self-targeting) act

### Feature Created Modification Cards in the Audit Log

When a Feature is created, you will see multiple modification cards populate in the Audit Log. The first modification card in the Audit Log will outline the initial Feature configuration (initial variable, variations, status, settings, etc.). Then, depending on the [Feature Type](/introduction/core-concepts/feature-types) selected when creating a new Feature, the following cards will highlight the each Environment's Targeting status, along with the templated Targeting Rules (if they exist). See an example below of an Experiment Feature Type.
When a Feature is created, you will see multiple modification cards populate in the Audit Log. The first modification card in the Audit Log will outline the initial Feature configuration (initial variable, variations, status, settings, etc.). Then, depending on the [Feature Type](/introduction/core-concepts/feature-types) selected when creating a new Feature, the following cards will highlight the each Environment's Targeting status, along with the templated Targeting Rules (if they exist). See an example below of an Experiment Feature Type.

![Audit Log Experiment Feature Type](/nov2023-audit-log-experiment-feature-type.png)
2 changes: 2 additions & 0 deletions docs/extras/webhooks/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: 'Webhooks'
position: 9
145 changes: 145 additions & 0 deletions docs/extras/webhooks/webhooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
title: Webhooks
sidebar_position: 1
---

This topic explains how to create and use Webhooks in DevCycle.

Webhooks allow you to build your own integrations that subscribe to Feature changes in DevCycle. Use Webhooks to update external ticket trackers, notify teammates of new features, targeting changes, and more.

## Outbound Webhooks

### Creating a Webhook

To create a Webhook:

1. Navigate to the Integrations page.
2. Navigate to the "Webhooks" section and click `+ New Webhook`. The "Create a Webhook" modal appears.
3. Give the Webhook a human-readable name.
4. (Optional) Give the Webhook a description.
5. Enter a Payload URL.
6. Click `Create Webhook`. From there, you will be taken to the Webhook details page.
7. Select if you'd like events sent for all Features in your project or a single Feature.
8. Select which events will be sent through the Webhook.
9. Click `Save`.

### Example Payload

Below is the type definition for the payload that gets sent to the Webhook url:

```typescript
/**
* The 'newContents' and 'previousContents' type is a subset of the resource
* that was changed
*/
export type AuditLogChange = {
type: string
newContents: Record<string, unknown> | null
previousContents: Record<string, unknown> | null
_environments?: string[]
metadata?: Record<string, unknown>
}

type User = {
name?: string
email: string
}

type WebhookPayload = {
/**
* An array of types that were triggered, the 'changes' property
* should have all these events in this array
*/
events: string[]

/**
* The key of the Feature
*/
key?: string

/**
* The key of the project
*/
projectId: string

/**
* The version of the payload so we can have different versions
* in the future
*/
version: string

/**
* The changes that were made
*/
changes: AuditLogChange[]

/**
* The date this Webhook triggered the URL on
*/
date: Date

/**
* The user that triggered the change
*/
user: User
}
```
For example, a user edits a Feature’s key and adds a new variable, the data posted to the user’s Webhook URL would be:
```json
{
"events": ["modifiedFeature", "addedVariable"],
"key": "feature-key",
"date": "2024-01-16T18:30:42.796Z",
"user": {
"name": "Jason",
"email": "[email protected]"
},
"version": "1"
"changes": [
{
"type": "modifiedFeature",
"newContents": {
"key": "new-feature-key"
},
"previousContents": {
"key": "feature-key"
}
},
{
"type": "addedVariable",
"newContents": {
... // new variable object
},
"previousContents": null
},
]
}
```
### Testing a Webhook
To test a Webhook:
1. Navigate to the Integrations page.
2. Navigate to the "Webhooks" section.
3. Click the expand arrows next to the Add integration button.
4. Navigate to the Test section of the Webhook details page.
5. Click `Test Connection` to verify the Webhook Url is accessible. The API response will be displayed below.
### Deleting a Webhook
To delete a Webhook:
1. Navigate to the Integrations page.
2. Navigate to the "Webhooks" section.
3. Click on the Webhook that you wish to delete.
4. Navigate to the Settings section of the Webhook details page.
5. Click `Delete Webhook`. A confirmation modal will appear.
6. Click `Delete`.
## Inbound Webhooks (Coming Soon)
This Feature will allow the user to create Webhook urls for certain actions, for e.g. turning on/off a Production Environment.
If you would like this Feature, contact [email protected]!
11 changes: 9 additions & 2 deletions docs/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ DevCycle APIs, as well as third party integrations to connect DevCycle to the to
starting point is <a href="/management-api/">DevCycle's Management API</a>{' '}
which allows you to modify and interact with features and more within a
DevCycle project, as well as the{' '}
<a href="/bucketing-api/">DevCycle Bucketing API</a> which is used to serve
users features and variables (and powers the DevCycle SDKs!)
<a href="/bucketing-api/">DevCycle Bucketing API</a> which is used to
serve users features and variables (and powers the DevCycle SDKs!)
</p>
</div>
</details>
Expand Down Expand Up @@ -66,6 +66,13 @@ DevCycle APIs, as well as third party integrations to connect DevCycle to the to
label: 'Feature Flag Importer',
icon: 'logos:launchdarkly-icon',
},
{
type: 'link',
href: '/extras/webhooks',
description: 'Connect apps and services to DevCycle. ',
label: 'Webhooks',
icon: 'ph:webhooks-logo',
},
]}
/>

Expand Down

1 comment on commit 1e47420

@vercel
Copy link

@vercel vercel bot commented on 1e47420 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.