Skip to content

Conversation

@Moiz47
Copy link
Contributor

@Moiz47 Moiz47 commented Sep 15, 2025

Summary

Added QR code click event support

Summary by CodeRabbit

  • Chores
    • Added analytics tracking for QR code clicks in document status to capture title, schema, and status; behavior and UI remain unchanged.
    • Removed a developer console log during analytics initialization; no impact on user experience.

@netlify
Copy link

netlify bot commented Sep 15, 2025

Deploy Preview for tradetrust-gallery ready!

Name Link
🔨 Latest commit a805789
🔍 Latest deploy log https://app.netlify.com/projects/tradetrust-gallery/deploys/68c79bd7b4db0e0008f913f0
😎 Deploy Preview https://deploy-preview-26--tradetrust-gallery.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Sep 15, 2025

Walkthrough

Adds analytics instrumentation: clicking the QR area in DocumentStatus now fires a GA event (sendGAEvent) with title, schema, and status before invoking onStatusClick. Also removes a runtime console.log from GTM initialization in gtmService. No public API or export signatures changed.

Changes

Cohort / File(s) Summary
DocumentStatus QR click
src/components/content/DocumentStatus.tsx
Changes QR area onClick from a single-expression call to a block-bodied handler that first calls sendGAEvent({ event: 'document_qr_click', payload: { document_qr_title: title, document_qr_schema: selectedSchema, document_qr_status: status.label } }) and then calls onStatusClick(...).
GTM service cleanup
src/lib/gtmService.ts
Removes a runtime console.log from the GTM initialization path; retains TagManager.initialize({ gtmId }) and unchanged sendGAEvent behavior that conditionally calls TagManager.dataLayer.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as DocumentStatus (QR area)
  participant GA as sendGAEvent
  participant App as onStatusClick

  User->>UI: Click QR area
  UI->>GA: sendGAEvent('document_qr_click', { title, schema, status }) 
  GA-->>UI: ack
  UI->>App: onStatusClick(...)
  App-->>UI: return
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • rongquan1

Poem

A rabbit taps the QR with glee,
I whisper events to GA’s tree.
I log the title, schema, status true,
Then hop to click — the action’s you.
Tiny paws, metrics anew. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description only includes a one-line Summary ("Added QR code click event support") and does not follow the repository template: it is missing the required "Changes" section detailing the modifications (for example, the QR click GA event added in DocumentStatus.tsx and the removed console log in gtmService.ts), the "Issues" section linking related issue or story IDs, and the "Releases" section specifying channel and ETA, which prevents reviewers from fully assessing scope and release planning. Please expand the PR description to include a "Changes" list describing the QR code GA event addition and the gtmService console-log removal, add any related issue or story references under "Issues", and populate the "Releases" section with the target channel and ETA so reviewers have complete context for review and release planning.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat: ga analytics qr code click support" concisely and accurately summarizes the primary change—adding GA analytics support for QR code click events—and aligns with the modified files (DocumentStatus.tsx and gtmService). It is specific, uses the conventional "feat:" prefix, and is short enough for quick scanning by reviewers.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ga-analytics-support

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5889457 and a805789.

📒 Files selected for processing (2)
  • src/components/content/DocumentStatus.tsx (1 hunks)
  • src/lib/gtmService.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/lib/gtmService.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/content/DocumentStatus.tsx

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link

@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: 3

🧹 Nitpick comments (1)
src/components/content/DocumentStatus.tsx (1)

40-41: Avoid duplicate IDs within a list

id="qr-code-icon" will repeat for every item rendered, which is invalid HTML and can break selectors/tests. Remove the id or switch to data-testid.

- <img className="w-[13px] h-[13px]" alt="Qrcode" src="/qrcode.svg" id="qr-code-icon" />
+ <img className="w-[13px] h-[13px]" alt="QR code icon" src="/qrcode.svg" data-testid="qr-code-icon" />
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03ac17f and 5889457.

📒 Files selected for processing (1)
  • src/components/content/DocumentStatus.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/content/DocumentStatus.tsx (1)
src/lib/gtmService.ts (1)
  • sendGAEvent (13-19)
🔇 Additional comments (1)
src/components/content/DocumentStatus.tsx (1)

24-37: Confirm GA event type covers the new fields (or add a specific event type).

src/types/types.ts exports GADataLayerEvent — ensure it allows the keys used here: document_qr_title, document_qr_schema, document_qr_status, document_title, preview_title. If not, either widen GADataLayerEvent (e.g., add an index signature) or create/use a narrow interface for these events (e.g., DocumentQrClickEvent, DocumentPreviewEvent) and pass that to sendGAEvent. Occurrences to check: src/components/content/DocumentStatus.tsx (document_qr_click, document_type) and src/components/content/DocumentPreview.tsx (document_preview).

Comment on lines 22 to +24
<div
className="inline-flex items-center justify-center p-2 rounded-xl border border-[#e2e3e7] cursor-pointer"
onClick={() =>
onClick={() => {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use a semantic button for the clickable control

This is an interactive control inside a dialog trigger; a <div> is not keyboard-focusable by default. Prefer a <button> (or add proper a11y props) to meet a11y expectations.

- <div
-   className="inline-flex items-center justify-center p-2 rounded-xl border border-[#e2e3e7] cursor-pointer"
-   onClick={...}
- >
+ <button
+   type="button"
+   aria-label={`Open ${status.label} QR code`}
+   className="inline-flex items-center justify-center p-2 rounded-xl border border-[#e2e3e7] cursor-pointer"
+   onClick={...}
+ >

Remember to close with </button> where the </div> currently is.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div
className="inline-flex items-center justify-center p-2 rounded-xl border border-[#e2e3e7] cursor-pointer"
onClick={() =>
onClick={() => {
<button
type="button"
aria-label={`Open ${status.label} QR code`}
className="inline-flex items-center justify-center p-2 rounded-xl border border-[#e2e3e7] cursor-pointer"
onClick={() => {
🤖 Prompt for AI Agents
In src/components/content/DocumentStatus.tsx around lines 22 to 24, the
interactive element is a <div> which is not keyboard-focusable; replace it with
a semantic <button> element (type="button") keeping the same className and
onClick handler, ensure you add an accessible label (aria-label or visible text)
if there is no textual content, and close with </button> where the </div>
currently is so the control is keyboard operable and meets a11y expectations.

Comment on lines +31 to +36
sendGAEvent({
event: 'document_qr_click',
document_qr_title: title,
document_qr_schema: selectedSchema,
document_qr_status: status.label,
});
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Normalize analytics payload keys with existing link click event

The link below uses document_title/document_schema/document_status. Using document_qr_* here creates two schemas to maintain. Align keys and add document_id for parity and queryability.

-  sendGAEvent({
-    event: 'document_qr_click',
-    document_qr_title: title,
-    document_qr_schema: selectedSchema,
-    document_qr_status: status.label,
-  });
+  sendGAEvent({
+    event: 'document_qr_click',
+    document_title: title,
+    document_schema: selectedSchema,
+    document_status: status.label,
+    document_id: id,
+  });

Please confirm GTM mappings expect these field names and that GADataLayerEvent typing allows them.


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "=== Searching for sendGAEvent usages ==="
rg -n --hidden --no-ignore "sendGAEvent" -S || true

echo
echo "=== Searching for GADataLayerEvent type/usage ==="
rg -n --hidden --no-ignore "GADataLayerEvent" -S || true

echo
echo "=== Searching for document_* analytics keys (document_title, document_schema, document_status, document_qr_*, document_id) ==="
rg -n --hidden --no-ignore "document_title|document_schema|document_status|document_qr_title|document_qr_schema|document_qr_status|document_qr_click|document_id" -S || true

echo
echo "=== Locate DocumentStatus.tsx files ==="
find . -maxdepth 6 -type f -name 'DocumentStatus.tsx' -print || true

echo
echo "=== Show up to first 300 lines of any DocumentStatus.tsx found ==="
while IFS= read -r file; do
  echo "---- FILE: $file ----"
  sed -n '1,300p' "$file" || true
done < <(find . -maxdepth 6 -type f -name 'DocumentStatus.tsx' -print) || true

echo
echo "=== Search for sendGAEvent definition(s) ==="
rg -n --hidden --no-ignore "function sendGAEvent|export function sendGAEvent|export const sendGAEvent|const sendGAEvent =|sendGTMEvent" -S || true

echo
echo "=== Search for GA data layer typing (interfaces / types) ==="
rg -n --hidden --no-ignore "interface .*GADataLayerEvent|type .*GADataLayerEvent|export .*GADataLayerEvent" -S || true

echo
echo "=== Done ==="

Length of output: 2226


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== src/types/types.ts ==="
if [ -f src/types/types.ts ]; then
  sed -n '1,240p' src/types/types.ts
else
  echo "NOT FOUND: src/types/types.ts"
fi

echo
echo "=== src/lib/gtmService.ts ==="
if [ -f src/lib/gtmService.ts ]; then
  sed -n '1,240p' src/lib/gtmService.ts
else
  echo "NOT FOUND: src/lib/gtmService.ts"
fi

echo
echo "=== src/components/content/DocumentStatus.tsx ==="
if [ -f src/components/content/DocumentStatus.tsx ]; then
  sed -n '1,240p' src/components/content/DocumentStatus.tsx
else
  echo "NOT FOUND: src/components/content/DocumentStatus.tsx"
fi

echo
echo "=== src/components/content/DocumentPreview.tsx ==="
if [ -f src/components/content/DocumentPreview.tsx ]; then
  sed -n '1,240p' src/components/content/DocumentPreview.tsx
else
  echo "NOT FOUND: src/components/content/DocumentPreview.tsx"
fi

echo
echo "=== Search for any document_id occurrences ==="
rg -n --hidden --no-ignore "document_id" -S || echo "no matches"

Length of output: 6261


Normalize analytics keys and add document_id — fix typing & verify GTM mappings

  • GADataLayerEvent (src/types/types.ts) is { event: string } & Record<string, string> — all payload values must be strings.
  • Adding document_id: id (number) will cause a TypeScript error; either send document_id: String(id) or widen GADataLayerEvent to accept number values.
  • Align the QR payload with the existing link keys (document_title, document_schema, document_status) and add document_id once you confirm GTM mappings expect these field names.

Location: src/components/content/DocumentStatus.tsx (sendGAEvent call in the QR DialogTrigger onClick).

🤖 Prompt for AI Agents
In src/components/content/DocumentStatus.tsx around lines 31 to 36, the
analytics payload uses non-normalized keys and may pass a number for document_id
which violates GADataLayerEvent (Record<string, string>) — rename the QR event
fields to match existing link keys (use document_title, document_schema,
document_status), add document_id as a string (e.g., String(id)) to avoid the
TypeScript error, and ensure every value passed to sendGAEvent is a string (or
alternatively widen GADataLayerEvent in src/types/types.ts to accept number
values if you prefer numeric ids).

@rongquan1 rongquan1 merged commit 346620f into main Sep 15, 2025
6 checks passed
@rongquan1 rongquan1 deleted the feat/ga-analytics-support branch September 15, 2025 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants