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

Source domain property directly from the request, not the context #35720

Merged
merged 4 commits into from
Jan 31, 2025

Conversation

mjriley
Copy link
Contributor

@mjriley mjriley commented Jan 31, 2025

Technical Summary

I was noticing that app preview events were setting the domain to none despite a domain being available. This was because the app preview's context does not include the domain.

Feature Flag

Safety Assurance

Safety story

In my local/staging testing, this fixed the issue with app preview while preserving existing behavior for other events. The code itself should be safe, but my main fear is that we might have some code that does not populate the request's domain data and instead relies upon the context. I don't think this is likely, and Ajeet agreed that this change should be safe. In the worst case, we'll start receiving some events where domain is incorrectly listed as none, which is where the app preview currently is.

Automated test coverage

No tests

QA Plan

No QA

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@mjriley mjriley added the product/invisible Change has no end-user visible impact label Jan 31, 2025
@mjriley mjriley requested review from zandre-eng and ajeety4 January 31, 2025 15:12
@mjriley mjriley requested a review from biyeun as a code owner January 31, 2025 15:12
Comment on lines 8 to 9
{% if request.domain %}
{% initial_analytics_data 'gtm.domain' request.domain %}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this? Not sure if prioritizing domain over request.domain is best, but seems to preserve existing behavior the best.

Suggested change
{% if request.domain %}
{% initial_analytics_data 'gtm.domain' request.domain %}
{% if domain or request.domain %}
{% initial_analytics_data 'gtm.domain' domain or request.domain %}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. I don't think there's any circumstance where we have domain data and would want to exclude it, so this is probably the best short-term fix, but is probably long-term confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Glad I tested this -- domain or request.domain doesn't appear to be working. My guess is django's template syntax doesn't evaluate or the same way python does. Seeing if there's a filter we can use

Copy link
Contributor Author

@mjriley mjriley Jan 31, 2025

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry about that! Thanks for testing.

@mjriley mjriley requested a review from orangejenny as a code owner January 31, 2025 16:48
@mjriley mjriley force-pushed the mjr/google-analytics-domain branch from e91fe3b to cf77a3c Compare January 31, 2025 16:54
@mjriley mjriley merged commit 500daf1 into master Jan 31, 2025
13 checks passed
@mjriley mjriley deleted the mjr/google-analytics-domain branch January 31, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/invisible Change has no end-user visible impact
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants