Skip to content

Commit

Permalink
Merge branch 'main' into Matvey-Kuk/moving-background-tasks-outside-o…
Browse files Browse the repository at this point in the history
…f-the-server
  • Loading branch information
Matvey-Kuk authored Nov 20, 2024
2 parents 84b5eef + 499abad commit 4e20033
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 30 deletions.
81 changes: 52 additions & 29 deletions keep-ui/app/read-only-banner.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
"use client";
import React from "react";
import { X } from "lucide-react";
import { useLocalStorage } from "utils/hooks/useLocalStorage";
import { Card, Text, Button } from "@tremor/react";
import { Text, Button } from "@tremor/react";
import Image from "next/image";
import KeepPng from "../keep.png";
import { capture } from "@/shared/lib/capture";

const ReadOnlyBanner = () => {
const [isVisible, setIsVisible] = useLocalStorage(
"read-only-banner-visible",
true
);

if (!isVisible) return null;

return (
<Card
className="w-full rounded-none bg-orange-400 text-black py-2"
decoration="none"
>
<div className="container mx-auto relative">
<div className="flex items-center justify-center gap-2">
<Image src={KeepPng} alt="Keep Logo" width={20} height={20} />
<Text className="text-sm font-medium text-black">
Keep is in read-only mode.
</Text>
<div className="w-full py-2 pl-4 pr-2 mb-4 bg-orange-50 border border-orange-200 rounded-lg">
<div className="flex items-center justify-between gap-4">
<Text className="text-sm font-medium text-black">
<Image
src={KeepPng}
alt="Keep Logo"
width={20}
height={20}
className="inline-block mr-2"
/>
Keep is in read-only mode.
</Text>
<div className="flex items-center gap-2">
<Button
className="[&>span]:text-xs"
onClick={() => {
capture("try-keep-for-free", {
source: "read-only-banner",
});
window.open(
"https://platform.keephq.dev/providers",
"_blank",
"noopener,noreferrer"
);
}}
variant="primary"
color="orange"
size="xs"
>
Try for free
</Button>
<Button
className="[&>span]:text-xs"
onClick={() => {
capture("talk-to-us", {
source: "read-only-banner",
});
window.open(
"https://www.keephq.dev/meet-keep",
"_blank",
"noopener,noreferrer"
);
}}
color="orange"
variant="secondary"
size="xs"
>
Talk to us
</Button>
</div>
<Button
onClick={() => setIsVisible(false)}
variant="light"
color="gray"
icon={X}
size="xs"
className="hover:text-gray-500 transition-colors absolute right-0 top-1/2 -translate-y-1/2"
/>
</div>
</Card>
</div>
);
};

Expand Down
9 changes: 9 additions & 0 deletions keep-ui/shared/lib/capture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import posthog from "posthog-js";

export const capture = (event: string, properties?: Record<string, any>) => {
try {
posthog.capture(event, properties);
} catch (error) {
console.error("Error capturing event:", error);
}
};
2 changes: 1 addition & 1 deletion keep/api/routes/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ async def receive_event(
redis: ArqRedis = await get_pool()
job = await redis.enqueue_job(
"async_process_incident",
{},
authenticated_entity.tenant_id,
provider_id,
provider_type,
event,
trace_id,
_queue_name=KEEP_ARQ_QUEUE_BASIC,
)
logger.info(
"Enqueued job",
Expand Down
4 changes: 4 additions & 0 deletions keep/api/tasks/process_incident_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def process_incident(
"trace_id": trace_id,
}

if ctx and isinstance(ctx, dict):
extra["job_try"] = ctx.get("job_try", 0)
extra["job_id"] = ctx.get("job_id", None)

if isinstance(incidents, IncidentDto):
incidents = [incidents]

Expand Down

0 comments on commit 4e20033

Please sign in to comment.