@shivnandan/connector-react 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # @tracepulse/connector-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Drop-in transaction intelligence, observability, and autonomous AI copilot provider for React and Next.js applications.
4
+
5
+ [![npm version](https://img.shields.io/badge/npm-v1.0.0-blue.svg)](https://npmjs.com/package/@tracepulse/connector-react)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Overview
9
+
10
+ `@tracepulse/connector-react` acts as an embeddable dependency for any internal portal, CRM, or e-commerce host application. It injects a floating AI SRE assistant into the host UI that enables support teams and engineers to diagnose payment retries, Kafka milestone failures, and microservice anomalies in real-time.
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @tracepulse/connector-react
18
+ # or
19
+ npm install @tracepulse/connector-react
20
+ # or
21
+ yarn add @tracepulse/connector-react
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Quick Start
27
+
28
+ ### 1. Wrap Your Root Layout or App
29
+
30
+ ```tsx
31
+ import { TracePulseProvider } from "@tracepulse/connector-react";
32
+
33
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
34
+ return (
35
+ <html lang="en">
36
+ <body>
37
+ <TracePulseProvider
38
+ apiKey="tp_live_9a7bc449e"
39
+ projectId="airtel-retailer-portal"
40
+ endpoint="https://tracepulse-api.yourcompany.com"
41
+ position="bottom-right"
42
+ >
43
+ {children}
44
+ </TracePulseProvider>
45
+ </body>
46
+ </html>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### 2. Programmatic Control (`useTracePulse` Hook)
52
+
53
+ You can trigger the AI Copilot programmatically from any button or table row in your application:
54
+
55
+ ```tsx
56
+ import { useTracePulse } from "@tracepulse/connector-react";
57
+
58
+ export function OrderRow({ leadId }: { leadId: string }) {
59
+ const { openCopilot } = useTracePulse();
60
+
61
+ return (
62
+ <div className="order-row">
63
+ <span>Lead #{leadId}</span>
64
+ <button onClick={() => openCopilot(leadId)}>
65
+ Diagnose with AI Copilot
66
+ </button>
67
+ </div>
68
+ );
69
+ }
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Props Reference
75
+
76
+ | Prop | Type | Default | Description |
77
+ | :--- | :--- | :--- | :--- |
78
+ | `apiKey` | `string` | **Required** | Project API token for telemetry authentication. |
79
+ | `projectId` | `string` | `"default-project"` | Microservice or tenant namespace identifier. |
80
+ | `endpoint` | `string` | `"http://127.0.0.1:8000"` | Base URL of your TracePulse backend server. |
81
+ | `targetTransactionId` | `string` | `undefined` | Pre-lock AI assistant to a specific `clientTxnId`. |
82
+ | `position` | `"bottom-right" \| "bottom-left"` | `"bottom-right"` | Screen corner docking position. |
83
+ | `floatingButton` | `boolean` | `true` | Set to `false` for headless mode (trigger via `useTracePulse`). |
84
+ | `children` | `ReactNode` | `undefined` | Child components wrapped by the provider. |
85
+
86
+ ---
87
+
88
+ ## Headless Mode (Custom Trigger Button)
89
+
90
+ If you prefer to design your own trigger button instead of the default floating action button:
91
+
92
+ ```tsx
93
+ <TracePulseProvider
94
+ apiKey="tp_live_..."
95
+ floatingButton={false} // Hides default floating button
96
+ >
97
+ <YourApp />
98
+ </TracePulseProvider>
99
+ ```
100
+
101
+ Then invoke `openCopilot(txnId)` or `toggleCopilot()` from your custom UI.
102
+
103
+ ---
104
+
105
+ ## License
106
+
107
+ MIT © TracePulse Observability
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+
3
+ interface ChatMessage {
4
+ id: string;
5
+ sender: "user" | "copilot";
6
+ text: string;
7
+ timestamp: string;
8
+ transactionId?: string;
9
+ }
10
+ interface TracePulseProviderProps {
11
+ apiKey: string;
12
+ projectId?: string;
13
+ endpoint?: string;
14
+ targetTransactionId?: string;
15
+ position?: "bottom-right" | "bottom-left";
16
+ theme?: "light" | "auto";
17
+ floatingButton?: boolean;
18
+ children?: React.ReactNode;
19
+ }
20
+ interface TracePulseContextValue {
21
+ isOpen: boolean;
22
+ openCopilot: (transactionId?: string) => void;
23
+ closeCopilot: () => void;
24
+ toggleCopilot: () => void;
25
+ activeTransactionId: string | null;
26
+ setActiveTransactionId: (id: string | null) => void;
27
+ sendMessage: (text: string, transactionId?: string) => Promise<string>;
28
+ messages: ChatMessage[];
29
+ isLoading: boolean;
30
+ endpoint: string;
31
+ apiKey: string;
32
+ }
33
+
34
+ declare function TracePulseProvider({ apiKey, projectId, endpoint, targetTransactionId, position, theme, floatingButton, children, }: TracePulseProviderProps): React.JSX.Element;
35
+
36
+ declare const TracePulseContext: React.Context<TracePulseContextValue | null>;
37
+
38
+ /**
39
+ * React hook to access TracePulse AI Copilot controls from any child component.
40
+ *
41
+ * Example:
42
+ * ```tsx
43
+ * import { useTracePulse } from "@tracepulse/connector-react";
44
+ *
45
+ * function OrderCard({ leadId }) {
46
+ * const { openCopilot } = useTracePulse();
47
+ * return <button onClick={() => openCopilot(leadId)}>Investigate with AI</button>;
48
+ * }
49
+ * ```
50
+ */
51
+ declare function useTracePulse(): TracePulseContextValue;
52
+
53
+ export { type ChatMessage, TracePulseContext, type TracePulseContextValue, TracePulseProvider, type TracePulseProviderProps, TracePulseProvider as default, useTracePulse };
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+
3
+ interface ChatMessage {
4
+ id: string;
5
+ sender: "user" | "copilot";
6
+ text: string;
7
+ timestamp: string;
8
+ transactionId?: string;
9
+ }
10
+ interface TracePulseProviderProps {
11
+ apiKey: string;
12
+ projectId?: string;
13
+ endpoint?: string;
14
+ targetTransactionId?: string;
15
+ position?: "bottom-right" | "bottom-left";
16
+ theme?: "light" | "auto";
17
+ floatingButton?: boolean;
18
+ children?: React.ReactNode;
19
+ }
20
+ interface TracePulseContextValue {
21
+ isOpen: boolean;
22
+ openCopilot: (transactionId?: string) => void;
23
+ closeCopilot: () => void;
24
+ toggleCopilot: () => void;
25
+ activeTransactionId: string | null;
26
+ setActiveTransactionId: (id: string | null) => void;
27
+ sendMessage: (text: string, transactionId?: string) => Promise<string>;
28
+ messages: ChatMessage[];
29
+ isLoading: boolean;
30
+ endpoint: string;
31
+ apiKey: string;
32
+ }
33
+
34
+ declare function TracePulseProvider({ apiKey, projectId, endpoint, targetTransactionId, position, theme, floatingButton, children, }: TracePulseProviderProps): React.JSX.Element;
35
+
36
+ declare const TracePulseContext: React.Context<TracePulseContextValue | null>;
37
+
38
+ /**
39
+ * React hook to access TracePulse AI Copilot controls from any child component.
40
+ *
41
+ * Example:
42
+ * ```tsx
43
+ * import { useTracePulse } from "@tracepulse/connector-react";
44
+ *
45
+ * function OrderCard({ leadId }) {
46
+ * const { openCopilot } = useTracePulse();
47
+ * return <button onClick={() => openCopilot(leadId)}>Investigate with AI</button>;
48
+ * }
49
+ * ```
50
+ */
51
+ declare function useTracePulse(): TracePulseContextValue;
52
+
53
+ export { type ChatMessage, TracePulseContext, type TracePulseContextValue, TracePulseProvider, type TracePulseProviderProps, TracePulseProvider as default, useTracePulse };