-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathingest-sample-data.ts
30 lines (29 loc) · 1.27 KB
/
ingest-sample-data.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
import { createRandomBizEvents } from '../src/app/data_import/functions/generate-sample-data';
/**
* For the purpose of getting you up and running fast, the application contains
* an option to simply generate a couple of fake github action runs on the fly.
*
* We will then import the data into your Grail database as business events. The rest of this application then reads
* this data from Grail to visualize some interesting insights.
*
* Once you are ready to dig a bit deeper, we recommend that you set up a workflow that imports data from an actual
* GitHub repository.
*
* You can use our GitHub Ingester Action (TODO: link to ingester) to do this.
*
* Documentation on workflows: https://developer.dynatrace.com/category/workflows .
*/
export default async (eventType: string) => {
const response = await fetch('/platform/classic/environment-api/v2/bizevents/ingest', {
method: 'POST',
headers: { 'Content-Type': 'application/cloudevent-batch+json' },
body: JSON.stringify(createRandomBizEvents({ eventType, maxRunsPerDay: 50, numberOfDays: 30 })),
});
if (response.ok) {
return 'OK';
} else {
throw Error(
'An error occured when trying to ingest sample data. The API responded with status code [${response.status}] ',
);
}
};