Skip to content

Commit 767421e

Browse files
committed
Update comments and rename type
1 parent 069d0c8 commit 767421e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/analytics/src/helpers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import { DynamicConfig, DataLayer, Gtag, MinimalDynamicConfig } from './types';
2525
import { GtagCommand, GTAG_URL } from './constants';
2626
import { logger } from './logger';
2727

28+
// Possible parameter types for gtag 'event' and 'config' commands
29+
type GtagConfigOrEventParams = ControlParams & EventParams & CustomParams;
30+
2831
/**
2932
* Makeshift polyfill for Promise.allSettled(). Resolves when all promises
3033
* have either resolved or rejected.
@@ -226,8 +229,7 @@ function wrapGtag(
226229
async function gtagWrapper(
227230
command: 'config' | 'set' | 'event' | 'consent',
228231
idOrNameOrParams: string | ControlParams,
229-
// TODO(dwyfrequency)Unsure if this is the best path.
230-
gtagParams?: GtagSetConfigEventParams | ConsentSettings
232+
gtagParams?: GtagConfigOrEventParams | ConsentSettings
231233
): Promise<void> {
232234
try {
233235
// If event, check that relevant initialization promises have completed.
@@ -238,7 +240,7 @@ function wrapGtag(
238240
initializationPromisesMap,
239241
dynamicConfigPromisesList,
240242
idOrNameOrParams as string,
241-
gtagParams as GtagSetConfigEventParams
243+
gtagParams as GtagConfigOrEventParams
242244
);
243245
} else if (command === GtagCommand.CONFIG) {
244246
// If CONFIG, second arg must be measurementId.
@@ -248,7 +250,7 @@ function wrapGtag(
248250
dynamicConfigPromisesList,
249251
measurementIdToAppId,
250252
idOrNameOrParams as string,
251-
gtagParams as GtagSetConfigEventParams
253+
gtagParams as GtagConfigOrEventParams
252254
);
253255
} else if (command === GtagCommand.CONSENT) {
254256
// If CONFIG, second arg must be measurementId.
@@ -263,8 +265,6 @@ function wrapGtag(
263265
}
264266
return gtagWrapper as Gtag;
265267
}
266-
// TODO(dwyfrequency)Unsure if this is the best path and where it should go. Probably the type file
267-
type GtagSetConfigEventParams = ControlParams & EventParams & CustomParams;
268268

269269
/**
270270
* Creates global gtag function or wraps existing one if found.

packages/analytics/src/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ export interface Gtag {
7070
): void;
7171
(
7272
command: 'consent',
73-
// TODO(dwyfrequency) should I make these subCommands their own type
7473
subCommand: 'default' | 'update',
75-
// TODO(dwyfrequency) should this be optional like eventParams and config.
76-
// Idk why we would want it as optional
7774
consentSettings: ConsentSettings
7875
): void;
7976
}

0 commit comments

Comments
 (0)