Skip to content

Commit

Permalink
Merge pull request #6950 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Oct 7, 2023
2 parents 4ffef6a + aacb641 commit 751a79f
Show file tree
Hide file tree
Showing 47 changed files with 864 additions and 212 deletions.
10 changes: 8 additions & 2 deletions .env.compose
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ HUBSTAFF_CLIENT_ID=
HUBSTAFF_CLIENT_SECRET=
HUBSTAFF_PERSONAL_ACCESS_TOKEN=

# Jitsu Configuration
JITSU_BROWSER_HOST=
# Jitsu Browser Configuration
JITSU_BROWSER_URL=
JITSU_BROWSER_WRITE_KEY=

# Jitsu Server Configuration
JITSU_SERVER_URL=
JITSU_SERVER_WRITE_KEY=
JITSU_SERVER_DEBUG=
JITSU_SERVER_ECHO_EVENTS=
10 changes: 8 additions & 2 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ HUBSTAFF_CLIENT_ID=
HUBSTAFF_CLIENT_SECRET=
HUBSTAFF_PERSONAL_ACCESS_TOKEN=

# Jitsu Configuration
JITSU_BROWSER_HOST=
# Jitsu Browser Configuration
JITSU_BROWSER_URL=
JITSU_BROWSER_WRITE_KEY=

# Jitsu Server Configuration
JITSU_SERVER_URL=
JITSU_SERVER_WRITE_KEY=
JITSU_SERVER_DEBUG=
JITSU_SERVER_ECHO_EVENTS=
10 changes: 8 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ HUBSTAFF_CLIENT_ID=
HUBSTAFF_CLIENT_SECRET=
HUBSTAFF_PERSONAL_ACCESS_TOKEN=

# Jitsu Configuration
JITSU_BROWSER_HOST=
# Jitsu Browser Configuration
JITSU_BROWSER_URL=
JITSU_BROWSER_WRITE_KEY=

# Jitsu Server Configuration
JITSU_SERVER_URL=
JITSU_SERVER_WRITE_KEY=
JITSU_SERVER_DEBUG=
JITSU_SERVER_ECHO_EVENTS=
10 changes: 8 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ HUBSTAFF_CLIENT_ID=
HUBSTAFF_CLIENT_SECRET=
HUBSTAFF_PERSONAL_ACCESS_TOKEN=

# Jitsu Configuration
JITSU_BROWSER_HOST=
# Jitsu Browser Configuration
JITSU_BROWSER_URL=
JITSU_BROWSER_WRITE_KEY=

# Jitsu Server Configuration
JITSU_SERVER_URL=
JITSU_SERVER_WRITE_KEY=
JITSU_SERVER_DEBUG=
JITSU_SERVER_ECHO_EVENTS=
22 changes: 7 additions & 15 deletions .scripts/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,19 @@ import { CloudinaryConfiguration } from '@cloudinary/angular-5.x';

if (!env.IS_DOCKER) {
if (!env.GOOGLE_MAPS_API_KEY) {
console.warn(
'WARNING: No Google Maps API Key defined in the .env file. Google Maps may not be working!'
);
console.warn('WARNING: No Google Maps API Key defined in the .env file. Google Maps may not be working!');
}

if (!env.SENTRY_DSN) {
console.warn(
'WARNING: No Sentry DSN defined in the .env file. Sentry logging may not be working!'
);
console.warn('WARNING: No Sentry DSN defined in the .env file. Sentry logging may not be working!');
}

if (!env.CLOUDINARY_CLOUD_NAME || !env.CLOUDINARY_API_KEY) {
console.warn(
'WARNING: No Cloudinary API keys defined in the .env file.'
);
console.warn('WARNING: No Cloudinary API keys defined in the .env file.');
}

if (!env.JITSU_BROWSER_HOST || !env.JITSU_BROWSER_WRITE_KEY) {
console.warn(
'WARNING: No Jitsu keys defined in the .env file. Jitsu analytics may not be working!'
);
if (!env.JITSU_BROWSER_URL || !env.JITSU_BROWSER_WRITE_KEY) {
console.warn('WARNING: No Jitsu keys defined for browser in the .env file. Jitsu analytics may not be working!');
}

envFileContent += `
Expand Down Expand Up @@ -149,7 +141,7 @@ if (!env.IS_DOCKER) {
FILE_PROVIDER: '${env.FILE_PROVIDER}',
JITSU_BROWSER_HOST: '${env.JITSU_BROWSER_HOST}',
JITSU_BROWSER_URL: '${env.JITSU_BROWSER_URL}',
JITSU_BROWSER_WRITE_KEY: '${env.JITSU_BROWSER_WRITE_KEY}',
GAUZY_GITHUB_APP_NAME: '${env.GAUZY_GITHUB_APP_NAME}',
Expand Down Expand Up @@ -256,7 +248,7 @@ if (!env.IS_DOCKER) {
FILE_PROVIDER: '${env.FILE_PROVIDER}',
JITSU_BROWSER_HOST: '${env.JITSU_BROWSER_HOST}',
JITSU_BROWSER_URL: '${env.JITSU_BROWSER_URL}',
JITSU_BROWSER_WRITE_KEY: '${env.JITSU_BROWSER_WRITE_KEY}',
GAUZY_GITHUB_APP_NAME: '${env.GAUZY_GITHUB_APP_NAME}',
Expand Down
6 changes: 3 additions & 3 deletions .scripts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export type Env = Readonly<{

FILE_PROVIDER: string;

// Jitsu Analytics
JITSU_BROWSER_HOST: string;
// Jitsu Browser Configurations
JITSU_BROWSER_URL: string;
JITSU_BROWSER_WRITE_KEY: string;

GAUZY_GITHUB_APP_NAME: string;
Expand Down Expand Up @@ -141,7 +141,7 @@ export const env: Env = cleanEnv(

FILE_PROVIDER: str({ default: 'LOCAL' }),

JITSU_BROWSER_HOST: str({ default: '' }),
JITSU_BROWSER_URL: str({ default: '' }),
JITSU_BROWSER_WRITE_KEY: str({ default: '' }),

GAUZY_GITHUB_APP_NAME: str({ default: '' }),
Expand Down
2 changes: 1 addition & 1 deletion apps/gauzy-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@faker-js/faker": "8.0.0-alpha.0",
"dayjs": "^1.11.4",
"resolve": "^1.20.0"
},
"scripts": {
Expand Down Expand Up @@ -66,7 +67,6 @@
"cypress": "^9.4.1",
"cypress-cucumber-preprocessor": "^4.3.1",
"cypress-file-upload": "^5.0.8",
"dayjs": "^1.10.6",
"jasmine-core": "^3.6.0",
"jasmine-spec-reporter": "^6.0.0",
"jest": "^26.4.2",
Expand Down
5 changes: 3 additions & 2 deletions apps/gauzy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@fullcalendar/timegrid": "^5.11.2",
"@gauzy/common-angular": "^0.1.0",
"@gauzy/contracts": "^0.1.0",
"@jitsu/js": "^1.3.0",
"@kurkle/color": "^0.2.0",
"@nebular/auth": "^9.0.3",
"@nebular/bootstrap": "^9.0.3",
Expand Down Expand Up @@ -94,6 +95,7 @@
"d3-selection-multi": "^1.0.1",
"date-fns": "^2.28.0",
"date-holidays": "^1.6.1",
"dayjs": "^1.11.4",
"detect-passive-events": "^1.0.4",
"echarts": "^5.0.1",
"eva-icons": "^1.1.3",
Expand Down Expand Up @@ -164,8 +166,7 @@
"uuid": "^8.3.2",
"web-animations-js": "^2.3.2",
"yargs": "^17.5.0",
"zone.js": "~0.11.4",
"@jitsu/js": "^1.3.0"
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^13.0.0",
Expand Down
25 changes: 14 additions & 11 deletions apps/gauzy/src/app/@core/services/analytics/event.type.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
interface IUserCreatedEvent {
eventType: 'UserCreated';
eventType: JitsuAnalyticsEventsEnum.USER_CREATED;
userId: string;
email: string;
}

interface IButtonClickedEvent {
eventType: 'ButtonClicked';
eventType: JitsuAnalyticsEventsEnum.BUTTON_CLICKED;
url: string;
userId: string;
userEmail: string;
Expand All @@ -16,28 +16,28 @@ interface IMenuItemClickedEvent extends IButtonClickedEvent {
}

interface IPageViewEvent {
eventType: 'PageView';
eventType: JitsuAnalyticsEventsEnum.PAGE_VIEW;
url: string;
periodicity: string;
}

interface IPageCreatedEvent {
eventType: 'PageCreated';
eventType: JitsuAnalyticsEventsEnum.PAGE_CREATED;
slug: string;
}

interface IUserUpgradedEvent {
eventType: 'UserUpgraded';
eventType: JitsuAnalyticsEventsEnum.USER_UPGRADED;
email: string;
}

interface IUserClickDownloadAppEvent {
eventType: 'UserClickDownloadApp';
eventType: JitsuAnalyticsEventsEnum.USER_CLICK_DOWNLOAD_APP;
email: string;
}

interface IUserSignedInEvent {
eventType: 'UserSignedIn';
eventType: JitsuAnalyticsEventsEnum.USER_SIGNED_IN;
email: string;
}

Expand All @@ -54,8 +54,11 @@ type JitsuAnalyticsEvents =
export default JitsuAnalyticsEvents;

export enum JitsuAnalyticsEventsEnum {
USER_CREATED = 'User Created',
BUTTON_CLICKED = 'Button_Clicked',
PAGE_VIEW = 'Page_View',
PAGE_CREATED = 'Page Created',
USER_CREATED = 'UserCreated',
USER_SIGNED_IN = 'UserSignedIn',
USER_CLICK_DOWNLOAD_APP = 'UserClickDownloadApp',
USER_UPGRADED = 'UserUpgraded',
BUTTON_CLICKED = 'ButtonClicked',
PAGE_VIEW = 'PageView',
PAGE_CREATED = 'PageCreated'
}
24 changes: 13 additions & 11 deletions apps/gauzy/src/app/@core/services/analytics/jitsu.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { jitsuAnalytics, emptyAnalytics, AnalyticsInterface } from '@jitsu/js';
import { filter } from 'rxjs/operators';
import { Location } from '@angular/common';
import { filter } from 'rxjs/operators';
import { jitsuAnalytics, emptyAnalytics, AnalyticsInterface } from '@jitsu/js';
import { environment } from '@env/environment';
import JitsuAnalyticsEvents, { JitsuAnalyticsEventsEnum } from './event.type';

Expand All @@ -11,15 +11,17 @@ import JitsuAnalyticsEvents, { JitsuAnalyticsEventsEnum } from './event.type';
})
export class JitsuService {
private jitsuClient: AnalyticsInterface;
constructor(private location: Location, private router: Router) {
this.jitsuClient =
environment.JITSU_BROWSER_HOST &&
environment.JITSU_BROWSER_WRITE_KEY
? jitsuAnalytics({
host: environment.JITSU_BROWSER_HOST,
writeKey: environment.JITSU_BROWSER_WRITE_KEY,
})
: emptyAnalytics;

constructor(
private readonly location: Location,
private readonly router: Router
) {
this.jitsuClient = environment.JITSU_BROWSER_URL && environment.JITSU_BROWSER_WRITE_KEY ? jitsuAnalytics({
host: environment.JITSU_BROWSER_URL,
writeKey: environment.JITSU_BROWSER_WRITE_KEY,
debug: false,
echoEvents: false
}) : emptyAnalytics;
}

async identify(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
Output,
} from '@angular/core';
import { Router } from '@angular/router';
import { NbSidebarService } from '@nebular/theme';
import JitsuAnalyticsEvents from 'apps/gauzy/src/app/@core/services/analytics/event.type';
import { JitsuService } from 'apps/gauzy/src/app/@core/services/analytics/jitsu.service';
import { Store } from 'apps/gauzy/src/app/@core/services/store.service';
import { IUser } from 'packages/contracts/dist';
import { tap } from 'rxjs/operators';
import { NbSidebarService } from '@nebular/theme';
import { IUser } from '@gauzy/contracts';
import JitsuAnalyticsEvents, { JitsuAnalyticsEventsEnum } from './../../../../../@core/services/analytics/event.type';
import { JitsuService } from './../../../../../@core/services/analytics/jitsu.service';
import { Store } from './../../../../../@core/services/store.service';
import { IMenuItem } from '../../interface/menu-item.interface';

@Component({
Expand All @@ -30,19 +30,17 @@ export class MenuItemComponent implements OnInit, AfterViewChecked {
private _selected: boolean;
private _user: IUser;

@Output()
public collapsedChange: EventEmitter<any> = new EventEmitter();
@Output()
public selectedChange: EventEmitter<any> = new EventEmitter();
@Output() public collapsedChange: EventEmitter<any> = new EventEmitter();
@Output() public selectedChange: EventEmitter<any> = new EventEmitter();

constructor(
private router: Router,
private sidebarService: NbSidebarService,
private cdr: ChangeDetectorRef,
private location: Location,
private jitsuService: JitsuService,
private readonly router: Router,
private readonly sidebarService: NbSidebarService,
private readonly cdr: ChangeDetectorRef,
private readonly location: Location,
private readonly jitsuService: JitsuService,
private readonly store: Store
) {}
) { }

ngOnInit(): void {
this._user = this.store.user;
Expand All @@ -60,20 +58,31 @@ export class MenuItemComponent implements OnInit, AfterViewChecked {
this.cdr.detectChanges();
}

/**
* Track a click event.
* @param item The item that was clicked.
* @param user The user who clicked the item.
*/
public jitsuTrackClick() {
const clickEvent: JitsuAnalyticsEvents = {
eventType: 'ButtonClicked',
eventType: JitsuAnalyticsEventsEnum.BUTTON_CLICKED,
url: this.item.url ?? this.item.link,
userId: this._user.id,
userEmail: this._user.email,
menuItemName: this.item.title,
};

// Track the click event
this.jitsuService.trackEvents(clickEvent.eventType, clickEvent);

// Identify the user
this.jitsuService.identify(this._user.id, {
email: this._user.email,
fullName: this._user.name,
timeZone: this._user.timeZone,
});

// Group the user
this.jitsuService.group(this._user.id, {
email: this._user.email,
fullName: this._user.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Represents a date range with a start date and end date.
export interface IDateRangePicker {
startDate: Date; // The start date of the date range.
endDate: Date; // The end date of the date range.
isCustomDate?: boolean; // Optional flag to indicate if it's a custom date range.
}

// Represents a time period with a start date and end date using moment.js.
export interface TimePeriod {
startDate: moment.Moment; // The start date of the time period.
endDate: moment.Moment; // The end date of the time period.
}

// Represents a collection of date ranges where each range is indexed by a string key.
export interface DateRanges {
[index: string]: [moment.Moment, moment.Moment]; // Key-value pairs of date ranges.
}

// Enum defining keys for common date range options.
export enum DateRangeKeyEnum {
TODAY = 'Today',
YESTERDAY = 'Yesterday',
CURRENT_WEEK = 'Current week',
LAST_WEEK = 'Last week',
CURRENT_MONTH = 'Current month',
LAST_MONTH = 'Last month'
}
Loading

0 comments on commit 751a79f

Please sign in to comment.