Skip to content
Permalink
Browse files

Chore: Migrate to shared telemetry utilities

Allows removing the significantly-sized client bundle from
Application Insights in favor of a minimal shared utility.
  • Loading branch information
antross authored and molant committed Nov 8, 2019
1 parent 618e13a commit c2f74dc1a3683ce54af1f70b053f56e3fde4b9f0
@@ -9,7 +9,7 @@
"timeout": "1m"
},
"browserslist": "last 2 chrome versions, last 2 firefox versions",
"bundleSize": 675000,
"bundleSize": 660000,
"description": "webhint browser extension",
"devDependencies": {
"@hint/hint-axe": "^4.2.0",
@@ -46,8 +46,8 @@
"@hint/utils-dom": "^1.0.0",
"@hint/utils-fs": "^1.0.0",
"@hint/utils-i18n": "^1.0.0",
"@hint/utils-telemetry": "^1.0.0",
"@hint/utils-types": "^1.0.0",
"@microsoft/applicationinsights-web-basic": "^2.2.0",
"@types/chrome": "^0.0.91",
"@types/har-format": "^1.2.4",
"@types/is-ci": "^2.0.0",

This file was deleted.

@@ -1,8 +1,6 @@
import { ApplicationInsights } from '@microsoft/applicationinsights-web-basic';

import { Config, ErrorData, Results } from '../../shared/types';

import { getUpdatedActivity } from './activity';
import { getUpdatedActivity, initTelemetry, updateTelemetry, trackEvent } from '@hint/utils-telemetry';
import { determineHintStatus } from './hints';
import * as storage from './storage';

@@ -13,25 +11,21 @@ const alreadyOptInKey = 'webhint-already-opt-in';

const instrumentationKey = '8ef2b55b-2ce9-4c33-a09a-2c3ef605c97d';

let appInsights: ApplicationInsights | null = null;
/** Check if telemetry is enabled */
export const enabled = (s = storage) => {
return !!s.getItem(storageKey);
};

const trackEvent = (name: string, properties: { [key: string]: string } = {}, measurements?: { [key: string]: number }) => {
if (!appInsights) {
return;
}
initTelemetry({
defaultProperties: { 'extension-version': manifest.version },
enabled: enabled(),
instrumentationKey,
post: async (url, data) => {
const response = await fetch(url, { body: data, method: 'POST' });

properties['extension-version'] = manifest.version;

appInsights.track({
baseData: {
measurements,
name,
properties
},
baseType: 'EventData',
name: `Microsoft.ApplicationInsights.${instrumentationKey}.Event`
});
};
return response.status;
}
});

/**
* Return true if the user has not respond yet
@@ -47,19 +41,13 @@ export const setup = (s = storage) => {

if (!telemetry) {
console.log('telemetry disabled');
appInsights = null;
updateTelemetry(false);

return;
}

console.log('telemetry enabled');

appInsights = new ApplicationInsights({ instrumentationKey });
};

/** Check if telemetry is enabled */
export const enabled = (s = storage) => {
return !!s.getItem(storageKey);
updateTelemetry(true);
};

/** Enables telemetry */

This file was deleted.

@@ -50,6 +50,7 @@
{ "path": "../utils-dom" },
{ "path": "../utils-fs" },
{ "path": "../utils-i18n" },
{ "path": "../utils-telemetry" },
{ "path": "../utils-types" }
]
}
@@ -365,39 +365,6 @@
dependencies:
arrify "^1.0.1"

"@microsoft/applicationinsights-channel-js@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-channel-js/-/applicationinsights-channel-js-2.2.0.tgz#3a424729c0176288e79db8e1b3478ce3e7fa8a9d"
integrity sha512-o67F1YVSXGyjZhMDrZQRzWJK0mH4Qm6YphG12ZVbdgQZeoouI4uoIDHxOOuIi4GLNdX8w59k8Wy2tnxFQbPY8A==
dependencies:
"@microsoft/applicationinsights-common" "2.2.0"
"@microsoft/applicationinsights-core-js" "2.2.0"
tslib "^1.9.3"

"@microsoft/applicationinsights-common@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-common/-/applicationinsights-common-2.2.0.tgz#12e81cca220450d16129fea4f16e3212efbfd32e"
integrity sha512-4zFUD4y8ekJ8tZSK2k5Ij6pvWYGFIcH8RoHKlkm7D+mO7vGkvR9dF7hJEJ/eliCtETbEJeNw/wi8TCxvc6oHkA==
dependencies:
"@microsoft/applicationinsights-core-js" "2.2.0"
tslib "^1.9.3"

"@microsoft/applicationinsights-core-js@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-core-js/-/applicationinsights-core-js-2.2.0.tgz#80b3352367834447499c0324ccddd1264d1770b4"
integrity sha512-+96gffh7TfYho8J0Oaxr9SUtUr0SwWMPArCMngnqqY5gcgNu9LaiVt/e/gsz8kKEuLb3m2+d22mmHb2fwpxMbQ==
dependencies:
tslib "^1.9.3"

"@microsoft/applicationinsights-web-basic@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@microsoft/applicationinsights-web-basic/-/applicationinsights-web-basic-2.2.0.tgz#85388f593239f264839b0e8fd5cd3dd47b7eb913"
integrity sha512-16IjDsmbnpWxQFOMrEliKWqWqXYEdMOjsqHEn96F3JSuJgsSN3f+ufURTfaiEbCwkgvSAjlaSIICYg2SqJGXPg==
dependencies:
"@microsoft/applicationinsights-channel-js" "2.2.0"
"@microsoft/applicationinsights-common" "2.2.0"
"@microsoft/applicationinsights-core-js" "2.2.0"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
@@ -11623,7 +11590,7 @@ ts-loader@^6.1.2:
micromatch "^4.0.0"
semver "^6.0.0"

tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
tslib@^1.8.1, tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

0 comments on commit c2f74dc

Please sign in to comment.
You can’t perform that action at this time.