I want to get usage stats of confluence plugin/Macro.
So is there any to get this? with user macro or any plugin is available?
Community moderators have prevented the ability to post new answers.
Not sure what you are looking for, but if you just want macro counts then I have written a user macro to do this. This requires at least Confluence 5.5.
Macro Body Processing:
No macro body
Template:
## Developed by: Davin Studer ## Date created: 12/17/2014 ## @param Space:title=Space|type=spacekey|desc=This will restrict the macro usage report to a specific space. #set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager = $getInstanceMethod.invoke(null,null)) #set($containerContext = $containerManager.containerContext) #set($macroBrowserManager = $containerContext.getComponent('macroBrowserManager')) #set($allMacros = $macroBrowserManager.getMacroSummaries()) ######################################################################################### ## This is used for getting around velocity issues when writing jQuery. ## ######################################################################################### #set( $d = '$' ) ######################################################################################### ## Populate the macro information into a string that we will use as a JS object array. ## ######################################################################################### #set ($i = 0) #set($macroObjects = "") #foreach($macro in $allMacros) #if($i != 0) #set($macroObjects = $macroObjects + ",") #end #set($macroObjects = $macroObjects + "{title:'" + $macro.getTitle().getKey().replace("'","\'") + "', name:'" + $macro.getMacroName().replace("'","\'") + "'}") #set ($i = $i + 1) #end ######################################################################################### ## Decide which space to search. ## ######################################################################################### #if ($!paramSpace && $!paramSpace != "") #set ($searchSpace = $!paramSpace) #else #set ($searchSpace = "conf_all") #end <script type="text/javascript"> var queue = { macros: [$macroObjects], current: 0, start: function () { this.macros.sort(compare); this.current = 0; this.next(); }, next: function () { if (this.current >= this.macros.length) { AJS.$('#queryStatus span').removeClass('aui-lozenge-current'); AJS.$('#queryStatus span').addClass('aui-lozenge-success'); AJS.$('#queryStatus span').text('Report Complete'); AJS.tablessortable.setTableSortable(AJS.$('#macroUsageReport table')); return null; } else { this.current += 1; lookupMacro(this.macros[this.current - 1]); } } }; function lookupMacro(macro) { var html = ''; var searchURL = ''; AJS.$('#queryStatus span').text('Getting counts for macro: ' + macro.title); searchURL = AJS.params.baseUrl + '/rest/searchv3/1.0/search?where=${searchSpace}&spaceSearch=true&queryString=macroName:' + encodeURIComponent(macro.name); AJS.${d}.ajax( { type: 'GET', url: searchURL, dataType: "json", timeout:60000, success: function(data) { if(data.total > 0) { var spaces = ''; for(var i = 0; i < data.results.length; i++) { if(spaces.indexOf(data.results[i].searchResultContainer.name) == -1) { spaces = spaces == '' ? '' : spaces + ', '; spaces = spaces + data.results[i].searchResultContainer.name; } } html = '<tr>'; html += ' <td class="confluenceTd">' + macro.title + '</td>'; html += ' <td class="confluenceTd">' + macro.name + '</td>'; html += ' <td class="confluenceTd">' + data.total + '</td>'; html += ' <td class="confluenceTd">' + spaces + '</td>'; html += ' <td class="confluenceTd"><a href="' + AJS.params.baseUrl + '/dosearchsite.action?where=conf_all&spaceSearch=true&queryString=macroName:' + encodeURIComponent(macro.name) + '" target="_blank">macro usage</a></td>'; html += '</tr>'; } AJS.$('#macroUsageReport table tbody').append(html); queue.next(); }, error: function (x, y, z) { AJS.$('#queryStatus span').removeClass('aui-lozenge-current'); AJS.$('#queryStatus span').addClass('aui-lozenge-error'); AJS.$('#queryStatus span').text('Error getting counts for macro:' + macro.title); } } ); } function compare(a, b) { if (a.title < b.title) { return -1; } if (a.title > b.title) { return 1; } return 0; } AJS.toInit(function(){ queue.start(); }); </script> <div id="queryStatus"> <span class="status-macro aui-lozenge aui-lozenge-current"></span> </div> <div id="macroUsageReport"> <table class="confluenceTable"> <thead> <tr> <th>Macro Title</th> <th>Macro Name</th> <th>Times Used</th> <th>Spaces Used In</th> <th>Pages Used On</th> </tr> </thead> <tbody> </tbody> </table> </div>
Thanks Davin :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great Macro!
Thanks for sharing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest adding $macro.getPluginKey() as 3rd column, so one can see, which plugin the macro comes from.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I considered adding it when I made the user macro, but the $macro.getPluginKey is normally already in the $macro.getMacroName() as well. So, it didn't seem to add much for me. If you would like that column as well then you would just need to change three lines.
Change line 23 from
#set($macroObjects = $macroObjects + "{title:'" + $macro.getTitle().getKey().replace("'","\'") + "', name:'" + $macro.getMacroName().replace("'","\'") + "'}")
to
#set($macroObjects = $macroObjects + "{title:'" + $macro.getTitle().getKey().replace("'","\'") + "', name:'" + $macro.getMacroName().replace("'","\'") + "', plugin:'" + $macro.getPluginKey().replace("'","\'") + "'}")
Change header block from (Lines 119-127)
<thead> <tr> <th>Macro Title</th> <th>Macro Name</th> <th>Times Used</th> <th>Spaces Used In</th> <th>Pages Used On</th> </tr> </thead>
to (just adding the Add-on header)
<thead> <tr> <th>Macro Title</th> <th>Macro Name</th> <th>Add-on</th> <th>Times Used</th> <th>Spaces Used In</th> <th>Pages Used On</th> </tr> </thead>
Change table body html from (Lines 81-87)
html = '<tr>'; html += ' <td class="confluenceTd">' + macro.title + '</td>'; html += ' <td class="confluenceTd">' + macro.name + '</td>'; html += ' <td class="confluenceTd">' + data.total + '</td>'; html += ' <td class="confluenceTd">' + spaces + '</td>'; html += ' <td class="confluenceTd"><a href="' + AJS.params.baseUrl + '/dosearchsite.action?where=conf_all&spaceSearch=true&queryString=macroName:' + encodeURIComponent(macro.name) + '" target="_blank">macro usage</a></td>'; html += '</tr>';
to (Adding the macro.plugin column)
html = '<tr>'; html += ' <td class="confluenceTd">' + macro.title + '</td>'; html += ' <td class="confluenceTd">' + macro.name + '</td>'; html += ' <td class="confluenceTd">' + macro.plugin + '</td>'; html += ' <td class="confluenceTd">' + data.total + '</td>'; html += ' <td class="confluenceTd">' + spaces + '</td>'; html += ' <td class="confluenceTd"><a href="' + AJS.params.baseUrl + '/dosearchsite.action?where=conf_all&spaceSearch=true&queryString=macroName:' + encodeURIComponent(macro.name) + '" target="_blank">macro usage</a></td>'; html += '</tr>';
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
👍
Having a dedicated column for the plugin name makes filtering in Excel much easier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Davin Studer for this useful macro.
However, I get this error message:
Error getting counts for macro:com.adaptavist.confluence.contentFormattingMacros.iframe.label
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't do this. Add-ons add all sorts of functions to Confluence and counting where one type is "used" is a totally different method to counting how another one might be used. If you have one that adds a macro, yes, you can count where the macro is used, but what about an add-on that provides a blueprint? There's nothing even stored you could count.
You'll need to define the question for each type of add-on you want to count usage of.
Macros are about the only thing you can take an easy swipe at - use CQL to search for "macro". You'll need to start with a list of macros you want to search for though.
There are also a couple of add-ons which can help with macros - https://marketplace.atlassian.com/plugins/de.kupper.it.atlassian.confluence.macro.usage is the one I've used which seems to do the job.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for mentioning this macro. Even if this is paid, its free trial period allows to perform an audit from time to time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Nic,
Could you aadvice if it’s possible to get stats on who uses the below JIRA plug-ins and the frequency of use:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please re-read. My answer already answers that question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Edit: Misread the question
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.