PESDK/Web/Concepts
Events
Understanding how users engage with a product is critical to every business. Learn how to track your user's interactions with PhotoEditor SDK for Web.
Event Types#
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.EXPORT/'export' | 
| EventYields: | Detailsthe image data (String/HTMLImageElement/Blob) | 
| EventDescription: | DetailsFires when the user clicks on the Exportbutton orEditorApi.exportis called. The event will return the image data in the format that is configured inexport.image.exportType. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.CLOSE/'close' | 
| EventYields: | Detailsnone | 
| EventDescription: | DetailsFires when the user clicks on the Closebutton orEditorApi.closeis called. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.ERROR_IMAGE_LOADING/'errorImageLoading' | 
| EventYields: | Detailsthe error (Error) | 
| EventDescription: | DetailsFires if there was an issue loading the image configured in image. The event will return an error with more information regarding the issue. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.IMAGE_LOAD/'imageLoad' | 
| EventYields: | Detailsnone | 
| EventDescription: | DetailsFires if the user selected a new image in the library. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.STICKER_UPLOAD_ADD/'stickerUploadAdd' | 
| EventYields: | Detailsthe uploaded stickers ( Array<UploadedSticker>) | 
| EventDescription: | DetailsFires if the user uploaded one or more custom stickers. Returns an array with the id, image and original File of the sticker. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.TOOL_ENTER/'toolEnter' | 
| EventYields: | Detailsthe selected tool (Tool) | 
| EventDescription: | DetailsFires for the default tool and if the active tool was changed. Returns the identifier of the new tool. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.HISTORY_CHANGED/'historyChanged' | 
| EventYields: | Detailsnone | 
| EventDescription: | DetailsFires when an entry was added to the history. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.EDITOR_READY/'editorReady' | 
| EventYields: | Detailsnone | 
| EventDescription: | DetailsFires once the editor was initialised completely and the user is able to edit an image. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.ERROR_WEBGL_CONTEXT_LOST/'errorWebGLContextLost' | 
| EventYields: | Detailsnone | 
| EventDescription: | DetailsFires if the WebGL context experiences some kind of issue and crashes in the background. | 
| Event | Details | 
|---|---|
| EventName: | Details UIEvent.CROP_DIMENSIONS_CHANGE/'cropDimensionsChange' | 
| EventYields: | Detailsthe width and height of the cropped area ( Size) | 
| EventDescription: | DetailsFires if the user changes the width or height of the crop area | 
Examples#
Exporting an image#
import {UIEvent,PhotoEditorSDKUI,ImageFormat,ExportFormat,} from 'photoeditorsdk';const editor = PhotoEditorSDKUI.init({image: '',license: '',container: '#editor',export: {image: {enableDownload: false, // will prevent the file download on the user sideformat: ImageFormat.JPEG,exportType: ExportFormat.DATA_URL,},},}).then(editor => {editor.on(UIEvent.EXPORT, image => {// handle the image here});});
Tracking tool usage#
It is possible to track which tools are used the most by the by listening for the TOOL_ENTER event.
import { UIEvent, PhotoEditorSDKUI } from 'photoeditorsdk';PhotoEditorSDKUI.init({image: '',license: '',container: '#editor',}).then(editor => {editor.on(UIEvent.TOOL_ENTER, tool => {// send the tool information to your analytics tool});});
Save custom sticker to your server#
The STICKER_UPLOAD_ADD event can be used to restore the custom user stickers the next time they open the editor. The event will return the sticker files which can be stored on a server. When a user opens the editor again you will need to add the stickers to the configuration.
this.config = {license: '',container: '.editor',image: '',sticker: {categories: [{identifier: 'imgly_sticker_custom',name: '', // fallback if the language file does not contain a namethumbnailURI: '', // the path to the category thumbnailitems: [// load the previous custom sticker from the server and add them here],},],},custom: {languages: {en: {sticker: {categories: {imgly_sticker_custom: '', // the displayed name for the category},},},},},};SDK.PhotoEditorSDKUI.init(this.config).then(editor => {editor.on(SDK.UIEvent.STICKER_UPLOADED, sticker => {// upload sticker to server to restore the next time});});