Call to homepageTrigger even when I'm in context - google-apps-script

I have this in my manifest:
"addOns": {
"common": {
"homepageTrigger": {
"runFunction": "handleHomePageStart",
"enabled": true
},
"name": "MyApp",
"openLinkUrlPrefixes": [
"https://www.myApp.com/",
],
"useLocaleFromApp": true
},
"gmail": {
"contextualTriggers": [
{
"unconditional": {},
"onTriggerFunction": "handleStart"
}
],
"composeTrigger": {
"selectActions": [
{
"text": "compose method",
"runFunction": "handleStartCompose"
}
],
"draftAccess": "METADATA"
}
},
...
When I'm out of context, the homepage is displayed and I see in the executions a call for that method(handleHomePageStart). However, when I click on an email, both the homePage and context triggers are fired, as I can see both handleHomePageStart and handleStart executions in the list. Is this by design or my app has some flaw on it?
Thanks in advance!

Related

What is this called in google workspace add-ins?

I would like to add custom actions on this menu in my project. But cannot find any documentation on how this is accessible.
You are looking for Universal actions
Those are being specified in the Addon manifest
The Universal actions contain labels (the menu entries you see in the three-dot menu) and are tied to either an openLink or runFunction action - depending on your intention
Sample manifest from the documentation:
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata"
],
"addOns": {
"common": {
"name": "Universal Actions Only Addon",
"logoUrl": "https://www.example.com/hosted/images/2x/my-icon.png",
"openLinkUrlPrefixes": [
"https://www.google.com",
"https://www.example.com/urlbase"
],
"universalActions": [{
"label": "Open google.com",
"openLink": "https://www.google.com"
}, {
"label": "Open contact URL",
"runFunction": "openContactURL"
}, {
"label": "Open settings",
"runFunction": "createSettingsResponse"
}, {
"label": "Run background sync",
"runFunction": "runBackgroundSync"
}],
...
},
"gmail": {
"contextualTriggers": [
{
"unconditional": {},
"onTriggerFunction": "getContextualAddOn"
}
]
},
...
},
...

Problems setting up debugging in Visual Studio code for Chrome, have it working for Firefox

I have the following in .vscode/launch.json :
{
"version": "0.2.0",
"configurations": [
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "vuejs: firefox",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"firefoxExecutable": "C:/Users/Geoffrey Swenson/AppData/Local/Mozilla Firefox/firefox.exe",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
},
"preLaunchTask": "serve"
},
{
"type": "chrome",
"request": "launch",
"reAttach": true,
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
},
"preLaunchTask": "serve"
}]
}
I have the following in .vscode/tasks.json :
{
"version": "2.0.0",
"tasks": [
{
"label": "start",
"type": "npm",
"script": "serve",
"isBackground": true
},
{
"label": "serve",
"type": "npm",
"script": "serve",
"isBackground": true,
"problemMatcher": [{
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "Starting development server",
"endsPattern": "Compiled successfully"
}
}],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
I also have vue.config.ts :
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
Breakpoints work in Firefox, though I have to press F5 the first time I load it. They never work in Chrome. Firefox involves installing a debugger extension, but there is supposedly no need for this for Chrome.
first you need to set launch.json and then set your config file as you need:
hereafter an example which works with vite running as bundler in front and server in back
{
"debug": {
"javascript": {
"terminalOptions": {
"skipFiles": [
"<node_internals>/**"
],
"trace": true
}
}
},
"configurations": [
{
"name": "Run bundler",
"request": "launch",
"type": "node-terminal",
"command": "npm run <your-command-to-run-app>",
"cwd": "${workspaceFolder}"
}
]
}
Then forget webpack and use vite, thus you need to install vite and a vite config file
import { defineConfig } from 'vite';
import vue from '#vitejs/plugin-vue';
// cf. https://vitejs.dev/config/
export default defineConfig(async ({ command, mode }) => {
return {
plugins: [vue()],
server: {
proxy: {
'/api/': {
target: 'http://localhost:3080',
changeOrigin: true,
secure: false
}
},
port: 3080,
strictPort: true
},
build: {
outDir: './server/public'
}
};
});
I use typescript and in my ts.config.json, I setted
...
"sourceMap": true,
"types": ["vite/server"],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
...
hope that's will help folk's !

What is wrong with this code for visual studio code highlighting?

I'm new in visual studio code language creation, and I tried to make my own syntax highlighting for my custom language using yo code. In my tmLanguge.json file, I got this code, but I don't work and it doesn't highlight anything at all. Can someone please tell me what the problem is?
When I tried it only with the "comments" object, it worked well...
Thanks
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "OP-RANDS++",
"patterns": [
{
"include": "#comments"
},
{
"include": "#numbers"
},
{
"include": "#blocks"
},
{
"include": "#basecalls"
},
{
"include": "#outin"
},
{
"include": "#defines"
},
{
"include": "#maths"
},
{
"include": "#others"
}
],
"repository": {
"comments": {
"patterns": [
{
"name":"comment",
"match": "^\u005c?.*"
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric",
"match": "\u005cd|\u005c\u005c\u005cd"
}
]
},
"blocks": {
"patterns": [
{
"name": "emphasis",
"match": "{|}|[|]|(|)"
}
]
},
"basecalls": {
"patterns": [
{
"name": "keyword.control",
"match": "\u005c.|\u005c|"
}
]
},
"outin": {
"patterns": [
{
"name": "entity.name.function",
"match": ";|,"
}
]
},
"defines": {
"patterns": [
{
"name": "variable.name",
"match": "~|`|^"
}
]
},
"maths": {
"patterns": [
{
"name": "keyword.operator",
"match": "+|-|*|/|%"
}
]
},
"others": {
"patterns": [
{
"name": "keyword.other",
"match": "'|$"
}
]
}
},
"scopeName": "source.opp"
}

Ammending Google Managed Preferences via the master_preferences JSON file

I am trying to set up an environment where the first time a user logs into chrome they have a list of pre-determined bookmarks and extensions installed. I have followed Chromiums guide to this as much as possible however seem to be failing when it comes to the granted_permissions section, in an ideal world the user would open Chrome and not be prompted with "This extension requires new permissions". From what i can gather this is through the granted_permissions entry however these do not appear to be parsing through to chrome, ive included a snapshot of the code below:
{
"homepage": "MY_URL",
"homepage_is_newtabpage": false,
"extensions": {
"settings": {
"hdokiejnpimakedhajhdlcegeplioahd": {
"location": 1,
"manifest": {
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiL9y2jziKp5kjb13uYG1bAXsuemUKAYUAwR/N9qTuhMIuly02Ecm63dOkn+M2r26IGfDE/lbPv/dB/W+d34pqGo5uJJY+Omt9t3xsIuz7mQwuvF1H5ozj0OHok5XDFRaBIfPa06RhQw3M7sSZJvQ+qqD3+dr0aLX+mvi0LQ11uQIDAQAB",
"name": "LastPass",
"update_url": "http://clients2.google.com/service/update2/crx",
"granted_permissions": {
"api": [ "contextMenus", "idle", "notifications", "tabs", "unlimitedStorage", "webRequest", "webRequestBlocking" ],
"explicit_host": [ "http://*/*", "https://*/*" ],
"scriptable_host": [ "file:///*", "http://*/*", "https://*/*", "https://1min-ui-prod.service.lastpass.com/*" ]
},
"version": "0.0"
},
"path": "hdokiejnpimakedhajhdlcegeplioahd\\0.0",
"state": 1
},
"cjpalhdlnbpafiamejdnhcphjbkeiagm": {
"location": 1,
"manifest": {
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmJNzUNVjS6Q1qe0NRqpmfX/oSJdgauSZNdfeb5RV1Hji21vX0TivpP5gq0fadwmvmVCtUpOaNUopgejiUFm/iKHPs0o3x7hyKk/eX0t2QT3OZGdXkPiYpTEC0f0p86SQaLoA2eHaOG4uCGi7sxLJmAXc6IsxGKVklh7cCoLUgWEMnj8ZNG2Y8UKG3gBdrpES5hk7QyFDMraO79NmSlWRNgoJHX6XRoY66oYThFQad8KL8q3pf3Oe8uBLKywohU0ZrDPViWHIszXoE9HEvPTFAbHZ1umINni4W/YVs+fhqHtzRJcaKJtsTaYy+cholu5mAYeTZqtHf6bcwJ8t9i2afwIDAQAB",
"name": "uBlock Origin",
"update_url": "http://clients2.google.com/service/update2/crx",
"version": "0.0"
},
"path": "cjpalhdlnbpafiamejdnhcphjbkeiagm\\0.0",
"state": 1
}
}
},
"session": {
"restore_on_startup": 1,
"startup_urls": [
"MY_URL/"
]
},
"browser": {
"show_home_button": true,
"check_default_browser": false
},
"bookmark_bar": {
"show_on_all_tabs": true
},
"distribution": {
"show_welcome_page": false,
"skip_first_run_ui": true,
"import_history": false,
"import_bookmarks_from_file": "/Library/Google/bookmarks.html",
"import_bookmarks": false,
"import_home_page": false,
"import_search_engine": false
},
"sync_promo": {
"user_skipped": true
}
}
After opening chrome even with those permissions in place it still disables the extensions pending further permissions however im not really sure what else its after.
Wrong structure. If you look at the docs, it should be as follows:
{
"extensions": {
"settings": {
"mihcahmgecmbnbcchbopgniflfhgnkff": {
"location": 1,
"manifest": {
...
},
"granted_permissions": {
"api": [ "tabs" ],
"explicit_host": [ "http://*.google.com/*", "https://*.google.com/" ],
"scriptable_host": [ "http://example.com/" ]
},
...
},
...
}
}
}
However, you have put the "granted_permissions" key inside, and not on the same level as the "manifest" key.

ReferenceError: ConferenceDataService is not defined for G Suite Calendar conferencing add-on

I am trying to play with the example at https://developers.google.com/gsuite/add-ons/calendar/calendar-actions#setting_conference_data_with_a_callback_function, and I am getting an error accessing some of the APIs.
Specifically, when I try to access the ConferenceDataService I get the error below.
ReferenceError: ConferenceDataService is not defined
I suspect there is a missing piece in the documentation for the G Suite Calendar conferencing add-ons.
There is also no information in the documentation about the "conferenceSolution" property in the manifest, which seems to be necessary in order to show up in the "Add Conferencing" drop down for a Google Calendar event.
Here is the manifest
{
"timeZone": "America/Mexico_City",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/calendar.addons.execute",
"https://www.googleapis.com/auth/calendar.addons.current.event.read",
"https://www.googleapis.com/auth/calendar.addons.current.event.write",
"https://www.googleapis.com/auth/calendar.readonly",
"https://www.googleapis.com/auth/calendar.events.readonly",
"https://www.googleapis.com/auth/calendar.settings.readonly",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/script.locale",
"https://www.googleapis.com/auth/userinfo.email"],
"urlFetchWhitelist": ["https://companyxyz.com/"],
"addOns": {
"common": {
"name": "companyxyz Test",
"logoUrl": "https://companyxyz.com/logo32.png",
"layoutProperties": {
"primaryColor": "#6963ff",
"secondaryColor": "#1f2933"
},
"useLocaleFromApp": true,
"homepageTrigger": {
"runFunction": "onHomepage",
"enabled": true
},
"universalActions": [{
"label": "Learn more about company xyz",
"openLink": "https://companyxyz.com"
}]
},
"calendar": {
"conferenceSolution": [{
"onCreateFunction": "createConference",
"id": "1",
"name": "Company XYZ",
"logoUrl": "https://companyxyz.com/images/logo192.png"
}],
"eventOpenTrigger": {
"runFunction": "buildSimpleCard"
},
"currentEventAccess": "READ_WRITE"
}
}
}
And here is the code.gs
function createConference(e) {
Logger.log(e);
var dataBuilder = ConferenceDataService.newConferenceDataBuilder();
return dataBuilder.build();
}
function onHomepage(e) {
}
function buildSimpleCard(e) {
}
Calling ConferenceDataService.newConferenceDataBuilder() breaks immediately with the reference error mentioned above.