Skip to content

Commit

Permalink
Update to Application Insights ^3.0.8 (#34)
Browse files Browse the repository at this point in the history
Update to dynamicProto-js ^2.0.3
 - Update GitHub status tool script
 - Update GitHub status script to include -dump switch
  • Loading branch information
MSNev authored Feb 13, 2024
1 parent 55a6683 commit 456728a
Show file tree
Hide file tree
Showing 7 changed files with 1,568 additions and 1,379 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Update rush shrinkwrap dependencies (for different node versions)
run: node common/scripts/install-run-rush.js update --full
- run: npm install rollup -g
- run: npm install grunt-cli findup-sync nopt [email protected]
- run: npm install
Expand Down
8 changes: 4 additions & 4 deletions applicationinsights-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
"uglify-js": "3.16.0"
},
"dependencies": {
"@microsoft/applicationinsights-common": "^3.0.5",
"@microsoft/applicationinsights-core-js": "^3.0.5",
"@microsoft/applicationinsights-common": "^3.0.8",
"@microsoft/applicationinsights-core-js": "^3.0.8",
"@microsoft/applicationinsights-shims": "^3.0.1",
"@microsoft/dynamicproto-js": "^2.0.2",
"@nevware21/ts-utils": ">= 0.9.4 < 2.x"
"@microsoft/dynamicproto-js": "^2.0.3",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x"
},
"peerDependencies": {
"tslib": "*",
Expand Down
2 changes: 1 addition & 1 deletion common/Tests/Framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
"tslib": "*"
},
"dependencies": {
"@microsoft/dynamicproto-js": "^2.0.2"
"@microsoft/dynamicproto-js": "^2.0.3"
}
}
2,835 changes: 1,478 additions & 1,357 deletions common/config/rush/npm-shrinkwrap.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
"whatwg-fetch": "^3.0.0"
},
"dependencies": {
"@microsoft/applicationinsights-common": "^3.0.5",
"@microsoft/applicationinsights-core-js": "^3.0.5",
"@microsoft/applicationinsights-common": "^3.0.8",
"@microsoft/applicationinsights-core-js": "^3.0.8",
"@microsoft/applicationinsights-shims": "^3.0.1",
"@microsoft/dynamicproto-js": "^2.0.2",
"@nevware21/ts-utils": ">= 0.9.4 < 2.x"
"@microsoft/dynamicproto-js": "^2.0.3",
"@nevware21/ts-utils": ">= 0.10.5 < 2.x"
},
"peerDependencies": {
"react-native": "*",
Expand Down
2 changes: 1 addition & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@expo/webpack-config": "^18.0.1",
"@microsoft/applicationinsights-react-native": "^4.0.2",
"@microsoft/applicationinsights-web": "^3.0.5",
"@microsoft/applicationinsights-web": "^3.0.8",
"expo": "~48.0.18",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
Expand Down
90 changes: 78 additions & 12 deletions tools/status-tools/github-status.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs");
const child_process = require("child_process");
const NO_LABELS = "<No Labels>";
const NO_MILESTONE = "<No Milestone>";
const DEFAULT_LABELS = [ "bug", "enhancement", "feature", "question", "documentation", "duplicate", "invalid", "wontfix" ];

let _startMonth = 0;
Expand All @@ -12,6 +13,7 @@ let _labels = null;
let _noLabels = false;
let _missingLabels = false;
let _prevMonths = 6;
let _dump = false;

function showHelp() {
var scriptParts;
Expand All @@ -38,6 +40,7 @@ function showHelp() {
console.log(" -noLabels - Don't report on any labels (overrides -l, -px and -all)");
console.log(" -missingLabels - Identify issues with no assigned labels");
console.log(" -noDefault - Don't add the default labels (bug,enhancement,feature,question,documentation,duplicate,invalid,wontfix)");
console.log(" -dump - Dump the raw JSON data to a file (issues.json)")
console.log(" -? | -h | -help - This help message");
console.log("");
console.log("Examples:");
Expand Down Expand Up @@ -129,6 +132,8 @@ function parseArgs() {
if (_prevMonths < 1) {
_prevMonths = 1;
}
} else if (theArg === "-dump") {
_dump = true;
} else {
console.error("!!! Unknown switch [" + theArg + "] detected");
return false;
Expand Down Expand Up @@ -177,7 +182,8 @@ function logHeader(title, firstYear, lastYear, lastMonth, issues) {
for (let mth = 0; mth < 12; mth++) {
let now = (yr * 100) + mth;
if (now <= lastMonth) {
if (now >= _startMonth) {
let month = year[String(mth + 1).padStart(2, "0")];
if (month && now >= _startMonth) {
csvOutput += `,\"${yr}-${String(mth + 1).padStart(2, "0")}\"`;
}
}
Expand Down Expand Up @@ -265,7 +271,7 @@ function dumpCount(label, issues, firstYear, lastYear, lastMonth, name) {
}
}

function sumValues(issues, createdAt, closedAt) {
function sumValues(issues, createdAt, closedAt, issue) {
let openYear = createdAt.getFullYear();
let openMonth = String(createdAt.getMonth() + 1).padStart(2, "0");
let year = issues[openYear] = issues[openYear] || { cnt: 0, opened: 0, closed: 0 };
Expand All @@ -275,7 +281,29 @@ function sumValues(issues, createdAt, closedAt) {
let month = year[openMonth] = year[openMonth] || { cnt: 0, opened: 0, closed: 0 };
month.opened++;
month.cnt++;

if (issue) {
let openIssues = month.openedIssues = (month.openedIssues || {});

if (issue.milestone) {
openIssues = openIssues[issue.milestone.title] = openIssues[issue.milestone.title] || [];
} else {
openIssues = openIssues[NO_MILESTONE] = openIssues[NO_MILESTONE] || [];
}

let labels = "";
if (issue.labels) {
issue.labels.forEach(label => {
labels += (labels ? ", " : "") + label.name;
});
}

if (!closedAt) {
openIssues.push(`#${issue.number} ${labels ? "[" + labels + "]" : ""} :${issue.title}`);
} else {
openIssues.push(`#${issue.number} ${labels ? "[" + labels + "]" : ""} =<(Closed)>=- :${issue.title}`);
}
}

if (closedAt) {
let closeYear = closedAt.getFullYear();
let closeMonth = String(closedAt.getMonth() + 1).padStart(2, "0");
Expand All @@ -286,6 +314,34 @@ function sumValues(issues, createdAt, closedAt) {
let month = year[closeMonth] = year[closeMonth] || { cnt: 0, opened: 0, closed: 0 };
month.closed++;
month.cnt--;

if (issue) {
let closedIssues = month.closedIssues = (month.closedIssues || {});
if (issue.milestone) {
closedIssues = closedIssues[issue.milestone.title] = closedIssues[issue.milestone.title] || [];
} else {
closedIssues = closedIssues[NO_MILESTONE] = closedIssues[NO_MILESTONE] || [];
}

closedIssues.push(`#${issue.number} - ${issue.title}`);
}
}
}

function writeFile(filename, data, extension, overwrite = true, idx = 0) {
let newFilename = filename + (idx ? ("-" + idx) : "") + "." + extension;

if (!overwrite && fs.existsSync(newFilename)) {
console.log(" -- Existing " + newFilename);
writeFile(filename, data, extension, overwrite, idx + 1);
return;
}

try {
fs.writeFileSync(newFilename, data);
} catch (e) {
console.error(` -- Failed to write newFilename - ${e}`);
writeFile(filename, data, extension, overwrite, idx + 1);
}
}

Expand All @@ -312,6 +368,9 @@ function processIssues(issues) {
if (lastMonth < openMonth) {
lastMonth = openMonth;
}
if (openYear > lastYear) {
lastYear = openYear;
}

if (closedAt) {
let closeYear = closedAt.getFullYear();
Expand All @@ -324,7 +383,7 @@ function processIssues(issues) {
}
}

sumValues(openIssues, createdAt, closedAt);
sumValues(openIssues, createdAt, closedAt, issue);
if (!_noLabels && issue.labels && issue.labels.length > 0) {
issue.labels.forEach(label => {
if (!_labels || _labels.includes(label.name)) {
Expand Down Expand Up @@ -359,6 +418,8 @@ function processIssues(issues) {
_startMonth = (yr * 100) + mon;
}

let filename = `issues-${_startMonth + 1}-${lastMonth + 1}`;

logMessage(`Reporting from: ${_startMonth + 1} to ${lastMonth + 1}`);
logHeader("Issues", firstYear, lastYear, lastMonth, openIssues);
dumpCount("New", openIssues, firstYear, lastYear, lastMonth, "opened");
Expand All @@ -370,7 +431,16 @@ function processIssues(issues) {
});
//console.log(JSON.stringify(labels, null, 4));

return lastMonth;

if (_dump) {
console.log("Dumping raw JSON data to: " + filename + "-dump");
writeFile(filename + "-dump", JSON.stringify(openIssues, null, 4), "json", true);

console.log("Dumping raw JSON data to: " + filename + "-issues");
writeFile(filename + "-issues", JSON.stringify(issues, null, 4), "json", true);
}

return filename;
}

if (parseArgs()) {
Expand All @@ -381,15 +451,11 @@ if (parseArgs()) {
console.log(`Running: \"${npmCmd}\"`);
try {
let output = child_process.execSync(npmCmd);
let lastMonth = processIssues(JSON.parse(output));
let filename = processIssues(JSON.parse(output));

if (_csv) {
fs.writeFileSync(`issues-${_startMonth + 1}-${lastMonth + 1}.csv`, _csvOutput, (err, data) => {
if (err) {
console.error(err);
throw `Failed to write ${dtsFileRollup}`;
}
});
console.log("Writing CSV data to: " + filename);
writeFile(filename, _csvOutput, "csv", true);
}
} catch (e) {
console.error("This command requires the Github CLI to be installed and configured.");
Expand Down

0 comments on commit 456728a

Please sign in to comment.