AngularJS version 1 - Application Insights integration - angularjs

I am currently supporting an application that is built using AngluarJS Version 1. I am quite new to this.
I have a task to integrate the Azure Application Insights into this application. The below reference link gives info about the integration using npm
https://learn.microsoft.com/en-us/azure/azure-monitor/app/javascript
I am not sure how to write the below code in AngularJS, this gives the error.
import { ApplicationInsights } from '#microsoft/applicationinsights-web'
Please help or if there are any references please share.

Either we can use NPM Setup and Snippet Setup.
For NPM
npm i --save #microsoft/applicationinsights-web
Configure Angular APP and Include Dependencies
You can use the environment.ts file to store the Instrumentation Key
export const environment =
{
. . .
appInsights: { instrumentationKey: '<Your Instrumentation Key>'
}
};
Add Dependency to package.json Restore it using npm install
"dependencies": { "#microsoft/applicationinsights-web": "~2.4.4",
...
}
Refer here for further steps

Related

Android build failures happening since 4th Nov 2022[FIX INSIDE]

The build error looks something like this:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'My Project'.
Could not determine the dependencies of null.
Could not resolve all task dependencies for configuration ':classpath'.
Could not resolve com.facebook.react:react-native:+.
Required by:
project :
No matching variant of com.facebook.react:react-native:0.71.0-rc.0 was found.
The consumer was configured to find a runtime of a library compatible with Java 11,
packaged as a jar, and its dependencies declared externally, as well
as attribute 'org.gradle.plugin.api-version' with value '7.3.3'
update this below content in project level build.gradle:
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
it's working for me
FIX INSIDE
Steps to resolve the react-native issue that we are facing since couple of days.
Goto package.json and upgrade the react-native version to 0.64.4.(or whatever the supported version we have on the GitHub thread)
Run yarn install.
Now cd android
./gradlew clean
cd ..
yarn android (now your project will execute properly)
Note: This issue occurred because of the new release of the react native(4th nov), here I'm attaching the link for the reference.
URL : https://github.com/facebook/react-native/issues/35210
(if you face any issues do let me know i'll help you in resolving the same.)
This fix works:
Reason for Failures : The build failures for Android was due to the publish of the React Native version 0.71.0-rc0 to Maven and because of which when the gradle is syncing its picking this 0.71.0-rc0 version of react-native rather then your current version of react-native.
Made it work without upgrading react-native version and by adding this in build.gradle, this works (hermes enabled or not, along with flipper too)
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
final snippet looks like this
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
gradle clean and rebuild after this fix. Then you can react native run android successfully.
What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules
If you dont want to put this fix, you can update your react native version for the project to the react native patch version as mentioned here
https://github.com/facebook/react-native/issues/35210

`/bin/sh: 1: tsc: not found` in Gatsby Cloud

I get /bin/sh: 1: tsc: not found error on build in Gatsby Cloud.
How can I fix this to build successfully?
I believe the reason for this would be I am specifying a branch for a npm package.
The npm package doesn't provide features I need and I cannot wait for PR to be merged, so I forked and modified the package with specifying it in package.json like:
{
"dependencies": {
"some-package": "https://github.com/xxxx/some-package.git#temporary"
}
}
It works fine on local development but not when building in Gatsby cloud.
Is there any way to fix this?
I tried to use gatsby-plugin-typescript(link) but didn't work.

reactjs application add to existing reactjs application

I'm just starting out in Reactjs.
I have a RedHat Linux VM.
I've installed nodejs and created a simple reactjs application:
npx create-react-app my-first-project
My first project works OK.
Now I have found this great reactjs package with a demo:
https://github.com/TarikHuber/material-ui-filter
I want to install the demo part of this package that consists of index.css, index.html, app.js, index.js
How would I go with this?
Where do I put this new code relative to my-first-project?
How do I call this new code?
The package I think calls redux so I assume I will install this first.
Thanks.
You should learn how npm works. If you find some cool package and you want to use it then you have to install that package. There is a installation command on Readme file on that github repo. Install package via npm install material-ui-filter then you can just use the html file on demo project.

I want to integrate IronSource ad network with my react native project

I have found a framework for integrating IronSource ad network with my react native project here.
I have a searched a lot in internet and have already tried opening an issue in the repository but no luck.
I did as it said in the readme file like so:
First installing the dependency
npm install #wowmaking/react-native-iron-source --save
Then linking the dependency
react-native link #wowmaking/react-native-iron-source
And finally importing the dependency
import { IronSource } from '#wowmaking/react-native-iron-source';
But as soon as I try to run my application I get this error:
native module cant be null
I don't know if I'm doing it right or not please help!
I'm using react native 0.60.5
I'm contributor of #wowmaking/react-native-iron-source.
Readme was updated for RN 60 last month. You dont need to link it anymore for RN 60.
npm install #wowmaking/react-native-iron-source --save
Add a repo to your android/app/build.gradle file
allprojects {
repositories {
// Existing repos here
// ...
maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
}
}
You are ready to run your app.
Add mediation networks which you need. Follow official docs.
https://github.com/wowmaking/react-native-iron-source#mediation-setup
Re-build your project via:
react-native run-android

Unknown module "Firebase" in React native

I am working on some sample apps using react native. I am trying to integrate Firebase plugin followed by firebase tutorial.
I can able to add firebase plugin using
npm install firebase --save
It gets added to node_modules, when i try to require the plugin
var Firebase = require('firebase');
It throws an exceptions "Requiring unknown module 'firebase'...."
First, make sure you've installed the dependency with:
npm install firebase --save
(make sure you are in your project folder)
Then end the NPM process and restart by running react-native start. That should do the trick.

Resources