-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also import api-fetch and wrap in dependencies object
import as wpX to namespace values
- Loading branch information
1 parent
abe0d1b
commit 7116c91
Showing
3 changed files
with
38 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
} ); | ||
}, | ||
}; |