refactor(analytics-module-ga): rename gaAddress option to scriptSrc
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
+2
-2
@@ -29,10 +29,10 @@ export interface Config {
|
||||
|
||||
/**
|
||||
* URL to Google Analytics analytics.js script
|
||||
* Defaults to https://www.google-analytics.com/analytics.js
|
||||
* Defaults to fetching from GA source (eg. https://www.google-analytics.com/analytics.js)
|
||||
* @visibility frontend
|
||||
*/
|
||||
gaAddress?: string;
|
||||
scriptSrc?: string;
|
||||
|
||||
/**
|
||||
* Whether or not to log analytics debug statements to the console.
|
||||
|
||||
+5
-7
@@ -42,13 +42,13 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
private constructor({
|
||||
cdmConfig,
|
||||
trackingId,
|
||||
gaAddress,
|
||||
scriptSrc,
|
||||
testMode,
|
||||
debug,
|
||||
}: {
|
||||
cdmConfig: CustomDimensionOrMetricConfig[];
|
||||
trackingId: string;
|
||||
gaAddress: string;
|
||||
scriptSrc?: string;
|
||||
testMode: boolean;
|
||||
debug: boolean;
|
||||
}) {
|
||||
@@ -56,9 +56,9 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
|
||||
// Initialize Google Analytics.
|
||||
ReactGA.initialize(trackingId, {
|
||||
gaAddress,
|
||||
testMode,
|
||||
debug,
|
||||
gaAddress: scriptSrc,
|
||||
titleCase: false,
|
||||
});
|
||||
}
|
||||
@@ -69,9 +69,7 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
static fromConfig(config: Config) {
|
||||
// Get all necessary configuration.
|
||||
const trackingId = config.getString('app.analytics.ga.trackingId');
|
||||
const gaAddress =
|
||||
config.getOptionalString('app.analytics.ga.gaAddress') ??
|
||||
'https://www.google-analytics.com/analytics.js';
|
||||
const scriptSrc = config.getOptionalString('app.analytics.ga.scriptSrc');
|
||||
const debug = config.getOptionalBoolean('app.analytics.ga.debug') ?? false;
|
||||
const testMode =
|
||||
config.getOptionalBoolean('app.analytics.ga.testMode') ?? false;
|
||||
@@ -92,7 +90,7 @@ export class GoogleAnalytics implements AnalyticsApi {
|
||||
// Return an implementation instance.
|
||||
return new GoogleAnalytics({
|
||||
trackingId,
|
||||
gaAddress,
|
||||
scriptSrc,
|
||||
cdmConfig,
|
||||
testMode,
|
||||
debug,
|
||||
|
||||
Reference in New Issue
Block a user