Event references

The Event library provides event handlers and actions which are functions and triggers used to handle all the possible interactions of the NewGen SDK.

How and what each handler and action trigger is used for is documented in the step-by-step integration guide.

Below you will find the general definition for every function and trigger action available:

Reference List

Misc

Credentials

Channel Mapping

TrustBadge

Widgets

Reviews

Settings

NOTIFICATION

Definition Event handler Action Notification required Code example
The notification event is used to fire up the success/failed message popup within the dashboard interface.
This is typically fired up after other event handlers have been executed. To learn more about notifications, check out the general concept guide
For the rest of this reference guide, all event handlers that require that a notification event be fired will be marked as Yes in the Notification required column.
NA EVENTS.NOTIFICATION NA
Click to view
        
            dispatchAction({
                action: EVENTS.NOTIFICATION,
                payload: {
                    event,
                    message,
                    status,
                    type: 'save'
                },
            })
        
        


INFORMATION_OF_SYSTEM

Definition Event handler Action Notification required Code example
This event is used to set all identity, options, and plugin data needed to brand and customize the plugin.
The options include but are not limited to the plugin/shop name and version as well as functionalities to display or leave out.
checkout the general concept guide to learn more.
GET_INFORMATION_OF_SYSTEM SET_INFORMATION_OF_SYSTEM No
Click to view
        
    [EVENTS.GET_INFORMATION_OF_SYSTEM]: () => {
        console.log('GET_INFORMATION_OF_SYSTEM')
        dispatchAction({
            action: EVENTS.SET_INFORMATION_OF_SYSTEM,
            payload: {
                nameOfSystem: 'eCommercPlatformName',
                versionNumberOfSystem: 'v-0.0.1',
                versionNumberOfPlugin: 'v-0.0.1',
                allowsEstimatedDeliveryDate: true,
                allowsEventsByOrderStatus: true,
                allowsSendReviewInvitesForPreviousOrders: true
            },
        })
    },
        
        


GET_LOCALE

Definition Event handler Action Notification required Code example
This event is used to set the language to display the dashboard text in
The list of locales supported at the moment includes: en-GB, de-DE, es-ES, fr-FR, it-IT, nl-NL, pl-PL, pt-PT checkout the general concept guide to learn more.
GET_LOCALE SET_LOCALE No
Click to view
        
        [EVENTS.GET_LOCALE]: () => {
            dispatchAction({
                action: EVENTS.SET_LOCALE,
                payload: 'en-GB', // de-DE, es-ES, fr-FR, it-IT, nl-NL, pl-PL, pt-PT
            })
        },
        
        

ERROR

Definition Event handler Action Notification required Code example
This event is fired whenever the connector layer encouters an error.
Thus this event will not be fired if the error is present in your code unless of cause your implementation leads to an error within the connector layer.
ERROR NA No
Click to view
        
        [EVENTS.ERROR]: () => {
            console.log('TS: eventError', error)
        }
        
        

Credentials


GET_CREDENTIALS_PROVIDED

Definition Event handler Action Notification required Code example
This handler when triggered allows you to fetch and set the stored credentials from storage if any.
This is typically fired up after other event handlers have been fired up. The authentication guide explains the event in detail.
GET_CREDENTIALS_PROVIDED SET_CREDENTIALS_PROVIDED No
Click to view
        
[EVENTS.GET_CREDENTIALS_PROVIDED]: () => {
    console.log('GET_CREDENTIALS_PROVIDED')
    const savedCredentials = sessionStorage.getItem('credentials')
    console.log(savedCredentials, "credentials");
    setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_CREDENTIALS_PROVIDED,
            payload: savedCredentials ? JSON.parse(savedCredentials) : credentials,
        })
    }, 400)
}
        
        

SAVE_CREDENTIALS

Definition Event handler Action Notification required Code example
This event handler is triggered when the user provides their credentials and clicks the button to connect.
The goal of this handler is to persist the credentials to storage. The `GET_CREDENTIALS_PROVIDED` is fired up after and the newly persisted credentials can then be used to authenticate the user. The authentication guide explains the event in detail.
SAVE_CREDENTIALS NA yes
Click to view
        
[EVENTS.SAVE_CREDENTIALS]: (event) => {
    try {
        sessionStorage.setItem('credentials', JSON.stringify(event.payload))
        setTimeout(() => {
            sendingNotification(EVENTS.SAVE_CREDENTIALS, 'CREDENTIALS SAVED', 'success')
        }, 400)
    } catch (error) {
        setTimeout(() => {
            sendingNotification(EVENTS.SAVE_CREDENTIALS, 'CREDENTIALS NOT SAVED', 'error')
        }, 400)
    }
},

        


Channel Mapping

SAVE_MAPPED_CHANNEL

Definition Event handler Action Notification required Code example
Once the shop owner selects which shops match which channels and hits the save button the event is fired and you can then persist this to storage
This is typically fired up after other event handlers have been fired up. Check out the channels setup guide
to learn more.
SAVE_MAPPED_CHANNEL SET_MAPPED_CHANNELS Yes
Click to view
        
[EVENTS.SAVE_MAPPED_CHANNEL]: (event) => {
    console.log('SAVE_MAPPED_CHANNEL', event.payload)
    sessionStorage.setItem('mappedChannelsData', JSON.stringify(event.payload))
    try {
        setTimeout(() => {
            dispatchAction({
                action: EVENTS.SET_MAPPED_CHANNELS,
                payload: event.payload,
            })
            sendingNotification(EVENTS.SET_MAPPED_CHANNELS, 'MAPPED CHANNELS SAVED', 'success')
        }, 2000)
    } catch (error) {
        setTimeout(() => {
            sendingNotification(EVENTS.SET_MAPPED_CHANNELS, 'MAPPED CHANNELS NOT SAVED', 'error')
        }, 400)
    }
}
        
        


GET_MAPPED_CHANNELS

Definition Event handler Action Notification required Code example
Once the shop and channel mapping is stored, this event is used to fetch it from the DB each time the plugin dashboard loads up. Check out the channels setup guide
to learn more.
GET_MAPPED_CHANNELS SET_MAPPED_CHANNELS No
Click to view
        
[EVENTS.GET_MAPPED_CHANNELS]: () => {
    console.log('GET_MAPPED_CHANNELS')
    const savedMappedChannels = sessionStorage.getItem('mappedChannelsData')

}


GET_SALES_CHANNELS_PROVIDED

Definition Event handler Action Notification required Code example
This event is used to pull the list of all shops within the e-commerce platform belonging to the owner. This list is later shown in a popup during the shop-channel mapping process.
Check out the channels setup guide
to learn more.
GET_SALES_CHANNELS_PROVIDED SET_SALES_CHANNELS_PROVIDED No
Click to view
        
const storeDetails = [ // sample store details
    {
        id: 'shop-7e52920a-2722-4881-9908-ecec98c716e4',
        name: 'Shop 1',
        url: 'shop1.example.com',
        locale: 'de_DE'
    },
    {
        id: 'shop-1e570f63-10f8-4d5a-ae18-21d3d933eb93',
        name: 'Trustsurance',
        url: 'shop2.example.com',
        locale: 'fr-FR'
    },
]
[EVENTS.GET_SALES_CHANNELS_PROVIDED]: () => {
    console.log('EVENTS.SET_SALES_CHANNELS_PROVIDED');
    setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_SALES_CHANNELS_PROVIDED,
            payload: storeDetails,
        })
    }, 1000)

}


GET_TRUSTBADGE_CONFIGURATION_PROVIDED

Definition Event handler Action Notification required Code example
Once the TrustBadge configuration is set and stored to DB, whenever this event handler is fired the configuration will be used to set the dashboard to the chosen settings. Checkout the Trustbadge guide to learn more.
GET_TRUSTBADGE_CONFIGURATION_PROVIDED SET_TRUSTBADGE_CONFIGURATION_PROVIDED No
Click to view
        
[EVENTS.GET_TRUSTBADGE_CONFIGURATION_PROVIDED]: (event) => {
    console.log('GET_TRUSTBADGE_CONFIGURATION_PROVIDED', event.payload)
    const shopId = event.payload.salesChannelRef
    const TBData = sessionStorage.getItem('trustBadge-'+shopId)
    setTimeout(() => {
        dispatchAction({
        action: EVENTS.SET_TRUSTBADGE_CONFIGURATION_PROVIDED,
        payload: (TBData)? JSON.parse(TBData) : [],
        })
    }, 400)
    }
        
        


SAVE_TRUSTBADGE_CONFIGURATION

Definition Event handler Action Notification required Code example
The event handler is used to set and persist the TrustBadge configuration chosen by the shop owner.
This event will be fired when the shop owner hits the save button.
Checkout the Trustbadge guide to learn more.
SAVE_TRUSTBADGE_CONFIGURATION SET_TRUSTBADGE_CONFIGURATION_PROVIDED Yes
Click to view
        
    [EVENTS.SAVE_TRUSTBADGE_CONFIGURATION]: (event) => {
    console.log('SAVE_TRUSTBADGE_CONFIGURATION', event.payload)
    const shopId = event.payload.salesChannelRef
    sessionStorage.setItem('trustBadge-'+shopId, JSON.stringify(event.payload))
    try {
        setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_TRUSTBADGE_CONFIGURATION_PROVIDED,
            payload: event.payload,
        })
        sendingNotification(
            EVENTS.SAVE_TRUSTBADGE_CONFIGURATION,
            'TRUSTBADGE CONFIGURATION SAVED',
            'success'
        )
        }, 3000)
    } catch (error) {
        setTimeout(() => {
        sendingNotification(
            EVENTS.SAVE_TRUSTBADGE_CONFIGURATION,
            'TRUSTBADGE CONFIGURATION NOT SAVED',
            'error'
        )
        }, 400)
    }
    }
        
        


GET_LOCATION_FOR_WIDGET

Definition Event handler Action Notification required Code example
The event handler is used to set all the different widget placement options you will like to make available to the shop owner.
Each location has a name and an id.
The name is shown to the shop owner and you can use the ID as an identifier to decide the placement of the widget. Check out the widget placement guide to learn more.
GET_LOCATION_FOR_WIDGET SET_LOCATION_FOR_WIDGET No
Click to view
        
    const widgetLocations = [
    {
        id: 'wdg-loc-pn',
        name: 'Product Title',
    },
    {
        id: 'wdg-loc-ft',
        name: 'Footer',
    },
    {
        id: 'wdg-loc-cst',
        name: 'Manual Placement',
    },
    {
        id: 'wdg-loc-hp',
        name: 'Home Page',
    },
]

[EVENTS.GET_LOCATION_FOR_WIDGET]: () => {

SAVE_WIDGET_CHANGES

Definition Event handler Action Notification required Code example
The event handler is used to persist review widget changes
SAVE_WIDGET_CHANGES SET_WIDGET_PROVIDED Yes
Click to view
        
        [EVENTS.SAVE_WIDGET_CHANGES]: (event) => {
            try {
                console.log('SAVE_WIDGET_CHANGES')
                const shopId = event.payload.salesChannelRef
                sessionStorage.setItem('widgets-' + shopId, JSON.stringify(event.payload))
                setTimeout(() => {
                    dispatchAction({
                        action: EVENTS.SET_WIDGET_PROVIDED,
                        payload: event.payload,
                    })
                    sendingNotification(EVENTS.SAVE_WIDGET_CHANGES, 'WIDGET SAVED', 'success')
                }, 3000)
            } catch (error) {
                setTimeout(() => {
                    sendingNotification(EVENTS.SAVE_WIDGET_CHANGES, 'WIDGET NOT SAVED', 'error')
                }, 400)
            }
        }
        
        


GET_AVAILABLE_PRODUCT_IDENTIFIERS

Definition Event handler Action Notification required Code example
Product identifiers are used to fetch and present specific products for review.
There are different ways to identify products. For example, by using the SKU. You can find the complete list of options in the integration guide
GET_AVAILABLE_PRODUCT_IDENTIFIERS SET_AVAILABLE_PRODUCT_IDENTIFIERS No
Click to view
        
const productIdentifiers = [
    { id: 'data-sku', name: 'SKU' },
    { id: 'data-gtin', name: 'GTIN' },
    { id: 'data-mpn', name: 'MPN' },
]

[EVENTS.GET_AVAILABLE_PRODUCT_IDENTIFIERS]: (event) => {


GET_WIDGET_PROVIDED

Definition Event handler Action Notification required Code example
This event handler is used to get and set the dashboard up using the persisted widget data (dashboard config, and shopfront widget components) from the DB.
Check out the widgets guide to learn more.
GET_WIDGET_PROVIDED SET_WIDGET_PROVIDED No
Click to view
        
[EVENTS.GET_WIDGET_PROVIDED]: (event) => {
    console.log('GET_WIDGET_PROVIDED')
    const shopId = event.payload.salesChannelRef
    const widgetsData = sessionStorage.getItem('widgets-' + shopId)
    setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_WIDGET_PROVIDED,
            payload: (widgetsData) ? JSON.parse(widgetsData) : { children: [] },
        })
    }, 3000)
}
        
        


ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL

Definition Event handler Action Notification required Code example
For shop owners who have product reviews enabled, they will be able to toggle the activation button to enable product review collection.
This event is called when the button is toggled to active mode, here you have to persist the shop owner's choice and use that data to decide whether to render the product review widget. Check out the product review collection guide to learn more.
ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL SET_PRODUCT_REVIEW_FOR_CHANNEL Yes
Click to view
        
        [EVENTS.ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL]: (event) => {
            try {
                console.log('ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL', event.payload)
                const shopId = event.payload.salesChannelRef
                sessionStorage.setItem('productReviewData-' + shopId, JSON.stringify(event.payload))
                setTimeout(() => {
                    dispatchAction({
                        action: EVENTS.SET_PRODUCT_REVIEW_FOR_CHANNEL,
                        payload: event.payload,
                    })
                    sendingNotification(
                        EVENTS.ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL,
                        'PRODUCT REVIEW FOR CHANNEL ACTIVATED',
                        'success'
                    )
                }, 400)
            } catch (error) {
                setTimeout(() => {
                    sendingNotification(
                        EVENTS.ACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL,
                        'PRODUCT REVIEW FOR CHANNEL NOT ACTIVATED',
                        'error'
                    )
                }, 400)
            }
        }
        
        


DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL

Definition Event handler Action Notification required Code example
For shop owners who have product reviews enabled, they will be able to toggle the activation button to disable product review collection.
This event is called when the button is toggled to inactive mode.
Here you can clear out the payload stored in the DB when set to inactive and further prevent the product review widget from rendering on the shopfront.
Check out the product review collection guide to learn more.
DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL SET_PRODUCT_REVIEW_FOR_CHANNEL Yes
Click to view
        
[EVENTS.DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL]: (event) => {
    try {
        console.log('DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL', event.payload)
        const shopId = event.payload.salesChannelRef
        sessionStorage.removeItem('productReviewData-' + shopId)
        setTimeout(() => {
            dispatchAction({
                action: EVENTS.SET_PRODUCT_REVIEW_FOR_CHANNEL,
                payload: null,
            })
            sendingNotification(
                EVENTS.DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL,
                'PRODUCT REVIEW FOR CHANNEL DEACTIVATED',
                'success'
            )
        }, 400)
    } catch (error) {
        setTimeout(() => {
            sendingNotification(
                EVENTS.DEACTIVATE_PRODUCT_REVIEW_FOR_CHANNEL,
                'PRODUCT REVIEW FOR CHANNEL NOT DEACTIVATED',
                'error'
            )
        }, 400)
    }
}
        
        


SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL

Definition Event handler Action Notification required Code example
When the shop owner selects to deliver review invites based on estimated delivery dates this event is fired.
You can then go ahead and persist the option contained in the payload to DB for later use.
Check out the invite timing guide to learn more.
SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL SET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL Yes
Click to view
        
[EVENTS.SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL]: (event) => {
    try {
        console.log('SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL', event.payload)
        const shopId = event.payload.salesChannelRef
        sessionStorage.setItem('useEstimatedDeliveryDateForChannel-' + shopId, JSON.stringify(event.payload))
        setTimeout(() => {
            dispatchAction({
                action: EVENTS.SET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL,
                payload: event.payload,
            })
            sendingNotification(
                EVENTS.SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL,
                'USE ESTIMATED DELIVERY DATE FOR CHANNEL SAVED',
                'success',
                'save'
            )
        }, 400)
    } catch (error) {
        setTimeout(() => {
            sendingNotification(
                EVENTS.SAVE_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL,
                'USE ESTIMATED DELIVERY DATE FOR CHANNEL NOT SAVED',
                'error',
                'save'
            )
        }, 400)
    }
}
        
        


SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL

Definition Event handler Action Notification required Code example
When the shop owner selects to deliver review invites based on order status this event is fired.
You can then go ahead and persist the option contained in the payload to DB for later use.
Check out the invite timing guide to learn more.
SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL SET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL Yes
Click to view
        
[EVENTS.SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL]: (event) => {
    SET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL = event.payload.active
    try {
        console.log('SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL', event.payload)
        const shopId = event.payload.salesChannelRef
        sessionStorage.setItem('useEventsByOrderStatusForChannel-' + shopId, JSON.stringify(event.payload))
        setTimeout(() => {
            dispatchAction({
                action: EVENTS.SET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL,
                payload: event.payload,
            })
            sendingNotification(
                EVENTS.SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL,
                'USE EVENTS BY ORDER FOR CHANNEL SAVED',
                'success',
                'save'
            )
        }, 400)
    } catch (error) {
        setTimeout(() => {
            sendingNotification(
                EVENTS.SAVE_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL,
                'USE EVENTS BY ORDER FOR CHANNEL NOT SAVED',
                'error',
                'save'
            )
        }, 400)
    }
}
        
        

GET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL

Definition Event handler Action Notification required Code example
Whenever the plugin dashboard is loaded this event is fired and you can then check your DB records to see if any data was stored for this.
If so you can set this by dispatching it thereby setting the dashboard to reflect the chosen option. Check out the invite timing guide to learn more.
GET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL SET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL No
Click to view
        
[EVENTS.GET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL]: (event) => {
    console.log('GET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL', event)
    const shopId = event.payload.salesChannelRef
    const storedPayload = sessionStorage.getItem('useEstimatedDeliveryDateForChannel-' + shopId)
    setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_USE_ESTIMATED_DELIVERY_DATE_FOR_CHANNEL,
            payload: (storedPayload) ? JSON.parse(storedPayload) : {},
        })
    }, 400)
},
        
        

GET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL

Definition Event handler Action Notification required Code example
Whenever the plugin dashboard is loaded this event is fired and you can then check your DB records to see if any data was stored for this.
If so you can set this by dispatching it thereby setting the dashboard to reflect the chosen option. Check out the invite timing guide to learn more.
GET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL SET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL No
Click to view
        
[EVENTS.GET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL]: (event) => {
    console.log('GET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL')
    const shopId = event.payload.salesChannelRef
    const storedPayload = sessionStorage.getItem('useEventsByOrderStatusForChannel-' + shopId)
    setTimeout(() => {
        dispatchAction({
            action: EVENTS.SET_USE_EVENTS_BY_ORDER_STATUS_FOR_CHANNEL,
            payload: (storedPayload) ? JSON.parse(storedPayload) : {},
        })
    }, 400)
},
        
        

ORDER_STATUSES

Definition Event handler Action Notification required Code example
This event handler is used to fetch all touchpoints stored in the DB.
You can find the full details on how to set this up from the review invites guide
GET_AVAILABLE_ORDER_STATUSES SET_AVAILABLE_ORDER_STATUSES No
Click to view
        
[EVENTS.EXPORT_PREVIOUS_ORDER]: (event) => {
    [EVENTS.GET_AVAILABLE_ORDER_STATUSES]: () => {
            console.log('GET_AVAILABLE_ORDER_STATUSE')
            dispatchAction({
                action: EVENTS.SET_AVAILABLE_ORDER_STATUSES,
                payload: availableOrderStatuses,
            })
        },
        
        
This event handler is get persisted touchpoints from the DB.
You can find the full details on how to set this up from the review invites guide
GET_USED_ORDER_STATUSES SET_USED_ORDER_STATUSES No
Click to view
        
        [EVENTS.GET_USED_ORDER_STATUSES]: (event) => {
            console.log('GET_USED_ORDER_STATUSES')
            const shopId = event.payload.salesChannelRef
            const storedPayload = sessionStorage.getItem('getUsedOrderStatuses-' + shopId)
            setTimeout(() => {
                dispatchAction({
                    action: EVENTS.SET_USED_ORDER_STATUSES,
                    payload: (storedPayload) ? JSON.parse(storedPayload) : {},
                })
            }, 400)
        },
        
        
This event handler is used to persist selected touchpoints to DB.
You can find the full details on how to set this up from the review invites guide
SAVE_USED_ORDER_STATUSES SET_USED_ORDER_STATUSES Yes
Click to view
        
        [EVENTS.SAVE_USED_ORDER_STATUSES]: (event) => {
            try {
                console.log('SAVE_USED_ORDER_STATUSES', event.payload)
                const shopId = event.payload.salesChannelRef
                sessionStorage.setItem('getUsedOrderStatusesw-' + shopId, JSON.stringify(event.payload))
                setTimeout(() => {
                    dispatchAction({
                        action: EVENTS.SET_USED_ORDER_STATUSES,
                        payload: event.payload,
                    })
                    sendingNotification(
                        EVENTS.SAVE_USED_ORDER_STATUSES,
                        'USE ORDER STATUSES SAVED',
                        'success',
                        'save',
                    )
                }, 400)
            } catch (error) {
                setTimeout(() => {
                    sendingNotification(
                        EVENTS.SAVE_USED_ORDER_STATUSES,
                        'USE ORDER STATUSES SAVEDs',
                        'error',
                        'save',
                    )
                }, 400)
            }

EXPORT_PREVIOUS_ORDER

Definition Event handler Action Notification required Code example
This event handler is used to fetch customer details from the shop DB to use for review invites.
You can find the full details on how to set this up from the review invites guide
EXPORT_PREVIOUS_ORDER SET_EXPORT_PREVIOUS_ORDER No
Click to view
        
[EVENTS.EXPORT_PREVIOUS_ORDER]: (event) => {
    console.log('EXPORT_PREVIOUS_ORDER', event.payload)
    setTimeout(() => {
        const link = document.createElement('a')
        link.download = `./invite_list.csv`
        const blob = new Blob(
            ['email; reference; productName; productSku; productUrl; productImageUrl',
                '\n',
                '[email protected]; 101912; demo product; 234; shop.com/productName; shop.com/image/productName'],
                { type: 'data:text/csv;charset=utf-8,' })
        link.href = URL.createObjectURL(blob)
        link.click()
        URL.revokeObjectURL(link.href)
        dispatchAction({
            action: EVENTS.SET_EXPORT_PREVIOUS_ORDER,
            payload: event.payload,
        })
    }, 400)
}
        
        


Destructor (DISCONNECTED, SET_DISCONNECTED)

Definition Event handler Action Notification required Code example
Whenever the shop owner clicks on the disconnect button within the plugin dashboard this event handler is fired.
From here you can clear out the plugin DB records and undo all configurations
The settings guide covers this in detail
DISCONNECTED SET_DISCONNECTED No
Click to view
        
[EVENTS.DISCONNECTED]: (event) => {
    console.log('DISCONNECTED', event)
    sessionStorage.clear()
    setTimeout(() => {
        dispatchAction({ action: EVENTS.SET_DISCONNECTED, payload: null })
    }, 400)
},