I have an existing webapp that I'd like to package up as a chrome packaged app, but I'm getting the following error when trying to hit google analytics:
Refused to load the image
'http://www.google-analytics.com/__utm.gif...' because it violates the
following Content Security Policy directive: "img-src 'self' blob:
filesystem: data: chrome-extension-resource:".
Adding content_security_policy to my manifest.son as described here seems to be out of date and is giving me the error.
There were warnings when trying to install this extension:
'content_security_policy' is only allowed for extensions and legacy
packaged apps, but this is a packaged app.
What is the package app way to register a google analytics page view?
The apps documentation says:
Your Chrome App can only refer to scripts and objects within your app, with the exception of media files (apps can refer to video and audio outside the package). Chrome extensions will let you relax the default Content Security Policy; Chrome Apps won’t.
Use chrome-platform-analytics version of the GA script that supports apps
Include the GA script in your app package, load it as a local script:
<script src="google-analytics-bundle.js"></script>
<script src="mainwindow.js"></script>
Add the necessary permissions in manifest.json:
"permissions": ["https://www.google-analytics.com/*"]
Initialize it:
service = analytics.getService('my_app');
service.getConfig().addCallback(function(config) {
console.log(config.isTrackingPermitted());
config.setTrackingPermitted(true);
});
// Get a Tracker using your Google Analytics app Tracking ID.
tracker = service.getTracker('UA-XXXXX-X');
// Record an "appView" each time the user launches your app or goes to a new
// screen within the app.
tracker.sendAppView('MainView');
The code is quoted from Google analytics app in the official app samples repository on github.
Related
I am working on transitioning from Manifest 2 to Manifest 3 and in Manifest 2 I was pulling in a remotely hosted json file and using that to enable and disable settings. It has to be dynamic otherwise I'd include it in the extension itself. Looking at the migration guide from Google I see this:
In Chrome Extension manifest v3 remotely hosted code is no longer allowed. The migration documentation has two solutions.
Configuration-driven features and logic—In this approach, your
extension loads a remote configuration (for example a JSON file) at
runtime and caches the configuration locally. The extension then uses
this cached configuration to decide which features to enable.
Externalize logic with a remote service—Consider migrating application
logic from the extension to a remote web service that your extension
can call. (Essentially a form of message passing.) This provides you
the ability to keep code private and change the code on demand while
avoiding the extra overhead of resubmitting to the Chrome Web Store.
The first option sounds like what I am looking for, but I can't find any documentation on to achieve this approach. If anyone can point me in the right direction it would be greatly appreciated.
For reference this is how I was previously pulling it into the extension:
async function readJson() {
const response = await fetch('https://www.example.com/config.json');
console.log(response.ok);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
const json = await response.json();
return json;
}
Describe the bug
migrating a chrome extension from manifest v2 to v3, content script static not working, dynamic also not working,
"chrome.scripting.registerContentScripts( " telling is not a function
To Reproduce
scenario1
Steps to reproduce the behavior:
1. create an extension with V3
2. mention in manifest one service worker and content script
3. then upload or refresh the extension
4. service worker working but not the content script ( static )
scenario2
Steps to reproduce the behavior:
1. create an extension with V3
2. mention in manifest one service worker
3. in service worker, the below event either execute or register the script is not working
chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) {
chrome.scripting.executeScript({ target: {tabId: tabId},
or
chrome.scripting.registerContentScripts(options,function(et){});
4. then upload or refresh the extension
5. service worker working but not the content script ( dynamic )
Expected behavior
in v2 I am able to either static or programmatically injecting the content script in a page where as in v3 is not, so expecting the steps for same in V3 to work
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: Windows 10
Browser: Chrome
Version 89.0.4389.90 (Official Build) (64-bit)
Additional context
please help me to resolve or any alternative work around to proceed further for migration
I'm using Kentico V10 and I can run the website locally. However, when i try to use the API from a console app, i'm getting the following error.
{"Object type 'cms.class' not found."}
The stackTrace has a call to check license. I'm following this page, and it says you have to add a license for your domain, but what domain is used when you are running from a console app?
https://docs.kentico.com/k10/integrating-3rd-party-systems/using-the-kentico-api-externally
I'm using this code from taken from this page.
https://docs.kentico.com/k10/managing-users/user-registration-and-authentication/configuring-single-sign-on
CMS.DataEngine.CMSApplication.Init();
string userName = "myuser";
// Gets the user with the specified user name
UserInfo userInfo = UserInfoProvider.GetUserInfo(userName);
// Gets the authentication URL for a specified user and target URL
string url = AuthenticationHelper.GetUserAuthenticationUrl(userInfo, "SecuredSurvey");
If that was available via the REST API, i'd be happy to get the URL that way, but from what i can see, it's not available.
-Randy
Kentico has some good documentation on how to use the API in an external application, specifically a console library here.
Very notable steps are:
Connecting to the database; make sure you use the same connection string as in your web.config
Install the Kentico.Libraries NuGet package
Initialize Kentico in your application in the Global.asax file.
Write custom code all day long.
I would like to use the Buildfire Custom Plugin to create a home page for my app. From there I need to link to external websites and internal plugins using Deep Linking.
When I target deep links I get a mixed content error:
Mixed Content: The page at 'https://app.buildfire.com/#/pluginControl/01331574-e5fc-4d9e-b226-ecd69029358b/01331574-e5fc-4d9e-b226-ecd69029358b-1549414186849/New%20Home/3000dd44-17a3-464c-a438-d31843d7cbe4/false?headerId=5c5a2f2b236aa005d368b399' was loaded over HTTPS, but requested an insecure resource 'app0070be://plugin/169d5e94-6c5e-4769-b4ca-a7d0175985e7-1528925513379'. This content should also be served over HTTPS.
Here is the code I'm using:
var search = document.getElementById("search");
search.addEventListener('click', function() {
console.log("Search"); // I am seeing this in the console prior to the error.
document.location('app0070be://plugin/ba4139dd-09c6-4121-aa4a-c72570af07fc-1490476490653');
});
Is there a way to make this secure? Is there a better / different approach I should consider?
I published a chrome extension to testers only. The app seems to work very well. I don't see any errors when inspecting the console for the popup or the background page. However, I get the following error when inspecting the console for any web page: "Uncaught Error: "getBackgroundPage" can only be used in extension processes. See the content scripts documentation for more extensions/schema_generated_bindings.js:418"
This app contains several JavaScript files, but each one includes the code within a self executing function. The "getBackgroundPage" calls are in the JavaScript files.
Could you please help? Isn't the app I built an isolated module independent from any web page? How can I prevent this error from happening?
I had the same error when I was trying to communicate with the background page from my content script. The correct way of doing it is via Message Passing. It is very well documented here : https://developer.chrome.com/extensions/messaging.html