Skip to content

Commit

Permalink
capture siteHash
Browse files Browse the repository at this point in the history
  • Loading branch information
jamo committed Sep 30, 2020
1 parent 5fda083 commit 2a5eae6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-telemetry/src/index.ts
Expand Up @@ -38,7 +38,7 @@ export function trackCli(
tags?: ITelemetryTagsPayload,
opts?: ITelemetryOptsPayload
): void {
instance.captureEvent(input, tags, opts)
instance.trackCli(input, tags, opts)
}

export function captureEvent(
Expand Down
17 changes: 16 additions & 1 deletion packages/gatsby-telemetry/src/telemetry.ts
@@ -1,6 +1,6 @@
import uuidv4 from "uuid/v4"
import os from "os"
import { isCI, getCIName } from "gatsby-core-utils"
import { isCI, getCIName, createContentDigest } from "gatsby-core-utils"
import {
getRepositoryId as _getRepositoryId,
IRepositoryId,
Expand Down Expand Up @@ -120,6 +120,7 @@ export class AnalyticsTracker {
repositoryId?: IRepositoryId
features = new Set<string>()
machineId: string
siteHash?: string = createContentDigest(process.cwd())

constructor({
componentId,
Expand Down Expand Up @@ -204,6 +205,20 @@ export class AnalyticsTracker {
return `-0.0.0`
}

trackCli(
type: string | Array<string> = ``,
tags: ITelemetryTagsPayload = {},
opts: ITelemetryOptsPayload = { debounce: false }
): void {
if (!this.isTrackingEnabled()) {
return
}
if (typeof tags.siteHash === `undefined`) {
tags.siteHash = this.siteHash
}
this.captureEvent(type, tags, opts)
}

captureEvent(
type: string | Array<string> = ``,
tags: ITelemetryTagsPayload = {},
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -20725,7 +20725,7 @@ remark-mdx@1.6.16:
remark-parse "8.0.3"
unified "9.1.0"

remark-mdx@^1.6.18, remark-mdx@^1.6.6:
remark-mdx@^1.6.18:
version "1.6.18"
resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-1.6.18.tgz#d8c76017c95824cc7fb853bb2759add8ba0cf319"
integrity sha512-xNhjv4kJZ8L6RV68yK8fQ6XWlvSIFOE5VPmM7wMKSwkvwBu6tlUJy0gRF2WiZ4fPPOj6jpqlVB9QakipvZuEqg==
Expand Down

0 comments on commit 2a5eae6

Please sign in to comment.