Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 4 deletions lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ export interface UserProfile {
experiment_bucket_map: ExperimentBucketMap;
}

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

export type EventTags = Record<string, unknown>;
Comment thread
junaed-optimizely marked this conversation as resolved.
Outdated
export interface UserProfileService {
lookup(userId: string): UserProfile;
save(profile: UserProfile): void;
Expand Down
11 changes: 6 additions & 5 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 All @@ -42,7 +41,8 @@ export function getRevenueValue(eventTags: EventTags, logger: LoggerFacade): num
return null;
}

const parsedRevenueValue = typeof rawValue === 'string' ? parseInt(rawValue) : rawValue;
const parsedRevenueValue =
Comment thread
junaed-optimizely marked this conversation as resolved.
Outdated
typeof rawValue === 'number' ? rawValue : typeof rawValue === 'string' ? parseInt(rawValue) : NaN;

if (isFinite(parsedRevenueValue)) {
logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.PARSED_REVENUE_VALUE, MODULE_NAME, parsedRevenueValue);
Expand All @@ -66,7 +66,8 @@ export function getEventValue(eventTags: EventTags, logger: LoggerFacade): numbe
return null;
}

const parsedEventValue = typeof rawValue === 'string' ? parseFloat(rawValue) : rawValue;
const parsedEventValue =
typeof rawValue === 'number' ? rawValue : typeof rawValue === 'string' ? parseFloat(rawValue) : NaN;
Comment thread
junaed-optimizely marked this conversation as resolved.
Outdated

if (isFinite(parsedEventValue)) {
logger.log(LOG_LEVEL.INFO, LOG_MESSAGES.PARSED_NUMERIC_VALUE, MODULE_NAME, parsedEventValue);
Expand All @@ -75,4 +76,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