Search code examples
cordovaionic-frameworkaws-pinpoint

Amazon Pinpoint Analytics in hybrid Ionic app?


Has anyone implemented Amazon Pinpoint, specifically the Analytics portion, into an Ionic or other type of hybrid mobile app? We'd like to stay on Amazon, but the only approach I'm seeing to using within hybrid apps is by making REST calls directly which seems pretty clunky.

Thanks in advance for the help.


Solution

  • I have integrated Pinpoint analytics in an Ionic 3 app using the AWS amplify SDK.

    You need to import "Analytics" into your component, then you can use the "record" method to push events to Pinpoint.

    // Import the AWS Stuff
    import { Analytics } from 'aws-amplify';
    

    Then where ever you need to record an event use

    Analytics.record("SomeEvent");
    

    This will create a custom event called "SomeEvent" (suggest you use a better name) in the Pinpoint Analytics console, which you can then view metrics on...

    Take a look here https://aws-amplify.github.io/amplify-js/media/analytics_guide.html

    I didn't need to call

    Analytics.configure({...})
    

    It worked out of the box.