Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(mvp) #16686

Merged
merged 1 commit into from
May 8, 2024
Merged

(mvp) #16686

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading