Audio Player and this.$user.$metaData.sessionsCount


#1

@AlexSwe I think I might have found a BUG with this.$user.$metaData.sessionsCount when it comes to the Alexa Audio Player.

I enable the following in config.js

  user: {
    context: {
      enabled: true,
    },
    metaData: {
      enabled: true,
    },
  },

When I start and stop the skill multiple times then the counter at this.$user.$metaData.sessionsCount increments correctly.

When I start the Audio Player and do multiple “Alexa, stop/pause”, “Alexa, next”, “Alexa, resume” then the NEW_SESSION handler is called and the counter is incremented even though there is no sessionId. Is this the intended behavior?

If I am using the counter to affect behavior based on the number of times the user launched the skill, then my count is all off.

Besides audio playback, I believe the counter would also be incremented on any AlexaSkillEvent requests.

The workaround is to do my own counter and not rely on this.$user.$metaData.sessionsCount

What is your recommendation?

Jovo CLI Version: 2.2.8

Jovo packages of current project:
jovo-analytics-dashbot: 2.2.14
jovo-analytics-voicehero: 2.2.14
jovo-cms-i18next: 2.2.15
jovo-core: 2.2.14
jovo-db-dynamodb: 2.2.14
jovo-db-filedb: 2.2.14
jovo-framework: 2.2.19
jovo-platform-alexa: 2.2.21
jovo-platform-dialogflow: 2.2.16
jovo-platform-googleassistant: 2.2.19
jovo-plugin-debugger: 2.2.16
jovo-plugin-error-slack: 2.1.1


#2

Hey @marktucker

That’s indeed a bug. The default value in isNewSession() is true. https://github.com/jovotech/jovo-framework/blob/ef4e4d4c94e9fa871a85b65512fd234497ed96b0/jovo-platforms/jovo-platform-alexa/src/core/AlexaRequest.ts#L529

The bugfix might be a breaking change. I will make the fix of the original isNewSession() method in v2.3.

Until then, I will add a workaround to fix the incrementing session counter. This temporary workaround won’t fix the incorrect calling of the NEW_SESSION handler on AudioPlayer requests. But it will be fixed in v2.3