Skip to content
New issue

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

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

Already on GitHub? # to your account

Add analytics to npq #1917

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Add analytics to npq #1917

merged 2 commits into from
Nov 7, 2024

Conversation

slawosz
Copy link
Contributor

@slawosz slawosz commented Nov 6, 2024

This PR is introducing def-analytics to NPQ.
Currently analytics will be send only to staging environment to test integration.

There is extra PR to be merge to allow excluding certain models, for the time being npq will be using fork: DFE-Digital/dfe-analytics#169

# config.user_identifier = proc { |user| user&.id

# if part of any model name is migration, it wont be loaded
config.excluded_models_proc = proc { |x| x.to_s =~ /Migration::/ }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the migration things not be added to the blocklist for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration needs to be added, otherwise plugin will not work.
Currently we have models like Statement and Migration::Statement, which are pointing to 2 databases, but both are using statements table. The dfe-analytics operates on tables names so it gets confused by 2 tables that have the same name but are using 2 different schemas.

Excluding Migration:: tables does not give much difference - all important data will be exported anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense! Thanks.

@peteryates
Copy link
Member

peteryates commented Nov 6, 2024

Looks good, I think you just need to regenerate the blocklist.

# A proc which returns true or false depending on whether you want to
# enable analytics. You might want to hook this up to a feature flag or
# environment variable.
config.enable_analytics = proc { Rails.env.staging? }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a feature flag instead so we can enable it in the envs we want incase?

# The environment we’re running in. This value will be attached
# to all events we send to BigQuery.
#
config.environment = ENV.fetch('RAILS_ENV', 'development')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we want to enable this?

Copy link
Contributor

@leandroalemao leandroalemao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any spec to add maybe?
Also It'd be a nice idea to have a look at the yml files in ECF as a base to generate the lists here?

https://github.com/DFE-Digital/early-careers-framework/blob/main/config/analytics_blocklist.yml
and
https://github.com/DFE-Digital/early-careers-framework/blob/main/config/analytics_pii.yml

# environment variable.
config.enable_analytics = proc { Rails.env.staging? }


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have this job enabled in ECF.. does it make any difference if we also add here?

https://github.com/DFE-Digital/dfe-analytics?tab=readme-ov-file#entity-table-check-job

Copy link
Contributor

github-actions bot commented Nov 7, 2024

Copy link

sonarqubecloud bot commented Nov 7, 2024

@slawosz slawosz added this pull request to the merge queue Nov 7, 2024
@slawosz slawosz removed this pull request from the merge queue due to a manual request Nov 7, 2024
@slawosz slawosz added this pull request to the merge queue Nov 7, 2024
Merged via the queue into main with commit bad5ca0 Nov 7, 2024
18 checks passed
@slawosz slawosz deleted the 2061-dfe-analytics branch November 7, 2024 17:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants