AMP: <amp-analytics> occasionally does not register click event on Firefox - firefox

For our AMP pages we use <amp-analytics> to track outclicks to web shops. This works fine in most browsers, but in Firefox it seems like these outclicks get registered only half of the time (or even less).
I did some research, and in the console I can see that the request (https://www.google-analytics.com/r/collect?...) is not made in the occasions that we do not see any click.
This is our JSON for registering the outclick. When the user clicks on an element with the .buy-link class, it should register the outclick in Google Analytics.
<script type="application/json">
{
"vars" : {
"gtag_id": "UA-XXXXXXX",
"config" : {
"UA-XXXXXXX": { "groups": "default" }
}
},
"triggers": {
"button": {
"selector": ".buy-link",
"on": "click",
"vars": {
"event_name": "NL",
"event_category": "outclick",
"method": "Google",
"event_label" : "${eventLabel}"
}
}
}
}
</script>
The event-label's value is the name of the store that was clicked on. The data for this retrieved from the HTML element that was clicked on:
<a class="buy-link" data-vars-event-label="Store name" href="https://example.com">...</a>
The data-vars-event-label attribute contains the value for the event_label.
Why do the click events get registered only occasionally? Is there maybe something that clashes between AMP and Firefox? I hope someone can answer me.

Related

Profile image is not displayed (error 403)

I'm using Google API (People) list and from returned JSON, I try to use image listed on "url" field:
"photos": [
{
"url": "https://lh3.googleusercontent.com/cm/AATWAfu9TeDbEEC2VEJqYuO1eGr1F7qRpGSvgKlsjMhny8UWSAB_STRGbHQYvwIQzgrp=s100",
"default": true,
"metadata": {
"source": {
"type": "CONTACT",
"id": "4da7eb9a8d9a19e5"
},
"primary": true
}
}
]
Problem is - not all images are displayed, like you can see here:
https://i.postimg.cc/BvPJLyD5/image-2023-01-11-172253699.png.
On console, I see error 403.
When I manually copy link (from "url" link above) and open it in browser, image is normally displayed. Also, when I reload page few times manually, some images are displayed and some other not (randomly).
Is there any solution for this?
It is related to logged status.
If I'm logged into Gmail or Drive, images are randomly displayed.
If I logout from Gmail and use API again, all images are always displayed. It is same for Google Drive, as you can see here: https://issuetracker.google.com/issues/229184403?pli=1

How to show FireFox extension popup only on specific websites? [duplicate]

I have been trying to read up on how to use WebExtension Page Actions by reading the following docs:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/page_action
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Page_actions
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction/show
I am unable to find how I configure my extension to show the page action button in the URL bar when a page from example.com has loaded. All the docs seem to assume the page action icon is already visible and shows how to handle clicks on it.
First I thought I could configure it through the manifest but it does not seem to be supported in the same way as content scripts. Then I tried to find an API to call from background.js but have not found any.
How do I show my page action icon on example.com?
Starting with Firefox 59, there will be a much simpler solution. In manifest.json, just use the show_matches property of page_action:
"page_action": {
"show_matches": ["*://*.example.com/*"],
...
}
Digging around the samples I found the following that listens for page loads across all tabs and updates the icon with popup that is configured in the manifest.
background.js
/*
Initialize the page action: set icon and title, then show.
Only operates on tabs whose URL's protocol is applicable.
*/
function initializePageAction(tab) {
if (tab.url.includes("example.com")) {
browser.pageAction.show(tab.id);
}
}
/*
When first loaded, initialize the page action for all tabs.
*/
var gettingAllTabs = browser.tabs.query({});
gettingAllTabs.then((tabs) => {
for (let tab of tabs) {
initializePageAction(tab);
}
});
/*
Each time a tab is updated, reset the page action for that tab.
*/
browser.tabs.onUpdated.addListener((id, changeInfo, tab) => {
initializePageAction(tab);
});
manifest.json
"permissions": [
"tabs",
"activeTab"
],
"content_scripts": [{
"matches": ["*://*.example.com/*"],
"js": ["content_scripts/download.js"]
}
],
"page_action": {
"browser_style": true,
"default_icon": {
"19": "icons/download-19.png",
"38": "icons/download-38.png"
},
"default_title": "Some title",
"default_popup": "popup/popup.html"
},
"background": {
"scripts": ["background.js"]
}

Why I can't save my connector on Microsoft Teams?

I made a custom connector for teams that display notifications on channels and add Tab on teams.
For the tab parts -> Everything is working well
But I have a problem for the connector parts, I get an error when I try to save my settings in the developer console:
Received error from connectors {"seq":1585127802210,"timestamp":1585127814174,"flightSettings":{"Name":"ConnectorFrontEndSettings","AriaSDKT....
-> registerOnSaveHandler is called
-> setSettings is correctly set with entityId, contentUrl (same configurationUrl as the connector configuration) and the configName.
getSettings -> is called to save to my app the webhook url -> it works
-> notifySuccess is then called and
I checked on the connector dashboard everything seems fine, on the App Studio everything is green also!
I don't know what is happening..
My manifest
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0.0",
"id": "ca153ede-92f2-46e7-8695-3726b5343bf4",
"packageName": "com.kagilum.icescrum",
"developer": {
"name": "Kagilum SAS",
"websiteUrl": "https://www.icescrum.com",
"privacyUrl": "https://www.icescrum.com/privacy",
"termsOfUseUrl": "https://www.icescrum.com/termsofuser"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "iceScrum",
"full": "Connect with iceScrum"
},
"description": {
"short": "A true Agile project management tool",
"full": "iceScrum is a web application for using Scrum while keeping the spirit of a collaborative workspace. It also offers virtual boards with post-its for sprint backlog, product backlog and others."
},
"accentColor": "#FFFFFF",
"configurableTabs": [
{
"configurationUrl": "https://preview.icescrum.com/msTeams/setupTab/",
"canUpdateConfiguration": true,
"scopes": [
"team",
"groupchat"
],
"supportedSharePointHosts": [
"sharePointFullPage",
"sharePointWebPart"
]
}
],
"connectors": [
{
"connectorId": "f00d8890-daa8-4c87-89f5-83cbab0bccd4",
"configurationUrl": "https://preview.icescrum.com/msTeams/setup/",
"scopes": [
"team"
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"preview.icescrum.com"
]
}
Piece of code related to
microsoftTeams.settings.registerOnSaveHandler(function(saveEvent) {
microsoftTeams.settings.setSettings({
entityId: 'icescrum-pkey-' + $scope.settings.project.pkey,
contentUrl: isSettings.serverUrl + '/msTeams/setup/',
configName: $scope.settings.project.name
});
microsoftTeams.settings.getSettings(function(settings) {
$scope.settings.webhookUrl = settings.webhookUrl;
return FormService.httpPost('msTeams/save', $scope.settings, true).then(function() {
saveEvent.notifySuccess(); //wait that the settings are really saved on iceScrum side
});
});
});
microsoftTeams.settings.getSettings(function(settings) {
$scope.setup = !settings.configName;
var tokenData = JSON.parse(localStorage.getItem("msTeams-oauth"));
var userData = JSON.parse(localStorage.getItem("msTeams-user"));
if (tokenData) {
FormService.httpGet('ws/project/user/' + userData.id + '?light=true', {headers: {'Authorization': 'Bearer ' + tokenData['accessToken']}}, true).then(function(projects) {
$scope.projects = projects;
if (settings.entityId) {
$scope.settings.project = _.find($scope.projects, {pkey: settings.entityId.split('icescrum-pkey-')[1]});
}
$scope.ready = true;
});
}
});
Full error:
angular.min.js:113 2020-03-25T20:35:25.953Z Received error from connectors {"seq":1585168484680,"timestamp":1585168525943,"flightSettings":{"Name":"ConnectorFrontEndSettings","AriaSDKToken":"d127f72a3abd41c9b9dd94faca947689-d58285e6-3a68-4cab-a458-37b9d9761d35-7033","SPAEnabled":true,"ClassificationFilterEnabled":true,"ClientRoutingEnabled":true,"EnableYammerGroupOption":true,"EnableFadeMessage":false,"EnableDomainBasedOwaConnectorList":false,"EnableDomainBasedTeamsConnectorList":false,"DevPortalSPAEnabled":true,"ShowHomeNavigationButtonOnConfigurationPage":false,"DisableConnectToO365InlineDeleteFeedbackPage":true},"status":500,"clientType":"SkypeSpaces","connectorType":"f00d8890-daa8-4c87-89f5-83cbab0bccd4","name":"handleMessageError"}
In case this helps anyone else, I spent ages today trying to get to the bottom of this and couldn't find a solution. Until...as a last gasp show of desperation I decide to use App Studio to recreate the entire connector manifest from scratch, including creating a new connector in the portal.
For some reason, this then worked fine - even though I can see that the two manifest files are identical with the exception of the ID (and I already tried regenerating the ID for the original one).
Bit late to the story, but having followed multiple github issues like this and stack overflow posts, I'm pretty convinced that its the problem with Connectors dashboard. If you made any change to settings, they are not really propageted/saved correctly.
So for example, if you changed validDomains or configurationPage URL, they won't actually do anything. You can verify that with your devtools. For me, after changing the configurationPage the Teams is still making request to old URL as well as the new one, but the old request produces error that's listed in question.
The only workaround I was able to find is to recreate connector in dashboard. Reported problem to MS Teams dev team, waiting to hear back.
Also late here, but I ran into this problem and the below was the solution after 3 days of frustration.
Despite everything mentioned in the documentation, the following is required otherwise you'll get this error. This fixed things for me.
microsoftTeams.settings.registerOnSaveHandler(saveEvent => {
microsoftTeams.settings.setSettings({
contentUrl: "https://xxxxxx.ngrok.io/teams/connector"
});
saveEvent.notifySuccess();
});
The documentation states that registering a save handler is optional and Teams will handle notify success if it's not declared. WRONG. You must register a save handler.
The documentation does not state that setSettings is required. WRONG. You must set settings or else you will receive this error.
The documentation does not state that you must save a contentURL. WRONG. You must set content URL in the setSettings. You can apparently omit other things when setting your settings, but not content URL.
The documentation does not specifically mention it, but the contentURL must comply with your validURLs in your manifest. If it does not, you'll also see this error.
So in your case, you must ensure that isSettings.serverUrl (setSettings() contentURL) does match preview.icescrum.com (manifest validURLs). If they do not, you'll see this error.

chrome extension ajax other chrome extension

I don't think this has been asked yet but a chrome extension ajax other chrome extension. I tried but failed. It's being ajaxed though jquery. My main goal is to get the current chrome theme background.
I get this error:
Denying load of chrome-extension:///manifest.json. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
Code I tried:
$.get( "chrome-extension://<ID>/manifest.json", function( data ) {
console.log(data)
});
Manifest.json:
{
"chrome_url_overrides": {
"newtab": "popup.html"
},
"description": "<description>",
"browser_action": {
"default_icon": "icon.png"
},
"manifest_version": 2,
"name": "<name>",
"permissions": [ "tabs","management","*://*/*" ,"<all_urls>"],
"web_accessible_resources": ["*"],
"version": "1.0.0"
}
You cannot read the data of another extension unless the resource is listed in the web_accessible_resources section of the other extension's manifest file.
For your specific use case, you'd better use the chrome.management API to get information about the other extension:
chrome.management.get('extension ID here', function(result) {
// See https://developer.chrome.com/extensions/management#type-ExtensionInfo
});

Constantly sending data with ajax in chrome extension

is it possible to post data from google chrome extension to another page, for example every minute? Someone opens chrome and then every minute will be information send to my page.. Thank you for answers.
Yes this is very possible. A short simple example:
background page
//These make sure that our function is run every time the browser is opened.
chrome.runtime.onInstalled.addListener(function() {
initialize();
});
chrome.runtime.onStartup.addListener(function() {
initialize();
});
function initialize(){
setInterval(function(){sendData()},60000);
}
function sendData(){
//Assuming data contains the data you want to post and url is the url
$.post(url,data);
}
Manifest.json
We need to request host permissions for where we are posting. Something along the lines of "http://www.example.com/postHere.php". See Match Patterns for more.
{
"name": "Chrome post test",
"version": "0.1",
"description": "A test for posting",
"manifest_version": 2,
"permissions": [
"http://www.example.com/postHere.php"
],
"background": {
"scripts": ["jquery-1.8.3.min.js","background.js"],
"persistent": true
}
}
Try setInterval(). You should wrap your logic in it in your background page. And don't forget to add "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" in your manifest.json if you are excute a string. For more you may want to browse this.

Resources