obi-sdk 0.18.24 → 0.18.26

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ObiSDK } from "./sdk";
2
+ /**
3
+ * Load the Obi SDK onto the current window. This takes care of any queued commands that may have
4
+ * been added to the window object by the loader script, and assigns the SDK class instance to the
5
+ * window object at "ObiSDK".
6
+ */
7
+ export declare function loadObiSDK(appToken?: string): Promise<ObiSDK | undefined>;
8
+ export declare function loadObiSDKWithWindow({ appToken, window, }: {
9
+ appToken?: string;
10
+ window: any;
11
+ }): Promise<ObiSDK | undefined>;
@@ -0,0 +1 @@
1
+ export declare function mountWidget(sdk?: any): void;
@@ -0,0 +1,84 @@
1
+ import { EventEmitter } from "eventemitter3";
2
+ import type { Identity } from "@obi/obi-client";
3
+ import { ObiClient } from "@obi/obi-client";
4
+ import { Command, CommandType, Config } from "./types";
5
+ export declare const PLAN_URL_PARAM = "49206C6F7665204F6269_session";
6
+ export declare const STORAGE_KEY = "obi-url-params";
7
+ export type ObiSDKEvents = {
8
+ initialised: () => void;
9
+ error: (err: Error) => void;
10
+ showMenu: (showMenu: boolean) => void;
11
+ configUpdated: () => void;
12
+ };
13
+ export type InitialiseArgs = {
14
+ queuedCommands?: Command[];
15
+ };
16
+ export declare class ObiSDK extends EventEmitter<ObiSDKEvents> {
17
+ client: ObiClient | null;
18
+ isActive: boolean;
19
+ primaryColour: string;
20
+ passivePlanUuid: string | null;
21
+ private commandQueue;
22
+ /** HACK: Need to prevent initialisation from being called if resumed. */
23
+ private _resumed;
24
+ /**
25
+ * Creates a client that should persist for the lifetime of the SDK.
26
+ * Resumes an ongoing session if one exists.
27
+ */
28
+ constructor(appToken?: string);
29
+ createClient(appToken: string): Promise<void>;
30
+ initialise(args?: InitialiseArgs): Promise<void>;
31
+ /**
32
+ * Update the SDK configuration. This is typically called before a plan starts,
33
+ * but it is possible to update the configuration during a plan.
34
+ */
35
+ updateConfig(config: Config): Promise<void>;
36
+ updateAppToken(appToken?: string): Promise<void>;
37
+ /**
38
+ * Update the SDK activity state. Activity controls whether the SDK is continuously
39
+ * visible or not.
40
+ * Ignores updates if the active state is undefined or the same as the current active state.
41
+ */
42
+ updateActive(isActive?: boolean): void;
43
+ /**
44
+ * Update the SDK primary colour. This is typically called before a plan starts,
45
+ * but it is possible to update the primary colour during a plan.
46
+ * Ignores updates if the primary colour is undefined or the same as the current primary colour.
47
+ */
48
+ updatePrimaryColour(primaryColour?: string): void;
49
+ /**
50
+ * Update the identity of the onboardee. This is typically called before a plan starts,
51
+ * but it is possible to update the identity during a plan.
52
+ * Ignores updates if the identity is undefined or the same as the current identity.
53
+ */
54
+ updateIdentity(identity?: Identity | null): Promise<void>;
55
+ updateShowMenu(showMenu?: boolean): void;
56
+ /**
57
+ * Say a message to the onboardee.
58
+ */
59
+ say(message: string): Promise<void>;
60
+ /**
61
+ * Start a new session.
62
+ */
63
+ startSession(): Promise<void>;
64
+ /**
65
+ * Dispatch all queued commands in the order they were added.
66
+ * TODO: Passing in the planuuid is not cool.
67
+ */
68
+ dispatchCommandQueue(): void;
69
+ /**
70
+ * This gets set on the window object by the loader script. It is used as an abstraction to allow
71
+ * users to call commands without having to wait for the client to be ready. This works in tandem
72
+ * with the loader script, which will queue any commands that are called before the client is ready.
73
+ */
74
+ dispatchCommand: (commandType: CommandType, args: any) => void;
75
+ /**
76
+ * Parse passive initiation parameters from the URL and/or local storage.
77
+ * Passive initiation parameters are values that indicate a plan & app token to use immediately.
78
+ */
79
+ parsePassiveParams(): null | undefined;
80
+ mountWidget(): void;
81
+ captureScreen(): Promise<string>;
82
+ save(): void;
83
+ load(): string | null;
84
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ interface SentryContext {
2
+ sessionId?: string;
3
+ apiKey?: string;
4
+ widgetState?: string;
5
+ componentName?: string;
6
+ userId?: string;
7
+ userEmail?: string;
8
+ userMetadata?: any;
9
+ handlerName?: string;
10
+ lifecycle?: string;
11
+ changedProperties?: string[];
12
+ eventType?: string;
13
+ eventData?: Record<string, any>;
14
+ userJourney?: string[];
15
+ [key: string]: any;
16
+ }
17
+ export declare function captureException(error: any, context?: SentryContext): void;
18
+ export declare function captureMessage(message: string, level?: "info" | "warning" | "error", context?: SentryContext): void;
19
+ export declare function trackEvent(eventType: string, eventData?: Record<string, any>, componentName?: string): void;
20
+ export declare function setGlobalContext(context: Partial<SentryContext>): void;
21
+ /**
22
+ * Wraps an async function to automatically capture any exceptions
23
+ */
24
+ export declare function withSentryAsyncHandler<T extends (...args: any[]) => Promise<any>>(fn: T, handlerName: string, componentName?: string): T;
25
+ /**
26
+ * Wraps a synchronous function to automatically capture any exceptions
27
+ */
28
+ export declare function withSentryHandler<T extends (...args: any[]) => any>(fn: T, handlerName: string, componentName?: string): T;
29
+ /**
30
+ * Simple wrapper to add Sentry error tracking to component lifecycle methods
31
+ * Use this in your component's connectedCallback, disconnectedCallback, etc.
32
+ */
33
+ export declare function withComponentErrorTracking(componentName: string): {
34
+ trackLifecycle: (lifecycleMethod: string, fn: () => void) => void;
35
+ trackRender: (renderFn: () => any) => any;
36
+ setContext: () => void;
37
+ };
38
+ export { captureException as default };
39
+ export type { SentryContext };
@@ -0,0 +1,13 @@
1
+ import { Identity } from "@obi/obi-client";
2
+ export type CommandType = "update" | "say" | "startSession" | "stopSession";
3
+ export type Command = {
4
+ type: CommandType;
5
+ args: any[];
6
+ };
7
+ export type Config = {
8
+ apiKey?: string;
9
+ isActive?: boolean;
10
+ primaryColour?: string;
11
+ user?: Identity;
12
+ showMenu?: boolean;
13
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Utility for matching URLs against glob patterns
3
+ */
4
+ /**
5
+ * Check if a URL matches any of the provided glob patterns
6
+ * @param url The URL to check
7
+ * @param patterns Array of glob patterns to match against
8
+ * @returns true if the URL matches any pattern, false otherwise
9
+ */
10
+ export declare function matchesUrlPattern(url: string, patterns: string[]): boolean;
11
+ /**
12
+ * Check if the current page URL is blacklisted
13
+ * @param blacklist Array of URL glob patterns
14
+ * @returns true if current URL is blacklisted, false otherwise
15
+ */
16
+ export declare function isCurrentUrlBlacklisted(blacklist?: string[]): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { ObiSDK } from "./sdk";
2
+ export type WidgetProps = {
3
+ sdk: ObiSDK;
4
+ shadowHost: HTMLDivElement;
5
+ };
6
+ export declare function Widget(props: WidgetProps): import("preact").JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.18.24",
3
+ "version": "0.18.26",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",
@@ -16,6 +16,26 @@
16
16
  "files": [
17
17
  "dist"
18
18
  ],
19
+ "scripts": {
20
+ "dev": "vite --mode development",
21
+ "dev:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite --mode staging",
22
+ "build": "vite build --mode production",
23
+ "build:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite build --mode staging",
24
+ "build:publish": "pnpm build --mode production",
25
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
26
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
27
+ "preview": "vite preview",
28
+ "types": "tsc --emitDeclarationOnly",
29
+ "types:check": "tsc --noEmit",
30
+ "prepublishOnly": "pnpm build:publish && pnpm types",
31
+ "clean": "rimraf dist",
32
+ "storybook": "storybook dev -p 6006",
33
+ "build-storybook": "storybook build",
34
+ "test": "vitest run",
35
+ "test:ui": "vitest --ui",
36
+ "test:watch": "vitest",
37
+ "test:coverage": "vitest run --coverage"
38
+ },
19
39
  "keywords": [
20
40
  "obi",
21
41
  "sdk",
@@ -31,18 +51,19 @@
31
51
  "homepage": "https://www.iamobi.ai",
32
52
  "dependencies": {
33
53
  "@lit/react": "^1.0.7",
54
+ "@obi/obi-client": "workspace:*",
55
+ "@obi/obi-components": "workspace:*",
56
+ "@obi/utils": "workspace:*",
34
57
  "@sentry/browser": "^9.23.0",
35
58
  "@sentry/vite-plugin": "^3.5.0",
36
59
  "@types/jsdom": "^21.1.7",
37
60
  "eventemitter3": "^5.0.1",
38
61
  "html2canvas-pro": "^1.5.11",
39
62
  "lit": "^3.0.0",
63
+ "mixpanel-browser": "^2.68.0",
40
64
  "preact": ">=10.0.0",
41
65
  "ts-pattern": "^5.7.0",
42
- "zod": "^3.22.0",
43
- "@obi/obi-client": "0.7.0",
44
- "@obi/obi-components": "0.1.0",
45
- "@obi/utils": "0.2.0"
66
+ "zod": "^3.22.0"
46
67
  },
47
68
  "devDependencies": {
48
69
  "@chromatic-com/storybook": "^4.0.0-0",
@@ -72,23 +93,5 @@
72
93
  "vite": "^4.5.0",
73
94
  "vitest": "^2.1.8"
74
95
  },
75
- "scripts": {
76
- "dev": "vite --mode development",
77
- "dev:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite --mode staging",
78
- "build": "vite build --mode production",
79
- "build:staging": "VITE_API_BASE_URL=https://staging.coragents.ai vite build --mode staging",
80
- "build:publish": "pnpm build --mode production",
81
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
82
- "format": "prettier --write \"src/**/*.{ts,tsx}\"",
83
- "preview": "vite preview",
84
- "types": "tsc --emitDeclarationOnly",
85
- "types:check": "tsc --noEmit",
86
- "clean": "rimraf dist",
87
- "storybook": "storybook dev -p 6006",
88
- "build-storybook": "storybook build",
89
- "test": "vitest run",
90
- "test:ui": "vitest --ui",
91
- "test:watch": "vitest",
92
- "test:coverage": "vitest run --coverage"
93
- }
94
- }
96
+ "packageManager": "pnpm@10.5.2"
97
+ }