Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
neSpecc committed Dec 20, 2024
1 parent 591247b commit d679e7b
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 39 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.20.2
8 changes: 6 additions & 2 deletions src/analytics/amplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const Analytics = {
* @param eventProperties - event properties
* @param eventOptions - user info
*/
track: (eventType: AnalyticsEventType, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined): Promise<Result|string> => {
track: (eventType: AnalyticsEventType, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined): boolean | Promise<Result|string> => {
if (!isRegistered) {
return Promise.reject('Analytics module is not connected');
return false;
}

return track(eventType, eventProperties, eventOptions).promise;
Expand All @@ -43,6 +43,10 @@ export const Analytics = {
* @param userId - user identifier
*/
setUserId: (userId: string): void => {
if (!isRegistered) {
return;
}

return setUserId(userId);
},
};
39 changes: 26 additions & 13 deletions src/components/event/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,36 @@ export default Vue.extend({
* @returns {Promise<void>}
*/
async created() {
const eventId = this.$route.params.eventId;
const repetitionId = this.$route.params.repetitionId;
try {
const eventId = this.$route.params.eventId;
const repetitionId = this.$route.params.repetitionId;
await this.$store.dispatch(FETCH_EVENT_REPETITION, {
projectId: this.projectId,
eventId,
repetitionId,
});
await this.$store.dispatch(FETCH_EVENT_REPETITION, {
projectId: this.projectId,
eventId,
repetitionId,
});
this.loading = false;
this.loading = false;
/**
* It can be empty event if it was archived
*/
if (this.event) {
this.markEventAsVisited();
/**
* It can be empty event if it was archived
*/
if (this.event) {
this.markEventAsVisited();
}
} catch (error) {
console.error(error);
this.$sendToHawk(`Error on Event page creation!: ${(error as Error).message}`);
this.$notify.open({
description: 'Error fetching event',
});
} finally {
this.loading = false;
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/project/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
<EventItem
v-for="dailyEventInfo in eventsByDate"
:key="dailyEventInfo.groupHash"
:key="`${date}:${dailyEventInfo.groupHash}:${dailyEventInfo.lastRepetitionId}`"
:last-occurrence-timestamp="dailyEventInfo.lastRepetitionTime"
:count="dailyEventInfo.count"
class="project-overview__event"
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ if (process.env.VUE_APP_HAWK_TOKEN) {
/**
* Sends error to the Hawk
*
* @param {Error} error - error to send
* @param error - error or message to send
* @example this.$sendToHawk(new Error('Some error'));
*/
Vue.prototype.$sendToHawk = function sendToHawk(error: Error): void {
Vue.prototype.$sendToHawk = function sendToHawk(error: Error | string): void {
track(error);
};

Expand Down
11 changes: 10 additions & 1 deletion src/store/modules/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ const module: Module<EventsModuleState, RootState> = {
return (projectId: string, eventId: string, repetitionId: string): HawkEvent | null => {
const key = getEventsListKey(projectId, eventId);

// console.trace()

if (!state.repetitions[key]) {
return state.list[key] || null;
}
Expand Down Expand Up @@ -497,14 +499,21 @@ const module: Module<EventsModuleState, RootState> = {
async [FETCH_EVENT_REPETITION]({ commit }, { projectId, eventId, repetitionId }): Promise<void> {
const event = await eventsApi.getEvent(projectId, eventId, repetitionId);

console.log('FETCH_EVENT_REPETITION', event);

if (!event) {
return;
}

const repetition = event.repetition;

filterBeautifiedAddons([ event ]);
filterBeautifiedAddons([ event.repetition ]);

if (event.repetition) {
filterBeautifiedAddons([ event.repetition ]);
}

console.log('repetition', repetition);

/**
* Updates or sets event's fetched payload in the state
Expand Down
21 changes: 4 additions & 17 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ export interface HawkEvent {

/**
* Event repetition
*
* Null for original (first) event
*/
repetition: HawkEventRepetition;
repetition: HawkEventRepetition | null;

/**
* Event repetitions
*/
repetitions: HawkEventRepetition[];
repetitions?: HawkEventRepetition[];

/**
* How many users catch this error
Expand Down Expand Up @@ -177,21 +179,6 @@ export interface HawkEventPayload {
*/
backtrace: HawkEventBacktraceFrame[];

/**
* Additional data about GET request
*/
get: Record<string, unknown>;

/**
* Additional data about POST request
*/
post: Record<string, unknown>;

/**
* HTTP headers
*/
headers: Record<string, unknown>;

/**
* Source code version identifier
*/
Expand Down
4 changes: 2 additions & 2 deletions src/types/sendToHawk.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ declare module 'vue/types/vue' {
/**
* Sends error to the Hawk
*
* @param {Error} error - error to send
* @param error - error or message to send
* @example this.$sendToHawk(new Error('Some error'));
*/
$sendToHawk: (error: Error) => void;
$sendToHawk: (error: Error | string) => void;
}
}
57 changes: 56 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,17 @@ export function deepMerge(target: object, ...sources: object[]): object {
* @returns fully assembled payload of the current repetition
*/
export function repetitionAssembler(originalEvent: HawkEventPayload, repetition: { [key: string ]: any} ): HawkEventPayload {
/**
* Specifies how to merge original and repetition values
* @param originalParam - value of some attribute from original event
* @param repetitionParam - value of some attribute from repetition event
*/
const customizer = (originalParam: any, repetitionParam: any): any => {
if (repetitionParam === null) {
return originalParam;
}


if (typeof repetitionParam === 'object' && typeof originalParam === 'object') {
/**
* If original event has null but repetition has some value, we need to return repetition value
Expand All @@ -203,6 +208,56 @@ export function repetitionAssembler(originalEvent: HawkEventPayload, repetition:
return mergeWith(cloneDeep(originalEvent), cloneDeep(repetition), customizer);
}

export function _repetitionAssembler(originalEvent: HawkEventPayload, repetition: { [key: string ]: any} ): HawkEventPayload {
console.log('ASSERMBLER', originalEvent, repetition);

// /**
// * Event timestamp
// */
// timestamp: number;

// /**
// * Event stack array from the latest call to the earliest
// */
// backtrace: HawkEventBacktraceFrame[];

// /**
// * Source code version identifier
// */
// release: string;

// /**
// * Current authenticated user
// */
// user: EventUser;

// /**
// * Any additional data of Event
// */
// context: Record<string, unknown>;

// /**
// * Custom data provided by project users
// */
// addons: EventAddons;

// /**
// * Event type: TypeError, ReferenceError etc.
// */
// type?: string;

return {
title: repetition.title ?? originalEvent.title,
timestamp: repetition.timestamp ?? originalEvent.timestamp,
backtrace: repetition.backtrace === undefined ? originalEvent.backtrace : repetition.backtrace,
release: repetition.release ?? originalEvent.release,
user: repetition.user ?? originalEvent.user,
context: repetition.context ?? originalEvent.context,
addons: repetition.addons ?? originalEvent.addons,
type: repetition.type ?? originalEvent.type,
}
}

/**
* Converts string in wrong language to the translited equal
*
Expand Down

0 comments on commit d679e7b

Please sign in to comment.