Skip to content

Commit

Permalink
Send Segment extra info to FE (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren authored Jul 22, 2022
1 parent 0076b63 commit d285aa8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
ANALYTICS_BE_KEY=${{ secrets.ANALYTICS_BE_KEY }}
ANALYTICS_FE_KEY=${{ secrets.ANALYTICS_FE_KEY }}
VERSION=sha-${{ steps.vars.outputs.sha_short }}
ENV=main
TRACETEST_ENV=main
deploy-beta:
if: github.event_name == 'push'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
VERSION=pr-${{ github.event.pull_request.number }}
ENV=pr
TRACETEST_ENV=pr
- name: Update docker cache
run: |
rm -rf /tmp/.buildx-cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
ANALYTICS_BE_KEY=${{ secrets.ANALYTICS_BE_KEY }}
ANALYTICS_FE_KEY=${{ secrets.ANALYTICS_FE_KEY }}
VERSION=${{ github.ref_name}}
ENV=main
TRACETEST_ENV=main
- name: Run GoReleaser to publish release notes
uses: goreleaser/goreleaser-action@v2
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
ANALYTICS_BE_KEY=${{ secrets.ANALYTICS_BE_KEY }}
ANALYTICS_FE_KEY=${{ secrets.ANALYTICS_FE_KEY }}
VERSION=${{ github.ref_name}}-demo
ENV=demo
TRACETEST_ENV=demo
- name: Set ouput docker tag
run: echo "::set-output tag=${{ steps.meta.outputs.tags }}"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WORKDIR /go/src
ARG ANALYTICS_BE_KEY
ARG ANALYTICS_FE_KEY
ARG VERSION
ARG ENV
ARG TRACETEST_ENV

RUN apk add --update make

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: .
args:
VERSION: dev
ENV: docker-compose
TRACETEST_ENV: docker-compose
volumes:
- type: bind
source: ./local-config/config.tests.yaml
Expand Down
3 changes: 2 additions & 1 deletion server/analytics/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func newSegmentTracker(hostname, serverID, appVersion, env string) Tracker {
client := segment.New(SecretKey)

client.Enqueue(segment.Identify{
UserId: serverID,
Traits: segment.NewTraits().
Set("serverID", serverID).
Set("env", env).
Set("appVersion", appVersion).
Set("hostname", hostname),
Expand Down Expand Up @@ -46,6 +46,7 @@ func (t segmentTracker) Ready() bool {

func (t segmentTracker) Track(name string, props map[string]string) error {
p := segment.NewProperties().
Set("serverID", t.serverID).
Set("env", t.env).
Set("appVersion", t.appVersion).
Set("hostname", t.hostname)
Expand Down
5 changes: 4 additions & 1 deletion server/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func spaHandler(prefix, staticPath, indexPath string, tplVars map[string]string)
}

func (a *App) Start() error {
fmt.Println("Starting tracetest", Version)
fmt.Printf("Starting tracetest (version %s, env %s)\n", Version, Env)

serverID, isNewInstall, err := a.db.ServerID()

Expand Down Expand Up @@ -151,6 +151,9 @@ func (a *App) Start() error {
"AnalyticsKey": analytics.FrontendKey,
"AnalyticsEnabled": fmt.Sprintf("%t", a.config.GA.Enabled),
"ServerPathPrefix": fmt.Sprintf("%s/", a.config.Server.PathPrefix),
"ServerID": serverID,
"AppVersion": Version,
"Env": Env,
},
),
)
Expand Down

0 comments on commit d285aa8

Please sign in to comment.