Skip to content

Commit

Permalink
fix: rename modules, move import
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelvin Lu committed Sep 14, 2023
1 parent c2d1e37 commit c1a5424
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnrichmentPlugin, Event } from '@amplitude/analytics-types';
import { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';
import { isAmplitudeIdentifyEvent, isNotSpecialAmplitudeEvent } from './helpers';
import { isAmplitudeIdentifyEvent, isTrackEvent } from './helpers';

export const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin = function (options: Options = {}) {
const plugin: EnrichmentPlugin = {
Expand All @@ -9,7 +9,7 @@ export const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin = function (

/* Note: The promise is because of the interface, not because this has any asynchronous behavior */
execute: async (event: Event): Promise<Event> => {
if (isNotSpecialAmplitudeEvent(event) || isAmplitudeIdentifyEvent(event)) {
if (isTrackEvent(event) || isAmplitudeIdentifyEvent(event)) {
event.global_user_properties = event.user_properties;

if (!options.shouldKeepOriginalUserProperties) {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-global-user-properties/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Event, BaseEvent, SpecialEventType, IdentifyEvent } from '@amplitude/analytics-types';
import { Event, TrackEvent, SpecialEventType, IdentifyEvent } from '@amplitude/analytics-types';

const specialAmplitudeEvents = new Set(Object.values(SpecialEventType));

export const isNotSpecialAmplitudeEvent = (event: Event): event is BaseEvent => {
export const isTrackEvent = (event: Event): event is TrackEvent => {
return !specialAmplitudeEvents.has(event.event_type as SpecialEventType);
};

Expand Down
12 changes: 0 additions & 12 deletions packages/plugin-global-user-properties/src/index.d.ts

This file was deleted.

12 changes: 12 additions & 0 deletions packages/plugin-global-user-properties/src/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { TrackEvent, IdentifyEvent } from '@amplitude/analytics-types';

declare module '@amplitude/analytics-types' {
export interface TrackEvent {
global_user_properties?: { [key: string]: any } | undefined;
}

export interface IdentifyEvent {
global_user_properties?: { [key: string]: any } | undefined;
}
}

0 comments on commit c1a5424

Please sign in to comment.