Skip to content

Commit fe885b4

Browse files
committed
Telemetry updates
1 parent 1ad5309 commit fe885b4

File tree

5 files changed

+58
-22
lines changed

5 files changed

+58
-22
lines changed

CHANGELOG.JSON

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
{
22
"versions": [
3+
{
4+
"version": "1.5.`",
5+
"changes": {
6+
"new": [],
7+
"enhancements": [],
8+
"fixes": [
9+
"Fix issue where Application Insights is not defined [#81](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/81)"
10+
]
11+
},
12+
"contributions": ["Asish Padhy", "Alex Terentiev"]
13+
},
314
{
415
"version": "1.5.0",
516
"changes": {
617
"new": [
718
"New `PeoplePicker` control added [#19](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/19)"
819
],
920
"enhancements": [
10-
"Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)"
21+
"Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)"
1122
],
1223
"fixes": [
1324
"Bug in `TaxonomyPicker` where values are not updated by an async change [#83](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/83)",

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Releases
22

3+
## 1.5.`
4+
5+
**Fixes**
6+
7+
- Fix issue where Application Insights is not defined [#81](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/81)
8+
39
## 1.5.0
410

511
**New control(s)**
@@ -8,7 +14,7 @@
814

915
**Enhancements**
1016

11-
- Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)
17+
- Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)
1218

1319
**Fixes**
1420

docs/documentation/docs/about/release-notes.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Releases
22

3+
## 1.5.`
4+
5+
**Fixes**
6+
7+
- Fix issue where Application Insights is not defined [#81](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/81)
8+
39
## 1.5.0
410

511
**New control(s)**
@@ -8,7 +14,7 @@
814

915
**Enhancements**
1016

11-
- Added a properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)
17+
- Added properties to the `TaxonomyPicker` to specify which terms are disabled/not-selectable [#82](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/82)
1218

1319
**Fixes**
1420

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pnp/spfx-controls-react",
33
"description": "Reusable React controls for SharePoint Framework solutions",
4-
"version": "1.5.0",
4+
"version": "1.5.1",
55
"engines": {
66
"node": ">=0.10.0"
77
},

src/common/appInsights/index.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,41 @@ import {Environment,EnvironmentType} from "@microsoft/sp-core-library";
44

55
const controlType = "react";
66

7-
AppInsights.downloadAndSetup({ instrumentationKey: "9f59b81e-d2ed-411e-a961-8bcf3f7f04d0" });
8-
9-
appInsights.queue.push(() => {
10-
// Remove operation name from the telemetry
11-
if (AppInsights.context && AppInsights.context.operation && AppInsights.context.operation.name) {
12-
AppInsights.context.operation.name = null;
13-
}
7+
if (typeof AppInsights !== "undefined") {
8+
AppInsights.downloadAndSetup({
9+
instrumentationKey: "9f59b81e-d2ed-411e-a961-8bcf3f7f04d0",
10+
disableExceptionTracking: true,
11+
disableAjaxTracking: true
12+
});
13+
}
1414

15-
// Filter out telemetry data
16-
appInsights.context.addTelemetryInitializer((envelope: Microsoft.ApplicationInsights.IEnvelope) => {
17-
const telemetryItem = envelope.data.baseData;
18-
// Only send telemetry data if it contains data of this library
19-
if (!telemetryItem.properties || !telemetryItem.properties.controlType) {
20-
return false;
15+
if (typeof appInsights !== "undefined") {
16+
appInsights.queue.push(() => {
17+
// Remove operation name from the telemetry
18+
if (AppInsights.context && AppInsights.context.operation && AppInsights.context.operation.name) {
19+
AppInsights.context.operation.name = null;
2120
}
2221

23-
// Only send telemetry if it is coming from the right control type
24-
if (telemetryItem.properties && telemetryItem.properties.controlType && telemetryItem.properties.controlType !== controlType) {
25-
return false;
26-
}
22+
// Filter out telemetry data
23+
appInsights.context.addTelemetryInitializer((envelope: Microsoft.ApplicationInsights.IEnvelope) => {
24+
const telemetryItem = envelope.data.baseData;
25+
// Only send telemetry data if it contains data of this library
26+
if (!telemetryItem.properties || !telemetryItem.properties.controlType) {
27+
return false;
28+
}
29+
30+
// Check if the type of data is only EventData, otherwise this may not be sent
31+
if (envelope.data && envelope.data.baseType !== "EventData") {
32+
return false;
33+
}
34+
35+
// Only send telemetry if it is coming from the right control type
36+
if (telemetryItem.properties && telemetryItem.properties.controlType && telemetryItem.properties.controlType !== controlType) {
37+
return false;
38+
}
39+
});
2740
});
28-
});
41+
}
2942

3043
export function track(componentName: string, properties: any = {}): void {
3144
AppInsights.trackEvent(componentName, {

0 commit comments

Comments
 (0)