15.2.4.2 Javascript Example

const { 
    GalEnvironment, 
    GalEvents, 
    GalReportingGroups, 
    GalaAnalytics
} = require('@gala-analytics/core');


// Create an instance of GalaAnalytics for use
const analytics = new GalaAnalytics({
    // publisherId provided by Core Tech Data team
    publisherId: 'Ht3QOWhvthSZjamSOorRldkzgP7l4XbE',
    publisherGroup: GalReportingGroups.product,
    // Recommend storing in environment
    reportingUri: '<https://alpha-data.gala.com/>',
    // Gala user id
    user: 'galaUserId1234',
    // set this per environment
    environment: GalEnvironment.test
});


// take care to normalize event data wherever possible
const GAME_NAME_IDENTIFIER = 'pokergo';


// example async wrapper boilerplate
const sendTestEvents = async () => {


    // passing the DTO to the method via generics e.g. report<GameplayBeginDTO>(... is optional
    // but doing so will give you type hints in the IDE making it easier to ensure the DTO is valid
    await analytics.report({
        type: GalEvents.GameplayBeginDTO,
        game: GAME_NAME_IDENTIFIER
    });


    await analytics.report({
        type: GalEvents.MilestoneDTO,
        name: 'testSuccessful',
        stepNumber: 1,
        timeTaken: 10232
    });


}


// boilerplate for example purposes
(async () => {
    await sendTestEvents();
})();