forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): add anonymous telemetry instrumentation to gatsby (gats…
…byjs#12758) This PR adds anonymous telemetry instrumentation as outlined in the [telemetry RFC](gatsbyjs/rfcs#33) This implementation buffers all telemetry events to a local buffer file, from which events are then sent asynchronously on in a background process.
- v2.5.0-rc.1
- v2.4.0-alpha.2
- v2.4.0-alpha.1
- gatsby-transformer-yaml@2.1.12
- gatsby-transformer-xml@2.0.10
- gatsby-transformer-toml@2.1.9
- gatsby-transformer-toml@2.1.8
- gatsby-transformer-sqip@2.0.40
- gatsby-transformer-sqip@2.0.39
- gatsby-transformer-sqip@2.0.38
- gatsby-transformer-sqip@2.0.37
- gatsby-transformer-sqip@2.0.36
- gatsby-transformer-sqip@2.0.35
- gatsby-transformer-sqip@2.0.34
- gatsby-transformer-sqip@2.0.33
- gatsby-transformer-sqip@2.0.32
- gatsby-transformer-sqip@2.0.31
- gatsby-transformer-sqip@2.0.30
- gatsby-transformer-sqip@2.0.29
- gatsby-transformer-sqip@2.0.28
- gatsby-transformer-sharp@2.1.21
- gatsby-transformer-sharp@2.1.20
- gatsby-transformer-sharp@2.1.19
- gatsby-transformer-sharp@2.1.18
- gatsby-transformer-screenshot@2.0.14
- gatsby-transformer-remark@2.3.12
- gatsby-transformer-remark@2.3.11
- gatsby-transformer-remark@2.3.10
- gatsby-transformer-remark@2.3.9
- gatsby-transformer-react-docgen@4.0.2
- gatsby-transformer-react-docgen@4.0.1
- gatsby-transformer-react-docgen@4.0.0
- gatsby-transformer-javascript-static-exports@2.1.7
- gatsby-transformer-javascript-frontmatter@2.0.10
- gatsby-transformer-hjson@2.1.8
- gatsby-transformer-excel@2.1.11
- gatsby-transformer-documentationjs@4.0.2
- gatsby-transformer-documentationjs@4.0.1
- gatsby-transformer-documentationjs@4.0.0
- gatsby-transformer-documentationjs@3.0.1
- gatsby-transformer-asciidoc@1.0.5
- gatsby-transformer-asciidoc@1.0.4
- gatsby-transformer-asciidoc@1.0.3
- gatsby-telemetry@1.0.11
- gatsby-telemetry@1.0.10
- gatsby-telemetry@1.0.9
- gatsby-telemetry@1.0.8
- gatsby-telemetry@1.0.7
- gatsby-telemetry@1.0.6
- gatsby-telemetry@1.0.5
- gatsby-telemetry@1.0.4
- gatsby-telemetry@1.0.3
- gatsby-telemetry@1.0.2
- gatsby-telemetry@1.0.1
- gatsby-telemetry@1.0.0
- gatsby-source-wordpress@3.0.64
- gatsby-source-wordpress@3.0.63
- gatsby-source-wordpress@3.0.62
- gatsby-source-wordpress@3.0.61
- gatsby-source-wordpress@3.0.60
- gatsby-source-wordpress@3.0.59
- gatsby-source-wordpress@3.0.58
- gatsby-source-wordpress@3.0.57
- gatsby-source-wordpress@3.0.56
- gatsby-source-wordpress@3.0.55
- gatsby-source-wordpress@3.0.54
- gatsby-source-wordpress@3.0.53
- gatsby-source-wordpress@3.0.52
- gatsby-source-wordpress@3.0.51
- gatsby-source-wordpress@3.0.50
- gatsby-source-wikipedia@2.0.8
- gatsby-source-wikipedia@2.0.7
- gatsby-source-wikipedia@2.0.6
- gatsby-source-shopify@2.0.36
- gatsby-source-shopify@2.0.35
- gatsby-source-shopify@2.0.34
- gatsby-source-shopify@2.0.33
- gatsby-source-shopify@2.0.32
- gatsby-source-shopify@2.0.31
- gatsby-source-shopify@2.0.30
- gatsby-source-shopify@2.0.29
- gatsby-source-shopify@2.0.28
- gatsby-source-shopify@2.0.27
- gatsby-source-shopify@2.0.26
- gatsby-source-shopify@2.0.25
- gatsby-source-shopify@2.0.24
- gatsby-source-shopify@2.0.23
- gatsby-source-npm-package-search@2.0.5
- gatsby-source-mongodb@2.0.19
- gatsby-source-mongodb@2.0.18
- gatsby-source-mongodb@2.0.17
- gatsby-source-medium@2.0.8
- gatsby-source-medium@2.0.7
- gatsby-source-lever@2.0.9
- gatsby-source-lever@2.0.8
- gatsby-source-hacker-news@2.0.12
- gatsby-source-hacker-news@2.0.11
- gatsby-source-graphql@2.0.18
- gatsby-source-graphql@2.0.17
- gatsby-source-graphql@2.0.16
- gatsby-source-filesystem@2.0.38
- gatsby-source-filesystem@2.0.37
- gatsby-source-filesystem@2.0.36
- gatsby-source-filesystem@2.0.35
- gatsby-source-filesystem@2.0.34
- gatsby-source-filesystem@2.0.33
- gatsby-source-filesystem@2.0.32
- gatsby-source-filesystem@2.0.31
- gatsby-source-filesystem@2.0.30
- gatsby-source-filesystem@2.0.29
- gatsby-source-drupal@3.1.10
- gatsby-source-drupal@3.1.9
- gatsby-source-drupal@3.1.8
- gatsby-source-drupal@3.1.7
- gatsby-source-drupal@3.1.6
- gatsby-source-drupal@3.1.5
- gatsby-source-drupal@3.1.4
- gatsby-source-drupal@3.1.3
- gatsby-source-drupal@3.1.2
- gatsby-source-drupal@3.1.1
- gatsby-source-drupal@3.1.0
- gatsby-source-drupal@3.0.34
- gatsby-source-drupal@3.0.33
- gatsby-source-contentful@2.0.67
- gatsby-source-contentful@2.0.66
- gatsby-source-contentful@2.0.65
- gatsby-source-contentful@2.0.64
- gatsby-source-contentful@2.0.63
- gatsby-source-contentful@2.0.62
- gatsby-source-contentful@2.0.61
- gatsby-source-contentful@2.0.60
- gatsby-source-contentful@2.0.59
- gatsby-source-contentful@2.0.58
- gatsby-source-contentful@2.0.57
- gatsby-source-contentful@2.0.56
- gatsby-source-contentful@2.0.55
- gatsby-source-contentful@2.0.54
- gatsby-source-contentful@2.0.53
- gatsby-source-contentful@2.0.52
- gatsby-source-contentful@2.0.51
- gatsby-source-contentful@2.0.50
- gatsby-source-contentful@2.0.49
- gatsby-source-contentful@2.0.48
- gatsby-source-contentful@2.0.47
- gatsby-source-contentful@2.0.46
- gatsby-source-contentful@2.0.45
- gatsby-remark-prismjs@3.2.10
- gatsby-remark-prismjs@3.2.9
- gatsby-remark-prismjs@3.2.8
- gatsby-remark-prismjs@3.2.7
- gatsby-remark-images-contentful@2.0.13
- gatsby-remark-images-contentful@2.0.12
- gatsby-remark-images-contentful@2.0.11
- gatsby-remark-images@3.0.14
- gatsby-remark-images@3.0.13
- gatsby-remark-images@3.0.12
- gatsby-remark-images@3.0.11
- gatsby-remark-graphviz@1.0.10
- gatsby-remark-copy-linked-files@2.0.13
- gatsby-remark-copy-linked-files@2.0.12
- gatsby-remark-code-repls@2.1.0
- gatsby-remark-code-repls@2.0.8
- gatsby-react-router-scroll@2.0.7
- gatsby-plugin-typography@2.2.13
- gatsby-plugin-typography@2.2.12
- gatsby-plugin-typography@2.2.11
- gatsby-plugin-typescript@2.0.15
- gatsby-plugin-typescript@2.0.14
- gatsby-plugin-typescript@2.0.13
- gatsby-plugin-typescript@2.0.12
- gatsby-plugin-subfont@1.0.6
- gatsby-plugin-subfont@1.0.5
- gatsby-plugin-styletron@4.0.0
- gatsby-plugin-sitemap@2.1.0
- gatsby-plugin-sitemap@2.0.12
- gatsby-plugin-sitemap@2.0.11
- gatsby-plugin-sharp@2.1.3
- gatsby-plugin-sharp@2.1.2
- gatsby-plugin-sharp@2.1.1
- gatsby-plugin-sharp@2.1.0
- gatsby-plugin-sharp@2.0.37
- gatsby-plugin-sharp@2.0.36
- gatsby-plugin-sharp@2.0.35
- gatsby-plugin-sharp@2.0.34
- gatsby-plugin-sharp@2.0.33
- gatsby-plugin-sharp@2.0.32
- gatsby-plugin-remove-trailing-slashes@2.0.11
- gatsby-plugin-react-helmet@3.0.12
- gatsby-plugin-preact@3.0.0
- gatsby-plugin-page-creator@2.0.13
- gatsby-plugin-page-creator@2.0.12
- gatsby-plugin-offline@2.1.1
- gatsby-plugin-offline@2.1.0
- gatsby-plugin-netlify-cms@4.0.1
- gatsby-plugin-netlify-cms@4.0.0
- gatsby-plugin-netlify-cms@3.0.18
- gatsby-plugin-netlify@2.0.17
- gatsby-plugin-netlify@2.0.16
- gatsby-plugin-netlify@2.0.15
- gatsby-plugin-netlify@2.0.14
- gatsby-plugin-manifest@2.1.1
- gatsby-plugin-manifest@2.1.0
- gatsby-plugin-manifest@2.0.29
- gatsby-plugin-manifest@2.0.28
- gatsby-plugin-manifest@2.0.27
- gatsby-plugin-manifest@2.0.26
- gatsby-plugin-manifest@2.0.25
- gatsby-plugin-less@2.0.13
- gatsby-plugin-layout@1.0.15
- gatsby-plugin-layout@1.0.14
- gatsby-plugin-guess-js@1.0.6
- gatsby-plugin-google-tagmanager@2.0.15
- gatsby-plugin-google-tagmanager@2.0.14
- gatsby-plugin-google-tagmanager@2.0.13
- gatsby-plugin-google-tagmanager@2.0.12
- gatsby-plugin-google-gtag@1.0.17
- gatsby-plugin-google-analytics@2.0.20
- gatsby-plugin-google-analytics@2.0.19
- gatsby-plugin-google-analytics@2.0.18
- gatsby-plugin-glamor@2.0.10
- gatsby-plugin-fullstory@2.0.5
- gatsby-plugin-flow@1.0.6
- gatsby-plugin-flow@1.0.5
- gatsby-plugin-feed@2.2.2
- gatsby-plugin-feed@2.2.1
- gatsby-plugin-feed@2.2.0
- gatsby-plugin-feed@2.1.2
- gatsby-plugin-feed@2.1.1
- gatsby-plugin-facebook-analytics@2.1.1
- gatsby-plugin-facebook-analytics@2.1.0
- gatsby-plugin-facebook-analytics@2.0.5
- gatsby-plugin-emotion@4.0.7
- gatsby-plugin-catch-links@2.0.15
- gatsby-plugin-catch-links@2.0.14
- gatsby-plugin-canonical-urls@2.0.13
- gatsby-link@2.1.1
- gatsby-link@2.1.0
- gatsby-link@2.0.17
- gatsby-image@2.1.2
- gatsby-image@2.1.1
- gatsby-image@2.1.0
- gatsby-image@2.0.41
- gatsby-image@2.0.40
- gatsby-image@2.0.39
- gatsby-image@2.0.38
- gatsby-image@2.0.37
- gatsby-image@2.0.36
- gatsby-image@2.0.35
- gatsby-graphiql-explorer@0.1.2
- gatsby-graphiql-explorer@0.1.1
- gatsby-graphiql-explorer@0.1.0
- gatsby-dev-cli@2.4.19
- gatsby-dev-cli@2.4.18
- gatsby-dev-cli@2.4.17
- gatsby-dev-cli@2.4.16
- gatsby-dev-cli@2.4.15
- gatsby-dev-cli@2.4.14
- gatsby-dev-cli@2.4.13
- gatsby-cypress@0.1.9
- gatsby-cypress@0.1.8
- gatsby-codemods@1.0.11
- gatsby-cli@2.6.5
- gatsby-cli@2.6.4
- gatsby-cli@2.6.3
- gatsby-cli@2.6.2
- gatsby-cli@2.6.1
- gatsby-cli@2.6.0
- gatsby-cli@2.5.15
- gatsby-cli@2.5.14
- gatsby-cli@2.5.13
- gatsby-cli@2.5.12
- gatsby-cli@2.5.11
- gatsby-cli@2.5.10
- gatsby-cli@2.5.9
- gatsby-cli@2.5.8
- gatsby-cli@2.5.7
- gatsby-cli@2.5.6
- gatsby-cli@2.5.5
- gatsby-cli@2.5.4
- gatsby-cli@2.5.3
- gatsby-cli@2.5.2
- gatsby-cli@2.5.1
- gatsby-cli@2.5.0
- gatsby@2.8.5
- gatsby@2.8.4
- gatsby@2.8.3
- gatsby@2.8.2
- gatsby@2.8.1
- gatsby@2.8.0
- gatsby@2.7.6
- gatsby@2.7.5
- gatsby@2.7.4
- gatsby@2.7.3
- gatsby@2.7.2
- gatsby@2.7.1
- gatsby@2.7.0
- gatsby@2.6.4
- gatsby@2.6.3
- gatsby@2.6.2
- gatsby@2.6.1
- gatsby@2.6.0
- gatsby@2.5.7
- gatsby@2.5.6
- gatsby@2.5.5
- gatsby@2.5.4
- gatsby@2.5.3
- gatsby@2.5.2
- gatsby@2.5.1
- gatsby@2.5.0
- gatsby@2.4.7
- gatsby@2.4.6
- gatsby@2.4.5
- gatsby@2.4.4
- gatsby@2.4.3
- gatsby@2.4.2
- gatsby@2.4.1
- gatsby@2.4.0
- gatsby@2.3.36
- gatsby@2.3.35
- gatsby@2.3.34
- gatsby@2.3.33
- gatsby@2.3.32
- gatsby@2.3.31
- gatsby@2.3.30
- gatsby@2.3.29
- gatsby@2.3.28
- gatsby@2.3.27
- gatsby@2.3.26
- gatsby@2.3.25
- gatsby@2.3.24
- gatsby@2.3.23
- gatsby@2.3.22
- gatsby@2.3.21
- gatsby@2.3.20
- gatsby@2.3.19
- gatsby@2.3.18
- gatsby@2.3.17
- gatsby@2.3.16
- gatsby@2.3.15
- gatsby@2.3.14
- gatsby@2.3.13
- gatsby@2.3.12
- gatsby@2.3.11
- gatsby@2.3.10
- gatsby@2.3.9
- gatsby@2.3.8
- gatsby@2.3.7
- gatsby@2.3.6
- gatsby@2.3.5
- gatsby@2.3.4
- gatsby@2.3.3
- gatsby@2.3.2
- gatsby@2.3.1
- gatsby@2.3.0
- babel-preset-gatsby@0.1.11
- babel-plugin-remove-graphql-queries@2.6.3
Showing
30 changed files
with
850 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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,49 @@ | ||
--- | ||
title: Telemetry | ||
--- | ||
|
||
Gatsby contains a telemetry feature that collects anonymous usage information that is used to help improve Gatsby for all users. | ||
The Gatsby user base is growing very rapidly. It's important that our small team and the greater community will better understand the usage patterns, so we can best decide how to design future features and prioritize current work. | ||
|
||
You will be notified when installing Gatsby and when running it for the first time. | ||
|
||
## How to opt-out | ||
|
||
Users may always opt-out from the telemetry with `gatsby telemetry --disable` or setting the environment variable `GATSBY_TELEMETRY_DISABLED` to `1` | ||
|
||
## Why? | ||
|
||
**Anonymous** aggregate user analytics allow us to prioritize fixes and features based on how and when people use Gatsby. | ||
Since much of Gatsby’s function revolves around community plugins and starters, we want to collect information on usage | ||
and reliability so that we can ensure a high-quality ecosystem. | ||
|
||
This raises a question: how will we use this telemetry data to improve the ecosystem? Some examples are helpful: | ||
|
||
- We will be able to understand which plugins are typically used together. This will enable us to surface this information in our public plugin library and build more relevant starters and tutorials based on this data. | ||
- We will be able to surface popularity of different starters in the starter showcase. | ||
- We will be able to get more detail on the types of errors users are running into in _every_ build stage (e.g. development, build, etc.). This will let us improve the quality of our tool and better focus our time on solving more common, frustrating issues. | ||
- We will be able to surface reliability of different plugins and starters, and detect which of these tend to error more frequently. We can use this data to surface quality metrics and improve the quality of our plugins and starters. | ||
- We will be able to see timings for different build stages to guide us in where we should focus optimization work. | ||
|
||
## What do we track? | ||
|
||
We track general usage details, including command invocation, build process status updates, performance measurements, and errors. | ||
We use these metrics to better understand the usage patterns. These metrics will directly allow us to better decide how to design future features and prioritize current work. | ||
|
||
Specifically, we collect the following information for _all_ telemetry events: | ||
|
||
- Timestamp of the occurrence | ||
- Command invoked (e.g. `build` or `develop`) | ||
- Gatsby machine ID. This is generated with UUID and stored in global gatsby config at ~/.config/gatsby/config.json. | ||
- Unique session ID. This is generated on each run with UUID. | ||
- One-way hash of the current working directory or a hash of the git remote | ||
- General OS level information (operating system, version, CPU architecture, and whether the command is run inside a CI) | ||
- Current Gatsby version | ||
|
||
The access to the raw data is highly controlled, and we cannot identify individual users from the dataset. It is anonymized and untraceable back to the user. | ||
|
||
## What about sensitive data? (e.g. secrets) | ||
|
||
We perform additional steps to ensure that secure data (e.g. environment variables used to store secrets for the build process) **do not** make their way into our analytics. [We strip logs, error messages, etc.](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-telemetry/src/sanitize-error.js) of this sensitive data to ensure we _never_ gain access to this sensitive data. | ||
|
||
You can view all the information that is sent by Gatsby’s telemetry by setting the environment variable `GATSBY_TELEMETRY_DEBUG`to `1` to print the telemetry data instead of sending it over. |
This file contains 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 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 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 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 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,5 @@ | ||
{ | ||
"presets": [ | ||
["babel-preset-gatsby-package"] | ||
] | ||
} |
This file contains 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,2 @@ | ||
/lib | ||
/node_modules |
This file contains 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 @@ | ||
# Change Log |
This file contains 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,38 @@ | ||
# gatsby-telemetry | ||
|
||
Check out: [gatsby.dev/telemetry](https://gatsby.dev/telemetry) | ||
|
||
## API | ||
|
||
### trackCli(type, tags) | ||
|
||
Capture an event of type `type` and decorate the generated event with these tags (note: allowed tags are filtered on server side) | ||
|
||
### trackError(type, tags) | ||
|
||
Capture an error of type `type`. The exception maybe passed in tags and it will be sanitize to anonymize the contents. | ||
|
||
### trackBuildError(type, tags) | ||
|
||
Capture an build error of type `type`. The exception maybe passed in tags and it will be sanitize to anonymize the contents. | ||
|
||
### setDefaultTags(tags) | ||
|
||
Set additional tags to be included in all future events. | ||
|
||
### decorateEvent(type, tags) | ||
|
||
Attach additional tags to the next event generated of type `type`. | ||
|
||
### setTelemetryEnabled(enabled) | ||
|
||
Enable or disable the telemetry collection. | ||
|
||
### expressMiddleware(type) | ||
|
||
Returns a debounced events tracker for collecting general activity information for incoming requests. | ||
|
||
## ENV Variables | ||
|
||
- Set `GATSBY_TELEMETRY_DEBUG` to `1` to print the telemetry data instead of sending it over | ||
- Set `GATSBY_TELEMETRY_DISABLED` to `1` to opt out of all telemetry |
This file contains 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,54 @@ | ||
{ | ||
"name": "gatsby-telemetry", | ||
"description": "Gatsby Telemetry", | ||
"version": "0.0.1", | ||
"author": "Jarmo Isotalo <[email protected]>", | ||
"bugs": { | ||
"url": "https://github.com/gatsbyjs/gatsby/issues" | ||
}, | ||
"dependencies": { | ||
"@babel/code-frame": "^7.0.0", | ||
"@babel/runtime": "^7.0.0", | ||
"bluebird": "^3.5.0", | ||
"ci-info": "2.0.0", | ||
"configstore": "4.0.0", | ||
"envinfo": "^5.8.1", | ||
"node-fetch": "2.3.0", | ||
"resolve-cwd": "^2.0.0", | ||
"source-map": "^0.5.7", | ||
"stack-trace": "^0.0.10", | ||
"stack-utils": "1.0.2", | ||
"uuid": "3.3.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"babel-jest": "^24.0.0", | ||
"babel-preset-gatsby-package": "^0.1.3", | ||
"cross-env": "^5.1.4", | ||
"jest": "^24.0.0", | ||
"jest-cli": "^24.0.0", | ||
"jest-junit": "^6.1.0" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src/postinstall.js" | ||
], | ||
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-telemetry#readme", | ||
"keywords": [ | ||
"telemetry" | ||
], | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-telemetry", | ||
"scripts": { | ||
"build": "babel src --out-dir lib --ignore **/__tests__", | ||
"prepare": "cross-env NODE_ENV=production npm run build", | ||
"jest": "jest", | ||
"postinstall": "node src/postinstall.js", | ||
"watch": "babel -w src --out-dir lib --ignore **/__tests__" | ||
}, | ||
"yargs": { | ||
"boolean-negation": false | ||
} | ||
} |
This file contains 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,22 @@ | ||
const isTruthy = require(`../is-truthy`) | ||
|
||
describe(`isTruthy`, () => { | ||
it(`handles Booleans`, () => { | ||
expect(isTruthy(true)).toBe(true) | ||
expect(isTruthy(false)).toBe(false) | ||
}) | ||
it(`handles true or false strings `, () => { | ||
expect(isTruthy(`true`)).toBe(true) | ||
expect(isTruthy(`false`)).toBe(false) | ||
expect(isTruthy(`TRUE`)).toBe(true) | ||
expect(isTruthy(`FALSE`)).toBe(false) | ||
}) | ||
it(`handles numbers`, () => { | ||
expect(isTruthy(`1`)).toBe(true) | ||
expect(isTruthy(`0`)).toBe(false) | ||
expect(isTruthy(`-1`)).toBe(false) | ||
}) | ||
it(`defaults to false`, () => { | ||
expect(isTruthy(`blah`)).toBe(false) | ||
}) | ||
}) |
This file contains 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,62 @@ | ||
const sanitize = require(`../sanitize-error`) | ||
|
||
describe(`sanitize errors`, () => { | ||
it(`Removes env, output and converts buffers to strings from execa output`, () => { | ||
const tags = { | ||
error: [ | ||
{ | ||
error: null, | ||
cmd: `git commit -m"test"`, | ||
file: `/bin/sh`, | ||
args: [`/bin/sh`, `-c`, `git commit -m"test`], | ||
options: { | ||
cwd: `here`, | ||
shell: true, | ||
envPairs: [`VERSION=1.2.3`], | ||
stdio: [{}, {}, {}], // pipes | ||
}, | ||
envPairs: [`VERSION=1.2.3`], | ||
|
||
stderr: Buffer.from(`this is a test`), | ||
stdout: Buffer.from(`this is a test`), | ||
}, | ||
], | ||
} | ||
|
||
const error = tags.error[0] | ||
expect(error).toBeDefined() | ||
expect(error.envPairs).toBeDefined() | ||
expect(error.options).toBeDefined() | ||
|
||
expect(typeof error.stdout).toEqual(`object`) | ||
|
||
sanitize(tags) | ||
expect(typeof error.stdout).toEqual(`string`) | ||
|
||
expect(error).toBeDefined() | ||
expect(error.envPairs).toBeUndefined() | ||
expect(error.options).toBeUndefined() | ||
}) | ||
|
||
it(`Sanitizes current path from error stracktraces`, () => { | ||
const errormessage = `this is a test` | ||
let e | ||
try { | ||
throw new Error(errormessage) | ||
} catch (error) { | ||
e = error | ||
} | ||
expect(e).toBeDefined() | ||
expect(e.message).toEqual(errormessage) | ||
expect(e.stack).toBeDefined() | ||
const localPathRegex = new RegExp( | ||
process.cwd().replace(/[-[/{}()*+?.\\^$|]/g, `\\$&`) | ||
) | ||
expect(localPathRegex.test(e.stack)).toBeTruthy() | ||
const tags = { error: [e] } | ||
|
||
sanitize(tags) | ||
|
||
expect(localPathRegex.test(e.stack)).toBeFalsy() | ||
}) | ||
}) |
Oops, something went wrong.