Seat installations by domain

59 views
Skip to first unread message

Andrew Apell

unread,
Feb 9, 2020, 12:46:34 PM2/9/20
to Google Apps Script Community
How does one go about determining how many people have their add-ons installed and enabled for each domain?
I have seen a few of the apps by some of our colleagues here and they seem to have a way of determining this; care to share?

Andrew Apell

unread,
Feb 10, 2020, 8:17:10 AM2/10/20
to Google Apps Script Community
Where are all the gurus today?

Faustino Rodriguez

unread,
Feb 10, 2020, 8:17:40 AM2/10/20
to Google Apps Script Community
The only way I know is when the user actually uses (enable) the add-on
- the you can get the source of installation and determine if it comes from a domain-install at GSM

ScriptApp.getInstallationSource()


The possible returned values are WEB_STORE_ADD_ON, APPS_MARKETPLACE_DOMAIN_ADD_ON

Andrew Apell

unread,
Feb 10, 2020, 8:30:36 AM2/10/20
to Google Apps Script Community
Thanks Faustino.
This method might work but for my idea to succeed, I need a way of finding out how many users have installed an enabled the addon.
I see the stat in the API console so it must be possible somehow.

Faustino Rodriguez

unread,
Feb 10, 2020, 9:18:28 AM2/10/20
to Google Apps Script Community
Using the the Api endpoint appsmarket/v2/licenseNotification you can get the list of installed domains
- I have tried that endpoint but unsuccessfully so far, have you succeed with that Api call?
- but that list won't include the number of users in those domains (that I guess would be a privacy issue if we could)
- I strongly believe that when there is a domain install, all the users count goes to "Domain installs" (I have seen those numbers in the console)
... even if the actual users have not used the add-on yet

When looking at the GCP GSM SDK Usage Dashboard page, three (3) sections: 
- Domain installs: Number of customer domains which have your app installed
- Seat installs: Number of users who have the app installed and enabled
- Individual end user installs: Number of users who have directly installed your app (not installed by their admin)

I guess, 
- the "Seat installs" corresponds to the number of users in the "Domain installs", so seats installed through domain installs, by the admin
- and by contrast, "Individual end user installs" would include individual installs and those migrated from the Chrome Web Store (CWS)

Andrew Apell

unread,
Feb 10, 2020, 9:38:03 AM2/10/20
to Google Apps Script Community
No, I have no tried that API before for precisely the reason you have highlighted i.e. the data it returns does not get me what I want to see.
That makes me curious now: How are the developers here segmenting Enterprise licenses by number of users? (Is it a scalpel or machete approach?)

Andrew Apell

unread,
Feb 10, 2020, 11:58:23 AM2/10/20
to Google Apps Script Community

John McGowan

unread,
Feb 11, 2020, 5:07:39 AM2/11/20
to Google Apps Script Community
Hi Andrew! Don't think of myself as a guru and not really answering your question but I license through firebase. I call the license on first interaction in the Add-on and store that in userprpoerties for that session.
I license by domain with am unlimited number of seats.
I also keep a reference to the user in the domain under that with a license value.
You could put a child in that domain stem to count installed seats then return a license value of over subscribed to restrict what features to give that user and to prompt them to buy more seats...
Not sure if that makes sense but that is one way to track users per domain.

Andrew Apell

unread,
Feb 11, 2020, 7:55:07 AM2/11/20
to Google Apps Script Community
Thanks for the input John.
How do you generate each license?

John McGowan

unread,
Feb 11, 2020, 12:10:51 PM2/11/20
to google-apps-sc...@googlegroups.com
Hi Andrew,
I use Firebase and just store the license based on their logged in email: Session.getEffectiveUser().getEmail();
Then I store a salted and hashed version of that in Firebase. 
I use Romain's library: MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l
Then here is my calls to store:
 var firebaseUrl = "https://<<yourProject>>.firebaseio.com";
  var secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";  

I do some calls here to hash+salt email for security and make them Firebase safe using encodeAsFirebaseKey which return newDomain and newUser

  //now send the info we want to Firebase
  //use Romain's library to update data. We can update even if the path does not exist yet
  var database = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
 var addPremiumToUser = database.updateData("users/"+newDomain+"/"+newUser,{"license":"true"});

Also need to make sure to make the email address Firebase ready. I use a function from Romain's Github:
/**
 * Thanks to Romain Vialard: https://github.com/RomainVialard/FirebaseApp/blob/master/src/Code.gs#L60
 * Returns a valid Firebase key from a given string
 * Firebase Keys can't contain any of the following characters: . $ # [ ] /
 * https://firebase.google.com/docs/database/usage/limits#data_tree
 * https://groups.google.com/forum/#!msg/firebase-talk/vtX8lfxxShk/skzA5vQFdosJ
 *
 * @param  {string} string - the string to encode
 *
 * @return {string} the encoded string
 */
function encodeAsFirebaseKey(string) {
  return string.replace(/\%/g, '%25')
    .replace(/\./g, '%2E')
    .replace(/\#/g, '%23')
    .replace(/\$/g, '%24')
    .replace(/\//g, '%2F')
    .replace(/\[/g, '%5B')
    .replace(/\]/g, '%5D');
}


Hope that helps!

I also hook in payment through Stripe elements and initially store the license on Firebase after that all through server side Apps Script.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/ABMFNKPWFFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6958ef4e-1267-4ec5-a368-05ebe2a30ff4%40googlegroups.com.

Andrew Roberts

unread,
Feb 12, 2020, 2:50:34 AM2/12/20
to google-apps-sc...@googlegroups.com
John, is your Add-on Public, and if so did you have to have a security assessment because you are using UrlFetch to access Firebase? Or do you deploy the Add-on privately to each domain?

You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CACWjEmfBGsnxsuOFabX4Z8u1aM9Qjoed-AtYkGZ-kF2vHU9uSA%40mail.gmail.com.

John McGowan

unread,
Feb 12, 2020, 3:08:04 AM2/12/20
to google-apps-sc...@googlegroups.com
My Add-ons are public. I did not have to do the Security Assessment since I don't use any of the restricted scopes, only sensitive scopes, so those get assessed in the Oauth verification process (which still is not fun). It is the necessary pain of publishing publicly as you do have to keep scope usage in mind. 

Reply all
Reply to author
Forward
0 new messages