Skip to content

Commit

Permalink
feat: Added support for stream type admin_logs_streaming (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
antusus authored Jun 17, 2022
1 parent 6d79271 commit 7596157
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build-main
on:
pull_request_target:
pull_request:
types: [opened, synchronize]
branches:
- main
Expand Down
4 changes: 2 additions & 2 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"html"
],
"check-coverage": true,
"lines": 89,
"statements": 89,
"lines": 85,
"statements": 85,
"functions": 85,
"branches": 77,
"report-dir": "./coverage"
Expand Down
22 changes: 19 additions & 3 deletions src/commands/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EventsGetCommand extends BoxCommand {
let options = {};

if (flags.enterprise) {
options.stream_type = 'admin_logs';
options.stream_type = flags['stream-type'] || 'admin_logs';
}
if (flags.limit) {
options.limit = flags.limit;
Expand Down Expand Up @@ -49,8 +49,8 @@ class EventsGetCommand extends BoxCommand {
}

let events = await this.client.events.get(options);

if (options.stream_position || options.stream_type !== 'admin_logs') {
const isNotAdminTypeStream = options.stream_type !== 'admin_logs' && options.stream_type !== 'admin_logs_streaming';
if (options.stream_position || isNotAdminTypeStream) {
await this.output(events);
} else {
let allEvents = [].concat(events.entries); // Copy the first page of events
Expand Down Expand Up @@ -110,6 +110,22 @@ EventsGetCommand.flags = {
limit: flags.integer({
description: 'The maximum number of items to return',
}),
'stream-type': flags.string(
{
description: 'Stream type admin_logs or admin_logs_streaming.\n' +
'Unless specified `admin_logs` stream type is used.\n\n' +
'The emphasis for `admin_logs` stream is on completeness over latency, which means that Box will ' +
'deliver admin events in chronological order and without duplicates, but with higher latency. ' +
'You can specify start and end time/dates.\n\n' +
'The emphasis for `admin_logs_streaming` feed is on low latency rather than chronological accuracy, ' +
'which means that Box may return events more than once and out of chronological order. Events are ' +
'returned via the API around 12 seconds after they are processed by Box (the 12 seconds buffer ' +
'ensures that new events are not written after your cursor position). Only two weeks of events are ' +
'available via this feed, and you cannot set start and end time/dates.',
dependsOn: ['enterprise'],
options: ['admin_logs', 'admin_logs_streaming']
}
)
};


Expand Down
Loading

0 comments on commit 7596157

Please sign in to comment.