-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCreateEvent.ts
61 lines (57 loc) · 1.68 KB
/
CreateEvent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Post an event returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration();
const apiInstance = new v2.EventsApi(configuration);
const params: v2.EventsApiCreateEventRequest = {
body: {
data: {
attributes: {
attributes: {
author: {
name: "[email protected]",
type: "user",
},
changeMetadata: {
dd: "{'team': 'datadog_team', 'user_email': '[email protected]', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}",
resource_link: "datadog.com/feature/fallback_payments_test",
},
changedResource: {
name: "fallback_payments_test",
type: "feature_flag",
},
impactedResources: [
{
name: "payments_api",
type: "service",
},
],
newValue: {
enabled: "True",
percentage: "50%",
rule: "{'datacenter': 'devcycle.us1.prod'}",
},
prevValue: {
enabled: "True",
percentage: "10%",
rule: "{'datacenter': 'devcycle.us1.prod'}",
},
},
category: "change",
message: "payment_processed feature flag has been enabled",
tags: ["env:test"],
title: "payment_processed feature flag updated",
},
type: "event",
},
},
};
apiInstance
.createEvent(params)
.then((data: v2.EventCreateResponsePayload) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));