Skip to main content
Inspiring
December 20, 2022
Answered

Is it possible to track how many times scripts have been activated in InDesign?

  • December 20, 2022
  • 4 replies
  • 1228 views

Dear all experts,


I have some scripts on the server, and I use CEP Extension to build the tool. Users will execute the scripts via the buttons on the extension. Is it possible to track how many times the scripts are activated/executed when the users click on the buttons?
I appreciate all your help.

This topic has been closed for replies.
Correct answer @AG

Hy @ShaneLe147 , we can do this by using a timestamp, and with the help of doScript we can create an excel and feed these time data inside that excel for each run.

4 replies

Community Expert
December 21, 2022

@m1b asked: "out of curiosity, is there even a way of listing all of an object's labels and values?"

 

Hi Mark,

yes, there is. As long as you can export an IDMS file from it:

 

List of all scripts labels
Loic.Aigon, Mar 10, 2017
https://community.adobe.com/t5/indesign-discussions/list-of-all-scripts-labels/m-p/8939286#M45716

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Community Expert
December 21, 2022

Just two or three side notes here:

 

[1] For a document you could exploit an exported IDML file.

[2] With the app object it's difficult. There are means to retrieve the key and value pairs by using the SDK.

[3] Once in InDesign CS5 and CS5.5 method extractLabel( ) without any arguments could retrieve all key/value strings. But this is gone. Even when you set back app.scriptPreferences.version to "7.0" or "7.5".

 

Regards,
Uwe Laubender
( Adobe Community Expert )

m1b
Community Expert
Community Expert
December 21, 2022

Thanks Uwe, that's good info.

Loic.Aigon
Legend
December 20, 2022

Given that you are talking of CEP, you could use localStorage

https://blog.logrocket.com/localstorage-javascript-complete-guide/

However that might not safe enough due to CEP inconsistencies (In Ai, localStorage is destroyed if the extension is uninstalled, it seems to persist with Ps, Not tested with Id)

It has been discussed here:

https://community.adobe.com/t5/exchange-discussions/how-to-use-cookies-for-cep-panel/td-p/10551769

Otherwise, you can try to take advantage of InDesign DOM and its app.insertLabel(key,value)

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html#d1e42253__d1e47367

Eventually, you could write down a log file somewhere but hardcore users could eventually find it.

The safest way might be to hit a web service onto your server to store user usage but they might be some GPDR concerns.

 

If I have to, I would use insertLabel with some cryptic key/value

 

FWIW

Loic

 

 

m1b
Community Expert
Community Expert
December 20, 2022

Thanks @Loic.Aigon, out of curiosity, is there even a way of listing all of an object's labels and values? If not, then your method could be extremely safe (aside from trashing preferences—the app's labels are stored in "Indesign Defaults" file).

- Mark

m1b
Community Expert
Community Expert
December 20, 2022

I think the easiest way would be just for the script to read from a text file (eg .json or .csv) the number of "runs" and then increment it, and update the text file. The script would do this every time it ran.

- Mark

Inspiring
December 21, 2022

Hi @m1b

It will extra time because we will add more scripts on the server day after day, so we have to edit the .json/.csv file every time we add a new one, and I'm not sure if the customer can do it by themself.

@AGCorrect answer
Inspiring
December 20, 2022

Hy @ShaneLe147 , we can do this by using a timestamp, and with the help of doScript we can create an excel and feed these time data inside that excel for each run.

Inspiring
December 21, 2022

Hi @@AG

I'm testing your solution but I will create a .json file instead of Excel. I hope it works 😛
I can’t thank you enough!

m1b
Community Expert
Community Expert
December 21, 2022

Sounds exciting! Please let us know what finally come up with. Even better, come back when you're finished and post some code for others to use.

- Mark