Skip to content

Commit

Permalink
fix: add redirect and promotion_click as funnel entry types (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonBerry authored Mar 2, 2022
1 parent 5b877cb commit 084068c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getItem, RequestError, setItem } from ".";

export const STORAGE_KEY = "searchio_events";
const EXPIRY_DAYS = 30;
const FUNNEL_ENTRY_TYPES = ["click"];
const FUNNEL_ENTRY_TYPES = ["click", "redirect", "promotion_click"];

type Metadata = Record<string, boolean | number | string>;
interface EventState {
Expand Down
41 changes: 22 additions & 19 deletions test/tracking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,25 +427,28 @@ describe("SearchIOAnalytics", () => {
);
});

it("calls trackForQuery with current queryId if type is click", () => {
const analytics = new SearchIOAnalytics(
"test_account",
"test_collection"
);
analytics.events = {
sku1: [eventState, { ...eventState, queryId: "ghi789" }],
};

analytics.updateQueryId("def456");
analytics.track("click", "sku1");

expect(trackForQuerySpy).toHaveBeenCalledWith(
"def456",
"click",
"sku1",
undefined
);
});
it.each(["click", "redirect", "promotion_click"])(
"calls trackForQuery with current queryId if type is %s",
(type) => {
const analytics = new SearchIOAnalytics(
"test_account",
"test_collection"
);
analytics.events = {
sku1: [eventState, { ...eventState, queryId: "ghi789" }],
};

analytics.updateQueryId("def456");
analytics.track(type, "sku1");

expect(trackForQuerySpy).toHaveBeenCalledWith(
"def456",
type,
"sku1",
undefined
);
}
);
});

describe("flush", () => {
Expand Down

0 comments on commit 084068c

Please sign in to comment.