Skip to content

Commit

Permalink
Refactor Event Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Oct 13, 2024
1 parent 80f7b85 commit e695353
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/frontend/event-inspector-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/frontend/event-inspector.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '361fa528b625299cad80');
<?php return array('dependencies' => array(), 'version' => 'd328580771c8363d4991');
2 changes: 1 addition & 1 deletion assets/frontend/event-inspector.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/frontend/event-inspector.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Frontend/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ public function dns_prefetch( array $hints, string $relation_type ): array {
* Get the Event Inspector HTML
*/
public function get_event_inspector(): void {
$restrict = apply_filters( 'gtmkit_restrict_event_inspector', false );
?>
<div id="gtmkit-event-inspector">
<div id="gtmkit-event-inspector"
<?php
if ( $restrict ) :
?>
class="restrict"<?php endif; ?>>
<div id="gtmkit-event-inspector-wrapper">
<div id="gtmkit-event-inspector-title">GTM Kit Event Inspector:</div>
<ul id="gtmkit-event-inspector-list"></ul>
Expand Down
4 changes: 2 additions & 2 deletions src/js/frontend/event-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function getDataLayer() {
) {
return;
}
storedEvents.push( event.event );
storedEvents.push( event );
} );

if ( storedEvents.length > 5 ) {
Expand All @@ -56,7 +56,7 @@ function renderList( events ) {
const listItem = '<li>{{event}}</li>';
const reversedList = [ ...events ].reverse();
const rendered = reversedList.map( ( item ) => {
return listItem.replace( '{{event}}', item );
return listItem.replace( '{{event}}', item.event );
} );

document.getElementById( 'gtmkit-event-inspector-list' ).innerHTML =
Expand Down
3 changes: 3 additions & 0 deletions src/js/frontend/event-inspector/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
background-color: var(--gtmkit-background-white);
border-top: 2px solid var(--gtmkit-color-grey);

&.restrict {
display: none;
}
}

#gtmkit-event-inspector-wrapper{
Expand Down

0 comments on commit e695353

Please sign in to comment.