@@ -7,6 +7,7 @@ import { PowerPointService } from './PowerPointService';
7
7
import { WordService } from './WordService' ;
8
8
import { InvalidTokenError } from '$lib/errors' ;
9
9
import { ExcelService } from './ExcelService' ;
10
+ import { sendBehaviorEvent } from '../util/sendEvents' ;
10
11
11
12
export interface Diagram {
12
13
base64Image : string ;
@@ -19,9 +20,11 @@ export interface Diagram {
19
20
export class OfficeManager {
20
21
officeService : OfficeService ;
21
22
mermaidChartApi : MermaidChart ;
23
+ host : Office . HostType ;
22
24
23
25
constructor ( host : Office . HostType , api : MermaidChart ) {
24
26
this . mermaidChartApi = api ;
27
+ this . host = host ;
25
28
switch ( host ) {
26
29
case Office . HostType . Word : {
27
30
this . officeService = new WordService ( this . mermaidChartApi ) ;
@@ -65,13 +68,28 @@ export class OfficeManager {
65
68
} ;
66
69
67
70
await this . officeService . insertDiagram ( diagram ) ;
71
+ sendBehaviorEvent (
72
+ 'Insert PNG of diagram' , {
73
+ area : 'insert-diagram' ,
74
+ eventID : `DIAGRAM_INSERT_${ this . host . toString ( ) . toUpperCase ( ) } `
75
+ } ) ;
68
76
} catch ( error ) {
69
77
if ( error instanceof InvalidTokenError ) {
78
+ sendBehaviorEvent (
79
+ 'Auth token invalid or not found' , {
80
+ area : 'insert-diagram' ,
81
+ eventID : `DIAGRAM_INSERT_${ this . host . toString ( ) . toUpperCase ( ) } `
82
+ } ) ;
70
83
showUserMessage (
71
84
'Auth token invalid or not found, please make sure that you are authenticated, or contact support' ,
72
85
'error'
73
86
) ;
74
87
} else {
88
+ sendBehaviorEvent (
89
+ 'Error generating PNG' , {
90
+ area : 'insert-diagram' ,
91
+ eventID : `DIAGRAM_INSERT_${ this . host . toString ( ) . toUpperCase ( ) } `
92
+ } ) ;
75
93
showUserMessage (
76
94
'Error generating image, or image not found. Please contact support' ,
77
95
'error'
@@ -86,7 +104,17 @@ export class OfficeManager {
86
104
try {
87
105
loading . setState ( true , 'Syncing diagrams in document...' ) ;
88
106
await this . officeService . syncDiagrams ( ) ;
107
+ sendBehaviorEvent (
108
+ 'Sync diagrams with mermaid chart' , {
109
+ area : 'sync-diagrams' ,
110
+ eventID : `SYNC_DIAGRAM_${ this . host . toString ( ) . toUpperCase ( ) } `
111
+ } ) ;
89
112
} catch {
113
+ sendBehaviorEvent (
114
+ 'Sync diagrams failed' , {
115
+ area : 'insert-diagram' ,
116
+ eventID : `SYNC_DIAGRAM_${ this . host . toString ( ) . toUpperCase ( ) } `
117
+ } ) ;
90
118
showUserMessage (
91
119
'Error refreshing diagrams. Please contact support' ,
92
120
'error'
0 commit comments