Can't load Features.Diagnostics - azure

I'm creating a web client for joining Teams meetings with the ACS Calling SDK.
I'm having trouble loading the diagnostics API. Microsoft provides this page:
https://learn.microsoft.com/en-us/azure/communication-services/concepts/voice-video-calling/call-diagnostics
You are supposed to get the diagnostics this way:
const callDiagnostics = call.api(Features.Diagnostics);
This does not work.
I am loading the Features like this:
import { Features } from '#azure/communication-calling'
A statement console.log(Features) shows only these four features:
DominantSpeakers: (...)
Recording: (...)
Transcription: (...)
Transfer: (...)
Where are the Diagnostics??

User Facing Diagnostics
For anyone, like me, looking now...
ATOW, using the latest version of #azure/communication-calling SDK, the documented solution, still doesn't work:
const callDiagnostics = call.api(Features.Diagnostics);
call.api is undefined.
TL;DR
However, once the call is instantiated, this allows you to subscribe to changes:
const call = callAgent.join(/** your settings **/);
const userFacingDiagnostics = call.feature(Features.UserFacingDiagnostics);
userFacingDiagnostics.media.on("diagnosticChanged", (diagnosticInfo) => {
console.log(diagnosticInfo);
});
userFacingDiagnostics.network.on("diagnosticChanged", (diagnosticInfo) => {
console.log(diagnosticInfo);
});
This isn't documented in the latest version, but is under this alpha version.
Whether this will continue to work is anyone's guess ¯\(ツ)/¯
Accessing Pre-Call APIs
Confusingly, this doesn't currently work using the specified version, despite the docs saying it will...
Features.PreCallDiagnostics is undefined.
This is actually what I was looking for, but I can get what I want by setting up a test call asking for the latest values, like this:
const call = callAgent.join(/** your settings **/);
const userFacingDiagnostics = call.feature(Features.UserFacingDiagnostics);
console.log(userFacingDiagnostics.media.getLatest())
console.log(userFacingDiagnostics.network.getLatest())
Hope this helps :)

Currently the User Facing Diagnostics API is only available in the Public Preview and npm beta packages right now. I confirmed this with a quick test comparing the 1.1.0 and beta packages.

Check the following link:
https://github.com/Azure-Samples/communication-services-web-calling-tutorial/
Features are imported from the #azure/communication-calling,
for example:
const {
Features
} = require('#azure/communication-calling');

Related

IFeatureManager Unit Testing

I have a Feature Flag in the Azure portal, used from some controllers in a .NET Core Web App.
At runtime, it works correctly switching on and off the FF on the real portal.
I should write 2 Unit tests, simulating when the Feature Flag is On and when Off.
For the Off, I can write
var featMan = new Mock<IFeatureManager>().Object;
And it works, the problem is to simulate when On.
I found this page, https://github.com/microsoft/FeatureManagement-Dotnet/issues/19#issue-517953297 , but in the downloadable code there is no StubFeatureManagerWithFeatureAOn definition.
You just need to configure your Mock to return specific value in specific cases. For example to emulate that test-feature is On you'd write something like this
[Test]
public async Task TestFeatureManager()
{
var featureManageMock = new Mock<IFeatureManager>();
featureManageMock
.Setup(m => m.IsEnabledAsync("test-feature"))
.Returns(Task.FromResult(true));
var featureManager = featureManageMock.Object;
Assert.IsTrue(await featureManager.IsEnabledAsync("test-feature"));
}

Google Translate V2

I've used Google Translate for years with excellent results. Now, Google has deprecated my version and now employs Google.Cloud.Translation.V2.
The Nuget Install-Package Google.Cloud.Translation.V2 -Version 2.0.0 installs, but causes the dreaded yellow screen saying is can't find one thing after another, and also System.Net.Http version conflicts. Manually edit Web and Machine configs, and on and on.
Also, Google samples reference things with undefined namespaces. i have the Google credentials json file.
I really don't want to change Environment vars in a production environment.
Bottom line? I'm in agreement with hundreds of folks saying that this is a nightmare.
With Nuget, it's usually easy to install, reference and run. Not so here. Google's primers on this are unnecessarily verbose and impossible, at least for me, to follow. This should be Nuget, reference, code.
I think I'm up to about 100 folks with the same problem. Aaaargh!
Ideas?
OK, figured this out and while the instructions are all over the board, the process is not.
This is for C#.
You need an account at Google that enables Google.Cloud.Translation.V2.
Once enabled, you'll need a json credentials file. Download it and save it.
The instructions show how to use the Package Manager Console to allow these to work.
In your translate class, add these:
using Google.Cloud.Translation.V2; //PM> Install-Package Google.Cloud.Translation.V2 -Version 2.0.0
using Google.Apis.Auth.OAuth2; //PM> Install-Package Google.Apis.Oauth2.v2 -Version 1.50.0.1869
Then this (the encoding can be whatever you need):
//usage:
var translated = TranslateText("en", "ar", "Happy Translating");
public string TranslateText(string srclang, string destlang, string trns)
{
var utf8 = new UTF8Encoding(false);
var client = TranslationClient.Create(GoogleCredential.FromFile(path to json credentials file));
var result = client.TranslateText(
text: trns,
targetLanguage: destlang, // ar
sourceLanguage: srclang, // en
model: TranslationModel.Base);
// or model: TranslationModel.NeuralMachineTranslation);
return utf8.GetString(utf8.GetBytes(result.TranslatedText));
}
Result: سعيد الترجمة

ag-grid-community vs ag-grid-enterprise new Grid

I have a Node client-side application with the latest ag-grid version.
I was using ag-grid-community without any issues with this require line
const {Grid} = require('ag-grid-community');
and this new
new Grid(agGridDiv, agGridOptions);
but if I change the require to
const {Grid} = require('ag-grid-enterprise');
the new fails with exception 'Grid is not a constructor'
How can I fix this? I have tried various changes such as new Grid.Grid etc but nothing seems to work.
For latest 23.1.1 version this page:
// ECMA 5 - using nodes require() method
const AgGrid = require('ag-grid-enterprise');
Another way to follow this guide, it all depends on which repository you download the dependencies from.
import {Grid, GridOptions} from '#ag-grid-community/core';
import {LicenseManager} from '#ag-grid-enterprise/core';
// or
const {Grid, GridOptions} = require('#ag-grid-community/core');
I used core and it worked for import.
For old version:
Grid, like everything else, needs to be imported from ag-grid-community.
1) ag-grid-enterprise is pure additive functionality for ag-grid-community.
2) You will use ag-grid-enterprise via the ag-grid-community api not explicit. Use ag-grid-enterprise for LicenseManager only.
Off-topic:
I would recommend starting with the old version, since the source code of the new version is minified and it will be more difficult for you to understand many nontrivial nuances.

AWSXRay.captureAsyncFunc() from Lambda - am I missing something?

I'm trying to get a custom X-Ray segment reporting, but I'm not seeing anything in the trace. My code looks something like this:
var AWSXRay = require('aws-xray-sdk-core');
AWSXRay.captureAsyncFunc('callSoapService', subsegment => {
doSomethingAsync(params, err => {
if (err) {
subsegment.close(err);
} else {
doSomethingElse().then(result => {
console.info('all done, now close the segment');
subsegment.close();
}, subsegment.close);
}
});
});
Do I need to add it to the parent segment or something?
ugh. there seems to be a bug with AWSXRay.captureHTTPs() - if I remove that call captureAsyncFunc() starts working
For the AWS X-Ray Node SDK, automatic mode is build on the continuation-local-storage (cls) package which has known compatibility issues with promise libraries. This is why your 'then' seems to be losing context. However, most of these libraries have various CLS shims available to provide the compatibility necessary to work.
Which promise library are you using?
For bluebird, there's 'cls-bluebird' or for Q there's 'cls-q' that's available that will get it working.
They usually ask to pass in the CLS namespace, which is available from xray.getNamespace().
Hope this helps.

Developer documentation for previous releases of the Chromium\Google Chrome [duplicate]

I love what chrome offers me through its extension API.
But I always find myself lost in the jungle of what API is supported by which chrome version and when did the last chrome.experimental feature make it into the supported extensions.
The Chrome extension page gives me a nice overview what is supported, but without mentioning since what version. The same is true for the experimental API overview. Is that specific API still experimental or is it already supported in canary, for example.
If I try a sample from the chrome Samples website I usually have to change some API calls from chrome.experimental.foo to chrome.foo or find out that it is not supported at all. (What happened to chrome.experimental.alarm?) That usually means to just use the trial and error approach to eliminate all errors, until the sample works.
tldr;
So, I'm wondering is there an overview page which tells me since what version, what API is supported or when it was decided to drop an experimental API. And if there is no such page, what is the recommended way or your personal approach to deal with this situation?
On this page, the process of generating the official documentation (automatically from the Chrome repository) is described. On the same page, you can also read how to retrieve documentation for older branches. Note that the documentation is somehow incomplete: Deprecated APIs are included immediately, although they're still existent (such as onRequest).
What's New in Extensions is a brief list of API changes and updates (excluding most of the experimental APIs). It has to be manually edited, so it's not always up-to-date. For example, the current stable version is 20, but the page's last entry is 19.
If you really need a single page containing all API changes, the following approach can be used:
First, install all Chrome versions. This is not time consuming when done automatically: I've written a script which automates the installation of Chrome, which duplicates a previous profile: see this answer.
Testing for the existence of the feature:
Write a manifest file which includes all permissions (unrecognised permissions are always ignored).
Chrome 18+: Duplicate the extension with manifest version 1 and 2. Some APIs are disabled in manifest version 1 (example).
Testing whether a feature is implemented and behaving as expected is very time-consuming. For this reason, you'd better test for the existence of an API.
A reasonable manner to do this is to recursively loop through the properties of chrome, and log the results (displayed to user / posted to a server).
The process of testing. Use one of the following methods:
Use a single Chrome profile, and start testing at the lowest version.
Use a separate profile for each Chrome version, so that you can test multiple Chrome versions side-by-side.
Post-processing: Interpret the results.
Example code to get information:
/**
* Returns a JSON-serializable object which shows all defined methods
* #param root Root, eg. chrome
* #param results Object, the result will look like {tabs:{get:'function'}}
*/
function getInfo(root, results) {
if (root == null) return results;
var keys = Object.keys(root), i, key;
results = results || {};
for (i=0; i<keys.length; i++) {
key = keys[i];
switch (typeof root[key]) {
case "function":
results[key] = 'function';
break;
case "object":
if (subtree instanceof Array) break; // Exclude arrays
var subtree = results[key] = {};
getInfo(root[key], subtree); // Recursion
break;
default:
/* Do you really want to know about primitives?
* ( Such as chrome.windows.WINDOW_ID_NONE ) */
}
}
return results;
}
/* Example: Get data, so that it can be saved for later use */
var dataToPostForLaterComparision = JSON.stringify(getInfo(chrome, {}));
// ...

Resources