Integrating Yandex Tracker with Cloud Functions

Learn how to integrate Yandex Tracker with Cloud Functions to copy time spent entries from sub-issues to their parent issue.

When the trigger fires, the function adds the latest time spent entry from the sub-issue to its parent issue.

Example limitations

The function does not recalculate the total time spent across all sub-issues. Updates and deletions of existing entries are not synchronized. Invoking the function again for the same entry may add a duplicate to the parent issue.

To configure copying time spent entries:

  1. Register an OAuth application and get an access token.
  2. Get an organization ID to access the API.
  3. Create a Cloud Functions function.
  4. Set up a trigger.
  5. Test out automatic data updates.

Getting started

This scenario is intended for the external Yandex Tracker service with a Yandex 360 for Business organization. For Yandex Cloud organizations and the internal Tracker service, you will need to adapt the function code.

To run the scenario, you will need:

  • A Yandex Cloud account with a billing account and a role of at least organization-manager.admin.
  • A Yandex Tracker account with a Yandex 360 for Business organization.

Sign up for Yandex Cloud and create a billing account:

  1. Go to the management console and log in to Yandex Cloud or create an account if you do not have one yet.
  2. On the Billing page, make sure you have a billing account activated and its status is ACTIVE or TRIAL_ACTIVE. If you do not have a billing account, create one.

If you have an active billing account, you can create or select a folder on the cloud page to host your infrastructure.

Learn more about clouds and folders.

The infrastructure maintenance fee covers the cost of using this function (see Cloud Functions pricing).

If you no longer need the resources you created, delete them.

Register an OAuth application and get an access token

Register an OAuth application and get a token by following the Tracker API access instructions. Save the token. You will need it to create the function.

Get an organization ID to access the API

  1. Go to Tracker. Click Log in to Tracker.
  2. In the right-hand panel, click Administration.
  3. Under Access and payment, click Organizations.
  4. Under Yandex 360 for businesses, copy and save your organization ID. You'll need it to create a function.

Create a Cloud Functions function

  1. Go to the management console.
  2. In the top-left corner, click All services.
  3. Select Serverless computing → Cloud Functions.
  4. Click Create function.
  5. Enter a function name, e.g., timeupdater.
  6. Click Create.
  7. In the Editor window that opens, select Python / 3.12 runtime environment.
  8. Click Next.
  9. In the Method field, click ZIP archive.
  10. Attach a test archive.
  11. In the Entry point field, specify index.handler.
  12. Go to Parameters and in the Environment variables field, add:
    • ORG: Yandex 360 for Business organization ID
    • TOKEN: Application access token
  13. Click Save changes.
  14. Wait for the page to load. Next, in the Link to invoke field, copy and save the function invocation link.
    Here is an example of such a link:
    https://functions.yandexcloud.net/d4e94uav3108********
    
  15. Enable the Public function option.

Set up a trigger

Create a queue

  1. On the left panel, click Queues → Create queue.
  2. Select a queue template, e.g., Basic development model.
  3. Enter a name, e.g., Function Test.
  4. Click Create.

Create a trigger

  1. In the top-right corner of the queue page, click  Queue settings.

  2. On the left-hand panel, select Automation → Triggers and click Create trigger.

  3. In the Name field, enter a trigger name, e.g., timeupdater.

  4. Under Conditions, select Time Tracking → Time Spent and set the Field value changed comparison operation.

  5. Under Trigger actions, select HTTP request.

  6. In the form that opens, select the POST request method.

    The function in the test archive also supports the GET method.

  7. In the Address field, enter:

    https://functions.yandexcloud.net/<function_ID>?id={{issue.key}}
    

    Where https://functions.yandexcloud.net/<function_ID> is the function invocation link you saved when creating the function.
    Example:

    https://functions.yandexcloud.net/d4e94uav3108********?id={{issue.key}}
    
  8. Click Create.

Test out automatic data updates

Create issues

  1. Create a parent issue to receive time spent entries from its sub-issues:
    1. On the Function Test queue page, click Create issue.
    2. In the form that opens, in the Issue name field, enter an issue name, e.g., Parent Task.
    3. Click Create.
  2. Create sub-issues:
    1. In the top right corner of the Parent Task issue page, select Add sub-issue in the Actions menu.
    2. In the form that opens, in the Issue name field, enter a sub-issue name, e.g., Subtask-1.
    3. In the same way, create another sub-issue or multiple sub-issues named Subtask-2, Subtask-3, and so on.

Enter time spent values for the sub-issues

  1. Go to the Subtask-1 sub-issue page and select Add time spent from the Actions menu in the top right corner.
  2. In the window that opens, specify any time value in the Time Spent field. For example, you can enter 1h25m.
  3. In the same way, add time spent values for the other sub-issues.

Check if the function works correctly

  1. Go to the Parent Task issue page.
  2. In the issue properties, make sure that the Time Spent field under Time Tracking includes the time you specified in the sub-issue.

How to delete the resources you created

To stop paying for the resources you created, delete the Cloud Functions function.