Skip to content

Commit 90d982c

Browse files
authored
Merge pull request #49 from SharePoint/dev
PR for 1.2.3
2 parents 6356a23 + 3cfa7ae commit 90d982c

File tree

5 files changed

+53
-16
lines changed

5 files changed

+53
-16
lines changed

CHANGELOG.md

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

3+
## 1.2.3
4+
5+
**Enhancements**
6+
7+
- Optimized telemetry so that it only pushes control data
8+
- `WebPartTitle` hide control completely when empty
9+
310
## 1.2.2
411

512
**Fixes**

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

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

3+
## 1.2.3
4+
5+
**Enhancements**
6+
7+
- Optimized telemetry so that it only pushes control data
8+
- `WebPartTitle` hide control completely when empty
9+
310
## 1.2.2
411

512
**Fixes**

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.2.2",
4+
"version": "1.2.3",
55
"engines": {
66
"node": ">=0.10.0"
77
},

src/common/appInsights/index.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,35 @@ import { AppInsights } from "applicationinsights-js";
22
import { version } from './version';
33
import {Environment,EnvironmentType} from "@microsoft/sp-core-library";
44

5+
const controlType = "react";
6+
57
AppInsights.downloadAndSetup({ instrumentationKey: "9f59b81e-d2ed-411e-a961-8bcf3f7f04d0" });
68

7-
// Remove operation name from the telemetry
8-
if (AppInsights.context && AppInsights.context.operation && AppInsights.context.operation.name) {
9-
AppInsights.context.operation.name = null;
10-
}
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+
}
14+
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;
21+
}
22+
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+
}
27+
});
28+
});
1129

1230
export function track(componentName: string, properties: any = {}): void {
1331
AppInsights.trackEvent(componentName, {
1432
version,
33+
controlType,
1534
debug: DEBUG ? "true" : "false",
1635
environment: EnvironmentType[Environment.type],
1736
...properties

src/controls/webPartTitle/WebPartTitle.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,20 @@ export class WebPartTitle extends React.Component<IWebPartTitleProps, {}> {
4141
* Default React component render method
4242
*/
4343
public render(): React.ReactElement<IWebPartTitleProps> {
44-
return (
45-
<div className={`${styles.webPartTitle} ${this.props.className ? this.props.className : ''}` }>
46-
{
47-
this.props.displayMode === DisplayMode.Edit && <textarea placeholder={strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} defaultValue={this.props.title}></textarea>
48-
}
49-
50-
{
51-
this.props.displayMode !== DisplayMode.Edit && this.props.title && <span>{this.props.title}</span>
52-
}
53-
</div>
54-
);
44+
if (this.props.title || this.props.displayMode === DisplayMode.Edit) {
45+
return (
46+
<div className={`${styles.webPartTitle} ${this.props.className ? this.props.className : ''}` }>
47+
{
48+
this.props.displayMode === DisplayMode.Edit && <textarea placeholder={strings.WebPartTitlePlaceholder} aria-label={strings.WebPartTitleLabel} onChange={this._onChange} defaultValue={this.props.title}></textarea>
49+
}
50+
51+
{
52+
this.props.displayMode !== DisplayMode.Edit && this.props.title && <span>{this.props.title}</span>
53+
}
54+
</div>
55+
);
56+
}
57+
58+
return null;
5559
}
5660
}

0 commit comments

Comments
 (0)