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

  • , I've just replied to LP4K3 with some thoughts and questions. Would be useful if you could check those out and respond to the same ones too :) 

  • Thanks, I ended up using another script from elsewhere on this forum, which seemed to work (I don't remember which one now). 

  • Glad it worked for you. It's odd because I've just tested this myself and it works absolutely fine but hopefully I can figure out the issue if someone else raises it again - maybe something is not clear in the guide. 

  • Superb! Many thanks for your clear guide on this.

  • I would love to use this but I am stuck at "3. Go to Sources" as I cannot find it.

    I am using Firefox 90.0.2 on Linux and I am logged into Garmin!

    Anything on the config I need to change before sources and snippets  will be available?

  • I'm not sure about Firefox sorry as I don't use it but I've done a quick Google and these might be helpful if you aren't able to use Chrome:

    • Scratchpad - this looks like the easiest
    • This article covers off someone asking this specific question but I can't immediately see how you'd use the answer
    • Possibly this extension called Greasemonkey

    Good luck - let me know how you get on. 

  • Hi ,

    thanks for sharing, I had a completely different need (change the privacy to export data) that forced me to make a slightly different version to filter activities by type, I post it here, maybe someone without any coding experience could find it useful.

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

    Best,

    R

  • Thanks for providing this change for doing it based on activity type, !! Slight smile

    To help with this, I've included a table below of the activity type values. It's also possible to further filter on activity sub-type and I'd be glad to show how this was done if anyone had that need. 

    Activity [ACTIVITY TYPE]
    Cycling cycling
    Running running
    Swimming swimming
    Multisport multi_sport
    Gym & fitness equipment 

    fitness_equipment

    Walking

    walking

    Winter sports

    winter_sports

    Other

    other

    Another way to achieve this would also be to adjust the first query so you only return activities of a particular type saving the need to loop through them. I don't think it matters as your way works but perhaps if there are many (1,000s) of activities there could be limits. 

    If anyone wanted to try this, you can edit this line:

    '/modern/proxy/activitylist-service/activities/search/activities?limit=[LIMIT]'

    to become:

    '/modern/proxy/activitylist-service/activities/search/activities?limit=[LIMIT]&activityType=[ACTIVITY TYPE]'

    where you use the same values in the table above. 

  • Thank you , I've just done it and it worked first try! Using Chrome on Mac in my case.

  • Glad it's worked for you and to see that this is still helping people a couple of years on.