Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/browser-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,14 @@ export class BucketClient {
* Add a hook to the client.
*
* @param hook Hook to add.
* @returns A function to remove the hook.
*/
on<THookType extends keyof HookArgs>(
type: THookType,
handler: (args0: HookArgs[THookType]) => void,
) {
this.hooks.addHook(type, handler);
return () => this.hooks.removeHook(type, handler);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-sdk/src/hooksManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface HookArgs {
track: TrackEvent;
}

type TrackEvent = {
export type TrackEvent = {
user: UserContext;
company?: CompanyContext;
eventName: string;
Expand Down
1 change: 1 addition & 0 deletions packages/browser-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export type {
OnScoreSubmitResult,
OpenFeedbackFormOptions,
} from "./feedback/ui/types";
export type { TrackEvent } from "./hooksManager";
export type { Logger } from "./logger";
export { feedbackContainerId, propagatedEvents } from "./ui/constants";
2 changes: 1 addition & 1 deletion packages/react-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"dependencies": {
"@bucketco/browser-sdk": "3.0.0-alpha.6",
"@bucketco/browser-sdk": "3.0.0",
"canonical-json": "^0.0.4",
"rollup": "^4.2.0"
},
Expand Down
20 changes: 17 additions & 3 deletions packages/react-sdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@ import canonicalJSON from "canonical-json";
import {
BucketClient,
BucketContext,
CheckEvent,
CompanyContext,
InitOptions,
RawFeatures,
RequestFeedbackData,
TrackEvent,
UnassignedFeedback,
UserContext,
} from "@bucketco/browser-sdk";

import { version } from "../package.json";

export type {
CheckEvent,
CompanyContext,
RawFeatures,
TrackEvent,
UserContext,
};

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface Features {}

Expand Down Expand Up @@ -349,9 +361,11 @@ export function useUpdateOtherContext() {
*
* ```ts
* const client = useClient();
* client.on("configCheck", () => {
* console.log("configCheck hook called");
* });
* useEffect(() => {
* return client?.on("enabledCheck", () => {
* console.log("enabledCheck hook called");
* });
* }, [client]);
* ```
*/
export function useClient() {
Expand Down
14 changes: 1 addition & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,6 @@ __metadata:
languageName: unknown
linkType: soft

"@bucketco/browser-sdk@npm:3.0.0-alpha.6":
version: 3.0.0-alpha.6
resolution: "@bucketco/browser-sdk@npm:3.0.0-alpha.6"
dependencies:
"@floating-ui/dom": "npm:^1.6.8"
canonical-json: "npm:^0.0.4"
js-cookie: "npm:^3.0.5"
preact: "npm:^10.22.1"
checksum: 10c0/3fe141d1674401d7bbfebec76a59cabbc0e76ed3006198aa91704d237cc0ee5c0731aae9bef5d1c101eef47a49460b06ecb30879f7a5d3cd29d2f35bddb26306
languageName: node
linkType: hard

"@bucketco/eslint-config@npm:0.0.2, @bucketco/eslint-config@npm:~0.0.2, @bucketco/eslint-config@workspace:^, @bucketco/eslint-config@workspace:packages/eslint-config":
version: 0.0.0-use.local
resolution: "@bucketco/eslint-config@workspace:packages/eslint-config"
Expand Down Expand Up @@ -567,7 +555,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@bucketco/react-sdk@workspace:packages/react-sdk"
dependencies:
"@bucketco/browser-sdk": "npm:3.0.0-alpha.6"
"@bucketco/browser-sdk": "npm:3.0.0"
"@bucketco/eslint-config": "workspace:^"
"@bucketco/tsconfig": "workspace:^"
"@testing-library/react": "npm:^15.0.7"
Expand Down