Skip to content

Commit

Permalink
add preferred route and target asset param (#1134)
Browse files Browse the repository at this point in the history
* add version & hash to mixpanel events

* changes

* New version of connect

* Test and type fixes

* REview fix

* Review fix

* Review fix

* Review fix

* Fix test

* Fix format

* add preferred route and target asset param

* fix prettier

* add unit test and fix old unit test

* fix prettier at test

* update docs

* update connect to use published beta

* #1136 - remove the fallback value for targetAsset when it is not explicitly provided

* fix unit test

* update docs, fix typos

* update connect version

* applied docs reviews

---------

Co-authored-by: Artur Sapek <[email protected]>
Co-authored-by: yuli-ferna <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2024
1 parent 878af08 commit 5337b64
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 214 deletions.
1 change: 1 addition & 0 deletions apps/connect-v1/src/hooks/useConnectConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getSortedChains } from "../utils/getSortedChains";

const defaultConfig: WormholeConnectConfig = {
...ENV.wormholeConnectConfig,
// @ts-expect-error: Type error because v1 is outdated
eventHandler: (e: WormholeConnectEvent) => {
if (isPreview || isProduction) {
// Send the event to Mixpanel
Expand Down
6 changes: 6 additions & 0 deletions apps/connect-v1/src/navs/navs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe("navs", () => {
toToken: EMPTY_TOKEN,
toChain: 1,
},
// @ts-expect-error: Type error because v1 is outdated
meta: { version: "version", hash: "hash", host: "host" },
});
expect(global.window.history.pushState).toHaveBeenCalledWith(
{ event: "transfer.start" },
Expand All @@ -47,6 +49,8 @@ describe("navs", () => {
toToken: EMPTY_TOKEN,
toChain: 1,
},
// @ts-expect-error: Type error because v1 is outdated
meta: { version: "version", hash: "hash", host: "host" },
});
expect(global.window.history.pushState).toHaveBeenCalledWith(
{ event: "transfer.success" },
Expand All @@ -66,6 +70,8 @@ describe("navs", () => {
toToken: EMPTY_TOKEN,
toChain: 1,
},
// @ts-expect-error: Type error because v1 is outdated
meta: { version: "version", hash: "hash", host: "host" },
});
expect(global.window.history.pushState).toHaveBeenCalledWith(
{ event: "transfer.redeem.success" },
Expand Down
10 changes: 9 additions & 1 deletion apps/connect-v1/src/providers/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ describe("telemetry", () => {
});

it("should not track load events", () => {
eventHandler({ type: "load" });
eventHandler({
type: "load",
// @ts-expect-error: Type error because v1 is outdated
meta: { version: "version", hash: "hash", host: "host" },
});

expect(mixpanel.track).not.toHaveBeenCalled();
});
Expand All @@ -44,6 +48,8 @@ describe("telemetry", () => {
chain: "bsc",
wallet: "wallet",
},
// @ts-expect-error: Type error because v1 is outdated
meta: { version: "version", hash: "hash", host: "host" },
});

expect(mixpanel.track).toHaveBeenCalledTimes(1);
Expand All @@ -67,6 +73,8 @@ describe("telemetry", () => {
route: "wstETH Bridge",
txId: "txId",
USDAmount: 123.456,
amount: undefined,
connectVersion: undefined,
});
});

Expand Down
8 changes: 7 additions & 1 deletion apps/connect-v1/src/providers/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import type { WormholeConnectConfig } from "@wormhole-foundation/wormhole-connec

export type WormholeConnectEvent = Parameters<
NonNullable<WormholeConnectConfig["eventHandler"]>
>[0];
>[0] & {
meta: {
version: string;
hash: string;
};
};

mixpanel.init(
isProduction
Expand Down Expand Up @@ -75,6 +80,7 @@ export const eventHandler = (e: WormholeConnectEvent) => {
txId: e.details.txId,
USDAmount: e.details.USDAmount,
amount: e.details.amount,
connectVersion: e.meta?.version,
route:
{
bridge: "Manual Bridge",
Expand Down
Loading

0 comments on commit 5337b64

Please sign in to comment.