# Tasks

## Started Content

This should be called whenever a logged in user starts any content including Live, Episodes, Movies, VPPO Clips and ShowMS Clips.

- contentId - For VPPO content it should be passed the Partner API Id, for ShowMS Clips the ShowMS Id and for live either "US/Eastern" or "US/Western".
- isWatchingNonstop - This defaults to false and should be set to true when the user is starting a stream in Nonstop mode. The client app should know this from the result of the presentChoiceCard call. It does not need to be set for VPPO or ShowMS Clips.

###### Default code sample

`var startContentTask = { 'contentId': 'VDKA0_52i1bahk', 'task': 'start-content', 'isWatchingNonstop': false }; Nonstop.default.userPerformedTask(startContentTask);`

Start Content

## Watch 1 Minute of Content

Whenever the logged in user is watching any content this task should be called once per every minute of viewing.

- contentId - For VPPO content it should be passed the Partner API Id, for ShowMS Clips the ShowMS Id and for live either "US/Eastern" or "US/Western".

###### Default code sample

`var watch1MinuteContentTask = { 'contentId': 'VDKA0_52i1bahk', 'task': 'watch-1-minute-of-content', }; Nonstop.default.userPerformedTask(watch1MinuteContentTask);`

Watch 1 Minute of Content

## Connect MVPD Account

This should be called whenever a logged in user connects their MVPD Provider.

- mvpdName - MVPD name of the TV provider the user successfully connected. Note this should be the value obtained from the Adobe SDK for the provider Name, not the provider Id. For example, for Comcast it should be "Comcast Xfinity" not "Comcast_sso". The value should be camel cased.

###### Default code sample

`var connectMvpdTask = { 'mvpdName': 'Spectrum', 'task': 'connect-mvpd-account' }; Nonstop.default.userPerformedTask(connectMvpdTask);`

Connect MVPD Account

## User Performed Task

The correct task input and parameters is then passed to userPerformedTask as follows:

###### Default code sample

`Nonstop.default.userPerformedTask(task).then(function(success) { if(success) { // Task recorded successfully } else { // Error when recording task } });`

Notes on calling userPerformedTask:

- If there is no logged in user an error will be thrown
- Any issues with the validation of the task will be returned as an error - e.g. content doesn't exist
- If the user should be receive points for completing the task then the SDK will assign them automatically
- If the user should see a Reward Card for completing the task the SDK will show it and play it before returning success

Success and Error should only be used for logging, if required.

## Internal Tasks

Note: For some tasks the completion of them is tracked internally within the SDK based on either user interactions within SDK components or based on other SDK calls. These are:

- Complete TrueX - This will be recorded when a user completes a TrueX Ad correctly within the Nonstop Home.
- Enter Code - This will be recorded when a user enters a code within the Nonstop home.
- Sign Up - This is recorded in the background whenever the Login function is called.
- Complete Content - This will be recorded automatically any time presentReportCard is called.