amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

Amplify Personalize Record Events For MediaAutoTrack are Failing

Open rkarthikr opened this issue 4 years ago • 5 comments

Describe the bug MediaAutoTrack Events Using Amplify SDK version - 3.3.3,3.3.2 is triggering events to tracker but they are failing due to bad payload . See the Sample Request/Response section at the bottom

https://docs.amplify.aws/lib/analytics/personalize/q/platform/js#working-with-the-api https://aws.amazon.com/blogs/aws/amazon-personalize-is-now-generally-available/

To Reproduce Steps to reproduce the behavior:

  1. Record Event for MediaAutoTrack Using the Dom ID for video player
  2. Play the Video
  3. Check Tracker Events are sent to Personalize
  4. Check Request/Response in Developer Tools
  5. HTTP 400 Error Code

Expected behavior Events are successfully submitted . HTTP 200 response code for Put Events

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Browser: Firefox
  • Version: 68.8.0esr (64-bit)

Additional context

Sample Request

{
    "eventList": [
        {
            "eventId": "01cfc340-0539-184387240-0526-11eb-aa3a-29f4dbbd8521",
            "eventType": "TimeWatched",
            "properties": "{\"itemId\":\"593\",\"timestamp\":139.472841,\"duration\":597,\"eventValue\":0.2336}",
            "sentAt": 1601702130
        },
        {
            "eventId": "01cfc340-0539-184387240-0526-11eb-aa3a-29f4dbbd8521",
            "eventType": "TimeWatched",
            "properties": "{\"itemId\":\"593\",\"timestamp\":139.472841,\"duration\":597,\"eventValue\":0.2336}",
            "sentAt": 1601702130
        },
        {
            "eventId": "01cfc340-0539-184387240-0526-11eb-aa3a-29f4dbbd8521",
            "eventType": "TimeWatched",
            "properties": "{\"itemId\":\"593\",\"timestamp\":139.472841,\"duration\":597,\"eventValue\":0.2336}",
            "sentAt": 1601702130
        },
        {
            "eventId": "01cfc340-0539-184387240-0526-11eb-aa3a-29f4dbbd8521",
            "eventType": "TimeWatched",
            "properties": "{\"itemId\":\"593\",\"timestamp\":139.472841,\"duration\":597,\"eventValue\":0.2336}",
            "sentAt": 1601702130
        }
    ],
    "sessionId": "84387240-0526-11eb-aa3a-29f4dbbd8521",
    "trackingId": "1b2644e0-5b91-4fd5-a92c-fdc56ee02e1d",
    "userId": "12345678"
}

Sample Response

{"message":"timestamp is not allowed in properties. Please refer to documentation to include timestamp"}

Error x-amzn-ErrorType: InvalidInputException:http://internal.amazon.com/coral/com.amazonaws.services.personalize.events.exceptions/

rkarthikr avatar Oct 03 '20 15:10 rkarthikr

Same issue on latest with @aws-amplify/analytics v4.0.5 Screen Shot 2021-01-12 at 1 13 44 PM Screen Shot 2021-01-12 at 1 14 35 PM

Editing the value to be TIMESTAMP in the provider solves this issue. This begs the question: does the provider just need changed to TIMESTAMP instead of timestamp?

kcwinner avatar Jan 12 '21 18:01 kcwinner

@agileurbanite - can this be handled as a bug by your team?

mauerbac avatar May 19 '21 15:05 mauerbac

I've just run into this issue too...

@mauerbac - any update on a bug fix?

{"message":"timestamp is not allowed in properties. Please refer to documentation to include timestamp"}

kylekirkby avatar Jul 08 '22 07:07 kylekirkby

Same issue on latest with @aws-amplify/analytics v4.0.5 Screen Shot 2021-01-12 at 1 13 44 PM Screen Shot 2021-01-12 at 1 14 35 PM

Editing the value to be TIMESTAMP in the provider solves this issue. This begs the question: does the provider just need changed to TIMESTAMP instead of timestamp?

Did you find a workaround for this issue? Any chance you could share your workaround, if so?

kylekirkby avatar Jul 08 '22 08:07 kylekirkby

https://github.com/aws-amplify/amplify-js/blob/main/packages/analytics/src/Providers/AmazonPersonalizeHelper/MediaAutoTrack.ts#L187-L192

Here is the problematic block of code. The timestamp property is not allowed in properties. Could you please rename timestamp?

@josefaidt @mauerbac

kylekirkby avatar Jul 08 '22 09:07 kylekirkby

@rkarthikr and @kylekirkby, this issue and the root problem appears to be the timestamp property having improper casing (needs to be camelCase) as referenced above in the comments. We are currently reviewing/testing PR #10329 that should fix this and will update this issue upon merging it in.

cwomack avatar Jan 10 '23 18:01 cwomack

@rkarthikr and @kylekirkby, this issue and the root problem appears to be the timestamp property having improper casing (needs to be camelCase) as referenced above in the comments. We are currently reviewing/testing PR #10329 that should fix this and will update this issue upon merging it in.

Hi @cwomack ,

Thanks for the update. It appears that PR #10329 has passed all tests. Any idea when this will be merged?

Cheers,

Kyle

kylekirkby avatar Jan 17 '23 11:01 kylekirkby

With help from @jimblanc and @cwomack I was able to reproduce this problem. The PR to change the case didn't resolve the issue. Doing a bit more research, we identified that the Personalization service reserves the timestamp field name for internal use. There is a blocklist of property field names that all result in errors like this.

I've created a PR to remove the timestamp property from the Amplify request, which I have tested and confirmed resolves the error without removing any previously supported behavior. The timestamp information will continue to be populated by the Personalization service for all successful requests.

I have also requested that the Personalization team add all blocklisted fields to their documentation.

stocaaro avatar Feb 07 '23 19:02 stocaaro

The fix has been merged and released. To validate, I have upgraded my test app to aws-amplify 5.0.14 and @aws-amplify/analytics 6.0.14, which works without the error describe by this issue.

Based on this, I am resolving the issue. If you are still seeing problems after adopting the fixed package versions, let us know.

Thanks, Aaron

stocaaro avatar Feb 10 '23 20:02 stocaaro