Integrate Lovable with Everhour effortlessly. Learn the step-by-step process to streamline project management and enhance time tracking in one simple guide.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
package.json
file.
"axios": "^0.21.1"
integrations
inside your project's src
folder (if it doesn’t exist already).src/integrations
folder, create a new file named everhourIntegration.ts
.everhourIntegration.ts
:
import axios from 'axios';
export interface EverhourTimeEntry {
projectId: string;
taskId: string;
userId: string;
startedAt: string; // ISO 8601 format
duration: number; // Duration in seconds
}
export class EverhourIntegration {
private apiKey: string;
private baseUrl: string = 'https://api.everhour.com/api'; // Base URL for Everhour API
constructor(apiKey: string) {
if (!apiKey) {
throw new Error("Everhour API key is required");
}
this.apiKey = apiKey;
}
public async createTimeEntry(entry: EverhourTimeEntry): Promise<any> {
try {
const response = await axios.post(${this.baseUrl}/time-entries, entry, {
headers: {
'X-Api-Key': this.apiKey,
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
console.error("Error creating Everhour time entry:", error);
throw error;
}
}
}
app.ts
or main.ts
) located in your src
folder.
import { EverhourIntegration, EverhourTimeEntry } from './integrations/everhourIntegration';
// Replace 'YOUREVERHOURAPIKEYHERE' with your actual Everhour API key.
const EVERHOURAPIKEY = 'YOUREVERHOURAPIKEYHERE';
const everhour = new EverhourIntegration(EVERHOURAPIKEY);
async function submitTimeEntry() {
const timeEntry: EverhourTimeEntry = {
projectId: 'projectidexample',
taskId: 'taskidexample',
userId: 'useridexample',
startedAt: new Date().toISOString(),
duration: 3600, // 1 hour in seconds
};
try {
const result = await everhour.createTimeEntry(timeEntry);
console.log('Time entry created:', result);
} catch (error) {
console.error('Failed to create time entry:', error);
}
}
// Call the function where appropriate in your application logic:
submitTimeEntry();
submitTimeEntry
function (or a suitably modified version) within the relevant part of your code so that the time entry is automatically sent to Everhour.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.