Skip to content

Conversation

@LyubovSugak
Copy link
Collaborator

@LyubovSugak LyubovSugak requested a review from Copilot December 1, 2025 12:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new Kilkaya conversion tracking extension that sends conversion events when a checkout is successfully completed. The implementation uses the browser's sendBeacon API for reliable tracking during page transitions, with fallback mechanisms to the Kilkaya API when needed.

Key Changes:

  • Implements conversion tracking that activates on checkout success events
  • Uses sendBeacon API with fallback to Kilkaya's native logging methods
  • Adds localStorage-based logging for debugging purposes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
extensions/kilkaya/k5a_meta_send.js New extension that sends conversion tracking data via sendBeacon when checkout success is detected
tests/kilkaya/k5a_meta_send.test.js Comprehensive test suite covering event filtering, URL construction, tracking methods, error handling, and integration scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

params.push('l=p'); // pageview log type
params.push('cs=1'); // conversion status = 1
params.push('_s=conversion');
params.push('_m=b'); // method=beacon
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The _h=pageView parameter is included in tests (line 124) but missing from the actual implementation. This inconsistency could cause tracking issues if the parameter is required by the Kilkaya backend.

Suggested change
params.push('_m=b'); // method=beacon
params.push('_m=b'); // method=beacon
params.push('_h=pageView'); // event type

Copilot uses AI. Check for mistakes.
setTimeout(function() {
try {
// Build the tracking URL manually based on Kilkaya's format
var installationId = '68ee5be64709bd7f4b3e3bf2';
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The installation ID is hardcoded. Consider making this configurable through window.k5aMeta or a configuration object to support different installations without code changes.

Suggested change
var installationId = '68ee5be64709bd7f4b3e3bf2';
var installationId = (window.k5aMeta && window.k5aMeta.installationId) ? window.k5aMeta.installationId : '68ee5be64709bd7f4b3e3bf2';

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +71
if (window.kilkaya && window.kilkaya.logger &&
typeof window.kilkaya.logger.fireNow === 'function') {
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

Potential null reference error if window.kilkaya.pageData is undefined. The check on line 70 only verifies window.kilkaya.logger exists, but doesn't validate window.kilkaya.pageData.

Suggested change
if (window.kilkaya && window.kilkaya.logger &&
typeof window.kilkaya.logger.fireNow === 'function') {
if (
window.kilkaya &&
window.kilkaya.logger &&
typeof window.kilkaya.logger.fireNow === 'function' &&
window.kilkaya.pageData &&
typeof window.kilkaya.pageData.getDefaultData === 'function'
) {

Copilot uses AI. Check for mistakes.
} catch (err) {
persistLog('✗ ERROR sending conversion', {error: err.message, stack: err.stack});
}
}, 150); // Small delay to ensure k5aMeta.conversion is set
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The 150ms delay is a magic number with unclear justification. Consider extracting this to a named constant (e.g., CONVERSION_DATA_WAIT_MS) to improve code clarity and maintainability.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link

Copilot AI commented Dec 1, 2025

@LyubovSugak I've opened a new pull request, #326, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

2 participants