Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
CGPROD-1824 Achievement and home stats (#295)
Browse files Browse the repository at this point in the history
Stats for Achievement Screens
  • Loading branch information
JaKraken authored Oct 9, 2019
1 parent ff4499d commit ae2852e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

| Version | Description |
|---------|-------------|
| | Stats for achievement screens and home buttons | |
| | Fix crashing when using Acheivement Screens | |
| 2.0.7 | |
| | Remove fullscreen api usage | |
Expand Down
11 changes: 10 additions & 1 deletion src/core/layout/gel-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const config = {
channel: buttonsChannel,
action: ({ game }) => {
const screen = game.state.states[game.state.current];
gmi.sendStatsEvent("home", "click");
screen.navigation.home();
},
},
Expand All @@ -60,7 +61,12 @@ export const config = {
order: 2,
id: "__back",
channel: buttonsChannel,
action: () => {
action: ({ game }) => {
const screen = game.state.states[game.state.current];

if (screen.key === "achievements") {
gmi.sendStatsEvent("achievements", "close");
}
gmi.sendStatsEvent("back", "click");
},
},
Expand Down Expand Up @@ -232,8 +238,11 @@ export const config = {
channel: buttonsChannel,
action: ({ game }) => {
const screen = game.state.states[game.state.current];

screen.scene.getLayouts()[0].buttons.achievements.setIndicator();

if (screen.navigation.achievements) {
gmi.sendStatsEvent("achievements", "open");
screen.navigation.achievements();
} else {
gmi.achievements.show();
Expand Down
23 changes: 19 additions & 4 deletions test/core/layout/gel-defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,22 @@ describe("Layout - Gel Defaults", () => {
});

describe("Back Button Callback", () => {
beforeEach(() => {
gel.config.back.action();
});

test("fires a click stat", () => {
gel.config.back.action({ game: mockGame });
expect(mockGmi.sendStatsEvent).toHaveBeenCalledWith("back", "click");
});

test("when backing out of an achievements page a stat is fired", () => {
const mockGame = {
state: {
current: "achievements",
states: { achievements: { key: "achievements" } },
},
};

gel.config.back.action({ game: mockGame });
expect(mockGmi.sendStatsEvent).toHaveBeenCalledWith("achievements", "close");
});
});

describe("How To Play Back Button Callback", () => {
Expand Down Expand Up @@ -235,6 +244,12 @@ describe("Layout - Gel Defaults", () => {
expect(mockGmi.achievements.show).toHaveBeenCalled();
});

test("calls 'achievements open' stats when local screen exists", () => {
gel.config.achievements.action({ game: mockGame });
expect(mockCurrentScreen.navigation.achievements).toHaveBeenCalled();
expect(mockGmi.sendStatsEvent).toHaveBeenCalledWith("achievements", "open");
});

test("clears the indicator when there is a achievements screen", () => {
gel.config.achievements.action({ game: mockGame });
expect(clearIndicatorSpy).toHaveBeenCalled();
Expand Down

0 comments on commit ae2852e

Please sign in to comment.