I am looking to see what "user" written macros have been utilized in the last year to potentially delete user macros that were created but never utilized in confluence. Is there a way to do that?
We have a "Macro Stats" plugin that lists the usage for all the plugins...I am looking to see if a similar one exists for User Macros.
One thing you could do is do a search for the user macros to see how many pages they have been used in. This quite simple, see http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/ for information.
It's manual work, alas.
I wrote a macro to iterate over a space's pages and detect macro usage in each space. It works on Confluence 4.2.x. I have not tested it on 3.x or 5.x.
## Macro title: Macro Usage Report ## Developed by: Matthew J. Horn ## Date created: 11/12/13 ## This macro takes no parameters ## @noparams ## Get a list of User Macros #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($macroManager = $containerContext.getComponent('userMacroLibrary')) #set($macroMetadataManager = $containerContext.getComponent('macroMetadataManager')) #set($macroNames = $macroManager.getMacroNames()) ## Get the ExcerptHelper (probably not supposed to be used for getting all macros, but it works) #set($eHelper = $containerContext.getComponent('excerptHelper')) ## Get a list of pages in the space #set ( $targetSpace = $spaceManager.getSpace("admin") ) #set ( $allPagesInSpace = $pageManager.getPages($targetSpace, true) ) ## List all macro names <h3>Macro names</h3> <hr/> #foreach($name in $macroNames) $name, #end #set($isValid = false) ## Iterate over each page and check if each of the macros in macroNames is used on that page <h3>Macro Usage</h3> <hr/> <table> <tr><th>Macro</th><th>Description</th><th>Page (isValid) (parameters)</th></tr> #foreach ($name in $macroNames) <tr> <td>$macroMetadataManager.getMacroMetadataByName($name).getTitle().getKey() ($name)</td> <td>$macroMetadataManager.getMacroMetadataByName($name).getDescription().getKey()</td> <td> #foreach ($page in $allPagesInSpace) ## $page is of type Page #if ($eHelper.getMacroDefinition($page, $name)) <a href="$page.getUrlPath()">$page.getTitle()</a> ($eHelper.getMacroDefinition($page, $name).isValid()) ($eHelper.getMacroDefinition($page, $name).getParameters())<br/> #end #end </td> </tr> #end </table>
Hi Community friends, We're working on sourcing more reviews on Capterra – a popular software review site – to help teams like yours make more informed decisions when choosing an inc...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events