Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally log more stats #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mrienstra
Copy link

⚠️ WIP

There are some additional stats being returned that could be logged:

averagerating
ratingcount
trendingdaily
trendingmonthly
trendingweekly
weightedRating

This is a POC of how it could be done. It defaults to logging the existing stats. If you uncomment lines 22-23, it will then also track trendingweekly & trendingdaily.

If there is an existing `${extensionName}-stats-${isoDateString}.csv` file with matching CSV headers, it will write to it. If the headers are wrong, it will append a number to the end, incrementing this number as needed: `${extensionName}-stats-${isoDateString}_${suffix++}.csv`


Some of the changes (the most glaring being the switch from require to import) are due to the use of a top-level await.

I added a package.json (npm init -y, then changed license and author), again to support the use of a top-level await.

Line 5: "type": "module", does the magic. See https://www.google.com/search?q=top+level+await+type+module+package.json

**WIP**

There are some additional stats that could be tracked:

```
averagerating
ratingcount
trendingdaily
trendingmonthly
trendingweekly
weightedRating
```

This is a POC of how it could be done.  It defaults to the existing stats. If you uncomment lines 22-23, it will then also track `trendingweekly` & `trendingdaily`.

If there is an existing ``` `${extensionName}-stats-${isoDateString}.csv` ``` file with matching CSV headers, it will write to it. If the headers are wrong, it will append a number to end, incrementing this number as needed: ``` `${extensionName}-stats-${isoDateString}_${suffix++}.csv` ```

Some of the changes (the most glaring being the switch from `require` to `import`) are due to the use of a top-level `await`.

---

While throwing this together, I ran across a bug introduced in RandomFractals#5 -- the CSV headers were only changed from `DateTime, Installs, Downloads, Version` to `DateTime, Installs, Updates, Downloads, Version` in the `console.log`, they should've also been changed on [line 65](https://github.com/RandomFractals/vscode-marketplace-ext-stats/blob/0224c96/tools/vscode-marketplace-stats.js#L65) where they are written to the `.csv` file (as well as in a few comments).
**WIP**

Needed for top-level `await` in `tools/vscode-marketplace-stats.js`

Line 5: `"type": "module",` does the magic. See https://www.google.com/search?q=top+level+await+type+module+package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant