This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bulk update activity privacy settings

I noticed that my activity privacy settings were set by default to be shown to members of groups I'm in. I don't know half the people in those groups so was uncomfortable with them knowing my activity and seeing my map data.

I updated my default privacy for new activities to something more secure but couldn't find a way to bulk update past activities. Disappointingly, this isn't a product feature but I have fed back to Garmin that this really should be. I managed to find a workaround to apply myself and wanted to share clear instructions here. I've stitched this together from a few other posts on these forums that provided the base solution - I just felt the instructions could be a bit clearer, a dummy's guide if you will. 

Please ask any questions if you have them and I'll do my best. Hope this actually helps someone!

Notes:

  • This worked at the time of writing on 26 Jan 2021
  • I had 542 activities to update and it was fine - there might be a limit at which this doesn't work though
  • I ran this on my Mac from Chrome but believe it should work fine on Mozilla Firefox and on a Windows machine (don't ask me about IE...)
  • This will update all your activities to the same privacy setting
  • The activities are worked through in the order they're displayed in the Garmin activities page
  • If you want to sort the order they are worked through in or filter the ones you update, this can be done by modifying line 2 of the script. I had no need to and haven't documented here how to do it - ask if you have this requirement and I can show you how
  • If your activities already have the privacy setting you're applying, they'll be fine

Preparation

I have prepared a script, which you can access here, but this requires a few updates. Copy the text into notepad or similar then make the edits below. 

Set an activity limit

You can control how many activities will be updated when you run this script. I used this to test the script and gain confidence it was working by setting the number to 2, then gradually increasing it towards 10 before I was comfortable I had a good script and ran it with a value of 1000. If you want to test this, please use this limit as you please. If you want to YOLO it, just set it to like 10000 and see what happens. 

To set the activity limit, replace the text [UPDATE LIMIT] with an integer, like 2, 10, or 1000. You need to remove the square brackets too. After updating, line 2 will look as follows, using 1000 as an example:

    '/modern/proxy/activitylist-service/activities/search/activities?limit=1000',

Set your privacy level

There are 4 privacy settings you can set your activities to. You will need to replace a bit of code depending on which you want to use. To do this, replace the text [UPDATE PRIVACY SETTING HERE] with one of the following

  • private for Only Me
  • subscribers for My Connections
  • groups for My Connections and Groups
  • public for Everyone

After updating, that line will look as follows, using subscribers as an example:

     'body': '{"accessControlRuleDTO":{"typeKey":"subscribers"},"activityId":' + act['activityId'] + '}',

Steps to update

  1. Go to the Garmin activities page (make sure you're logged in!)
  2. Open developer tools - you can do this as in the screenshot below or by pressing F12. Note that the tool may open in a different position on your screen. 



  3. Go to Sources
  4. Click on Snippets if you're not already on it
  5. Click New Snippet - give the snippet a name if you wish
  6. Copy and paste your updated code, with limit and privacy setting, into the box to the side
  7. Click the play button to run the script 

How will I know if it has worked?

During my testing, I gained confidence the activity settings were updating by:

  • opening a few activities
  • changing the privacy settings to something other than the value I set in the script
  • running the script
  • refreshing those activity pages
  • checking the privacy settings had updated to what was specified in the script

To know if all my activities were updated, I looked at something on the console. I set a limit of 1000 and saw that 542 activities had been updated. This meant I had run through all my activities. If the number you see here is the same as your limit, try increasing your limit until it is higher than the number of updates made. 

How does this work?

Essentially, we are:

  • calling an API on the Garmin page to return the activities 
  • using another API to update the privacy setting for the first activity returned
  • repeating this process for all activities in the list

Top Replies

All Replies

  • hmmm, chrome returns to me

    Uncaught ReferenceError: jQuery is not defined - https://ibb.co/Ydj76zG

  • Are you running this from the Garmin Connect activities page (https://connect.garmin.com/modern/activities)? You need to be on this and logged in first.

    It looks like you may still be on the Garmin forum, just based on the bit of colour I can see in the screenshot! 

  • Looks like a great tool, but unfortunaly I don't get it work. See below my code for testing first.

    jQuery.getJSON(
    '/modern/proxy/activitylist-service/activities/search/activities?limit=2',
    function(act_list)
    {
    console.log(act_list.length)
    act_list.forEach(
    function(act)
    {
    // Update privacy
    fetch('/proxy/activity-service/activity/' + act['activityId'],
    {
    'headers': { 'Content-Type': 'application/json', 'nk': 'NT', 'X-HTTP-Method-Override': 'PUT' },
    'body': '{"accessControlRuleDTO":{"typeKey":"My Connections and Groups"},"activityId":' + act['activityId'] + '}',
    'method': 'POST'
    });
    }
    );
    }
    );

    I'm getting the error below. What is going wrong and how can I solve it? Thanx for any help!

    POST connect.garmin.com/.../6378236185 400

    vendor.js?bust=4.40.1.0:1 POST connect.garmin.com/.../6378236185 400
    (anonymous) @ vendor.js?bust=4.40.1.0:1
    (anonymous) @ Script snippet %231:10
    (anonymous) @ Script snippet %231:6
    o @ backbone-lib.js?bust=4.40.1.0:1
    fireWith @ backbone-lib.js?bust=4.40.1.0:1
    S @ backbone-lib.js?bust=4.40.1.0:1
    t @ backbone-lib.js?bust=4.40.1.0:1
    XMLHttpRequest.send (async)
    (anonymous) @ vendor.js?bust=4.40.1.0:1
    (anonymous) @ vendor.js?bust=4.40.1.0:1
    send @ backbone-lib.js?bust=4.40.1.0:1
    ajax @ backbone-lib.js?bust=4.40.1.0:1
    A.<computed> @ backbone-lib.js?bust=4.40.1.0:1
    getJSON @ backbone-lib.js?bust=4.40.1.0:1
    (anonymous) @ Script snippet %231:1

  • Looks like the issue is with your value for typeKey. You have used My Connections and Groups but you need to use a value of groups for that privacy setting. Give that a go and let me know how you get on. 

  • Thanks for your reply! I've got it done :-)

  • I have tried using this to alter my settings for my activites. Code used is as follows;

    j

    jQuery.getJSON(

        '/modern/proxy/activitylist-service/activities/search/activities?limit=200’,

        function(act_list)

        {

            console.log(act_list.length)

            act_list.forEach(

            function(act)

                {

                    // Update privacy

                    fetch('/proxy/activity-service/activity/' + act['activityId'],

                    {

                        'headers': { 'Content-Type': 'application/json', 'nk': 'NT', 'X-HTTP-Method-Override': 'PUT' },

                        'body': '{"accessControlRuleDTO":{"typeKey”:”subscribers”},”activityId":' + act['activityId'] + '}',

                        'method': 'POST'

                    });

                }

            );

        }

    );

    I get the following error;

    Uncaught SyntaxError: Invalid or unexpected token

    Any help would be appreciated.

  • Does the script start with the earliest or the most recent activities, does anyone know?

  • getting the same issue, seems that line 2 of the script is the problem

  • The way this script will work, it will update the most recent activities first.

    If this didn't work for you, you could change the order by modifying the query in the line below to apply some sorting of the activities in a different order. This is not something I have figured out how to do since I wanted to update all my activities and it didn't matter to me in which order they were updated. 

    Query to udpate:

        '/modern/proxy/activitylist-service/activities/search/activities?limit=[UPDATE LIMIT]',
    
  • The only problem I can see with this is the j on the first line. This first line should not be j, it should be jQuery.getJSON(

    Another thought - are you on the Garmin Connect activities page and logged in before attempting this? 

    If that's not working and you share a screenshot, I might be able to help further.