Skip to content

Commit

Permalink
also import api-fetch and wrap in dependencies object
Browse files Browse the repository at this point in the history
import as wpX to namespace values
  • Loading branch information
circlecube committed Feb 4, 2025
1 parent abe0d1b commit 7116c91
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 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' => 'c32db55d2154248d2e88');
<?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' => '31b06a75b450ead36c57');
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

67 changes: 36 additions & 31 deletions src/sdk/analytics.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import {
HiiveAnalytics,
HiiveEvent,
} from "@newfold/js-utility-ui-analytics";
import { NewfoldRuntime } from "@newfold/wp-module-runtime";
import data from "@wordpress/data";
import { HiiveAnalytics, HiiveEvent } from '@newfold/js-utility-ui-analytics';
import { NewfoldRuntime } from '@newfold/wp-module-runtime';
import { default as wpData } from '@wordpress/data';
import { default as wpApiFetch } from '@wordpress/api-fetch';

export const AnalyticsSdk = {
track(category, action, value) {
const hiiveEvent = new HiiveEvent(
category,
action,
value,
"wp-module-ecommerce"
);
HiiveAnalytics.send(hiiveEvent);
},
initialize() {
HiiveAnalytics.initialize({
namespace: "wp-module-ecommerce",
urls: {
single: NewfoldRuntime.createApiUrl("/newfold-data/v1/events"),
batch: NewfoldRuntime.createApiUrl("/newfold-data/v1/events/batch"),
},
settings: {
debounce: {
time: 3000,
},
},
data
});
},
};
track( category, action, value ) {
const hiiveEvent = new HiiveEvent(
category,
action,
value,
'wp-module-ecommerce'
);
HiiveAnalytics.send( hiiveEvent );
},
initialize() {
HiiveAnalytics.initialize( {
namespace: 'wp-module-ecommerce',
urls: {
single: NewfoldRuntime.createApiUrl(
'/newfold-data/v1/events'
),
batch: NewfoldRuntime.createApiUrl(
'/newfold-data/v1/events/batch'
),
},
settings: {
debounce: {
time: 3000,
},
},
dependencies: { // passing dependencies to HiiveAnalytics solely for build purposes
wpData,
wpApiFetch,
},
} );
},
};

0 comments on commit 7116c91

Please sign in to comment.