-
Notifications
You must be signed in to change notification settings - Fork 90
VSCODE-20: setup telemetry #52
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fccc4b6
feat: setup telemetry
alenakhineika 64aada7
build: set variable
alenakhineika e45a201
build: rebase from master
alenakhineika 7512bc9
build: change format of the variable
alenakhineika 2e1c177
build: update format
alenakhineika b21635c
feat: add local env file to npmignore
alenakhineika 974f1a2
test: try no-force-async-hooks to solve tests fail on mac
alenakhineika 391fff2
test: try cross-env
alenakhineika d5b704c
fix: use vscode ignore
alenakhineika 33cee36
refactor: fix variables and command description
alenakhineika a9253df
feat: throw error if the segment key is missing in environment variables
alenakhineika b5c2c20
build: add key env variable to the build task
alenakhineika File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ node_modules | |
.DS_Store | ||
test-results.xml | ||
connect-form | ||
constants.json | ||
.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ vsc-extension-quickstart.md | |
**/tsconfig.json | ||
**/tslint.json | ||
**/*.map | ||
**/*.ts | ||
**/*.ts | ||
.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /usr/bin/env ts-node | ||
|
||
import ora = require('ora'); | ||
import fs = require('fs'); | ||
import path = require('path'); | ||
import { resolve } from 'path'; | ||
import { config } from 'dotenv'; | ||
|
||
const { promisify } = require('util'); | ||
const writeFile = promisify(fs.writeFile); | ||
const ROOT_DIR = path.join(__dirname, '..'); | ||
const ui = ora('Generate constants keyfile').start(); | ||
|
||
config({ path: resolve(__dirname, '../.env') }); | ||
|
||
(async () => { | ||
if (process.env.SEGMENT_KEY) { | ||
await writeFile( | ||
`${ROOT_DIR}/constants.json`, | ||
JSON.stringify({ segmentKey: process.env.SEGMENT_KEY }, null, 2) | ||
); | ||
ui.succeed('Generated .constants.json'); | ||
} else { | ||
await Promise.reject(new Error('The Segment key is missing in environment variables')); | ||
} | ||
})().catch((error) => { | ||
ui.fail('Failed to generate constants keyfile'); | ||
console.log(error); | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clarifying so I understand - Is the reason for creating the
constants.json
file so that we can use it in the built extension?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid storing segment key on git, we keep il locally in .env file, that is not being pushed to git, and during the compilation process, we generate constants.json file with this key injected. The constants.json file is also added to
.gitignore
, so the key exists only on the local machine.To publish vscode extension or to build a package locally we use
vsce
command-line tool, sort ofnpm publish
for vscode, that require the compilation step as well, therefore the build will also include constants.json file.When we run tests on Azure, we don't have access to .env file that is stored on our computer, therefore to get constants.json generated there, I use Azure Pipeline variable that I pass to npm test script in azure-pipelines.yml.
I think later when we will have automatic publishing using CI we can get rid of .env file and pass a the same azure variable to deploy script. Since we don't publish to the marketplace yet, and I can't test how this key injection will work, I have this intermediate solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can keep .env, in any case, if we want to continue building packages locally, what also can be useful.