Merge pull request #5153 from petkir/appinsights-usage
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "SPFx 1.18.2",
|
||||
"image": "docker.io/m365pnp/spfx:1.18.2",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
||||
},
|
||||
"forwardPorts": [
|
||||
4321,
|
||||
35729,
|
||||
5432
|
||||
],
|
||||
"portsAttributes": {
|
||||
"4321": {
|
||||
"protocol": "https",
|
||||
"label": "Manifest",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
},
|
||||
"5432": {
|
||||
"protocol": "https",
|
||||
"label": "Workbench",
|
||||
"onAutoForward": "silent"
|
||||
},
|
||||
"35729": {
|
||||
"protocol": "https",
|
||||
"label": "LiveReload",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
|
||||
"remoteUser": "node"
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
echo
|
||||
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
|
||||
npm install
|
||||
|
||||
## commands to create dev certificate and copy it to the root folder of the project
|
||||
echo
|
||||
echo -e "\e[1;94mGenerating dev certificate\e[0m"
|
||||
gulp trust-dev-cert
|
||||
|
||||
# Convert the generated PEM certificate to a CER certificate
|
||||
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
|
||||
|
||||
# Copy the PEM ecrtificate for non-Windows hosts
|
||||
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
|
||||
|
||||
## add *.cer to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.cer' ./.gitignore
|
||||
then
|
||||
echo "# .CER Certificates" >> .gitignore
|
||||
echo "*.cer" >> .gitignore
|
||||
fi
|
||||
|
||||
## add *.pem to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.pem' ./.gitignore
|
||||
then
|
||||
echo "# .PEM Certificates" >> .gitignore
|
||||
echo "*.pem" >> .gitignore
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "\e[1;92mReady!\e[0m"
|
||||
|
||||
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"
|
|
@ -0,0 +1,352 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
parserOptions: { tsconfigRootDir: __dirname },
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'project': './tsconfig.json',
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
},
|
||||
rules: {
|
||||
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/no-new-null': 1,
|
||||
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/hoist-jest-mock': 1,
|
||||
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
|
||||
'@rushstack/security/no-unsafe-regexp': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/adjacent-overload-signatures': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
|
||||
'@typescript-eslint/ban-types': [
|
||||
1,
|
||||
{
|
||||
'extendDefaults': false,
|
||||
'types': {
|
||||
'String': {
|
||||
'message': 'Use \'string\' instead',
|
||||
'fixWith': 'string'
|
||||
},
|
||||
'Boolean': {
|
||||
'message': 'Use \'boolean\' instead',
|
||||
'fixWith': 'boolean'
|
||||
},
|
||||
'Number': {
|
||||
'message': 'Use \'number\' instead',
|
||||
'fixWith': 'number'
|
||||
},
|
||||
'Object': {
|
||||
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
|
||||
},
|
||||
'Symbol': {
|
||||
'message': 'Use \'symbol\' instead',
|
||||
'fixWith': 'symbol'
|
||||
},
|
||||
'Function': {
|
||||
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
|
||||
// Even if the compiler may be able to infer a type, this inference will be unavailable
|
||||
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
|
||||
// but writing code is a much less important activity than reading it.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
1,
|
||||
{
|
||||
'allowExpressions': true,
|
||||
'allowTypedFunctionExpressions': true,
|
||||
'allowHigherOrderFunctions': false
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-array-constructor': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
|
||||
// This rule should be suppressed only in very special cases such as JSON.stringify()
|
||||
// where the type really can be anything. Even if the type is flexible, another type
|
||||
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
|
||||
'@typescript-eslint/no-explicit-any': 1,
|
||||
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
|
||||
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
|
||||
// or else return the object to a caller (who assumes this responsibility). Unterminated
|
||||
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||
// they can also cause a NodeJS process to terminate unexpectedly.
|
||||
'@typescript-eslint/no-floating-promises': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'@typescript-eslint/no-for-in-array': 2,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-misused-new': 2,
|
||||
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
|
||||
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
|
||||
// optimizations. If you are declaring loose functions/variables, it's better to make them
|
||||
// static members of a class, since classes support property getters and their private
|
||||
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
|
||||
// class name tends to produce more discoverable APIs: for example, search+replacing
|
||||
// the function "reverse()" is likely to return many false matches, whereas if we always
|
||||
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
|
||||
// to decompose your code into separate NPM packages, which ensures that component
|
||||
// dependencies are tracked more conscientiously.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-namespace': [
|
||||
1,
|
||||
{
|
||||
'allowDeclarations': false,
|
||||
'allowDefinitionFiles': false
|
||||
}
|
||||
],
|
||||
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
|
||||
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
|
||||
// code easier to write, but arguably sacrifices readability: In the notes for
|
||||
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
|
||||
// a class's design, so we wouldn't want to bury them in a constructor signature
|
||||
// just to save some typing.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/parameter-properties': 0,
|
||||
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
|
||||
// may impact performance.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
1,
|
||||
{
|
||||
'vars': 'all',
|
||||
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
|
||||
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
|
||||
// that are overriding a base class method or implementing an interface.
|
||||
'args': 'none'
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-use-before-define': [
|
||||
2,
|
||||
{
|
||||
'functions': false,
|
||||
'classes': true,
|
||||
'variables': true,
|
||||
'enums': true,
|
||||
'typedefs': true
|
||||
}
|
||||
],
|
||||
// Disallows require statements except in import statements.
|
||||
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/prefer-namespace-keyword': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
|
||||
'accessor-pairs': 1,
|
||||
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||
'dot-notation': [
|
||||
1,
|
||||
{
|
||||
'allowPattern': '^_'
|
||||
}
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'eqeqeq': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'for-direction': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'guard-for-in': 2,
|
||||
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
|
||||
// to split up your code.
|
||||
'max-lines': ['warn', { max: 2000 }],
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-async-promise-executor': 2,
|
||||
// RATIONALE: Deprecated language feature.
|
||||
'no-caller': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-compare-neg-zero': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-cond-assign': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-constant-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-control-regex': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-debugger': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-delete-var': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-duplicate-case': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-character-class': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-pattern': 1,
|
||||
// RATIONALE: Eval is a security concern and a performance concern.
|
||||
'no-eval': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-ex-assign': 2,
|
||||
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
|
||||
// If two different libraries (or two versions of the same library) both try to modify
|
||||
// a type, only one of them can win. Polyfills are acceptable because they implement
|
||||
// a standardized interoperable contract, but polyfills are generally coded in plain
|
||||
// JavaScript.
|
||||
'no-extend-native': 1,
|
||||
// Disallow unnecessary labels
|
||||
'no-extra-label': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-fallthrough': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-func-assign': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-implied-eval': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-invalid-regexp': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-label-var': 2,
|
||||
// RATIONALE: Eliminates redundant code.
|
||||
'no-lone-blocks': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-misleading-character-class': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-multi-str': 2,
|
||||
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
|
||||
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
|
||||
// or else implies that the constructor is doing nontrivial computations, which is often
|
||||
// a poor class design.
|
||||
'no-new': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-func': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-object': 2,
|
||||
// RATIONALE: Obsolete notation.
|
||||
'no-new-wrappers': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-octal': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'no-octal-escape': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-regex-spaces': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-return-assign': 2,
|
||||
// RATIONALE: Security risk.
|
||||
'no-script-url': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-self-assign': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-self-compare': 2,
|
||||
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
|
||||
// commas to create compound expressions. In general code is more readable if each
|
||||
// step is split onto a separate line. This also makes it easier to set breakpoints
|
||||
// in the debugger.
|
||||
'no-sequences': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-shadow-restricted-names': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-sparse-arrays': 2,
|
||||
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
|
||||
// such flexibility adds pointless complexity, by requiring every catch block to test
|
||||
// the type of the object that it receives. Whereas if catch blocks can always assume
|
||||
// that their object implements the "Error" contract, then the code is simpler, and
|
||||
// we generally get useful additional information like a call stack.
|
||||
'no-throw-literal': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unmodified-loop-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unsafe-finally': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unused-expressions': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unused-labels': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-useless-catch': 1,
|
||||
// RATIONALE: Avoids a potential performance problem.
|
||||
'no-useless-concat': 1,
|
||||
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
|
||||
// Always use "let" or "const" instead.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'no-var': 2,
|
||||
// RATIONALE: Generally not needed in modern code.
|
||||
'no-void': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-with': 2,
|
||||
// RATIONALE: Makes logic easier to understand, since constants always have a known value
|
||||
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
|
||||
'prefer-const': 1,
|
||||
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
|
||||
'promise/param-names': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-atomic-updates': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-yield': 1,
|
||||
// "Use strict" is redundant when using the TypeScript compiler.
|
||||
'strict': [
|
||||
2,
|
||||
'never'
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'use-isnan': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
// Rationale to disable: !!{}
|
||||
'no-extra-boolean-cast': 0,
|
||||
// ====================================================================
|
||||
// @microsoft/eslint-plugin-spfx
|
||||
// ====================================================================
|
||||
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||
'@microsoft/spfx/no-require-ensure': 2,
|
||||
'@microsoft/spfx/pair-react-dom-render-unmount': 1
|
||||
}
|
||||
},
|
||||
{
|
||||
// For unit tests, we can be a little bit less strict. The settings below revise the
|
||||
// defaults specified in the extended configurations, as well as above.
|
||||
files: [
|
||||
// Test files
|
||||
'*.test.ts',
|
||||
'*.test.tsx',
|
||||
'*.spec.ts',
|
||||
'*.spec.tsx',
|
||||
|
||||
// Facebook convention
|
||||
'**/__mocks__/*.ts',
|
||||
'**/__mocks__/*.tsx',
|
||||
'**/__tests__/*.ts',
|
||||
'**/__tests__/*.tsx',
|
||||
|
||||
// Microsoft convention
|
||||
'**/test/*.ts',
|
||||
'**/test/*.tsx'
|
||||
],
|
||||
rules: {}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
release
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
.heft
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -0,0 +1 @@
|
|||
v18.17.1
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"plusBeta": false,
|
||||
"isCreatingSolution": false,
|
||||
"nodeVersion": "18.17.1",
|
||||
"sdksVersions": {
|
||||
"@microsoft/microsoft-graph-client": "3.0.2",
|
||||
"@microsoft/teams-js": "2.12.0"
|
||||
},
|
||||
"version": "1.18.2",
|
||||
"libraryName": "app-insights-spfx-webparts",
|
||||
"libraryId": "27b8ab0e-bb2e-4ba5-90e7-ee50b5419c0f",
|
||||
"environment": "spo",
|
||||
"packageManager": "npm",
|
||||
"solutionName": "app-insights-spfx-webparts",
|
||||
"solutionShortDescription": "app-insights-spfx-webparts description",
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
# Application Insights not only a Dev Tool
|
||||
|
||||
## Summary
|
||||
|
||||
Application Insights provides telemetry data to monitor and improve application performance and user experience, while AB Testing, user flow analysis, and logging help in optimizing and debugging applications by comparing different versions, mapping user paths, and recording significant events. The 3 sample web part demonstrates web part functionalities to aid developers in integrating customizable components effectively.
|
||||
|
||||
![UserFlow by Session](assets/SampleRouterUserFlow.png)
|
||||
|
||||
more details after the `Features` section
|
||||
|
||||
## Compatibility
|
||||
|
||||
| :warning: Important |
|
||||
|:---------------------------|
|
||||
| Every SPFx version is optimally compatible with specific versions of Node.js. In order to be able to build this sample, you need to ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
This sample is optimally compatible with the following environment configuration:
|
||||
|
||||
![SPFx 1.18.2](https://img.shields.io/badge/SPFx-1.18.2-green.svg)
|
||||
![Node.js v16 | v18](https://img.shields.io/badge/Node.js-v16%20%7C%20v18-green.svg)
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above")
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
- [SharePoint Framework](https://aka.ms/spfx)
|
||||
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
|
||||
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||
|
||||
## Contributors
|
||||
|
||||
* [Peter Paul Kirschner](https://github.com/petkir)
|
||||
|
||||
## Version history
|
||||
|
||||
| Version | Date | Comments |
|
||||
| ------- | ---------------- | --------------- |
|
||||
| 1.0 | Mai 26, 2024 | Initial release |
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Application Insight Service on Azure
|
||||
Add the connection string of this Service to the the variable ```AIConnectionString``` at ```src/EnvProps.ts```
|
||||
|
||||
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Clone this repository
|
||||
- Ensure that you are at the solution folder
|
||||
- Create or use Existing Azure Application Insights
|
||||
- Update `src/EnvProps.ts` and set `AIConnectionString`
|
||||
- in the command-line run:
|
||||
- `npm install`
|
||||
- `gulp serve`
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
Description of the extension that expands upon high-level summary above.
|
||||
|
||||
This extension illustrates the following concepts:
|
||||
|
||||
- Sample Router WebPart
|
||||
- Using Hash Router and use Page Tracking
|
||||
- ABTest WebPart (check User activity)
|
||||
- Event Tracking
|
||||
- Logging
|
||||
- PnP JS Logger
|
||||
- Logging with PnPJS
|
||||
|
||||
|
||||
## Sample Router WebPart
|
||||
|
||||
How is your application used by Users
|
||||
|
||||
![Sample WebPart Screen](assets/SampleRouterUI.png)
|
||||
|
||||
Analyze in Application Insight
|
||||
|
||||
![UserFlow by Session](assets/SampleRouterUserFlow.png)
|
||||
|
||||
Query in Application Insights Count PageViews
|
||||
|
||||
```
|
||||
pageViews
|
||||
| where name contains "Page"
|
||||
| where cloud_RoleName contains "app-insights-spfx-webparts"
|
||||
| where cloud_RoleInstance contains "SampleRouterWebPart"
|
||||
| where timestamp >= ago(8h)
|
||||
| summarize count() by name
|
||||
| render barchart
|
||||
```
|
||||
|
||||
![Page visit count evaluation](assets/SampleRouterEvaluation.png)
|
||||
|
||||
Query in Application Insights Average Page visit duration by PageName
|
||||
|
||||
```
|
||||
customMetrics
|
||||
| where name contains "PageVisitTime"
|
||||
| where customDimensions.PageName contains "Page"
|
||||
| where cloud_RoleName contains "app-insights-spfx-webparts"
|
||||
| where cloud_RoleInstance contains "SampleRouterWebPart"
|
||||
| where timestamp >= ago(8h)
|
||||
| summarize avg(value) by tostring(customDimensions.PageName)
|
||||
| render barchart
|
||||
```
|
||||
|
||||
![Page visit duration evaluation](assets/SampleRouterDurationEvaluation.png)
|
||||
|
||||
## AB-Test WebPart
|
||||
|
||||
How users add new items?
|
||||
|
||||
![AB UI Screen](assets/ABTextUI.png)
|
||||
|
||||
Query in Application Insights
|
||||
|
||||
```
|
||||
customEvents
|
||||
| where name contains "AddItem"
|
||||
| where cloud_RoleName contains "app-insights-spfx-webparts"
|
||||
| where cloud_RoleInstance contains "ABTestWebPart"
|
||||
| where timestamp >= ago(1h)
|
||||
| summarize count() by name
|
||||
| render barchart
|
||||
```
|
||||
|
||||
![AB Evaluation](assets/ABEvaluation.png)
|
||||
|
||||
## PnPJS Logger WebPart
|
||||
|
||||
![Logoutput with Browser Log Level Filter](assets/PNPJSLogger.png)
|
||||
|
||||
|
||||
## Help
|
||||
|
||||
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
|
||||
|
||||
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
|
||||
|
||||
You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20react-appinsights-usage%22) to see if anybody else is having the same issues.
|
||||
|
||||
You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-appinsights-usage) and see what the community is saying.
|
||||
|
||||
If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-appinsights-usage&template=bug-report.yml&sample=react-appinsights-usage&authors=@petkir&title=react-appinsights-usage%20-%20).
|
||||
|
||||
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-appinsights-usage&template=question.yml&sample=react-appinsights-usage&authors=@petkir&title=react-appinsights-usage%20-%20).
|
||||
|
||||
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-appinsights-usage&template=suggestion.yml&sample=react-appinsights-usage&authors=@petkir&title=react-appinsights-usage%20-%20).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-appinsights-usage" />
|
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 50 KiB |
|
@ -0,0 +1,112 @@
|
|||
[
|
||||
{
|
||||
"name": "pnp-sp-dev-spfx-web-parts-react-appinsights-usage",
|
||||
"source": "pnp",
|
||||
"title": "React AppInsights Usage WebParts",
|
||||
"shortDescription": "This web parts shows different use cases for capturing data in your application and store it into the Azure Application Insights service.",
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-appinsights-usage",
|
||||
"longDescription": [
|
||||
"This web parts shows different use cases for capturing data in your application. Azure Application Insights is more than only Logging and Tracing. It can be used to analyse data and display them in a graphical representation."
|
||||
],
|
||||
"creationDateTime": "2024-05-26",
|
||||
"updateDateTime": "2024-05-26",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"key": "CLIENT-SIDE-DEV",
|
||||
"value": "React"
|
||||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.18.2"
|
||||
},
|
||||
{
|
||||
"key": "SPFX-FULLPAGEAPP",
|
||||
"value": "true"
|
||||
},
|
||||
{
|
||||
"key": "PNPCONTROLS",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
{
|
||||
"type": "image",
|
||||
"order": 100,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-appinsights-dashboard/assets/AppInsights_Dashboard.gif",
|
||||
"alt": "React AppInsights Dashboard"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 101,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/ABEvaluation.png?raw=true",
|
||||
"alt": "AppInsights AB Test Chart"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 102,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/ABTextUI.png?raw=true",
|
||||
"alt": "AppInsights AB Test UI"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 103,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/PNPJSLogger.png?raw=true",
|
||||
"alt": "Logger in Terminal"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 104,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/SampleRouterDurationEvaluation.png?raw=true",
|
||||
"alt": "AppInsights Page visit average duration Chart"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 105,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/SampleRouterEvaluation.png?raw=true",
|
||||
"alt": "AppInsights Page visit count Chart"
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"order": 105,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/blob/main/samples/react-appinsights-usage/assets/SampleRouterUserFlow.png?raw=true",
|
||||
"alt": "AppInsights User Flow"
|
||||
}
|
||||
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"gitHubAccount": "petkir",
|
||||
"company": "ACP CUBIDO Digital Solutions GmbH",
|
||||
"pictureUrl": "https://github.com/petkir.png",
|
||||
"name": "Peter Paul Kirschner",
|
||||
"twitter": "petkir_at"
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"name": "Build your first SharePoint client-side web part",
|
||||
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
|
||||
"url": "https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
|
||||
},
|
||||
{
|
||||
"name": "Using single part app pages in SharePoint Online",
|
||||
"description": "Single part app pages provide a capability to host SharePoint Framework web parts or Microsoft Teams applications in SharePoint Online with a locked layout. End users cannot modify or configure the page that is using the Single Part App Page layout.",
|
||||
"url": "https://learn.microsoft.com/sharepoint/dev/spfx/web-parts/single-part-app-pages?tabs=pnpposh"
|
||||
},
|
||||
{
|
||||
"name": "PNPJS Understanding the Logging Framework",
|
||||
"description": "The logging framework is centered on the Logger class to which any number of listeners can be subscribed. Each of these listeners will receive each of the messages logged. Each listener must implement the ILogListener interface",
|
||||
"url": "https://pnp.github.io/pnpjs/logging/"
|
||||
},
|
||||
{
|
||||
"name": "Application Insights",
|
||||
"description": "Application Insights provides many experiences to enhance the performance, reliability, and quality of your applications.",
|
||||
"url": "https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"sample-router-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/sampleRouter/SampleRouterWebPart.js",
|
||||
"manifest": "./src/webparts/sampleRouter/SampleRouterWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ab-test-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/abTest/AbTestWebPart.js",
|
||||
"manifest": "./src/webparts/abTest/AbTestWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pn-pjs-logger-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/pnPjsLogger/PnPjsLoggerWebPart.js",
|
||||
"manifest": "./src/webparts/pnPjsLogger/PnPjsLoggerWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"SampleRouterWebPartStrings": "lib/webparts/sampleRouter/loc/{locale}.js",
|
||||
"AbTestWebPartStrings": "lib/webparts/abTest/loc/{locale}.js",
|
||||
"PnPjsLoggerWebPartStrings": "lib/webparts/pnPjsLogger/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "app-insights-spfx-webparts",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "app-insights-spfx-webparts-client-side-solution",
|
||||
"id": "27b8ab0e-bb2e-4ba5-90e7-ee50b5419c0f",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"developer": {
|
||||
"name": "",
|
||||
"websiteUrl": "",
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "Undefined-1.18.2"
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "app-insights-spfx-webparts description"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "app-insights-spfx-webparts description"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "app-insights-spfx-webparts Feature",
|
||||
"description": "The feature that activates elements of the app-insights-spfx-webparts solution.",
|
||||
"id": "f6d484c8-f321-4c90-bc8b-58578c4c3431",
|
||||
"version": "1.0.0.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/app-insights-spfx-webparts.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,18 @@
|
|||
## Login
|
||||
```bash
|
||||
az login
|
||||
az account set --subscription "..."
|
||||
az group list
|
||||
```
|
||||
|
||||
## Create Resource Group
|
||||
```bash
|
||||
az group create --name 'rg-appinsight' --location eastus
|
||||
```
|
||||
|
||||
## Create Resources
|
||||
|
||||
```bash
|
||||
az deployment group create --resource-group 'rg-appinsight' --template-file main.bicep `
|
||||
--parameters
|
||||
```
|
|
@ -0,0 +1,18 @@
|
|||
//gernerate application insights as iac and get as output instrumentation key
|
||||
|
||||
param location string = resourceGroup().location
|
||||
param appInsightsName string = 'ai-${replace(resourceGroup().name, 'rg-', '')}'
|
||||
|
||||
|
||||
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
|
||||
name: appInsightsName
|
||||
location: location
|
||||
kind: 'web'
|
||||
properties: {
|
||||
Application_Type: 'web'
|
||||
}
|
||||
}
|
||||
|
||||
output aiKey string = appInsights.properties.InstrumentationKey
|
||||
output aiConnectionString string = appInsights.properties.ConnectionString
|
||||
output aiName string = appInsights.name
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "app-insights-spfx-webparts",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluentui/react": "^8.106.4",
|
||||
"@microsoft/applicationinsights-react-js": "^17.2.0",
|
||||
"@microsoft/applicationinsights-web": "^3.2.1",
|
||||
"@microsoft/sp-component-base": "1.18.2",
|
||||
"@microsoft/sp-core-library": "1.18.2",
|
||||
"@microsoft/sp-lodash-subset": "1.18.2",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.18.2",
|
||||
"@microsoft/sp-property-pane": "1.18.2",
|
||||
"@microsoft/sp-webpart-base": "1.18.2",
|
||||
"@pnp/logging": "^4.0.1",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"tslib": "2.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/eslint-config-spfx": "1.18.2",
|
||||
"@microsoft/eslint-plugin-spfx": "1.18.2",
|
||||
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
|
||||
"@microsoft/sp-build-web": "1.18.2",
|
||||
"@microsoft/sp-module-interfaces": "1.18.2",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webpack-env": "~1.15.2",
|
||||
"ajv": "^6.12.5",
|
||||
"eslint": "8.7.0",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"react-router-dom": "^6.23.1",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export const AIConnectionString = 'set-your-connection-string-here';
|
||||
|
||||
export const Version="1";
|
||||
export const Build ="4021";
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "8be16228-e6d7-4d49-a6d9-2466ae27e9c8",
|
||||
"alias": "AbTestWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "ABTest" },
|
||||
"description": { "default": "ABTest description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "ABTest"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
type IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
import * as strings from 'AbTestWebPartStrings';
|
||||
import AbTest from './components/AbTest';
|
||||
import { IAbTestProps } from './components/IAbTestProps';
|
||||
import { ApplicationInsights, DistributedTracingModes, ITelemetryItem, SeverityLevel } from '@microsoft/applicationinsights-web';
|
||||
import { AIConnectionString } from '../../EnvProps';
|
||||
import { AILogLevel, IAILogEntry } from './components/IAILogEntry';
|
||||
|
||||
export interface IAbTestWebPartProps {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default class AbTestWebPart extends BaseClientSideWebPart<IAbTestWebPartProps> {
|
||||
|
||||
private _isDarkTheme: boolean = false;
|
||||
private _environmentMessage: string = '';
|
||||
private _appInsights: ApplicationInsights;
|
||||
|
||||
public render(): void {
|
||||
|
||||
const element: React.ReactElement<IAbTestProps> = React.createElement(
|
||||
AbTest,
|
||||
{
|
||||
description: this.properties.description,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
userDisplayName: this.context.pageContext.user.displayName,
|
||||
trackEvent: (eventName: string, properties?: { [key: string]: string }) =>
|
||||
this._appInsights.trackEvent({ name: eventName }, properties),
|
||||
log: this.log.bind(this)
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
const allAsynCalls = []
|
||||
allAsynCalls.push(this._getEnvironmentMessage().then(message => {
|
||||
this._environmentMessage = message;
|
||||
})
|
||||
)
|
||||
|
||||
const userId: string = this.context.pageContext.user.loginName.replace(/([\\|:;=])/g, '');
|
||||
|
||||
// App Insights JS Documentation: https://github.com/microsoft/applicationinsights-js
|
||||
this._appInsights = new ApplicationInsights({
|
||||
config: {
|
||||
connectionString: AIConnectionString,
|
||||
accountId: userId,
|
||||
disableFetchTracking: false,
|
||||
enableRequestHeaderTracking: true,
|
||||
enableResponseHeaderTracking: true,
|
||||
enableAjaxErrorStatusText: true,
|
||||
enableAjaxPerfTracking: true,
|
||||
enableUnhandledPromiseRejectionTracking: true,
|
||||
enableCorsCorrelation: true,
|
||||
disableExceptionTracking: false,
|
||||
distributedTracingMode: DistributedTracingModes.AI
|
||||
}
|
||||
});
|
||||
|
||||
this._appInsights.loadAppInsights();
|
||||
this._appInsights.addTelemetryInitializer(this._appInsightsInitializer);
|
||||
this._appInsights.setAuthenticatedUserContext(userId, userId, true);
|
||||
this._appInsights.trackPageView();
|
||||
|
||||
return Promise.all(allAsynCalls).then(() => {
|
||||
return super.onInit();
|
||||
});
|
||||
}
|
||||
|
||||
private _appInsightsInitializer = (telemetryItem: ITelemetryItem): boolean | void => {
|
||||
if (telemetryItem) {
|
||||
if (!telemetryItem.tags) telemetryItem.tags = {};
|
||||
telemetryItem.tags['ai.cloud.role'] = "app-insights-spfx-webparts";
|
||||
telemetryItem.tags['ai.cloud.roleInstance'] = "ABTestWebPart";
|
||||
|
||||
if (telemetryItem.baseType === 'RemoteDependencyData' && telemetryItem.baseData?.target) {
|
||||
const isExcluded = telemetryItem.baseData.target.toLowerCase().indexOf('my_un_monitored_api ') !== -1;
|
||||
if (isExcluded) return false; // don't track
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _getEnvironmentMessage(): Promise<string> {
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||
.then(context => {
|
||||
let environmentMessage: string = '';
|
||||
switch (context.app.host.name) {
|
||||
case 'Office': // running in Office
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||
break;
|
||||
case 'Outlook': // running in Outlook
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
|
||||
break;
|
||||
case 'Teams': // running in Teams
|
||||
case 'TeamsModern':
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||
break;
|
||||
default:
|
||||
environmentMessage = strings.UnknownEnvironment;
|
||||
}
|
||||
|
||||
return environmentMessage;
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
const {
|
||||
semanticColors
|
||||
} = currentTheme;
|
||||
|
||||
if (semanticColors) {
|
||||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
|
||||
this.domElement.style.setProperty('--link', semanticColors.link || null);
|
||||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
private _logMessageFormat(entry: IAILogEntry): string {
|
||||
// const date = entry.timestamp ? entry.timestamp.toISOString() : new Date().toISOString();
|
||||
const msg = `${entry.message}`;
|
||||
return msg;
|
||||
}
|
||||
|
||||
private getAdditionalProperties(): { [key: string]: string } {
|
||||
return {};
|
||||
}
|
||||
|
||||
private log(entry: IAILogEntry): void {
|
||||
const msg = this._logMessageFormat(entry);
|
||||
if (entry.level === AILogLevel.Off) {
|
||||
// No log required since the level is Off
|
||||
return;
|
||||
}
|
||||
const additionalProperties = {...this.getAdditionalProperties(),...entry.properties};
|
||||
|
||||
if (this._appInsights) {
|
||||
switch (entry.level) {
|
||||
case AILogLevel.Verbose:
|
||||
this._appInsights.trackTrace({ message: msg, severityLevel: SeverityLevel.Verbose }, additionalProperties);
|
||||
console.log({ ...additionalProperties, Message: msg });
|
||||
break;
|
||||
case AILogLevel.Info:
|
||||
this._appInsights.trackTrace({ message: msg, severityLevel: SeverityLevel.Information }, additionalProperties);
|
||||
console.log({ ...additionalProperties, Message: msg });
|
||||
break;
|
||||
case AILogLevel.Warning:
|
||||
this._appInsights.trackTrace({ message: msg, severityLevel: SeverityLevel.Warning }, additionalProperties);
|
||||
console.warn({ ...additionalProperties, Message: msg });
|
||||
break;
|
||||
case AILogLevel.Error:
|
||||
this._appInsights.trackException({ error: new Error(msg), exception: entry.exception, severityLevel: SeverityLevel.Error },additionalProperties);
|
||||
console.error({ ...additionalProperties, Message: msg });
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('description', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,34 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.abTest {
|
||||
overflow: hidden;
|
||||
padding: 1em;
|
||||
color: "[theme:bodyText, default: #323130]";
|
||||
color: var(--bodyText);
|
||||
&.teams {
|
||||
font-family: $ms-font-family-fallbacks;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcomeImage {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.links {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: "[theme:link, default:#03787c]";
|
||||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: "[theme:linkHovered, default: #014446]";
|
||||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
import * as React from 'react';
|
||||
import styles from './AbTest.module.scss';
|
||||
import type { IAbTestProps } from './IAbTestProps';
|
||||
|
||||
import { ActionButton, CommandBar, DocumentCard, DocumentCardDetails, DocumentCardPreview, DocumentCardTitle, DocumentCardType, ICommandBarItemProps, ImageFit, TextField } from '@fluentui/react';
|
||||
import { AILogLevel } from './IAILogEntry';
|
||||
import { AddItemCalendar } from './AddItemCalendar';
|
||||
|
||||
|
||||
export interface IAbTestState {
|
||||
carditems: string[];
|
||||
textinput?: string;
|
||||
showAddDialog: boolean;
|
||||
}
|
||||
|
||||
export default class AbTest extends React.Component<IAbTestProps, IAbTestState> {
|
||||
constructor(props: IAbTestProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
carditems: ['item1', 'item2', 'item3'],
|
||||
showAddDialog: false
|
||||
};
|
||||
}
|
||||
|
||||
public override componentDidMount(): void {
|
||||
this.props.log({
|
||||
level: AILogLevel.Info,
|
||||
message: 'Component mounted',
|
||||
properties: { componentDidMount: 'true' }
|
||||
});
|
||||
}
|
||||
|
||||
public render(): React.ReactElement<IAbTestProps> {
|
||||
const {
|
||||
hasTeamsContext,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
|
||||
<section className={`${styles.abTest} ${hasTeamsContext ? styles.teams : ''}`}>
|
||||
<div className={styles.welcome}>
|
||||
<CommandBar
|
||||
items={this._items}
|
||||
/>
|
||||
{this.state.showAddDialog && <AddItemCalendar />}
|
||||
<div>
|
||||
{this.state.carditems.map((item, index) => {
|
||||
return (<DocumentCard key={index}
|
||||
type={DocumentCardType.compact}
|
||||
>
|
||||
<DocumentCardPreview
|
||||
previewImages={[{ previewImageSrc: `https://picsum.photos/id/${index}/100/100`, width: 100, height: 100, imageFit: ImageFit.cover, }]} />
|
||||
<DocumentCardDetails>
|
||||
<DocumentCardTitle title={item} shouldTruncate />
|
||||
</DocumentCardDetails>
|
||||
</DocumentCard>
|
||||
);
|
||||
})}
|
||||
<DocumentCard key={'New Item'}
|
||||
type={DocumentCardType.compact}
|
||||
>
|
||||
|
||||
<DocumentCardDetails>
|
||||
Add New item:
|
||||
<TextField onChange={(e, v) => { this.setState({ textinput: v }); }} />
|
||||
<ActionButton onClick={() => {
|
||||
this.props.trackEvent('AddItemWebPartContext');
|
||||
if (this.state.textinput) {
|
||||
this.state.carditems.push(this.state.textinput);
|
||||
this.setState({ carditems: this.state.carditems, textinput: '' });
|
||||
|
||||
}
|
||||
}} text='Add Item' />
|
||||
</DocumentCardDetails>
|
||||
</DocumentCard>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
public override componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
|
||||
|
||||
this.props.log({
|
||||
level: AILogLevel.Error,
|
||||
message: error.message,
|
||||
exception: error,
|
||||
properties: { componentDidCatch: errorInfo.componentStack }
|
||||
});
|
||||
alert('An error occurred'+ error);
|
||||
}
|
||||
private _items: ICommandBarItemProps[] = [
|
||||
{
|
||||
key: 'action1',
|
||||
text: 'New',
|
||||
iconProps: { iconName: 'Add' },
|
||||
subMenuProps: {
|
||||
items: [
|
||||
{
|
||||
key: 'action1_1', text: 'Add Item', iconProps: { iconName: 'Mail' },
|
||||
onClick: () => {
|
||||
this.props.trackEvent('AddItemContextualMenu');
|
||||
this.state.carditems.push('New Item' + (this.state.carditems.length + 1));
|
||||
this.setState({ carditems: this.state.carditems });
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'action1_2', text: 'Calendar event', iconProps: { iconName: 'Calendar' },
|
||||
onClick: () => { this.setState({ showAddDialog: true }); }
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
import * as React from 'react';
|
||||
|
||||
export function AddItemCalendar(): JSX.Element {
|
||||
throw new Error("Add Dialog for Calendar event not implemented yet.");
|
||||
return (
|
||||
<div />
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
export interface IAILogEntry
|
||||
{
|
||||
level: AILogLevel;
|
||||
message: string;
|
||||
properties?: { [key: string]: string };
|
||||
measurements?: { [key: string]: number };
|
||||
exception?: Error;
|
||||
timestamp?: Date;
|
||||
}
|
||||
|
||||
export enum AILogLevel{
|
||||
Off,
|
||||
Verbose,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Critical
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { IAILogEntry } from "./IAILogEntry";
|
||||
|
||||
export interface IAbTestProps {
|
||||
description: string;
|
||||
isDarkTheme: boolean;
|
||||
environmentMessage: string;
|
||||
hasTeamsContext: boolean;
|
||||
userDisplayName: string;
|
||||
trackEvent: (eventName: string, properties?: { [key: string]: string }) => void;
|
||||
log:(entry: IAILogEntry)=> void;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field",
|
||||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
|
||||
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
|
||||
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
|
||||
"AppOfficeEnvironment": "The app is running in office.com",
|
||||
"AppOutlookEnvironment": "The app is running in Outlook",
|
||||
"UnknownEnvironment": "The app is running in an unknown environment"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
declare interface IAbTestWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
AppLocalEnvironmentSharePoint: string;
|
||||
AppLocalEnvironmentTeams: string;
|
||||
AppLocalEnvironmentOffice: string;
|
||||
AppLocalEnvironmentOutlook: string;
|
||||
AppSharePointEnvironment: string;
|
||||
AppTeamsTabEnvironment: string;
|
||||
AppOfficeEnvironment: string;
|
||||
AppOutlookEnvironment: string;
|
||||
UnknownEnvironment: string;
|
||||
}
|
||||
|
||||
declare module 'AbTestWebPartStrings' {
|
||||
const strings: IAbTestWebPartStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "d7a67fb2-5c34-4b5b-bd48-9febef735d70",
|
||||
"alias": "PnPjsLoggerWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "PnPJS Logger" },
|
||||
"description": { "default": "PnPJS Logger description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "PnPJS Logger"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
type IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
import * as strings from 'PnPjsLoggerWebPartStrings';
|
||||
import PnPjsLogger from './components/PnPjsLogger';
|
||||
import { IPnPjsLoggerProps } from './components/IPnPjsLoggerProps';
|
||||
import { ApplicationInsights, DistributedTracingModes, ITelemetryItem } from '@microsoft/applicationinsights-web';
|
||||
import { ConsoleListener, LogLevel, Logger } from '@pnp/logging';
|
||||
import { AppInsightListener } from './listener/appinsight-loglistener';
|
||||
import { AIConnectionString } from '../../EnvProps';
|
||||
|
||||
export interface IPnPjsLoggerWebPartProps {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default class PnPjsLoggerWebPart extends BaseClientSideWebPart<IPnPjsLoggerWebPartProps> {
|
||||
|
||||
private _isDarkTheme: boolean = false;
|
||||
private _environmentMessage: string = '';
|
||||
private _appInsights: ApplicationInsights;
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IPnPjsLoggerProps> = React.createElement(
|
||||
PnPjsLogger,
|
||||
{
|
||||
description: this.properties.description,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
userDisplayName: this.context.pageContext.user.displayName
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected onInit(): Promise<void> {
|
||||
const allAsynCalls = []
|
||||
allAsynCalls.push(this._getEnvironmentMessage().then(message => {
|
||||
this._environmentMessage = message;
|
||||
})
|
||||
)
|
||||
|
||||
const userId: string = this.context.pageContext.user.loginName.replace(/([\\|:;=])/g, '');
|
||||
|
||||
// App Insights JS Documentation: https://github.com/microsoft/applicationinsights-js
|
||||
this._appInsights = new ApplicationInsights({
|
||||
config: {
|
||||
connectionString: AIConnectionString,
|
||||
accountId: userId,
|
||||
disableFetchTracking: false,
|
||||
enableRequestHeaderTracking: true,
|
||||
enableResponseHeaderTracking: true,
|
||||
enableAjaxErrorStatusText: true,
|
||||
enableAjaxPerfTracking: true,
|
||||
enableUnhandledPromiseRejectionTracking: true,
|
||||
enableCorsCorrelation: true,
|
||||
disableExceptionTracking: false,
|
||||
distributedTracingMode: DistributedTracingModes.AI
|
||||
}
|
||||
});
|
||||
|
||||
this._appInsights.loadAppInsights();
|
||||
this._appInsights.addTelemetryInitializer(this._appInsightsInitializer);
|
||||
this._appInsights.setAuthenticatedUserContext(userId, userId, true);
|
||||
this._appInsights.trackPageView();
|
||||
|
||||
Logger.subscribe(new AppInsightListener(this._appInsights));
|
||||
Logger.subscribe( ConsoleListener("pnpjs"));
|
||||
Logger.activeLogLevel = LogLevel.Info;
|
||||
|
||||
return Promise.all(allAsynCalls).then(() => {
|
||||
return super.onInit();
|
||||
});
|
||||
}
|
||||
|
||||
private _appInsightsInitializer = (telemetryItem: ITelemetryItem): boolean | void => {
|
||||
if (telemetryItem) {
|
||||
if (!telemetryItem.tags) telemetryItem.tags = {};
|
||||
telemetryItem.tags['ai.cloud.role'] = "app-insights-spfx-webparts";
|
||||
telemetryItem.tags['ai.cloud.roleInstance'] = "PnPjsLoggerWebPart";
|
||||
|
||||
if (telemetryItem.baseType === 'RemoteDependencyData' && telemetryItem.baseData?.target) {
|
||||
const isExcluded = telemetryItem.baseData.target.toLowerCase().indexOf('my_un_monitored_api ') !== -1;
|
||||
if (isExcluded) return false; // don't track
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private _getEnvironmentMessage(): Promise<string> {
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||
.then(context => {
|
||||
let environmentMessage: string = '';
|
||||
switch (context.app.host.name) {
|
||||
case 'Office': // running in Office
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||
break;
|
||||
case 'Outlook': // running in Outlook
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
|
||||
break;
|
||||
case 'Teams': // running in Teams
|
||||
case 'TeamsModern':
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||
break;
|
||||
default:
|
||||
environmentMessage = strings.UnknownEnvironment;
|
||||
}
|
||||
|
||||
return environmentMessage;
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
const {
|
||||
semanticColors
|
||||
} = currentTheme;
|
||||
|
||||
if (semanticColors) {
|
||||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
|
||||
this.domElement.style.setProperty('--link', semanticColors.link || null);
|
||||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('description', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,7 @@
|
|||
export interface IPnPjsLoggerProps {
|
||||
description: string;
|
||||
isDarkTheme: boolean;
|
||||
environmentMessage: string;
|
||||
hasTeamsContext: boolean;
|
||||
userDisplayName: string;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.pnPjsLogger {
|
||||
overflow: hidden;
|
||||
padding: 1em;
|
||||
color: "[theme:bodyText, default: #323130]";
|
||||
color: var(--bodyText);
|
||||
&.teams {
|
||||
font-family: $ms-font-family-fallbacks;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcomeImage {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.links {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: "[theme:link, default:#03787c]";
|
||||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: "[theme:linkHovered, default: #014446]";
|
||||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
import * as React from 'react';
|
||||
import styles from './PnPjsLogger.module.scss';
|
||||
import type { IPnPjsLoggerProps } from './IPnPjsLoggerProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
import { LogLevel, Logger } from '@pnp/logging';
|
||||
import { ActionButton } from '@fluentui/react';
|
||||
|
||||
export default class PnPjsLogger extends React.Component<IPnPjsLoggerProps, {}> {
|
||||
constructor(props: IPnPjsLoggerProps) {
|
||||
super(props);
|
||||
Logger.writeJSON(this.props, LogLevel.Info);
|
||||
}
|
||||
public render(): React.ReactElement<IPnPjsLoggerProps> {
|
||||
Logger.write("PnPjsLogger:Render", LogLevel.Info);
|
||||
|
||||
const {
|
||||
description,
|
||||
isDarkTheme,
|
||||
environmentMessage,
|
||||
hasTeamsContext,
|
||||
userDisplayName
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<section className={`${styles.pnPjsLogger} ${hasTeamsContext ? styles.teams : ''}`}>
|
||||
<div className={styles.welcome}>
|
||||
<img alt="" src={isDarkTheme ? require('../assets/welcome-dark.png') : require('../assets/welcome-light.png')} className={styles.welcomeImage} />
|
||||
<h2>Well done, {escape(userDisplayName)}!</h2>
|
||||
<div>{environmentMessage}</div>
|
||||
<div>Web part property value: <strong>{escape(description)}</strong></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Logging Actions</h3>
|
||||
<ul className={styles.links}>
|
||||
<li>
|
||||
<ActionButton onClick={() => Logger.write("PnPjsLogger:ActionButtonClick_Verbose", LogLevel.Verbose)}>Log Verbose</ActionButton>
|
||||
</li>
|
||||
<li>
|
||||
<ActionButton onClick={() => Logger.write("PnPjsLogger:ActionButtonClick_Info", LogLevel.Info)}>Log Info</ActionButton>
|
||||
</li>
|
||||
<li>
|
||||
<ActionButton onClick={() => Logger.write("PnPjsLogger:ActionButtonClick_Warning", LogLevel.Warning)}>Log Warning</ActionButton>
|
||||
</li>
|
||||
<li>
|
||||
<ActionButton onClick={() => Logger.write("PnPjsLogger:ActionButtonClick_Error", LogLevel.Error)}>Log Error</ActionButton>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import { ApplicationInsights, SeverityLevel } from "@microsoft/applicationinsights-web";
|
||||
import { ILogEntry, ILogListener, LogLevel } from "@pnp/logging";
|
||||
|
||||
export class AppInsightListener implements ILogListener {
|
||||
private appInsights: ApplicationInsights;
|
||||
constructor(appInsights: ApplicationInsights) {
|
||||
this.appInsights = appInsights;
|
||||
}
|
||||
|
||||
log(entry: ILogEntry): void {
|
||||
if (entry.level === LogLevel.Error)
|
||||
this.appInsights.trackException({ error: new Error(entry.message), severityLevel: SeverityLevel.Error });
|
||||
else if (entry.level === LogLevel.Warning)
|
||||
this.appInsights.trackException({ error: new Error(entry.message), severityLevel: SeverityLevel.Warning });
|
||||
else if (entry.level === LogLevel.Info)
|
||||
this.appInsights.trackException({ error: new Error(entry.message), severityLevel: SeverityLevel.Information });
|
||||
else
|
||||
this.appInsights.trackException({ error: new Error(entry.message), severityLevel: SeverityLevel.Verbose });
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field",
|
||||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
|
||||
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
|
||||
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
|
||||
"AppOfficeEnvironment": "The app is running in office.com",
|
||||
"AppOutlookEnvironment": "The app is running in Outlook",
|
||||
"UnknownEnvironment": "The app is running in an unknown environment"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
declare interface IPnPjsLoggerWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
AppLocalEnvironmentSharePoint: string;
|
||||
AppLocalEnvironmentTeams: string;
|
||||
AppLocalEnvironmentOffice: string;
|
||||
AppLocalEnvironmentOutlook: string;
|
||||
AppSharePointEnvironment: string;
|
||||
AppTeamsTabEnvironment: string;
|
||||
AppOfficeEnvironment: string;
|
||||
AppOutlookEnvironment: string;
|
||||
UnknownEnvironment: string;
|
||||
}
|
||||
|
||||
declare module 'PnPjsLoggerWebPartStrings' {
|
||||
const strings: IPnPjsLoggerWebPartStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "133b3fc0-beeb-4d1b-bb49-01d911d3a6c0",
|
||||
"alias": "SampleRouterWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "SampleRouter" },
|
||||
"description": { "default": "SampleRouter description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "SampleRouter"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
type IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
|
||||
import * as strings from 'SampleRouterWebPartStrings';
|
||||
import SampleRouter from './components/SampleRouter';
|
||||
import { ISampleRouterProps } from './components/ISampleRouterProps';
|
||||
|
||||
import { ApplicationInsights, ITelemetryItem } from '@microsoft/applicationinsights-web';
|
||||
import { ReactPlugin } from '@microsoft/applicationinsights-react-js';
|
||||
import { AIConnectionString } from '../../EnvProps';
|
||||
|
||||
|
||||
|
||||
export interface ISampleRouterWebPartProps {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default class SampleRouterWebPart extends BaseClientSideWebPart<ISampleRouterWebPartProps> {
|
||||
|
||||
private _isDarkTheme: boolean = false;
|
||||
private _environmentMessage: string = '';
|
||||
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<ISampleRouterProps> = React.createElement(
|
||||
SampleRouter,
|
||||
{
|
||||
description: this.properties.description,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
userDisplayName:this.context.pageContext.user.displayName
|
||||
|
||||
}
|
||||
);
|
||||
const userId: string = this.context.pageContext.user.loginName.replace(/([\\|:;=])/g, '');
|
||||
|
||||
const reactPlugin = new ReactPlugin();
|
||||
const appInsights = new ApplicationInsights({
|
||||
config: {
|
||||
connectionString: AIConnectionString,
|
||||
accountId: userId,
|
||||
extensions: [reactPlugin],
|
||||
enableAutoRouteTracking: true,
|
||||
autoTrackPageVisitTime: true,
|
||||
}
|
||||
});
|
||||
appInsights.loadAppInsights();
|
||||
appInsights.addTelemetryInitializer((telemetryItem: ITelemetryItem) => {
|
||||
if (telemetryItem) {
|
||||
if (!telemetryItem.tags) telemetryItem.tags = {};
|
||||
telemetryItem.tags['ai.cloud.role'] = "app-insights-spfx-webparts";
|
||||
telemetryItem.tags['ai.cloud.roleInstance'] = "SampleRouterWebPart";
|
||||
}
|
||||
});
|
||||
appInsights.setAuthenticatedUserContext(userId, userId, true);
|
||||
appInsights.trackPageView();
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
|
||||
|
||||
}
|
||||
protected onInit(): Promise<void> {
|
||||
return this._getEnvironmentMessage().then(message => {
|
||||
this._environmentMessage = message;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private _getEnvironmentMessage(): Promise<string> {
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||
.then(context => {
|
||||
let environmentMessage: string = '';
|
||||
switch (context.app.host.name) {
|
||||
case 'Office': // running in Office
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||
break;
|
||||
case 'Outlook': // running in Outlook
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
|
||||
break;
|
||||
case 'Teams': // running in Teams
|
||||
case 'TeamsModern':
|
||||
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||
break;
|
||||
default:
|
||||
environmentMessage = strings.UnknownEnvironment;
|
||||
}
|
||||
|
||||
return environmentMessage;
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
|
||||
}
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
const {
|
||||
semanticColors
|
||||
} = currentTheme;
|
||||
|
||||
if (semanticColors) {
|
||||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
|
||||
this.domElement.style.setProperty('--link', semanticColors.link || null);
|
||||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('description', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,7 @@
|
|||
export interface ISampleRouterProps {
|
||||
description: string;
|
||||
isDarkTheme: boolean;
|
||||
environmentMessage: string;
|
||||
hasTeamsContext: boolean;
|
||||
userDisplayName: string;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.sampleRouter {
|
||||
overflow: hidden;
|
||||
padding: 1em;
|
||||
color: "[theme:bodyText, default: #323130]";
|
||||
color: var(--bodyText);
|
||||
&.teams {
|
||||
font-family: $ms-font-family-fallbacks;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcomeImage {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.links {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: "[theme:link, default:#03787c]";
|
||||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: "[theme:linkHovered, default: #014446]";
|
||||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
import * as React from 'react';
|
||||
import styles from './SampleRouter.module.scss';
|
||||
import type { ISampleRouterProps } from './ISampleRouterProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
import { Route, Routes,Link, HashRouter } from 'react-router-dom';
|
||||
|
||||
import { Page1 } from './pages/page1';
|
||||
import { Page2 } from './pages/page2';
|
||||
import { GenericPage } from './pages/genericPage';
|
||||
|
||||
|
||||
export default class SampleRouter extends React.Component<ISampleRouterProps, {}> {
|
||||
public render(): React.ReactElement<ISampleRouterProps> {
|
||||
const {
|
||||
|
||||
isDarkTheme,
|
||||
environmentMessage,
|
||||
hasTeamsContext,
|
||||
userDisplayName
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<HashRouter>
|
||||
<section className={`${styles.sampleRouter} ${hasTeamsContext ? styles.teams : ''}`}>
|
||||
<div className={styles.welcome}>
|
||||
<img alt="" src={isDarkTheme ? require('../assets/welcome-dark.png') : require('../assets/welcome-light.png')} className={styles.welcomeImage} />
|
||||
<h2>Well done, {escape(userDisplayName)}!</h2>
|
||||
<div>{environmentMessage}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>Sample Router!</h3>
|
||||
<ul className={styles.links}>
|
||||
<li><Link to="/">Home</Link> </li>
|
||||
<li><Link to="/page1">Page1</Link> </li>
|
||||
<li><Link to="/page2">Page2</Link> </li>
|
||||
<li><Link to="/page3">Page3</Link> </li>
|
||||
</ul>
|
||||
|
||||
<Routes>
|
||||
<Route path="/page1" Component={Page1} />
|
||||
<Route path="/page2" element={<Page2 />} />
|
||||
<Route path="/page3" element={<GenericPage headline='Page3' />} />
|
||||
<Route path="/" element={<GenericPage headline='StartPage' />} />
|
||||
</Routes>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</HashRouter>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
import * as React from 'react';
|
||||
|
||||
export interface IGenericPageProps {
|
||||
headline: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const GenericPage: React.FC<IGenericPageProps> = ({headline, children}) => {
|
||||
React.useEffect(() => {
|
||||
document.title = headline;
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
<h1>{headline}</h1>
|
||||
<div>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
import * as React from 'react';
|
||||
|
||||
|
||||
export const Page1: React.FC = () => {
|
||||
React.useEffect(() => {
|
||||
document.title = 'Page1';
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
<h1>Welcome To Page1</h1>
|
||||
<div>
|
||||
This is a sample page with a simple message.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
|
||||
|
||||
export const Page2: React.FC = () => {
|
||||
React.useEffect(() => {
|
||||
document.title = 'Page2';
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
<h1>Welcome To Page2</h1>
|
||||
<div>
|
||||
The page 2 is a simple page with a simple message.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec nisl ac justo lacinia ultricies.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field",
|
||||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
|
||||
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
|
||||
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
|
||||
"AppOfficeEnvironment": "The app is running in office.com",
|
||||
"AppOutlookEnvironment": "The app is running in Outlook",
|
||||
"UnknownEnvironment": "The app is running in an unknown environment"
|
||||
}
|
||||
});
|
19
samples/react-appinsights-usage/src/webparts/sampleRouter/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
declare interface ISampleRouterWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
AppLocalEnvironmentSharePoint: string;
|
||||
AppLocalEnvironmentTeams: string;
|
||||
AppLocalEnvironmentOffice: string;
|
||||
AppLocalEnvironmentOutlook: string;
|
||||
AppSharePointEnvironment: string;
|
||||
AppTeamsTabEnvironment: string;
|
||||
AppOfficeEnvironment: string;
|
||||
AppOutlookEnvironment: string;
|
||||
UnknownEnvironment: string;
|
||||
}
|
||||
|
||||
declare module 'SampleRouterWebPartStrings' {
|
||||
const strings: ISampleRouterWebPartStrings;
|
||||
export = strings;
|
||||
}
|
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 249 B |
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"noImplicitAny": true,
|
||||
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
]
|
||||
}
|