Skip to content

Commit

Permalink
(mvp)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdewey committed May 8, 2024
1 parent c51141a commit 1d8a912
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
module Analytics

Check failure on line 1 in modules/analytics/app/controllers/analytics/v0/analytics_controller.rb

View workflow job for this annotation

GitHub Actions / Audit Service Tags

Analytics::V0::AnalyticsController is missing a service tag. Please associate with a service catalog entry using the Traceable#service_tag method.
module V0
class AnalyticsController < ApplicationController
skip_before_action :authenticate

before_action :authenticate
def index
data = { hello: 'world', salt: Settings.analytics.unique_user.salt }
render json: data
return unless current_user
render json: {
user_fingerprint: get_user_fingerprint(current_user.uuid)
}
end

private

def get_user_fingerprint(user_property)
Digest::SHA256.hexdigest("#{Settings.analytics.unique_user.salt}#{user_property}")
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions modules/analytics/spec/request/v0/analytics_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'V0::Analytics', type: :request do
before do
sign_in_as(current_user)
end

describe 'GET `index`' do
let(:current_user) { build(:user, :loa3, icn: '123498767V234859', uuid:'test-guid') }

it 'returns things' do
get '/analytics/v0/user/hashes'
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq({ 'user_fingerprint' => 'e867710d806a3533f0843405c3ba9bdd0769b2ff84fcce8f75e6b64a406e70c3' })
end


end
end

0 comments on commit 1d8a912

Please sign in to comment.