@streamlayer/feature-gamification 0.29.0 → 0.29.2

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.
Files changed (2) hide show
  1. package/lib/gamification.js +26 -16
  2. package/package.json +3 -3
@@ -7,7 +7,7 @@ import * as actions from './queries/actions';
7
7
  import { GamificationStorage } from './storage';
8
8
  import { leaderboard } from './leaderboard';
9
9
  import { deepLink } from './deepLink';
10
- import { onboarding } from './onboarding';
10
+ import { OnboardingStatus, onboarding } from './onboarding';
11
11
  import { gamificationBackground } from './';
12
12
  const GamificationQuestionTypes = new Set([QuestionType.POLL, QuestionType.PREDICTION, QuestionType.TRIVIA]);
13
13
  /**
@@ -74,25 +74,35 @@ export class Gamification extends AbstractFeature {
74
74
  * listen for active question and show in-app notification
75
75
  */
76
76
  this.background.activeQuestionId.listen((question) => {
77
- if (question && question.data && this.onboardingStatus.$store.get()) {
77
+ const onboardingStatus = this.onboardingStatus.$store.get();
78
+ if (question && question.data && onboardingStatus) {
78
79
  if (question.data.question?.id !== undefined &&
79
80
  question.data.question.notification !== undefined &&
80
- question.data.moderation?.bypassNotifications?.inAppSilence !== SilenceSetting.ON &&
81
+ question.data.question?.bypassNotifications?.inAppSilence !== SilenceSetting.ON &&
81
82
  question.data.question.status === QuestionStatus.ACTIVE) {
82
83
  if (GamificationQuestionTypes.has(question.data.question.type)) {
83
- this.notifications.add({
84
- type: NotificationType.QUESTION,
85
- action: () => question.data?.question && this.openQuestion(question.data.question.id),
86
- close: () => question.data?.question && this.closeQuestion(question.data.question.id),
87
- autoHideDuration: 1000 * 60,
88
- id: this.background.getCurrentSessionId({ prefix: 'notification', entity: question.data.question.id }),
89
- data: {
90
- questionType: question.data.question.type,
91
- question: {
92
- title: question.data.question.notification.title,
93
- },
94
- },
95
- });
84
+ const optInEnabled = this.settings.getValues().inplayGame?.titleCard?.optIn;
85
+ const onboardingCompleted = onboardingStatus === OnboardingStatus.Completed;
86
+ if (optInEnabled !== undefined) {
87
+ if (!optInEnabled || onboardingCompleted) {
88
+ this.notifications.add({
89
+ type: NotificationType.QUESTION,
90
+ action: () => question.data?.question && this.openQuestion(question.data.question.id),
91
+ close: () => question.data?.question && this.closeQuestion(question.data.question.id),
92
+ autoHideDuration: 1000 * 60,
93
+ id: this.background.getCurrentSessionId({
94
+ prefix: 'notification',
95
+ entity: question.data.question.id,
96
+ }),
97
+ data: {
98
+ questionType: question.data.question.type,
99
+ question: {
100
+ title: question.data.question.notification.title,
101
+ },
102
+ },
103
+ });
104
+ }
105
+ }
96
106
  }
97
107
  else if (question.data.question.type === QuestionType.FACTOID) {
98
108
  const optionsValue = question.data.question.options?.options.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/feature-gamification",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
4
4
  "peerDependencies": {
5
5
  "@bufbuild/protobuf": "^1.4.2",
6
6
  "@streamlayer/sl-eslib": "^5.53.6",
@@ -11,8 +11,8 @@
11
11
  "@streamlayer/sdk-web-interfaces": "^0.0.1",
12
12
  "@streamlayer/sdk-web-logger": "^0.0.1",
13
13
  "@streamlayer/sdk-web-notifications": "^0.1.0",
14
- "@streamlayer/sdk-web-types": "^0.1.0",
15
- "@streamlayer/sdk-web-storage": "^0.0.4"
14
+ "@streamlayer/sdk-web-storage": "^0.0.4",
15
+ "@streamlayer/sdk-web-types": "^0.1.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "tslib": "^2.6.2"