update to google analytics 4#1944
Conversation
this required adding a new env var GA4_PROPERTY_ID now there are ultiple *_gospel_presented events that we sum to get a total gopsel presented value
|
I see you added the "On Staging" label, I'll get this merged to the staging branch! |
|
Merge conflict attempting to merge this into staging. Please fix manually. |
| # grab dump data - crowdin-json format returns a direct hash | ||
| # grab dump data - crowdin-json format returns a direct hash or array | ||
| response = Net::HTTP.get_response(URI.parse(r["data"]["url"])) | ||
| crowdin_json_export = response.body | ||
| JSON.parse(crowdin_json_export) | ||
| parsed = JSON.parse(crowdin_json_export) | ||
|
|
||
| # Handle array format: [{identifier: "key", translation: "value"}, ...] | ||
| if parsed.is_a?(Array) | ||
| parsed.each_with_object({}) { |item, hash| hash[item["identifier"]] = item["translation"] } | ||
| else | ||
| parsed | ||
| end |
There was a problem hiding this comment.
I believe this change snuck in, we didn't need to handle different json formats from Crowdin
There was a problem hiding this comment.
relevant PR we closed after addressing the issue elsewhere: #1912
| it "handles array format from Crowdin API" do | ||
| mock_client = double("Crowdin::Client") | ||
| allow(CrowdinService).to receive(:client).and_return(mock_client) | ||
|
|
||
| # Use the seeded language | ||
| language = Language.find_by!(code: language_code) | ||
| # Ensure crowdin_code is set for the test | ||
| language.update!(crowdin_code: "en") | ||
|
|
||
| # Mock the export call | ||
| export_response = { | ||
| "data" => { | ||
| "url" => "http://example.com/export.xml" | ||
| } | ||
| } | ||
| allow(mock_client).to receive(:export_project_translation) | ||
| .with({targetLanguageId: "en", format: "crowdin-json"}, nil, project_id) | ||
| .and_return(export_response) | ||
|
|
||
| # Mock the HTTP request to return array format | ||
| json_content = '[{"identifier":"test_key","translation":"translated_text"},{"identifier":"another_key","translation":"another_translation"}]' | ||
| stub_request(:get, "http://example.com/export.xml") | ||
| .to_return(status: 200, body: json_content, headers: {}) | ||
|
|
||
| result = CrowdinService.download_translated_phrases(project_id: project_id, language_code: language_code) | ||
|
|
||
| expect(result).to eq("test_key" => "translated_text", "another_key" => "another_translation") | ||
| end | ||
|
|
There was a problem hiding this comment.
this test shouldn't have been added, I believe it was from the Crowdin PR we had closed a couple months ago
frett
left a comment
There was a problem hiding this comment.
Some Crowdin changes we previously decided to not use crept into this PR
this is related to the crowdin fix
frett
left a comment
There was a problem hiding this comment.
this is fine with me now that the unrelated Crowdin changes were removed
this required adding a new env var GA4_PROPERTY_ID
now there are multiple *_gospel_presented events that we sum to get a total gopsel presented value