djug
djug

Reputation: 550

is Asana API sending too many events?

I’m working on a new app using asana API,

after I create a webhook on a project, I’d receive too many events for even the simplest tasks

lets take a look at an example: I have a project, with a webhook receiving all updates that occur on it.

I created a new task on this project and I received, not one, not two but 11 events.

{
    "events": [
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:15.327Z",
            "parent": null
        },
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:15.547Z",
            "parent": null
        },
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:19.814Z",
            "parent": null
        },
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:19.928Z",
            "parent": null
        },
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:20.080Z",
            "parent": null
        },
        {
            "resource": 208671118519207,
            "user": 50164104471653,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:32:20.178Z",
            "parent": null
        },
        {
            "resource": 208671118519208,
            "user": 50164104471653,
            "type": "story",
            "action": "removed",
            "created_at": "2016-11-08T07:32:15.153Z",
            "parent": 208671118519207
        },
        {
            "resource": 208720288746880,
            "user": 50164104471653,
            "type": "story",
            "action": "added",
            "created_at": "2016-11-08T07:32:15.332Z",
            "parent": 208671118519207
        }
    ]
}

and after a moment, I received this:

{
    "events": [
        {
            "resource": 116224991348154,
            "user": 50164104471653,
            "type": "project",
            "action": "changed",
            "created_at": "2016-11-08T07:32:20.556Z",
            "parent": null
        },
        {
            "resource": 208671118519211,
            "user": 50164104471653,
            "type": "task",
            "action": "added",
            "created_at": "2016-11-08T07:32:20.520Z",
            "parent": 116224991348154
        },
        {
            "resource": 208671118519212,
            "user": 50164104471653,
            "type": "story",
            "action": "added",
            "created_at": "2016-11-08T07:32:20.550Z",
            "parent": 208671118519211
        }
    ]
}

I understand that the event bubble up and an event in a task will trigger an event in the parent project too, I understand also that each event generates a “story” event too, but what I don’t understand is why we have too many “task changed” event?

Is it a bug or a feature? or am I doing it wrong?

And if I want to get just a single event for each task change, what should I do ?

Another problem. Sometime I receive events on tasks without any user ID like this one:

{
    "events": [
        {
            "resource": 207890837706528,
            "user": null,
            "type": "task",
            "action": "changed",
            "created_at": "2016-11-08T07:16:19.270Z",
            "parent": null
        }
    ]
}

what does it mean to have an event without a user id ?

Thanks

Upvotes: 0

Views: 160

Answers (1)

agnoster
agnoster

Reputation: 3784

Asana dev here. You're correct that we're sending too many events - we're a little overzealous there. Some of it is due to the factors you already recognized - event bubbling, stories that get added to the task, etc. However, I wouldn't expect to see that many "task-changed" events... are you creating it in the UI? If you're typing the name/notes it could certainly be sending events, not for each keystroke, but every few seconds perhaps? We haven't found a solution we're happy with for coalescing change events, as the Asana app is reactive - it sends updates continuously as you type, and each of those appears as an "edit" event.

As for events with no user, that occurs when something happens on the system - for example, if a task gets duplicated by automatically recurring.

We have no current plans to make changes to this - in the longer term, we may add new types of events. Right now it's basically just a firehose of each time the model changes in any way, plus add/remove events.

Upvotes: 3

Related Questions