Skip to content

Commit

Permalink
Merge pull request #123 from pwa-builder/dev
Browse files Browse the repository at this point in the history
Fix App Insights
  • Loading branch information
khmyznikov authored Nov 2, 2023
2 parents 964e582 + 98d593a commit bf146a1
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 82 deletions.
2 changes: 1 addition & 1 deletion build/analytics.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions build/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
setup,
defaultClient,
DistributedTracingModes,
import appInsights, {
DistributedTracingModes
} from 'applicationinsights';

enum AppInsightsStatus {
Expand All @@ -13,7 +11,7 @@ enum AppInsightsStatus {
var appInsightsStatus: AppInsightsStatus = AppInsightsStatus.DEFAULT;
export function setupAnalytics() {
try {
setup(process.env.APPINSIGHTSCONNECTIONSTRING)
appInsights.setup()
.setDistributedTracingMode(DistributedTracingModes.AI_AND_W3C)
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(false)
Expand Down Expand Up @@ -41,10 +39,11 @@ export function trackEvent(
setupAnalytics();
}
if (
defaultClient == null ||
defaultClient == undefined ||
appInsights.defaultClient == null ||
appInsights.defaultClient == undefined ||
appInsightsStatus == AppInsightsStatus.DISABLED
) {
console.error("App insights no defaultClient");
return;
}

Expand All @@ -61,17 +60,17 @@ export function trackEvent(
analyticsInfo.correlationId != undefined &&
typeof analyticsInfo.correlationId == 'string'
) {
defaultClient.context.tags[defaultClient.context.keys.operationId] =
appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.operationId] =
analyticsInfo.correlationId;
}
if (success) {
defaultClient.trackEvent({
appInsights.defaultClient.trackEvent({
name: 'AndroidPackageEvent',
properties: properties,
});
} else {
properties.error = error;
defaultClient.trackEvent({
appInsights.defaultClient.trackEvent({
name: 'AndroidPackageFailureEvent',
properties: properties,
});
Expand Down
147 changes: 78 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@types/fs-extra": "^8.0.1",
"@types/q": "^1.5.2",
"@types/tmp": "^0.1.0",
"applicationinsights": "^2.5.1",
"applicationinsights": "^2.9.0",
"concurrently": "^5.1.0",
"cors": "^2.8.5",
"ts-node": "^10.9.1",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit bf146a1

Please sign in to comment.