Skip to content

Commit

Permalink
chore(analytics): add GARDEN_DISABLE_ANALYTICS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Feb 14, 2020
1 parent 1eb0a92 commit f27ecd0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ orbs:
- image: circleci/node:12
environment:
GARDEN_DISABLE_VERSION_CHECK: "true"
GARDEN_DISABLE_ANALYTICS: "true"
GARDEN_TASK_CONCURRENCY_LIMIT: "10"
resource_class: large

Expand Down Expand Up @@ -335,6 +336,7 @@ jobs:
- image: gardendev/garden-gcloud:${CIRCLE_SHA1}
environment:
GARDEN_DISABLE_VERSION_CHECK: "true"
GARDEN_DISABLE_ANALYTICS: "true"
GARDEN_TASK_CONCURRENCY_LIMIT: "10"
steps:
# Need to checkout to run example project
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ Before pushing, we automatically run the `check-all` script from above, as well
git push origin <my-branch> --no-verify
```

### Environment Variables

You should set the following environment variables when developing on Garden:

```sh
GARDEN_DISABLE_ANALYTICS=true
GARDEN_DISABLE_VERSION_CHECK=true
ANALYTICS_DEV=true
```

## CI

We use [Circle CI](https://circleci.com) for integration and end to end testing. Sometimes
Expand Down
7 changes: 5 additions & 2 deletions garden-service/src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ export class AnalyticsHandler {
/**
* Used internally to check if a users has opted-in or not.
*/
private hasOptedIn(): boolean {
private analyticsEnabled(): boolean {
if (process.env.GARDEN_DISABLE_ANALYTICS === "true") {
return false
}
return this.globalConfig.optedIn || false
}

Expand Down Expand Up @@ -310,7 +313,7 @@ export class AnalyticsHandler {
* @memberof AnalyticsHandler
*/
private async track(event: AnalyticsEvent) {
if (this.segment && this.hasOptedIn()) {
if (this.segment && this.analyticsEnabled()) {
const segmentEvent: SegmentEvent = {
userId: this.globalConfig.userId || "unknown",
event: event.type,
Expand Down

0 comments on commit f27ecd0

Please sign in to comment.