Skip to content

fix(newsletter): set first_name on signup so issues stop greeting "Namaste ," - #473

Open
damo-da wants to merge 1 commit into
mainfrom
fix/newsletter-first-name-variable
Open

fix(newsletter): set first_name on signup so issues stop greeting "Namaste ,"#473
damo-da wants to merge 1 commit into
mainfrom
fix/newsletter-first-name-variable

Conversation

@damo-da

@damo-da damo-da commented Aug 29, 2026

Copy link
Copy Markdown
Member

User description

What

The subscribe endpoint never set the first_name SendPulse variable. It joined firstName and lastName into a display name and passed it as name, which SendPulse stores as its own Name field. No newsletter template reads that field.

Every newsletter greets with {{first_name}}. SendPulse renders a missing merge variable as empty, not as a fallback, so organic signups received:

Namaste ,

comma still attached.

Why now

Not hypothetical, and not historical. The four most recent website signups before this change all arrived with Name and no first_name:

Added Contact
2026-08-25 root@awafdehi.org
2026-08-26 kgurung@yahoo.com
2026-08-28 sujeshsah01@gmail.com
2026-08-28 kamalghimire121@gmail.com

All four had to be backfilled by hand before the event-postponement issue could go out. Contacts from 2026-07-22 to 08-20 look correct only because someone already swept them, which is why this reads as fixed when you glance at the book.

The fix

NewsletterSubscriptionSerializer has carried firstName as its own validated field the whole time, so the given name only needs forwarding into the variable the templates read. The joined display name still rides along as name for SendPulse's dashboard column.

Tests

Two, both verified to fail with the change reverted:

  • test_subscribe_success_calls_sendpulse now asserts first_name and the display name are populated independently, so a future refactor cannot collapse one into the other unnoticed
  • test_subscribe_sets_first_name_without_last_name covers the optional-lastName path

newsletter/ suite: 34 passed. ruff check clean. ruff format is not run: it wants to reformat four files including ones this PR does not touch, so the repo is not format-clean to begin with and reformatting would bury the change.

Not covered here

  • Existing contacts are already backfilled in book 719648 (116 contacts, 0 missing first_name as of 2026-08-29). This only stops new ones arriving broken.
  • A SendPulse-side default value for first_name is still worth setting as a safety net, since it also covers contacts added by any other route. That is a dashboard setting under Personalisation, not reachable from the API.

🤖 Generated with Claude Code


PR Type

Bug fix, Tests


Description

  • SendPulse first_name populated

  • Display name preserved separately

  • Optional lastName covered


Diagram Walkthrough

flowchart LR
  signup["Signup payload"]
  view["Newsletter view"]
  sendpulse["SendPulse contact"]
  template["Newsletter greeting"]
  signup -- "firstName" --> view
  view -- "first_name variable" --> sendpulse
  sendpulse -- "{{first_name}}" --> template
Loading

File Walkthrough

Relevant files
Bug fix
views.py
Forward firstName into SendPulse variable                               

newsletter/views.py

  • Adds first_name to SendPulse variables.
  • Uses validated data["firstName"].
  • Keeps joined name for dashboard display.
+6/-0     
Tests
test_api.py
Cover newsletter first_name subscription behavior               

newsletter/tests/test_api.py

  • Asserts first_name sent on subscription.
  • Verifies name remains full display name.
  • Adds no-lastName coverage.
+18/-0   


🛠️ Relevant configurations:


These are the relevant configurations for this tool:

[config]

model: openai/cx/gpt-5.5
git_provider: github
custom_reasoning_model: False
output_relevant_configurations: True
custom_model_max_tokens: 200000
fallback_models: ['openai/cx/gpt-5.4-mini']
ENABLE_AUTO_APPROVAL: True
is_auto_command: True
publish_output: True
publish_output_progress: True
progress_gif_url: 
progress_gif_width: 48
verbosity_level: 0
use_extra_bad_extensions: False
log_level: DEBUG
use_wiki_settings_file: True
use_repo_settings_file: True
use_global_settings_file: True
extra_config_url: 
disable_auto_feedback: False
ai_timeout: 120
response_language: en-US
repo_context_files: ['AGENTS.md']
repo_context_from_default_branch: True
repo_context_max_lines: 500
max_description_tokens: 500
max_commits_tokens: 500
max_model_tokens: 32000
model_token_count_estimate_factor: 0.3
patch_extension_skip_types: ['.md', '.txt']
allow_dynamic_context: True
max_extra_lines_before_dynamic_context: 10
patch_extra_lines_before: 5
patch_extra_lines_after: 1
cli_mode: False
large_patch_policy: clip
duplicate_prompt_examples: False
seed: -1
temperature: 0.2
ignore_pr_title: ['^\\[Auto\\]', '^Auto', '^Bump ', '^chore\\(deps\\)']
ignore_pr_target_branches: []
ignore_pr_source_branches: []
ignore_pr_labels: []
ignore_pr_authors: []
ignore_repositories: []
ignore_language_framework: []
restricted_mode: False
enable_ai_metadata: False
reasoning_effort: medium
enable_claude_extended_thinking: False
extended_thinking_budget_tokens: 2048
extended_thinking_max_output_tokens: 4096
claude_extended_thinking_models_override: []
extract_issue_from_branch: True
branch_issue_regex: 
enable_custom_labels: False

[pr_description]

publish_labels: False
add_original_user_description: True
generate_ai_title: False
use_bullet_points: True
extra_instructions: 
enable_pr_type: True
final_update_message: True
enable_help_text: False
enable_help_comment: False
enable_pr_diagram: True
publish_description_as_comment: False
publish_description_as_comment_persistent: True
enable_semantic_files_types: True
collapsible_file_list: adaptive
collapsible_file_list_threshold: 6
inline_file_summary: False
use_description_markers: False
enable_large_pr_handling: True
include_generated_by_header: True
max_ai_calls: 4
async_ai_calls: True

Summary by CodeRabbit

  • Bug Fixes
    • Newsletter greetings now correctly use the subscriber’s first name.
    • Subscriptions without a last name are handled correctly, with the first name used as the display name fallback.

…maste ,"

Every newsletter template greets with {{first_name}}, but the subscribe
endpoint never set that variable. It joined firstName and lastName into a
display name and passed it as `name`, which SendPulse stores as its own
"Name" field. Nothing reads that.

So every organic signup landed with a name SendPulse could show in its
dashboard column and no name any issue could greet with. SendPulse renders
a missing merge variable as empty, not as a fallback, so those contacts
received "Namaste ," with the comma still attached.

This is not hypothetical and it is not historical. The four most recent
website signups before this change (2026-08-25 through 08-28) all arrived
with Name and no first_name, and had to be backfilled by hand before the
event-postponement issue could go out. Earlier contacts look correct only
because someone already swept them.

The serializer has carried firstName as its own validated field the whole
time, so the given name just needs forwarding into the variable the
templates actually read. The joined display name still rides along as
`name` for the dashboard column.

Two tests cover it, both of which fail without the change: the main
subscribe path asserts first_name and the display name are populated
independently, and a second asserts first_name survives when lastName is
omitted, since lastName is optional.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jawafdehi-pr-agent

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

🛠️ Relevant configurations:


These are the relevant configurations for this tool:

[config]

enable_ai_metadata: False
model: openai/cx/gpt-5.5
git_provider: github
custom_reasoning_model: False
output_relevant_configurations: True
custom_model_max_tokens: 200000
fallback_models: ['openai/cx/gpt-5.4-mini']
ENABLE_AUTO_APPROVAL: True
is_auto_command: True
publish_output: True
publish_output_progress: True
progress_gif_url: 
progress_gif_width: 48
verbosity_level: 0
use_extra_bad_extensions: False
log_level: DEBUG
use_wiki_settings_file: True
use_repo_settings_file: True
use_global_settings_file: True
extra_config_url: 
disable_auto_feedback: False
ai_timeout: 120
response_language: en-US
repo_context_files: ['AGENTS.md']
repo_context_from_default_branch: True
repo_context_max_lines: 500
max_description_tokens: 500
max_commits_tokens: 500
max_model_tokens: 32000
model_token_count_estimate_factor: 0.3
patch_extension_skip_types: ['.md', '.txt']
allow_dynamic_context: True
max_extra_lines_before_dynamic_context: 10
patch_extra_lines_before: 5
patch_extra_lines_after: 1
cli_mode: False
large_patch_policy: clip
duplicate_prompt_examples: False
seed: -1
temperature: 0.2
ignore_pr_title: ['^\\[Auto\\]', '^Auto', '^Bump ', '^chore\\(deps\\)']
ignore_pr_target_branches: []
ignore_pr_source_branches: []
ignore_pr_labels: []
ignore_pr_authors: []
ignore_repositories: []
ignore_language_framework: []
restricted_mode: False
reasoning_effort: medium
enable_claude_extended_thinking: False
extended_thinking_budget_tokens: 2048
extended_thinking_max_output_tokens: 4096
claude_extended_thinking_models_override: []
extract_issue_from_branch: True
branch_issue_regex: 
enable_custom_labels: False

[pr_reviewer]

require_ticket_analysis_review: False
require_score_review: False
require_tests_review: True
require_estimate_effort_to_review: True
require_can_be_split_review: False
require_security_review: True
require_estimate_contribution_time_cost: False
require_todo_scan: False
publish_output_no_suggestions: True
persistent_comment: True
extra_instructions: Focus on: logic errors and edge cases; security/authz regressions; missing error handling;
Django/DRF correctness (migrations, N+1 queries, transaction/atomicity, serializer & permission gaps).
Do NOT comment on formatting, import order, or naming — ruff handles those in CI.

num_max_findings: 3
final_update_message: True
enable_review_labels_security: True
enable_review_labels_effort: True
require_all_thresholds_for_incremental_review: False
minimal_commits_for_incremental_review: 0
minimal_minutes_for_incremental_review: 0
enable_intro_text: True
enable_help_text: False

@jawafdehi-pr-agent

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@jawafdehi-pr-agent

Copy link
Copy Markdown

PR Agent Walkthrough 🤖

Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more.

Here is a list of tools you can use to interact with the PR Agent:

ToolDescriptionTrigger Interactively 💎

DESCRIBE

Generates PR description - title, type, summary, code walkthrough and labels
  • Run

REVIEW

Adjustable feedback about the PR, possible issues, security concerns, review effort and more
  • Run

IMPROVE

Code suggestions for improving the PR
  • Run

UPDATE CHANGELOG

Automatically updates the changelog
  • Run

HELP DOCS

Answers a question regarding this repository, or a given one, based on given documentation path
  • Run

ADD DOCS

Generates documentation to methods/functions/classes that changed in the PR
  • Run

ASK

Answering free-text questions about the PR

[*]

GENERATE CUSTOM LABELS

Generates custom labels for the PR, based on specific guidelines defined by the user

[*]

(1) Note that each tool can be triggered automatically when a new PR is opened, or called manually by commenting on a PR.

(2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the /ask tool, you need to comment on a PR: /ask "<question content>". See the relevant documentation for each tool for more details.

@jawafdehi-pr-agent

Copy link
Copy Markdown

Auto-approved PR

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2a7f187-526b-4577-920f-d780b093fac1

📥 Commits

Reviewing files that changed from the base of the PR and between 5a1b0e0 and b17f4f1.

📒 Files selected for processing (2)
  • newsletter/tests/test_api.py
  • newsletter/views.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The newsletter subscribe view now forwards the subscriber’s first name to SendPulse as first_name. Tests verify the mapping with and without a last name.

Changes

Newsletter subscription

Layer / File(s) Summary
SendPulse name mapping and coverage
newsletter/views.py, newsletter/tests/test_api.py
The subscribe view passes the given name as first_name and keeps the joined display name in name. Tests cover complete names and requests without lastName.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b17f4

The signup flow now populates the first name used by newsletter greetings while preserving the existing display name, with no actionable merge-blocking risk remaining after normal checks and review.

Poem

I’m a rabbit with a name to send,
first_name now greets each friend.
With last name or without its pair,
SendPulse gets the fields laid bare.
Tests hop lightly through the flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: setting first_name during newsletter signup to correct the greeting. It is concise and specific.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/newsletter-first-name-variable

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant