I'm in a project where I am building a simulator of a website. I am testing how feature toggling can provide some cons that can help a team release more often than they do now.
One thing I do like to simulate is how the Canary release is working. Lets say I just finished building a new feature and I need to have it tested in production. Canary release is just to push this feature out to a small number of users.
How do you simulate this with code? I'm building the applikation with angular2 anad with typescript. Have created configurationfiles for the features that I can use.
How do you, lets say pick only 5 percents of random people that visit the site to test the specific feature? Is it all done with server configuration (running another build at a different server).
If any could make a code example of how I could simulate this when the application starts, I've be happy.
Have made this code myself:
var switchKey: string = localStorage.getItem('featureSwitch');
if (this.featureSwitch != null) {
if (switchKey == "11") {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
else {
if (switchKey != null) {
if (switchKey == "11") {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
else {
this.featureSwitch = Number(switchKey) + 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
else {
this.featureSwitch = 1;
localStorage.setItem('featureSwitch', this.featureSwitch.toString());
}
}
This is maybe a bad example, cause I don't think it will work on a live site (on the internet), this is only tested on a localhost server. Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.
Any have some ideas how I could do this easily?
Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.
You should do canary releases based on users (not browser sessions). Otherwise the user will be surprised as they switch browsers / devices / locations. And you will not know which users are participating in a test (a user can AND can't be in the test if they use two devices).
This needs server side support, the switch belongs in the server.
Related
I am writing an application for Android with Xamarin and I need to implement text-to-speech in Polish language.
My first step was, of course, to google it and I've found out that text-to-speech is implemented already in Xamarin (link to developer.xamarin.com).
Unfortunatelly, not in Polish (there is a way to change language, but I wasn't able to change it to Polish). Is there a way to do this?
I've found a nice website with text-to-speech in many languages and free non-commercial api: https://responsivevoice.org/api/
But, it works in JS and I don't know a way to implement JS in Xamarin, Android app. Is there a way to do this?
There are some other free text-to-speech APIs, but they don't seem to sound great, just 3/10 or something, but my work is an engineer project, so I don't wont to use such weak things.
Android supports Polish and a couple of dozen other languages, you could do this in the (TextToSpeech.IOnInitListener) OnInit method to review all the languages available and set the one you want:
public void OnInit([GeneratedEnum] OperationResult status)
{
if (status.Equals(OperationResult.Success))
{
foreach (var locale in speaker.AvailableLanguages)
{
Log.Debug(TAG, locale.Language); // review all the languages available
if (locale.Language == "pl")
speaker.SetLanguage(locale);
}
speaker.Speak("jak się masz?", QueueMode.Flush, null, null);
}
else
Log.Error(TAG, status.ToString());
}
iOS also supports a couple of dozen languages, including Polish (pl-PL). You can review all the support languages via AVSpeechSynthesisVoice.GetSpeechVoices() and assign one via the AVSpeechSynthesisVoice.FromLanguage to the AVSpeechUtterance.Voice property:
foreach (var voice in AVSpeechSynthesisVoice.GetSpeechVoices())
{
Console.WriteLine(voice.Language); // review all the languages available
}
var speechSynthesizer = new AVSpeechSynthesizer();
var speechUtterance = new AVSpeechUtterance("jak się masz?")
{
Voice = AVSpeechSynthesisVoice.FromLanguage("pl-PL"),
Volume = 1.0f,
PitchMultiplier = 1.0f
};
I have been working (slowly) through the in app purchase example.
I have created 2 in app purchases in the Store for my app. I have linked Visual Studio to that app. I finally have not got any errors when I enter the callback function from requesting my in app purchases.
The error: It says there are 0 products when there should be 2.
My Code:
var ProductsARR = [];
var storeContext = Windows.Services.Store.StoreContext.getDefault();
var productKinds = ["Consumable", "Durable", "UnmanagedConsumable"];
storeContext.getAssociatedStoreProductsAsync(productKinds).then(function (addOns) {
var i;
if (addOns.extendedError) {
if (addOns.extendedError === (0x803f6107 | 0)) {
alert("This sample has not been properly configured.");
} else {
// The user may be offline or there might be some other server failure.
alert("ExtendedError: " + addOns.extendedError.toString());
}
} else if (addOns.products.size === 0) {
alert("No configured Add-ons found for this Store Product.");
} else {
for (i = 0; i < addOns.products.size;i++){
var item = {
title: addOns.products[i].title,
price: addOns.products[i].price.formattedPrice,
inCollection: addOns.products[i].isInUserCollection,
productKind: addOns.products[i].productKind,
storeId: addOns.products[i].storeId
};
ProductsARR .push(item);
}
}
});
What could be causing it to think there are no in app purchases where there are 2?
The only thing I think could be causing confusion is I have not submitted the actual xapproduct to the store yet, but I do not want to do that until I have fleshed out the rest of the code. I am working on the in app purchase code right now. Could that be causing the problem?
If not, what else could be causing the problem. It says in my dashboard that the in app purchase is 'In Store'.
You have to submit your products to the store. They go through a certification process and you should receive 2 emails stating something like "Your productX has been certified".
If you don't want this product to appear and only be available for Beta testing, make sure it's availability is set to "Hide this app in the Store".
Here's some info.
The only thing I think could be causing confusion is I have not
submitted the actual xapproduct to the store yet, but I do not want to
do that until I have fleshed out the rest of the code.
You're using Windows.Services.Store namespace, which doesn't provide a class that you can use to simulate license info during testing, unlike Windows.ApplicationModel.Store provding the CurrentAppSimulator class . So you must publish the app and download it to your development device to use its license for testing.
For testing purpose, this app doesn't need to be your real version but a basic app that meets minimum Windows App Certification Kit requirements. Also, you could choose to hide this app first to prevent customers from seeing your app during your test.
For more details about testing guidance, you might refer to Test your in-app purchase or trial implementation.
First of all, sorry for ressurrecting this question here.
I've been trying for two days how to reach this job using javascript/jquery and i think i've read all stack overflow and other blogs posts about that, so please, don't mark it as duplicated because I can't use out-dated scripts from 2012 now in 2017.
I've a single page that redirects to a third party e-learning platform where some content needs flash to work. Many users don't care about which software is installed on their machines (what a new, huh) so i need to detect it and show the tipical message "please install/update flash player clicking here", but i cannot find a "modern" script/way to do this, in any place, simplified, if possible.
All scripts i've tried are deprecated or returns false in all browsers, even i've newest version of flash installed and active.
Anny help will be appreciated (except links to older posts or scripts that don't work nowadays, obviously).
Thanks a lot!
There is a simple way to check for Flash since all the installed and enabled plugins will be listed in navigator.plugins;
Note that if a plugin is installed, but not enabled, it will not be detected in the navigator.plugins array. There is NO way to detect this using Javascript (this Question which confirms the same).
Having said that, use the following function isFlashEnabled(); to detect Flash :
<html>
<script>
if(isFlashEnabled())
{ document.write('Flash is installed (but may need to be enabled)'); }
else { document.write('Flash is either not installed or disabled'); }
function isFlashEnabled()
{
var flash = navigator.plugins.namedItem('Shockwave Flash');
if (!flash) { return 0; }
else { return 1; }
}
</script>
<body> <embed src="https://www.w3schools.com/tags/helloworld.swf"> </body>
</html>
You can get an array which contains all installed plugins of a browser like this:
var plugins = navigator.plugins;
Then you can then check if the array contains the flash plugin.
From https://developer.mozilla.org/de/docs/Web/API/NavigatorPlugins/plugins:
function getFlashVersion() {
var flash = navigator.plugins.namedItem('Shockwave Flash');
if (typeof flash != 'object') {
// flash is not present
return undefined;
}
if(flash.version){
return flash.version;
} else {
//No version property (e.g. in Chrome)
return flash.description.replace(/Shockwave Flash /,"");
}
}
Background:
I'm authorised to "automate" a 3rd party site for the purpose of pushing "service orders" into it and monitoring the progress of those requests.
I tried taking a normal "scraping" approach (using WWW::Mechanize, HTML::Query, etc from Perl) but ran into a lot of issues predicting what the JavaScript in the site would do under a variety of circumstances. I intend to go back to this approach if I ever receive support from the vendor of the product which runs the 3rd party site, or can get hold of some better documentation w.r.t business-rules of the product.
To avoid second guessing the JavaScript code, and to save a lot of time, I ended up taking an approach were I load the 3rd party site in Firefox on a dedicated VM, and then execute "privileged" code (i.e: nsI*) in the context of the site to "drive" and "scrape" the site.
I'm currently using nsIWebProgressListener/DOMContentLoaded (when I already have a reference to a ChromeWindow), and nsIWindowMediator window+tab enumeration called from setInterval to find new windows and tabs (when I have no way to predict them opening, nor gain a reference to their DOMWindow objects due to scoping of 3rd party JavaScript).
Question:
How can I automatically install a "hook" into each Window/Tab opened now (and in the future) by the 3rd party site's JavaScript? Something like a "window watcher" nsI~ interface for the whole of the Firefox UI would be very useful in this case.
There are so many ways you could do this, so the right choice depends on how you're going about everything else.
Here are just a few ways of listening, rather than polling.
New Chrome Windows
function ChromeWindowObserver() {
this.observe = function(subject, topic, data) {
// subject is a ChromeWindow
}
}
Components.classes["#mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.registerNotification(new ChromeWindowObserver());
New Tabs
function tabListener(event) {
var browser = gBrowser.getBrowserForTab(event.target):
}
gBrowser.tabContainer.addEventListener("TabOpen", tabListener, false);
Observer Notifications (my favorite)
const dumpObserver = {
observe: function(subject, topic, data) { dump(topic + "\n"); }
}
const domObserver = {
observe: function(subject, topic, data) { dump(subject.location + "\n"); }
}
const ObserverService = Components.classes["#mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
/* debug log notifications */
ObserverService.addObserver(dumpObserver, "*", false);
/* debug log all new content locations */
ObserverService.addObserver(domObserver, "content-document-global-created", false);
Side note, check out JavaScript code modules. I think that might be helpful for you when sharing data between chrome windows.
I'm currently working on an app that aggressively uses webviews on both iOS and Android to render content, with native chrome surrounding it. I want to be able to control this chrome via javascript methods.
Android Webview has addJavascriptInterface which allows this to happen, but iOS does not have this facility. I've already checked out the SO answer at iOS JavaScript bridge, and this has usefuleinformation, but It's iOS-only; optimally the same underlying web code could power the callbacks on both Andorid and iOS devices.
I'm wondering if something like PhoneGap or Appcelerator provides a way to do this simply; however I don't need their core product (providing a native experience via underlying html/css/js) and I dont even know if what I need is included in their package.
Thanks for any info!
I would say that the best way would be to do it yourself, combining those two examples:
function nativeDoStuff() {
if (androidbridge != null {
androidbridge.doStuff();
}
else {
//construct url
window.location = "myiphonescheme://dostuff";
}
come to think of it, if you're feeling ambitious you could code up a quick javascript object to do it for you:
function NativeAppBridge () {
function runMethod(methodName, params) {
if (androidbridge != null {
// If the android bridge and the method you're trying to call exists,
// we'll just call the method directly:
if (androidbridge[methodName] != null) {
androidbridge[methodName].apply(this, params);
}
}
else {
// building the url is more complicated; best I can think
// of is something like this:
var url = "myiphonescheme://" + methodName;
if (params.length > 0) {
url += "?"
var i = 0;
for (param in params) {
url += "param" + i + "=" + param;
++i;
if (i < params.length) {
url += "&";
}
}
}
}
}
}
Using it would then be as simple as:
var bridge = new NativeAppBridge();
function onClick() {
bridge.runMethod("doStuff", null);
}
Be aware that I coded this off the top of my head and don't have time to test, at the moment - but I think it should work well enough, provided I didn't make any major mistakes
You can try the XWebView project if you plan to use WKWebView
You can use phonegap plugins to do it. They provide an excelent way to communicate between their webview and your native layer.
Here you can see how to create one!
And my personal opinion on the subject: I've been using phonegap for a while and if you are on webviews, I strongly suggest you to rethink the way you're doing stuff and move to a mobile web platform. You probably can save a lot of time.
The way I see it, the great disadvantage on using this is you are creating a webpage instead of a mobile app. You cant use native components and your app gets less responsive. As you are already on webviews, I believe you can only find benefits on these platforms.