Skip to content

Commit

Permalink
Added Store page button & links tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
aratidgr8 committed Aug 6, 2024
1 parent 7187c98 commit 065db4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '88c3965074fd64b0e3b4');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-date', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '8aa092b05dbe537af35e');
32 changes: 28 additions & 4 deletions src/components/Store.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useEffect } from "@wordpress/element";
import { __ } from "@wordpress/i18n";
import { NewfoldRuntime } from "../sdk/NewfoldRuntime";
import { onAnchorNavigate, onButtonNavigate } from "../sdk/hiiveEventsTracking";
import { QuickLook } from "./QuickLook";
import { Section } from "./Section";
import { WooCommerceUnavailable } from "./WooCommerceUnavailable";
import { useEffect } from "@wordpress/element";
import { SiteStatus } from "./SiteStatus";
import { NewfoldRuntime } from "../sdk/NewfoldRuntime";
import { WooCommerceUnavailable } from "./WooCommerceUnavailable";

export function Store(props) {

Expand All @@ -13,9 +14,32 @@ export function Store(props) {
const child = document.querySelector(".nfd-feature-upsell > div");
child.classList.remove("nfd-grayscale")
document.querySelector(".nfd-feature-upsell .nfd-absolute.nfd-justify-center").style.backgroundColor = "rgba(255, 255, 255, .5)"
}
}

const storeContainer = document.querySelector('#ecommerce-features-wrapper');

const storeButtons = Array.from(
storeContainer.querySelectorAll( 'button' )
);
const storeAnchors = Array.from( storeContainer.querySelectorAll( 'a' ) );

if ( storeButtons.length ) {
storeButtons.forEach( ( button ) => {
button.addEventListener( 'click', onButtonNavigate );
button.addEventListener( 'onkeydown', onButtonNavigate );
} );
}

if ( storeAnchors.length ) {
storeAnchors.forEach( ( link ) => {
link.addEventListener( 'click', onAnchorNavigate );
link.addEventListener( 'onkeydown', onAnchorNavigate );
} );
}

}, []);


return (
<>
<Section.Container>
Expand Down
5 changes: 3 additions & 2 deletions src/sdk/hiiveEventsTracking.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import apiFetch from "@wordpress/api-fetch";
import { NewfoldRuntime } from "./NewfoldRuntime";

/**
* Send events to the WP REST API
*
* @param {Object} event The event data to be tracked.
*/
export const sendEvent = ( event ) => {
const sendEvent = ( event ) => {
event.data = event.data || {};
event.data.page = window.location.href;
methods.apiFetch( {
apiFetch( {
url: NewfoldRuntime.createApiUrl( '/newfold-data/v1/events/' ),
method: 'POST',
data: event,
Expand Down

0 comments on commit 065db4d

Please sign in to comment.