Skip to content

Usage tracking for test mode in Lite#2941

Open
truongwp wants to merge 6 commits into
masterfrom
test-mode-usage-tracking
Open

Usage tracking for test mode in Lite#2941
truongwp wants to merge 6 commits into
masterfrom
test-mode-usage-tracking

Conversation

@truongwp
Copy link
Copy Markdown
Contributor

@truongwp truongwp commented Feb 5, 2026

This tracks the number of times user views the test mode without the add-on installed and with the chat form.

This is tracked in the flows data with the format:

[view_test_mode] => Array
    (
        [no_addon] => 1
        [chat_form] => 2
    )

Summary by CodeRabbit

  • Enhancements
    • Test mode now tracks views of chat-enabled forms for richer analytics.
    • Test mode records when the required addon is not present to improve visibility.
  • New Features
    • Testing UI can now be extended via a hook so additional form-action controls can be injected into the Test Mode interface.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cab5e9f7-df98-417e-8032-8aff7caef015

📥 Commits

Reviewing files that changed from the base of the PR and between da35035 and 0b49f80.

📒 Files selected for processing (2)
  • classes/controllers/FrmUsageController.php
  • classes/views/test-mode/container.php
✅ Files skipped from review due to trivial changes (1)
  • classes/controllers/FrmUsageController.php

📝 Walkthrough

Walkthrough

Adds usage-tracking calls when rendering test mode (captures chat-form views and missing-addon views) and inserts a frm_testmode_form_actions action hook into the Enabled form actions container.

Changes

Test mode UI & usage tracking

Layer / File(s) Summary
Test-mode UI: form actions hook
classes/views/test-mode/container.php
Inserted do_action( 'frm_testmode_form_actions', $form_actions ) inside the enabled form actions container so extensions can output additional UI for each enabled form action.
Usage API doc update
classes/controllers/FrmUsageController.php
Clarified update_flows_data docblock to state it increments flow_data[ $key ][ $value ].
Usage tracking calls
classes/controllers/FrmTestModeController.php
Added calls to FrmUsageController::update_flows_data() when rendering test mode for chat forms and when the test mode addon is not present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through test mode, whiskers twitching bright,

I mark each chat and absent plugin sight,
A tiny hook I plant where actions play,
So helpers may arrive and join the fray,
I gather traces softly through the night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Usage tracking for test mode in Lite' accurately describes the main changes in the PR, which add usage tracking for test mode views in the Lite version.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-mode-usage-tracking

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 and usage tips.

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Feb 5, 2026

DeepSource Code Review

We reviewed changes in f1a73c6...0b49f80 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Jun 3, 2026 7:39p.m. Review ↗
JavaScript Jun 3, 2026 7:39p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@classes/controllers/FrmUsageController.php`:
- Line 18: The class constant declaration "private const FLOWS_ACTION_NAME" in
FrmUsageController causes a PHP 7.0 parse error because visibility on constants
is supported only from PHP 7.1; change the declaration to a plain const
FLOWS_ACTION_NAME (remove the "private" visibility) inside the
FrmUsageController class (or alternatively update project PHP requirement to
>=7.1), ensuring all references to FLOWS_ACTION_NAME continue to work.

Comment thread classes/controllers/FrmUsageController.php Outdated
@truongwp truongwp removed the run tests label Feb 5, 2026
@truongwp truongwp requested a review from Crabcyborg February 5, 2026 15:32
?>
</select>

<?php
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@truongwp This is for the add-on tracking?

Can we add a new hook here instead so we can move this logic into the add-on?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can we use $enabled to check, like we did with other test mode add-on features?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@truongwp Like the hook is only called if $enabled is true?

That would be fine.

Otherwise I'm not sure if I follow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Crabcyborg No. I meant we won't need to add a hook there, just check if ( $enabled ) { foreach ... }. Because that file contains many test mode add-ons code.

Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg Jun 3, 2026

Choose a reason for hiding this comment

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

@truongwp

I just think there's a difference.

This file is intended to use the whole UI, as it's shown in Lite as disabled placeholders.

And these inputs are only used when the add-on is actually active, and have no visual benefit for being in Lite.

Since they only impact the add-on, it would be nice if we only needed to modify the add-on when we needed to make changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I added the hook and moved the code to the add-on.

*
* @param array $form_actions
*/
do_action( 'frm_testmode_form_actions', $form_actions );
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $form_actions might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

@Crabcyborg Crabcyborg added this to the 6.32 milestone Jun 4, 2026
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.

2 participants