From f18a74082472a90e15a387b295c63d17a1673215 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 13 Jul 2018 08:28:34 +0200 Subject: [PATCH] Telemetry updates for #79 --- CHANGELOG.json | 13 ++++++- CHANGELOG.md | 8 +++- .../documentation/docs/about/release-notes.md | 8 +++- gulpfile.js | 2 +- package-lock.json | 18 ++++----- package.json | 9 ++--- src/common/appInsights/index.ts | 38 ------------------- src/common/appInsights/version.ts | 1 - src/common/telemetry/index.ts | 16 ++++++++ src/common/telemetry/version.ts | 1 + .../PropertyFieldButtonWithCalloutHost.tsx | 4 +- .../PropertyFieldCheckboxWithCalloutHost.tsx | 4 +- ...ropertyFieldChoiceGroupWithCalloutHost.tsx | 4 +- .../PropertyFieldCodeEditorHost.tsx | 4 +- .../PropertyFieldCollectionDataHost.tsx | 4 +- .../PropertyFieldColorPickerHost.tsx | 4 +- .../PropertyFieldDateTimePickerHost.tsx | 6 +-- .../PropertyFieldDropdownWithCalloutHost.tsx | 4 +- .../PropertyFieldLabelWithCalloutHost.tsx | 4 +- .../PropertyFieldLinkWithCalloutHost.tsx | 4 +- .../PropertyFieldListMultiPickerHost.tsx | 4 +- .../PropertyFieldListPickerHost.tsx | 4 +- .../PropertyFieldMultiSelectHost.tsx | 4 +- .../number/PropertyFieldNumberHost.tsx | 4 +- .../order/PropertyFieldOrderHost.tsx | 4 +- .../PropertyFieldPeoplePickerHost.tsx | 4 +- .../PropertyFieldSliderWithCalloutHost.tsx | 4 +- .../PropertyFieldSpinButtonHost.tsx | 4 +- .../PropertyFieldSwatchColorPickerHost.tsx | 4 +- .../PropertyFieldTermPickerHost.tsx | 4 +- .../PropertyFieldTextWithCalloutHost.tsx | 4 +- .../PropertyFieldToggleWithCalloutHost.tsx | 4 +- 32 files changed, 101 insertions(+), 103 deletions(-) delete mode 100644 src/common/appInsights/index.ts delete mode 100644 src/common/appInsights/version.ts create mode 100644 src/common/telemetry/index.ts create mode 100644 src/common/telemetry/version.ts diff --git a/CHANGELOG.json b/CHANGELOG.json index 7c552501..59c88aa9 100644 --- a/CHANGELOG.json +++ b/CHANGELOG.json @@ -1,5 +1,16 @@ { "versions": [ + { + "version": "1.8.0", + "changes": { + "new": [], + "enhancements": [ + "New telemetry approach which allows you to use Application Insights instance [#79](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/79)" + ], + "fixes": [] + }, + "contributions": [] + }, { "version": "1.7.0", "changes": { @@ -10,7 +21,7 @@ "Added a font field type for the `PropertyFieldCollectionData` control [#66](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/66)", "Added a URL field type for the `PropertyFieldCollectionData` control [#72](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/72)", "Field validation implemented to enable/disable save buttons in `PropertyFieldCollectionData` control. Related to previous enhancement.", - "Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69)" + "Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69)" ], "fixes": [ "`PropertyFieldPeoplePicker` validation error does not clear as expected [#68](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/68)" diff --git a/CHANGELOG.md b/CHANGELOG.md index f875af17..b3c40409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Releases +## 1.8.0 + +**Enhancements** + +- New telemetry approach which allows you to use Application Insights instance [#79](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/79) + ## 1.7.0 **Enhancements** @@ -9,7 +15,7 @@ - Added a font field type for the `PropertyFieldCollectionData` control [#66](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/66) - Added a URL field type for the `PropertyFieldCollectionData` control [#72](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/72) - Field validation implemented to enable/disable save buttons in `PropertyFieldCollectionData` control. Related to previous enhancement. -- Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69) +- Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69) **Fixes** diff --git a/docs/documentation/docs/about/release-notes.md b/docs/documentation/docs/about/release-notes.md index f875af17..b3c40409 100644 --- a/docs/documentation/docs/about/release-notes.md +++ b/docs/documentation/docs/about/release-notes.md @@ -1,5 +1,11 @@ # Releases +## 1.8.0 + +**Enhancements** + +- New telemetry approach which allows you to use Application Insights instance [#79](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/79) + ## 1.7.0 **Enhancements** @@ -9,7 +15,7 @@ - Added a font field type for the `PropertyFieldCollectionData` control [#66](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/66) - Added a URL field type for the `PropertyFieldCollectionData` control [#72](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/72) - Field validation implemented to enable/disable save buttons in `PropertyFieldCollectionData` control. Related to previous enhancement. -- Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69) +- Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#69](https://github.com/SharePoint/sp-dev-fx-property-controls/issues/69) **Fixes** diff --git a/gulpfile.js b/gulpfile.js index e9152e82..5e953858 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,7 +7,7 @@ const fs = require('fs'); // Update the version number in the version.ts file gulp.task('versionUpdater', (done) => { const pkgContents = require('./package.json'); - const filePath = './src/common/appInsights/version.ts'; + const filePath = './src/common/telemetry/version.ts'; const fileContents = `export const version: string = "{versionPlaceholder}";`; const newContents = fileContents.replace("{versionPlaceholder}", pkgContents.version); console.log(`Updating version number to: ${pkgContents.version}`); diff --git a/package-lock.json b/package-lock.json index 4a28727a..d0c86d7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1161,6 +1161,14 @@ } } }, + "@pnp/telemetry-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@pnp/telemetry-js/-/telemetry-js-1.0.0.tgz", + "integrity": "sha512-7Lr22EB6DgB8MZi0WDuou8VuXru3wHdiOQPenB2B2gdhp7bJj2ijN9vTiqF8aL1nh80uJxIyX269Ix/PSnJC7g==", + "requires": { + "whatwg-fetch": "2.0.4" + } + }, "@types/adal": { "version": "1.0.27", "resolved": "https://registry.npmjs.org/@types/adal/-/adal-1.0.27.tgz", @@ -1176,11 +1184,6 @@ "integrity": "sha1-vr01fpECFjatKorqhaNZLbUFZW4=", "dev": true }, - "@types/applicationinsights-js": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/applicationinsights-js/-/applicationinsights-js-1.0.5.tgz", - "integrity": "sha1-sLq3VeZ+1YSsO/dYafwSWJoziiw=" - }, "@types/assertion-error": { "version": "1.0.30", "resolved": "https://registry.npmjs.org/@types/assertion-error/-/assertion-error-1.0.30.tgz", @@ -1841,11 +1844,6 @@ } } }, - "applicationinsights-js": { - "version": "1.0.18", - "resolved": "https://registry.npmjs.org/applicationinsights-js/-/applicationinsights-js-1.0.18.tgz", - "integrity": "sha1-b/JwYjbXi0azn9G4P+D2iABxr3A=" - }, "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", diff --git a/package.json b/package.json index cc9a445a..b5696a77 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@pnp/spfx-property-controls", "description": "Reusable property pane controls for SharePoint Framework solutions", - "version": "1.7.0", + "version": "1.8.0", "engines": { "node": ">=0.10.0" }, @@ -11,12 +11,11 @@ "test": "gulp test", "versionUpdater": "gulp versionUpdater", "prepublishOnly": "gulp", - "changelog": "node scripts/create-changelog.js && node scripts/sync-changelogs.js", + "changelog": "node scripts/create-changelog.js && node scripts/sync-changelogs.js && gulp versionUpdater", "postinstall": "node postinstall/install.js" }, "dependencies": { - "@types/applicationinsights-js": "1.0.5", - "applicationinsights-js": "^1.0.14", + "@pnp/telemetry-js": "1.0.0", "react-ace": "5.8.0" }, "devDependencies": { @@ -52,7 +51,7 @@ "bugs": { "url": "https://github.com/SharePoint/sp-dev-fx-property-controls/issues" }, - "homepage": "https://github.com/SharePoint/sp-dev-fx-property-controls", + "homepage": "https://sharepoint.github.io/sp-dev-fx-property-controls/", "main": "lib/index.js", "maintainers": [ { diff --git a/src/common/appInsights/index.ts b/src/common/appInsights/index.ts deleted file mode 100644 index 3b075951..00000000 --- a/src/common/appInsights/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { AppInsights } from "applicationinsights-js"; -import { version } from './version'; -import {Environment,EnvironmentType} from "@microsoft/sp-core-library"; - -const controlType = "property"; - -AppInsights.downloadAndSetup({ instrumentationKey: "9f59b81e-d2ed-411e-a961-8bcf3f7f04d0" }); - -appInsights.queue.push(() => { - // Remove operation name from the telemetry - if (AppInsights.context && AppInsights.context.operation && AppInsights.context.operation.name) { - AppInsights.context.operation.name = null; - } - - // Filter out telemetry data - appInsights.context.addTelemetryInitializer((envelope: Microsoft.ApplicationInsights.IEnvelope) => { - const telemetryItem = envelope.data.baseData; - // Only send telemetry data if it contains data of this library - if (!telemetryItem.properties || !telemetryItem.properties.controlType) { - return false; - } - - // Only send telemetry if it is coming from the right control type - if (telemetryItem.properties && telemetryItem.properties.controlType && telemetryItem.properties.controlType !== controlType) { - return false; - } - }); -}); - -export function track(componentName: string, properties: any = {}): void { - AppInsights.trackEvent(componentName, { - version, - controlType, - debug: DEBUG ? "true" : "false", - environment: EnvironmentType[Environment.type], - ...properties - }); -} diff --git a/src/common/appInsights/version.ts b/src/common/appInsights/version.ts deleted file mode 100644 index 1b9a68dc..00000000 --- a/src/common/appInsights/version.ts +++ /dev/null @@ -1 +0,0 @@ -export const version: string = "1.2.0"; \ No newline at end of file diff --git a/src/common/telemetry/index.ts b/src/common/telemetry/index.ts new file mode 100644 index 00000000..1975626c --- /dev/null +++ b/src/common/telemetry/index.ts @@ -0,0 +1,16 @@ +import PnPTelemetry from "@pnp/telemetry-js"; +import { version } from './version'; +import { Environment, EnvironmentType } from "@microsoft/sp-core-library"; + +const CONTROL_TYPE = "property"; + +export function track(componentName: string, properties: any = {}): void { + const telemetry = PnPTelemetry.getInstance(); + telemetry.trackEvent(componentName, { + version, + controlType: CONTROL_TYPE, + debug: DEBUG ? "true" : "false", + environment: EnvironmentType[Environment.type], + ...properties + }); +} diff --git a/src/common/telemetry/version.ts b/src/common/telemetry/version.ts new file mode 100644 index 00000000..fc942def --- /dev/null +++ b/src/common/telemetry/version.ts @@ -0,0 +1 @@ +export const version: string = "1.8.0"; \ No newline at end of file diff --git a/src/propertyFields/buttonWithCallout/PropertyFieldButtonWithCalloutHost.tsx b/src/propertyFields/buttonWithCallout/PropertyFieldButtonWithCalloutHost.tsx index 290a6d05..f55cdaeb 100644 --- a/src/propertyFields/buttonWithCallout/PropertyFieldButtonWithCalloutHost.tsx +++ b/src/propertyFields/buttonWithCallout/PropertyFieldButtonWithCalloutHost.tsx @@ -5,7 +5,7 @@ import * as _ from 'lodash'; import PlaceholderWithCallout from '../../common/placeholderWithCallout/PlaceholderWithCallout'; import { IPropertyFieldButtonWithCalloutHostProps } from './IPropertyFieldButtonWithCalloutHost'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; /** @@ -15,7 +15,7 @@ export default class PropertyFieldButtonHost extends React.Component { constructor(props: IPropertyFieldChoiceGroupWithCalloutHostProps) { super(props); - appInsights.track('PropertyFieldToggleWithCallout', { + telemetry.track('PropertyFieldToggleWithCallout', { disabled: props.disabled }); } diff --git a/src/propertyFields/codeEditor/PropertyFieldCodeEditorHost.tsx b/src/propertyFields/codeEditor/PropertyFieldCodeEditorHost.tsx index 083f55fc..a3a04046 100644 --- a/src/propertyFields/codeEditor/PropertyFieldCodeEditorHost.tsx +++ b/src/propertyFields/codeEditor/PropertyFieldCodeEditorHost.tsx @@ -8,7 +8,7 @@ import { TextField } from 'office-ui-fabric-react/lib/TextField'; import { IPropertyFieldCodeEditorHostProps, IPropertyFieldCodeEditorHostState } from './IPropertyFieldCodeEditorHost'; import styles from './PropertyFieldCodeEditorHost.module.scss'; import FieldErrorMessage from '../errorMessage/FieldErrorMessage'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; import * as strings from 'PropertyControlStrings'; import * as brace from 'brace'; import AceEditor from 'react-ace'; @@ -35,7 +35,7 @@ export default class PropertyFieldCodeEditorHost extends React.Component { constructor(props: IPropertyFieldColorPickerHostProps, state: IPropertyFieldColorPickerHostState) { super(props); - appInsights.track('PropertyFieldColorPicker', { + telemetry.track('PropertyFieldColorPicker', { disabled: props.disabled }); diff --git a/src/propertyFields/dateTimePicker/PropertyFieldDateTimePickerHost.tsx b/src/propertyFields/dateTimePicker/PropertyFieldDateTimePickerHost.tsx index cca3a982..141fc0ea 100644 --- a/src/propertyFields/dateTimePicker/PropertyFieldDateTimePickerHost.tsx +++ b/src/propertyFields/dateTimePicker/PropertyFieldDateTimePickerHost.tsx @@ -11,7 +11,7 @@ import styles from './PropertyFieldDateTimePickerHost.module.scss'; import HoursComponent from './HoursComponent'; import MinutesComponent from './MinutesComponent'; import SecondsComponent from './SecondsComponent'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; /** * Defines the labels of the DatePicker control (as months, days, etc.) @@ -90,7 +90,7 @@ export default class PropertyFieldDateTimePickerHost extends React.Component { constructor(props: IPropertyFieldDropdownWithCalloutHostProps) { super(props); - appInsights.track('PropertyFieldDropdown', { + telemetry.track('PropertyFieldDropdown', { disabled: props.disabled }); } diff --git a/src/propertyFields/labelWithCallout/PropertyFieldLabelWithCalloutHost.tsx b/src/propertyFields/labelWithCallout/PropertyFieldLabelWithCalloutHost.tsx index fa302d85..30c5d9e1 100644 --- a/src/propertyFields/labelWithCallout/PropertyFieldLabelWithCalloutHost.tsx +++ b/src/propertyFields/labelWithCallout/PropertyFieldLabelWithCalloutHost.tsx @@ -5,7 +5,7 @@ import * as _ from 'lodash'; import PlaceholderWithCallout from '../../common/placeholderWithCallout/PlaceholderWithCallout'; import { IPropertyFieldLabelWithCalloutHostProps } from './IPropertyFieldLabelWithCalloutHost'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; /** * Renders the control for PropertyFieldLabelWithCallout component @@ -14,7 +14,7 @@ export default class PropertyFieldLabelHost extends React.Component { constructor(props: IPropertyFieldMultiSelectHostProps) { super(props); - appInsights.track('PropertyFieldMultiSelect', { + telemetry.track('PropertyFieldMultiSelect', { disabled: props.disabled }); } diff --git a/src/propertyFields/number/PropertyFieldNumberHost.tsx b/src/propertyFields/number/PropertyFieldNumberHost.tsx index c4754a42..0846bb8e 100644 --- a/src/propertyFields/number/PropertyFieldNumberHost.tsx +++ b/src/propertyFields/number/PropertyFieldNumberHost.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { TextField } from 'office-ui-fabric-react/lib/TextField'; import { IPropertyFieldNumberHostProps, IPropertyFieldNumberHostState } from './IPropertyFieldNumberHost'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; import { Async } from 'office-ui-fabric-react/lib/Utilities'; import * as strings from 'PropertyControlStrings'; @@ -12,7 +12,7 @@ export default class PropertyFieldNumberHost extends React.Component { constructor(props: IPropertyFieldSliderWithCalloutHostProps) { super(props); - appInsights.track('PropertyFieldSliderWithCallout', { + telemetry.track('PropertyFieldSliderWithCallout', { disabled: props.disabled }); } diff --git a/src/propertyFields/spinButton/PropertyFieldSpinButtonHost.tsx b/src/propertyFields/spinButton/PropertyFieldSpinButtonHost.tsx index 9fc8728e..11ee3291 100644 --- a/src/propertyFields/spinButton/PropertyFieldSpinButtonHost.tsx +++ b/src/propertyFields/spinButton/PropertyFieldSpinButtonHost.tsx @@ -7,14 +7,14 @@ import { IPropertyFieldSpinButtonHostState } from './IPropertyFieldSpinButtonHost'; import * as strings from 'PropertyControlStrings'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; export default class PropertyFieldSpinButtonHost extends React.Component { constructor(props: IPropertyFieldSpinButtonHostProps, state: IPropertyFieldSpinButtonHostState) { super(props); - appInsights.track('PropertyFieldSpinButton', { + telemetry.track('PropertyFieldSpinButton', { disabled: props.disabled }); diff --git a/src/propertyFields/swatchColorPicker/PropertyFieldSwatchColorPickerHost.tsx b/src/propertyFields/swatchColorPicker/PropertyFieldSwatchColorPickerHost.tsx index 9d345561..a798e9a3 100644 --- a/src/propertyFields/swatchColorPicker/PropertyFieldSwatchColorPickerHost.tsx +++ b/src/propertyFields/swatchColorPicker/PropertyFieldSwatchColorPickerHost.tsx @@ -4,7 +4,7 @@ import { IColorCellProps, SwatchColorPicker } from 'office-ui-fabric-react/lib/S import * as strings from 'PropertyControlStrings'; import * as React from 'react'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; import { IPropertyFieldSwatchColorOption, PropertyFieldSwatchColorPickerStyle } from './IPropertyFieldSwatchColorPicker'; import { IPropertyFieldSwatchColorPickerHostProps, @@ -17,7 +17,7 @@ export default class PropertyFieldSwatchColorPickerHost extends React.Component< constructor(props: IPropertyFieldSwatchColorPickerHostProps, state: IPropertyFieldSwatchColorPickerHostState) { super(props); - appInsights.track('PropertyFieldSwatchColorPicker', { + telemetry.track('PropertyFieldSwatchColorPicker', { disabled: props.disabled }); diff --git a/src/propertyFields/termPicker/PropertyFieldTermPickerHost.tsx b/src/propertyFields/termPicker/PropertyFieldTermPickerHost.tsx index 965bd5b7..693907ee 100644 --- a/src/propertyFields/termPicker/PropertyFieldTermPickerHost.tsx +++ b/src/propertyFields/termPicker/PropertyFieldTermPickerHost.tsx @@ -19,7 +19,7 @@ import styles from './PropertyFieldTermPickerHost.module.scss'; import { sortBy, uniqBy, cloneDeep } from '@microsoft/sp-lodash-subset'; import TermGroup from './TermGroup'; import FieldErrorMessage from '../errorMessage/FieldErrorMessage'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; import * as strings from 'PropertyControlStrings'; /** @@ -47,7 +47,7 @@ export default class PropertyFieldTermPickerHost extends React.Component { constructor(props: IPropertyFieldTextWithCalloutHostProps) { super(props); - appInsights.track('PropertyFieldTextWithCallout', { + telemetry.track('PropertyFieldTextWithCallout', { disabled: props.disabled }); } diff --git a/src/propertyFields/toggleWithCallout/PropertyFieldToggleWithCalloutHost.tsx b/src/propertyFields/toggleWithCallout/PropertyFieldToggleWithCalloutHost.tsx index 0073b58c..42df08b6 100644 --- a/src/propertyFields/toggleWithCallout/PropertyFieldToggleWithCalloutHost.tsx +++ b/src/propertyFields/toggleWithCallout/PropertyFieldToggleWithCalloutHost.tsx @@ -5,13 +5,13 @@ import { Toggle } from 'office-ui-fabric-react'; import PropertyFieldHeader from '../../common/propertyFieldHeader/PropertyFieldHeader'; import { IPropertyFieldToggleWithCalloutHostProps } from './IPropertyFieldToggleWithCalloutHost'; -import * as appInsights from '../../common/appInsights'; +import * as telemetry from '../../common/telemetry'; export default class PropertyFieldToggleWithCalloutHost extends React.Component { constructor(props: IPropertyFieldToggleWithCalloutHostProps) { super(props); - appInsights.track('PropertyFieldToggleWithCallout', { + telemetry.track('PropertyFieldToggleWithCallout', { disabled: props.disabled }); }