Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/core/event_builder/build_event_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
EventTags,
ConversionEvent,
ImpressionEvent,
} from '../../modules/event_processor';
import { ConversionEvent, ImpressionEvent } from '../../modules/event_processor';

import { Event } from '../../shared_types';
import { Event, EventTags } from '../../shared_types';

type ProcessableEvent = ConversionEvent | ImpressionEvent

Expand Down
6 changes: 2 additions & 4 deletions lib/modules/event_processor/events.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EventTags } from "../../shared_types"

/**
* Copyright 2022, Optimizely
*
Expand Down Expand Up @@ -82,10 +84,6 @@ export interface ConversionEvent extends BaseEvent {
tags: EventTags | undefined
}

export type EventTags = {
[key: string]: string | number | null
}

export function areEventContextsEqual(eventA: BaseEvent, eventB: BaseEvent): boolean {
const contextA = eventA.context
const contextB = eventB.context
Expand Down
3 changes: 2 additions & 1 deletion lib/modules/event_processor/v1/buildEventV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EventTags, ConversionEvent, ImpressionEvent, VisitorAttribute } from '../events'
import { ConversionEvent, ImpressionEvent, VisitorAttribute } from '../events'
import { ProcessableEvent } from '../eventProcessor'
import { EventV1Request } from '../eventDispatcher'
import { EventTags } from '../../../shared_types'

const ACTIVATE_EVENT_KEY = 'campaign_activated'
const CUSTOM_ATTRIBUTE_FEATURE_TYPE = 'custom'
Expand Down
5 changes: 4 additions & 1 deletion lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export interface UserProfile {
}

export type EventTags = {
[key: string]: string | number | null;
revenue?: string | number | null;
value?: string | number | null;
$opt_event_properties?: Record<string, unknown>;
[key: string]: unknown;
};

export interface UserProfileService {
Expand Down
7 changes: 3 additions & 4 deletions lib/utils/event_tag_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EventTags } from '../../modules/event_processor';
import { EventTags } from '../../shared_types';
import { LoggerFacade } from '../../modules/logging';

import {
LOG_LEVEL,
LOG_MESSAGES,
Expand Down Expand Up @@ -66,7 +65,7 @@ export function getEventValue(eventTags: EventTags, logger: LoggerFacade): numbe
return null;
}

const parsedEventValue = typeof rawValue === 'string' ? parseFloat(rawValue) : rawValue;
const parsedEventValue = typeof rawValue === 'string' ? parseFloat(rawValue): rawValue;

if (isFinite(parsedEventValue)) {
logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.PARSED_NUMERIC_VALUE, MODULE_NAME, parsedEventValue);
Expand All @@ -75,4 +74,4 @@ export function getEventValue(eventTags: EventTags, logger: LoggerFacade): numbe
logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.FAILED_TO_PARSE_VALUE, MODULE_NAME, rawValue);
return null;
}
}
}
Loading