@@ -239,6 +239,9 @@ type trackEventProps = {
239239}
240240
241241const trackEvent = ( { object, verb, attributes } : trackEventProps ) => {
242+ try {
243+
244+
242245 const event = `${ object } ${ _SEP_ } ${ verb } `
243246 Object . keys ( attributes ) . map ( attr => {
244247 const value = attributes [ attr ] ;
@@ -259,31 +262,37 @@ const trackEvent = ({ object, verb, attributes }: trackEventProps) => {
259262 return ;
260263 }
261264
262- track ( event , attributes ) ;
265+ track ( event , attributes ) ;
266+ } catch ( e ) {
267+ console . log ( "analytics" , e )
268+ }
263269}
264270
265271const identifyUserProperty = ( attributes : Attributes , value : string | string [ ] ) => {
266272
267- let formatedValue ;
273+ try {
274+ let formatedValue ;
275+ if ( Array . isArray ( value ) ) {
276+ formatedValue = value . filter ( Boolean ) . map ( item => item . toLowerCase ( ) ) ;
277+ } else {
278+ formatedValue = value . toLowerCase ( ) ;
279+ }
268280
269- if ( Array . isArray ( value ) ) {
270- formatedValue = value . filter ( Boolean ) . map ( item => item . toLowerCase ( ) ) ;
271- } else {
272- formatedValue = value . toLowerCase ( ) ;
273- }
281+ if ( isDevelopment ( ) ) {
282+ console . log ( "analytics" , "identify" , attributes , formatedValue )
283+ return ;
284+ }
274285
275- if ( isDevelopment ( ) ) {
276- console . log ( "analytics" , "identify" , attributes , formatedValue )
277- return ;
278- }
286+ if ( formatedValue == null ) {
287+ return ;
288+ }
279289
280- if ( formatedValue == null ) {
281- return ;
290+ const identity = new Identify ( )
291+ identity . set ( attributes . toString ( ) , formatedValue )
292+ identify ( identity )
293+ } catch ( e ) {
294+ console . log ( "analytics" , e )
282295 }
283-
284- const identity = new Identify ( )
285- identity . set ( attributes . toString ( ) , formatedValue )
286- identify ( identity )
287296}
288297
289298/**
0 commit comments