@metamask-previews/profile-sync-controller 19.0.0-preview-f9a5dd05 → 19.0.0-preview-bfad74b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,107 +1,157 @@
1
1
  "use strict";
2
2
  /**
3
- * MetaMetrics event constants for profile-sync-controller
3
+ * MetaMetrics events library for profile-sync-controller
4
4
  *
5
- * This library provides standardized constants for MetaMetrics events
6
- * to avoid magic strings and ensure consistency across clients.
5
+ * This library provides type-safe event definitions that mirror the segment schema,
6
+ * ensuring consistency and providing compile-time validation for event properties.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BackupAndSyncEventProperties = exports.createBackupAndSyncEventProperties = exports.BackupAndSyncActions = exports.BackupAndSyncFeatureNames = void 0;
9
+ exports.buildIdentityEvent = exports.IDENTITY_EVENTS = void 0;
10
10
  /**
11
- * Feature names used in profile-sync-controller MetaMetrics events
11
+ * Identity events definitions matching the segment schema
12
12
  */
13
- exports.BackupAndSyncFeatureNames = {
14
- /**
15
- * The main backup and sync feature
16
- */
17
- BACKUP_AND_SYNC: 'Backup And Sync',
18
- /**
19
- * Account syncing functionality
20
- */
21
- ACCOUNT_SYNCING: 'Account Syncing',
22
- /**
23
- * Contact syncing functionality
24
- */
25
- CONTACT_SYNCING: 'Contact Syncing',
26
- /**
27
- * Network syncing functionality
28
- */
29
- NETWORK_SYNCING: 'Network Syncing',
30
- /**
31
- * Authentication functionality
32
- */
33
- AUTHENTICATION: 'Authentication',
13
+ exports.IDENTITY_EVENTS = {
14
+ ACCOUNT_SYNCING: {
15
+ ACCOUNTS_SYNC_ADDED: {
16
+ name: 'Accounts Sync Added',
17
+ properties: {
18
+ profile_id: {
19
+ required: true,
20
+ type: 'string',
21
+ },
22
+ },
23
+ },
24
+ ACCOUNTS_SYNC_NAME_UPDATED: {
25
+ name: 'Accounts Sync Name Updated',
26
+ properties: {
27
+ profile_id: {
28
+ required: true,
29
+ type: 'string',
30
+ },
31
+ },
32
+ },
33
+ ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {
34
+ name: 'Accounts Sync Erroneous Situation',
35
+ properties: {
36
+ profile_id: {
37
+ required: true,
38
+ type: 'string',
39
+ },
40
+ situation_message: {
41
+ required: true,
42
+ type: 'string',
43
+ },
44
+ },
45
+ },
46
+ },
47
+ NETWORK_SYNCING: {
48
+ NETWORK_SYNC_ADDED: {
49
+ name: 'Network Sync Added',
50
+ properties: {
51
+ profile_id: {
52
+ required: true,
53
+ type: 'string',
54
+ },
55
+ chain_id: {
56
+ required: true,
57
+ type: 'string',
58
+ },
59
+ },
60
+ },
61
+ NETWORK_SYNC_UPDATED: {
62
+ name: 'Network Sync Updated',
63
+ properties: {
64
+ profile_id: {
65
+ required: true,
66
+ type: 'string',
67
+ },
68
+ chain_id: {
69
+ required: true,
70
+ type: 'string',
71
+ },
72
+ },
73
+ },
74
+ NETWORK_SYNC_REMOVED: {
75
+ name: 'Network Sync Removed',
76
+ properties: {
77
+ profile_id: {
78
+ required: true,
79
+ type: 'string',
80
+ },
81
+ chain_id: {
82
+ required: true,
83
+ type: 'string',
84
+ },
85
+ },
86
+ },
87
+ },
88
+ PROFILE: {
89
+ ACTIVITY_UPDATED: {
90
+ name: 'Profile Activity Updated',
91
+ properties: {
92
+ profile_id: {
93
+ required: false,
94
+ type: 'string',
95
+ },
96
+ feature_name: {
97
+ required: true,
98
+ type: 'string',
99
+ fromObject: {
100
+ BACKUP_AND_SYNC: 'Backup And Sync',
101
+ AUTHENTICATION: 'Authentication',
102
+ },
103
+ },
104
+ action: {
105
+ required: true,
106
+ type: 'string',
107
+ fromObject: {
108
+ CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',
109
+ CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',
110
+ CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',
111
+ SETTINGS_TOGGLE_ENABLED: 'settings_toggle_enabled',
112
+ SETTINGS_TOGGLE_DISABLED: 'settings_toggle_disabled',
113
+ SIGN_IN: 'Sign In',
114
+ SIGN_OUT: 'Sign Out',
115
+ AUTHENTICATION_FAILED: 'Authentication Failed',
116
+ },
117
+ },
118
+ additional_description: {
119
+ required: false,
120
+ type: 'string',
121
+ },
122
+ },
123
+ },
124
+ BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {
125
+ name: 'Backup And Sync Introduction Modal Interaction',
126
+ properties: {
127
+ profile_id: {
128
+ required: false,
129
+ type: 'string',
130
+ },
131
+ action: {
132
+ required: true,
133
+ type: 'string',
134
+ fromObject: {
135
+ MODAL_OPENED: 'modal_opened',
136
+ MODAL_CLOSED: 'modal_closed',
137
+ ENABLE_CLICKED: 'enable_clicked',
138
+ DISMISS_CLICKED: 'dismiss_clicked',
139
+ },
140
+ },
141
+ },
142
+ },
143
+ },
34
144
  };
35
145
  /**
36
- * Actions used in profile-sync-controller MetaMetrics events
37
- */
38
- exports.BackupAndSyncActions = {
39
- // Account syncing actions
40
- ACCOUNTS_SYNC_ADDED: 'Accounts Sync Added',
41
- ACCOUNTS_SYNC_NAME_UPDATED: 'Accounts Sync Name Updated',
42
- ACCOUNTS_SYNC_ERRONEOUS_SITUATION: 'Accounts Sync Erroneous Situation',
43
- // Contact syncing actions
44
- CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',
45
- CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',
46
- CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',
47
- // Network syncing actions
48
- NETWORK_SYNC_ADDED: 'Network Sync Added',
49
- NETWORK_SYNC_UPDATED: 'Network Sync Updated',
50
- NETWORK_SYNC_REMOVED: 'Network Sync Removed',
51
- // Authentication actions
52
- SIGN_IN: 'Sign In',
53
- SIGN_OUT: 'Sign Out',
54
- AUTHENTICATION_FAILED: 'Authentication Failed',
55
- };
56
- /**
57
- * Helper function to create standardized MetaMetrics event properties
58
- * for profile-sync-controller events
146
+ * Type-safe event builder function
59
147
  *
60
- * @param featureName - The feature name to use in the event properties
61
- * @param action - The action to use in the event properties
62
- * @param additionalProperties - Optional additional properties to include
63
- * @returns An object containing the standardized event properties
148
+ * @param event - The event definition
149
+ * @param properties - The event properties (type-checked)
150
+ * @returns An object with the event name and properties
64
151
  */
65
- const createBackupAndSyncEventProperties = (featureName, action, additionalProperties) => ({
66
- feature_name: featureName,
67
- action,
68
- ...additionalProperties,
152
+ const buildIdentityEvent = (event, properties) => ({
153
+ name: event.name,
154
+ properties,
69
155
  });
70
- exports.createBackupAndSyncEventProperties = createBackupAndSyncEventProperties;
71
- /**
72
- * Pre-defined event property sets for common profile-sync-controller events
73
- */
74
- exports.BackupAndSyncEventProperties = {
75
- // Account syncing events
76
- ACCOUNT_ADDED: (profileId) => ({
77
- profile_id: profileId,
78
- }),
79
- ACCOUNT_NAME_UPDATED: (profileId) => ({
80
- profile_id: profileId,
81
- }),
82
- ACCOUNT_SYNC_ERROR: (profileId, situationMessage) => ({
83
- profile_id: profileId,
84
- situation_message: situationMessage,
85
- }),
86
- // Contact syncing events
87
- CONTACT_UPDATED: (profileId) => (0, exports.createBackupAndSyncEventProperties)(exports.BackupAndSyncFeatureNames.BACKUP_AND_SYNC, exports.BackupAndSyncActions.CONTACTS_SYNC_CONTACT_UPDATED, { profile_id: profileId }),
88
- CONTACT_DELETED: (profileId) => (0, exports.createBackupAndSyncEventProperties)(exports.BackupAndSyncFeatureNames.BACKUP_AND_SYNC, exports.BackupAndSyncActions.CONTACTS_SYNC_CONTACT_DELETED, { profile_id: profileId }),
89
- CONTACT_SYNC_ERROR: (profileId, situationMessage) => (0, exports.createBackupAndSyncEventProperties)(exports.BackupAndSyncFeatureNames.BACKUP_AND_SYNC, exports.BackupAndSyncActions.CONTACTS_SYNC_ERRONEOUS_SITUATION, {
90
- profile_id: profileId,
91
- additional_description: situationMessage,
92
- }),
93
- // Network syncing events
94
- NETWORK_ADDED: (profileId, chainId) => ({
95
- profile_id: profileId,
96
- chain_id: chainId,
97
- }),
98
- NETWORK_UPDATED: (profileId, chainId) => ({
99
- profile_id: profileId,
100
- chain_id: chainId,
101
- }),
102
- NETWORK_REMOVED: (profileId, chainId) => ({
103
- profile_id: profileId,
104
- chain_id: chainId,
105
- }),
106
- };
156
+ exports.buildIdentityEvent = buildIdentityEvent;
107
157
  //# sourceMappingURL=metametrics.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"metametrics.cjs","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;GAEG;AACU,QAAA,yBAAyB,GAAG;IACvC;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAClC;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAClC;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAClC;;OAEG;IACH,eAAe,EAAE,iBAAiB;IAClC;;OAEG;IACH,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAEX;;GAEG;AACU,QAAA,oBAAoB,GAAG;IAClC,0BAA0B;IAC1B,mBAAmB,EAAE,qBAAqB;IAC1C,0BAA0B,EAAE,4BAA4B;IACxD,iCAAiC,EAAE,mCAAmC;IAEtE,0BAA0B;IAC1B,6BAA6B,EAAE,+BAA+B;IAC9D,6BAA6B,EAAE,+BAA+B;IAC9D,iCAAiC,EAAE,mCAAmC;IAEtE,0BAA0B;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAE5C,yBAAyB;IACzB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,qBAAqB,EAAE,uBAAuB;CACtC,CAAC;AAUX;;;;;;;;GAQG;AACI,MAAM,kCAAkC,GAAG,CAChD,WAAqC,EACrC,MAA2B,EAC3B,oBAA8C,EAC9C,EAAE,CAAC,CAAC;IACJ,YAAY,EAAE,WAAW;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B,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,eAAe,EAAE,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,CAAC;QACxD,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,OAAO;KAClB,CAAC;CACM,CAAC","sourcesContent":["/**\n * MetaMetrics event constants for profile-sync-controller\n *\n * This library provides standardized constants for MetaMetrics events\n * to avoid magic strings and ensure consistency across clients.\n */\n\n/**\n * Feature names used in profile-sync-controller MetaMetrics events\n */\nexport const BackupAndSyncFeatureNames = {\n /**\n * The main backup and sync feature\n */\n BACKUP_AND_SYNC: 'Backup And Sync',\n /**\n * Account syncing functionality\n */\n ACCOUNT_SYNCING: 'Account Syncing',\n /**\n * Contact syncing functionality\n */\n CONTACT_SYNCING: 'Contact Syncing',\n /**\n * Network syncing functionality\n */\n NETWORK_SYNCING: 'Network Syncing',\n /**\n * Authentication functionality\n */\n AUTHENTICATION: 'Authentication',\n} as const;\n\n/**\n * Actions used in profile-sync-controller MetaMetrics events\n */\nexport const BackupAndSyncActions = {\n // Account syncing actions\n ACCOUNTS_SYNC_ADDED: 'Accounts Sync Added',\n ACCOUNTS_SYNC_NAME_UPDATED: 'Accounts Sync Name Updated',\n ACCOUNTS_SYNC_ERRONEOUS_SITUATION: 'Accounts Sync Erroneous Situation',\n\n // Contact syncing actions\n CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',\n CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',\n CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',\n\n // Network syncing actions\n NETWORK_SYNC_ADDED: 'Network Sync Added',\n NETWORK_SYNC_UPDATED: 'Network Sync Updated',\n NETWORK_SYNC_REMOVED: 'Network Sync Removed',\n\n // Authentication actions\n SIGN_IN: 'Sign In',\n SIGN_OUT: 'Sign Out',\n AUTHENTICATION_FAILED: 'Authentication Failed',\n} as const;\n\n/**\n * Type definitions for the constants to ensure type safety\n */\nexport type BackupAndSyncFeatureName =\n (typeof BackupAndSyncFeatureNames)[keyof typeof BackupAndSyncFeatureNames];\nexport type BackupAndSyncAction =\n (typeof BackupAndSyncActions)[keyof typeof BackupAndSyncActions];\n\n/**\n * Helper function to create standardized MetaMetrics event properties\n * for profile-sync-controller events\n *\n * @param featureName - The feature name to use in the event properties\n * @param action - The action to use in the event properties\n * @param additionalProperties - Optional additional properties to include\n * @returns An object containing the standardized event properties\n */\nexport const createBackupAndSyncEventProperties = (\n featureName: BackupAndSyncFeatureName,\n action: BackupAndSyncAction,\n additionalProperties?: Record<string, unknown>,\n) => ({\n feature_name: featureName,\n action,\n ...additionalProperties,\n});\n\n/**\n * Pre-defined event property sets for common profile-sync-controller events\n */\nexport const BackupAndSyncEventProperties = {\n // Account syncing events\n ACCOUNT_ADDED: (profileId: string) => ({\n profile_id: profileId,\n }),\n ACCOUNT_NAME_UPDATED: (profileId: string) => ({\n profile_id: profileId,\n }),\n ACCOUNT_SYNC_ERROR: (profileId: string, situationMessage: string) => ({\n profile_id: profileId,\n situation_message: situationMessage,\n }),\n\n // Contact syncing events\n CONTACT_UPDATED: (profileId: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_CONTACT_UPDATED,\n { profile_id: profileId },\n ),\n CONTACT_DELETED: (profileId: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_CONTACT_DELETED,\n { profile_id: profileId },\n ),\n CONTACT_SYNC_ERROR: (profileId: string, situationMessage: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_ERRONEOUS_SITUATION,\n {\n profile_id: profileId,\n additional_description: situationMessage,\n },\n ),\n\n // Network syncing events\n NETWORK_ADDED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n NETWORK_UPDATED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n NETWORK_REMOVED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n} as const;\n"]}
1
+ {"version":3,"file":"metametrics.cjs","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiDH;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,eAAe,EAAE;QACf,mBAAmB,EAAE;YACnB,IAAI,EAAE,qBAAqB;YAC3B,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,0BAA0B,EAAE;YAC1B,IAAI,EAAE,4BAA4B;YAClC,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,iCAAiC,EAAE;YACjC,IAAI,EAAE,mCAAmC;YACzC,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;gBACD,iBAAiB,EAAE;oBACjB,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;KACF;IACD,eAAe,EAAE;QACf,kBAAkB,EAAE;YAClB,IAAI,EAAE,oBAAoB;YAC1B,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;gBACD,QAAQ,EAAE;oBACR,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,sBAAsB;YAC5B,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,QAAQ;iBAC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I;oBACd,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,YAAY,EAAE,cAAc;wBAC5B,YAAY,EAAE,cAAc;wBAC5B,cAAc,EAAE,gBAAgB;wBAChC,eAAe,EAAE,iBAAiB;qBACnC;iBACF;aACF;SACF;KACF;CAC+D,CAAC;AAEnE;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAChC,KAAQ,EACR,UAA8B,EACmC,EAAE,CAAC,CAAC;IACrE,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,UAAU;CACX,CAAC,CAAC;AANU,QAAA,kBAAkB,sBAM5B","sourcesContent":["/**\n * MetaMetrics events library for profile-sync-controller\n *\n * This library provides type-safe event definitions that mirror the segment schema,\n * ensuring consistency and providing compile-time validation for event properties.\n */\n\n/**\n * Interface defining the structure of an identity event\n */\nexport type IdentityEvent = {\n name: string;\n properties: {\n [key: string]: {\n required: boolean;\n type: 'string' | 'number' | 'boolean';\n fromObject?: Record<string, string>;\n };\n };\n};\n\n/**\n * Type utility to extract property types from event definitions\n */\ntype PropertyType<T, FromObject> =\n FromObject extends Record<string, string>\n ? FromObject[keyof FromObject]\n : T extends 'string'\n ? string\n : T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : never;\n\n/**\n * Type utility to generate event properties with proper required/optional handling\n */\ntype EventProperties<T extends IdentityEvent> = {\n [K in keyof T['properties'] as T['properties'][K]['required'] extends true\n ? K\n : never]: PropertyType<\n T['properties'][K]['type'],\n T['properties'][K]['fromObject']\n >;\n} & {\n [K in keyof T['properties'] as T['properties'][K]['required'] extends false\n ? K\n : never]?: PropertyType<\n T['properties'][K]['type'],\n T['properties'][K]['fromObject']\n >;\n};\n\n/**\n * Identity events definitions matching the segment schema\n */\nexport const IDENTITY_EVENTS = {\n ACCOUNT_SYNCING: {\n ACCOUNTS_SYNC_ADDED: {\n name: 'Accounts Sync Added',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n },\n },\n ACCOUNTS_SYNC_NAME_UPDATED: {\n name: 'Accounts Sync Name Updated',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n },\n },\n ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {\n name: 'Accounts Sync Erroneous Situation',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n situation_message: {\n required: true,\n type: 'string',\n },\n },\n },\n },\n NETWORK_SYNCING: {\n NETWORK_SYNC_ADDED: {\n name: 'Network Sync Added',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n NETWORK_SYNC_UPDATED: {\n name: 'Network Sync Updated',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n NETWORK_SYNC_REMOVED: {\n name: 'Network Sync Removed',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n },\n PROFILE: {\n ACTIVITY_UPDATED: {\n name: 'Profile Activity Updated',\n properties: {\n profile_id: {\n required: false,\n type: 'string',\n },\n feature_name: {\n required: true,\n type: 'string',\n fromObject: {\n BACKUP_AND_SYNC: 'Backup And Sync',\n AUTHENTICATION: 'Authentication',\n },\n },\n action: {\n required: true,\n type: 'string',\n fromObject: {\n CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',\n CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',\n CONTACTS_SYNC_ERRONEOUS_SITUATION:\n 'Contacts Sync Erroneous Situation',\n SETTINGS_TOGGLE_ENABLED: 'settings_toggle_enabled',\n SETTINGS_TOGGLE_DISABLED: 'settings_toggle_disabled',\n SIGN_IN: 'Sign In',\n SIGN_OUT: 'Sign Out',\n AUTHENTICATION_FAILED: 'Authentication Failed',\n },\n },\n additional_description: {\n required: false,\n type: 'string',\n },\n },\n },\n BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {\n name: 'Backup And Sync Introduction Modal Interaction',\n properties: {\n profile_id: {\n required: false,\n type: 'string',\n },\n action: {\n required: true,\n type: 'string',\n fromObject: {\n MODAL_OPENED: 'modal_opened',\n MODAL_CLOSED: 'modal_closed',\n ENABLE_CLICKED: 'enable_clicked',\n DISMISS_CLICKED: 'dismiss_clicked',\n },\n },\n },\n },\n },\n} as const satisfies Record<string, Record<string, IdentityEvent>>;\n\n/**\n * Type-safe event builder function\n *\n * @param event - The event definition\n * @param properties - The event properties (type-checked)\n * @returns An object with the event name and properties\n */\nexport const buildIdentityEvent = <T extends IdentityEvent>(\n event: T,\n properties: EventProperties<T>,\n): { name: (typeof event)['name']; properties: typeof properties } => ({\n name: event.name,\n properties,\n});\n\n// Export types for external use\nexport type IdentityEventBuilder = typeof buildIdentityEvent;\nexport type IdentityEventDefinitions = typeof IDENTITY_EVENTS;\n"]}
@@ -1,106 +1,181 @@
1
1
  /**
2
- * MetaMetrics event constants for profile-sync-controller
2
+ * MetaMetrics events library for profile-sync-controller
3
3
  *
4
- * This library provides standardized constants for MetaMetrics events
5
- * to avoid magic strings and ensure consistency across clients.
4
+ * This library provides type-safe event definitions that mirror the segment schema,
5
+ * ensuring consistency and providing compile-time validation for event properties.
6
6
  */
7
7
  /**
8
- * Feature names used in profile-sync-controller MetaMetrics events
8
+ * Interface defining the structure of an identity event
9
9
  */
10
- export declare const BackupAndSyncFeatureNames: {
11
- /**
12
- * The main backup and sync feature
13
- */
14
- readonly BACKUP_AND_SYNC: "Backup And Sync";
15
- /**
16
- * Account syncing functionality
17
- */
18
- readonly ACCOUNT_SYNCING: "Account Syncing";
19
- /**
20
- * Contact syncing functionality
21
- */
22
- readonly CONTACT_SYNCING: "Contact Syncing";
23
- /**
24
- * Network syncing functionality
25
- */
26
- readonly NETWORK_SYNCING: "Network Syncing";
27
- /**
28
- * Authentication functionality
29
- */
30
- readonly AUTHENTICATION: "Authentication";
31
- };
32
- /**
33
- * Actions used in profile-sync-controller MetaMetrics events
34
- */
35
- export declare const BackupAndSyncActions: {
36
- readonly ACCOUNTS_SYNC_ADDED: "Accounts Sync Added";
37
- readonly ACCOUNTS_SYNC_NAME_UPDATED: "Accounts Sync Name Updated";
38
- readonly ACCOUNTS_SYNC_ERRONEOUS_SITUATION: "Accounts Sync Erroneous Situation";
39
- readonly CONTACTS_SYNC_CONTACT_UPDATED: "Contacts Sync Contact Updated";
40
- readonly CONTACTS_SYNC_CONTACT_DELETED: "Contacts Sync Contact Deleted";
41
- readonly CONTACTS_SYNC_ERRONEOUS_SITUATION: "Contacts Sync Erroneous Situation";
42
- readonly NETWORK_SYNC_ADDED: "Network Sync Added";
43
- readonly NETWORK_SYNC_UPDATED: "Network Sync Updated";
44
- readonly NETWORK_SYNC_REMOVED: "Network Sync Removed";
45
- readonly SIGN_IN: "Sign In";
46
- readonly SIGN_OUT: "Sign Out";
47
- readonly AUTHENTICATION_FAILED: "Authentication Failed";
10
+ export type IdentityEvent = {
11
+ name: string;
12
+ properties: {
13
+ [key: string]: {
14
+ required: boolean;
15
+ type: 'string' | 'number' | 'boolean';
16
+ fromObject?: Record<string, string>;
17
+ };
18
+ };
48
19
  };
49
20
  /**
50
- * Type definitions for the constants to ensure type safety
21
+ * Type utility to extract property types from event definitions
51
22
  */
52
- export type BackupAndSyncFeatureName = (typeof BackupAndSyncFeatureNames)[keyof typeof BackupAndSyncFeatureNames];
53
- export type BackupAndSyncAction = (typeof BackupAndSyncActions)[keyof typeof BackupAndSyncActions];
23
+ type PropertyType<T, FromObject> = FromObject extends Record<string, string> ? FromObject[keyof FromObject] : T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : never;
54
24
  /**
55
- * Helper function to create standardized MetaMetrics event properties
56
- * for profile-sync-controller events
57
- *
58
- * @param featureName - The feature name to use in the event properties
59
- * @param action - The action to use in the event properties
60
- * @param additionalProperties - Optional additional properties to include
61
- * @returns An object containing the standardized event properties
25
+ * Type utility to generate event properties with proper required/optional handling
62
26
  */
63
- export declare const createBackupAndSyncEventProperties: (featureName: BackupAndSyncFeatureName, action: BackupAndSyncAction, additionalProperties?: Record<string, unknown>) => {
64
- feature_name: BackupAndSyncFeatureName;
65
- action: BackupAndSyncAction;
27
+ type EventProperties<T extends IdentityEvent> = {
28
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends true ? K : never]: PropertyType<T['properties'][K]['type'], T['properties'][K]['fromObject']>;
29
+ } & {
30
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? K : never]?: PropertyType<T['properties'][K]['type'], T['properties'][K]['fromObject']>;
66
31
  };
67
32
  /**
68
- * Pre-defined event property sets for common profile-sync-controller events
33
+ * Identity events definitions matching the segment schema
69
34
  */
70
- export declare const BackupAndSyncEventProperties: {
71
- readonly ACCOUNT_ADDED: (profileId: string) => {
72
- profile_id: string;
73
- };
74
- readonly ACCOUNT_NAME_UPDATED: (profileId: string) => {
75
- profile_id: string;
76
- };
77
- readonly ACCOUNT_SYNC_ERROR: (profileId: string, situationMessage: string) => {
78
- profile_id: string;
79
- situation_message: string;
80
- };
81
- readonly CONTACT_UPDATED: (profileId: string) => {
82
- feature_name: BackupAndSyncFeatureName;
83
- action: BackupAndSyncAction;
35
+ export declare const IDENTITY_EVENTS: {
36
+ readonly ACCOUNT_SYNCING: {
37
+ readonly ACCOUNTS_SYNC_ADDED: {
38
+ readonly name: "Accounts Sync Added";
39
+ readonly properties: {
40
+ readonly profile_id: {
41
+ readonly required: true;
42
+ readonly type: "string";
43
+ };
44
+ };
45
+ };
46
+ readonly ACCOUNTS_SYNC_NAME_UPDATED: {
47
+ readonly name: "Accounts Sync Name Updated";
48
+ readonly properties: {
49
+ readonly profile_id: {
50
+ readonly required: true;
51
+ readonly type: "string";
52
+ };
53
+ };
54
+ };
55
+ readonly ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {
56
+ readonly name: "Accounts Sync Erroneous Situation";
57
+ readonly properties: {
58
+ readonly profile_id: {
59
+ readonly required: true;
60
+ readonly type: "string";
61
+ };
62
+ readonly situation_message: {
63
+ readonly required: true;
64
+ readonly type: "string";
65
+ };
66
+ };
67
+ };
84
68
  };
85
- readonly CONTACT_DELETED: (profileId: string) => {
86
- feature_name: BackupAndSyncFeatureName;
87
- action: BackupAndSyncAction;
69
+ readonly NETWORK_SYNCING: {
70
+ readonly NETWORK_SYNC_ADDED: {
71
+ readonly name: "Network Sync Added";
72
+ readonly properties: {
73
+ readonly profile_id: {
74
+ readonly required: true;
75
+ readonly type: "string";
76
+ };
77
+ readonly chain_id: {
78
+ readonly required: true;
79
+ readonly type: "string";
80
+ };
81
+ };
82
+ };
83
+ readonly NETWORK_SYNC_UPDATED: {
84
+ readonly name: "Network Sync Updated";
85
+ readonly properties: {
86
+ readonly profile_id: {
87
+ readonly required: true;
88
+ readonly type: "string";
89
+ };
90
+ readonly chain_id: {
91
+ readonly required: true;
92
+ readonly type: "string";
93
+ };
94
+ };
95
+ };
96
+ readonly NETWORK_SYNC_REMOVED: {
97
+ readonly name: "Network Sync Removed";
98
+ readonly properties: {
99
+ readonly profile_id: {
100
+ readonly required: true;
101
+ readonly type: "string";
102
+ };
103
+ readonly chain_id: {
104
+ readonly required: true;
105
+ readonly type: "string";
106
+ };
107
+ };
108
+ };
88
109
  };
89
- readonly CONTACT_SYNC_ERROR: (profileId: string, situationMessage: string) => {
90
- feature_name: BackupAndSyncFeatureName;
91
- action: BackupAndSyncAction;
92
- };
93
- readonly NETWORK_ADDED: (profileId: string, chainId: string) => {
94
- profile_id: string;
95
- chain_id: string;
96
- };
97
- readonly NETWORK_UPDATED: (profileId: string, chainId: string) => {
98
- profile_id: string;
99
- chain_id: string;
100
- };
101
- readonly NETWORK_REMOVED: (profileId: string, chainId: string) => {
102
- profile_id: string;
103
- chain_id: string;
110
+ readonly PROFILE: {
111
+ readonly ACTIVITY_UPDATED: {
112
+ readonly name: "Profile Activity Updated";
113
+ readonly properties: {
114
+ readonly profile_id: {
115
+ readonly required: false;
116
+ readonly type: "string";
117
+ };
118
+ readonly feature_name: {
119
+ readonly required: true;
120
+ readonly type: "string";
121
+ readonly fromObject: {
122
+ readonly BACKUP_AND_SYNC: "Backup And Sync";
123
+ readonly AUTHENTICATION: "Authentication";
124
+ };
125
+ };
126
+ readonly action: {
127
+ readonly required: true;
128
+ readonly type: "string";
129
+ readonly fromObject: {
130
+ readonly CONTACTS_SYNC_CONTACT_UPDATED: "Contacts Sync Contact Updated";
131
+ readonly CONTACTS_SYNC_CONTACT_DELETED: "Contacts Sync Contact Deleted";
132
+ readonly CONTACTS_SYNC_ERRONEOUS_SITUATION: "Contacts Sync Erroneous Situation";
133
+ readonly SETTINGS_TOGGLE_ENABLED: "settings_toggle_enabled";
134
+ readonly SETTINGS_TOGGLE_DISABLED: "settings_toggle_disabled";
135
+ readonly SIGN_IN: "Sign In";
136
+ readonly SIGN_OUT: "Sign Out";
137
+ readonly AUTHENTICATION_FAILED: "Authentication Failed";
138
+ };
139
+ };
140
+ readonly additional_description: {
141
+ readonly required: false;
142
+ readonly type: "string";
143
+ };
144
+ };
145
+ };
146
+ readonly BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {
147
+ readonly name: "Backup And Sync Introduction Modal Interaction";
148
+ readonly properties: {
149
+ readonly profile_id: {
150
+ readonly required: false;
151
+ readonly type: "string";
152
+ };
153
+ readonly action: {
154
+ readonly required: true;
155
+ readonly type: "string";
156
+ readonly fromObject: {
157
+ readonly MODAL_OPENED: "modal_opened";
158
+ readonly MODAL_CLOSED: "modal_closed";
159
+ readonly ENABLE_CLICKED: "enable_clicked";
160
+ readonly DISMISS_CLICKED: "dismiss_clicked";
161
+ };
162
+ };
163
+ };
164
+ };
104
165
  };
105
166
  };
167
+ /**
168
+ * Type-safe event builder function
169
+ *
170
+ * @param event - The event definition
171
+ * @param properties - The event properties (type-checked)
172
+ * @returns An object with the event name and properties
173
+ */
174
+ export declare const buildIdentityEvent: <T extends IdentityEvent>(event: T, properties: EventProperties<T>) => {
175
+ name: T["name"];
176
+ properties: EventProperties<T>;
177
+ };
178
+ export type IdentityEventBuilder = typeof buildIdentityEvent;
179
+ export type IdentityEventDefinitions = typeof IDENTITY_EVENTS;
180
+ export {};
106
181
  //# sourceMappingURL=metametrics.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metametrics.d.cts","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB;IACpC;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;CAoBvB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAClC,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,OAAO,yBAAyB,CAAC,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAC7B,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,gBAChC,wBAAwB,UAC7B,mBAAmB,yBACJ,OAAO,MAAM,EAAE,OAAO,CAAC;;;CAK9C,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,4BAA4B;wCAEZ,MAAM;;;+CAGC,MAAM;;;6CAGR,MAAM,oBAAoB,MAAM;;;;0CAMnC,MAAM;;;;0CAMN,MAAM;;;;6CAMH,MAAM,oBAAoB,MAAM;;;;wCAWrC,MAAM,WAAW,MAAM;;;;0CAIrB,MAAM,WAAW,MAAM;;;;0CAIvB,MAAM,WAAW,MAAM;;;;CAI5C,CAAC"}
1
+ {"version":3,"file":"metametrics.d.cts","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,CAAC,GA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoIsC,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;CAM7B,CAAC;AAGH,MAAM,MAAM,oBAAoB,GAAG,OAAO,kBAAkB,CAAC;AAC7D,MAAM,MAAM,wBAAwB,GAAG,OAAO,eAAe,CAAC"}
@@ -1,106 +1,181 @@
1
1
  /**
2
- * MetaMetrics event constants for profile-sync-controller
2
+ * MetaMetrics events library for profile-sync-controller
3
3
  *
4
- * This library provides standardized constants for MetaMetrics events
5
- * to avoid magic strings and ensure consistency across clients.
4
+ * This library provides type-safe event definitions that mirror the segment schema,
5
+ * ensuring consistency and providing compile-time validation for event properties.
6
6
  */
7
7
  /**
8
- * Feature names used in profile-sync-controller MetaMetrics events
8
+ * Interface defining the structure of an identity event
9
9
  */
10
- export declare const BackupAndSyncFeatureNames: {
11
- /**
12
- * The main backup and sync feature
13
- */
14
- readonly BACKUP_AND_SYNC: "Backup And Sync";
15
- /**
16
- * Account syncing functionality
17
- */
18
- readonly ACCOUNT_SYNCING: "Account Syncing";
19
- /**
20
- * Contact syncing functionality
21
- */
22
- readonly CONTACT_SYNCING: "Contact Syncing";
23
- /**
24
- * Network syncing functionality
25
- */
26
- readonly NETWORK_SYNCING: "Network Syncing";
27
- /**
28
- * Authentication functionality
29
- */
30
- readonly AUTHENTICATION: "Authentication";
31
- };
32
- /**
33
- * Actions used in profile-sync-controller MetaMetrics events
34
- */
35
- export declare const BackupAndSyncActions: {
36
- readonly ACCOUNTS_SYNC_ADDED: "Accounts Sync Added";
37
- readonly ACCOUNTS_SYNC_NAME_UPDATED: "Accounts Sync Name Updated";
38
- readonly ACCOUNTS_SYNC_ERRONEOUS_SITUATION: "Accounts Sync Erroneous Situation";
39
- readonly CONTACTS_SYNC_CONTACT_UPDATED: "Contacts Sync Contact Updated";
40
- readonly CONTACTS_SYNC_CONTACT_DELETED: "Contacts Sync Contact Deleted";
41
- readonly CONTACTS_SYNC_ERRONEOUS_SITUATION: "Contacts Sync Erroneous Situation";
42
- readonly NETWORK_SYNC_ADDED: "Network Sync Added";
43
- readonly NETWORK_SYNC_UPDATED: "Network Sync Updated";
44
- readonly NETWORK_SYNC_REMOVED: "Network Sync Removed";
45
- readonly SIGN_IN: "Sign In";
46
- readonly SIGN_OUT: "Sign Out";
47
- readonly AUTHENTICATION_FAILED: "Authentication Failed";
10
+ export type IdentityEvent = {
11
+ name: string;
12
+ properties: {
13
+ [key: string]: {
14
+ required: boolean;
15
+ type: 'string' | 'number' | 'boolean';
16
+ fromObject?: Record<string, string>;
17
+ };
18
+ };
48
19
  };
49
20
  /**
50
- * Type definitions for the constants to ensure type safety
21
+ * Type utility to extract property types from event definitions
51
22
  */
52
- export type BackupAndSyncFeatureName = (typeof BackupAndSyncFeatureNames)[keyof typeof BackupAndSyncFeatureNames];
53
- export type BackupAndSyncAction = (typeof BackupAndSyncActions)[keyof typeof BackupAndSyncActions];
23
+ type PropertyType<T, FromObject> = FromObject extends Record<string, string> ? FromObject[keyof FromObject] : T extends 'string' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : never;
54
24
  /**
55
- * Helper function to create standardized MetaMetrics event properties
56
- * for profile-sync-controller events
57
- *
58
- * @param featureName - The feature name to use in the event properties
59
- * @param action - The action to use in the event properties
60
- * @param additionalProperties - Optional additional properties to include
61
- * @returns An object containing the standardized event properties
25
+ * Type utility to generate event properties with proper required/optional handling
62
26
  */
63
- export declare const createBackupAndSyncEventProperties: (featureName: BackupAndSyncFeatureName, action: BackupAndSyncAction, additionalProperties?: Record<string, unknown>) => {
64
- feature_name: BackupAndSyncFeatureName;
65
- action: BackupAndSyncAction;
27
+ type EventProperties<T extends IdentityEvent> = {
28
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends true ? K : never]: PropertyType<T['properties'][K]['type'], T['properties'][K]['fromObject']>;
29
+ } & {
30
+ [K in keyof T['properties'] as T['properties'][K]['required'] extends false ? K : never]?: PropertyType<T['properties'][K]['type'], T['properties'][K]['fromObject']>;
66
31
  };
67
32
  /**
68
- * Pre-defined event property sets for common profile-sync-controller events
33
+ * Identity events definitions matching the segment schema
69
34
  */
70
- export declare const BackupAndSyncEventProperties: {
71
- readonly ACCOUNT_ADDED: (profileId: string) => {
72
- profile_id: string;
73
- };
74
- readonly ACCOUNT_NAME_UPDATED: (profileId: string) => {
75
- profile_id: string;
76
- };
77
- readonly ACCOUNT_SYNC_ERROR: (profileId: string, situationMessage: string) => {
78
- profile_id: string;
79
- situation_message: string;
80
- };
81
- readonly CONTACT_UPDATED: (profileId: string) => {
82
- feature_name: BackupAndSyncFeatureName;
83
- action: BackupAndSyncAction;
35
+ export declare const IDENTITY_EVENTS: {
36
+ readonly ACCOUNT_SYNCING: {
37
+ readonly ACCOUNTS_SYNC_ADDED: {
38
+ readonly name: "Accounts Sync Added";
39
+ readonly properties: {
40
+ readonly profile_id: {
41
+ readonly required: true;
42
+ readonly type: "string";
43
+ };
44
+ };
45
+ };
46
+ readonly ACCOUNTS_SYNC_NAME_UPDATED: {
47
+ readonly name: "Accounts Sync Name Updated";
48
+ readonly properties: {
49
+ readonly profile_id: {
50
+ readonly required: true;
51
+ readonly type: "string";
52
+ };
53
+ };
54
+ };
55
+ readonly ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {
56
+ readonly name: "Accounts Sync Erroneous Situation";
57
+ readonly properties: {
58
+ readonly profile_id: {
59
+ readonly required: true;
60
+ readonly type: "string";
61
+ };
62
+ readonly situation_message: {
63
+ readonly required: true;
64
+ readonly type: "string";
65
+ };
66
+ };
67
+ };
84
68
  };
85
- readonly CONTACT_DELETED: (profileId: string) => {
86
- feature_name: BackupAndSyncFeatureName;
87
- action: BackupAndSyncAction;
69
+ readonly NETWORK_SYNCING: {
70
+ readonly NETWORK_SYNC_ADDED: {
71
+ readonly name: "Network Sync Added";
72
+ readonly properties: {
73
+ readonly profile_id: {
74
+ readonly required: true;
75
+ readonly type: "string";
76
+ };
77
+ readonly chain_id: {
78
+ readonly required: true;
79
+ readonly type: "string";
80
+ };
81
+ };
82
+ };
83
+ readonly NETWORK_SYNC_UPDATED: {
84
+ readonly name: "Network Sync Updated";
85
+ readonly properties: {
86
+ readonly profile_id: {
87
+ readonly required: true;
88
+ readonly type: "string";
89
+ };
90
+ readonly chain_id: {
91
+ readonly required: true;
92
+ readonly type: "string";
93
+ };
94
+ };
95
+ };
96
+ readonly NETWORK_SYNC_REMOVED: {
97
+ readonly name: "Network Sync Removed";
98
+ readonly properties: {
99
+ readonly profile_id: {
100
+ readonly required: true;
101
+ readonly type: "string";
102
+ };
103
+ readonly chain_id: {
104
+ readonly required: true;
105
+ readonly type: "string";
106
+ };
107
+ };
108
+ };
88
109
  };
89
- readonly CONTACT_SYNC_ERROR: (profileId: string, situationMessage: string) => {
90
- feature_name: BackupAndSyncFeatureName;
91
- action: BackupAndSyncAction;
92
- };
93
- readonly NETWORK_ADDED: (profileId: string, chainId: string) => {
94
- profile_id: string;
95
- chain_id: string;
96
- };
97
- readonly NETWORK_UPDATED: (profileId: string, chainId: string) => {
98
- profile_id: string;
99
- chain_id: string;
100
- };
101
- readonly NETWORK_REMOVED: (profileId: string, chainId: string) => {
102
- profile_id: string;
103
- chain_id: string;
110
+ readonly PROFILE: {
111
+ readonly ACTIVITY_UPDATED: {
112
+ readonly name: "Profile Activity Updated";
113
+ readonly properties: {
114
+ readonly profile_id: {
115
+ readonly required: false;
116
+ readonly type: "string";
117
+ };
118
+ readonly feature_name: {
119
+ readonly required: true;
120
+ readonly type: "string";
121
+ readonly fromObject: {
122
+ readonly BACKUP_AND_SYNC: "Backup And Sync";
123
+ readonly AUTHENTICATION: "Authentication";
124
+ };
125
+ };
126
+ readonly action: {
127
+ readonly required: true;
128
+ readonly type: "string";
129
+ readonly fromObject: {
130
+ readonly CONTACTS_SYNC_CONTACT_UPDATED: "Contacts Sync Contact Updated";
131
+ readonly CONTACTS_SYNC_CONTACT_DELETED: "Contacts Sync Contact Deleted";
132
+ readonly CONTACTS_SYNC_ERRONEOUS_SITUATION: "Contacts Sync Erroneous Situation";
133
+ readonly SETTINGS_TOGGLE_ENABLED: "settings_toggle_enabled";
134
+ readonly SETTINGS_TOGGLE_DISABLED: "settings_toggle_disabled";
135
+ readonly SIGN_IN: "Sign In";
136
+ readonly SIGN_OUT: "Sign Out";
137
+ readonly AUTHENTICATION_FAILED: "Authentication Failed";
138
+ };
139
+ };
140
+ readonly additional_description: {
141
+ readonly required: false;
142
+ readonly type: "string";
143
+ };
144
+ };
145
+ };
146
+ readonly BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {
147
+ readonly name: "Backup And Sync Introduction Modal Interaction";
148
+ readonly properties: {
149
+ readonly profile_id: {
150
+ readonly required: false;
151
+ readonly type: "string";
152
+ };
153
+ readonly action: {
154
+ readonly required: true;
155
+ readonly type: "string";
156
+ readonly fromObject: {
157
+ readonly MODAL_OPENED: "modal_opened";
158
+ readonly MODAL_CLOSED: "modal_closed";
159
+ readonly ENABLE_CLICKED: "enable_clicked";
160
+ readonly DISMISS_CLICKED: "dismiss_clicked";
161
+ };
162
+ };
163
+ };
164
+ };
104
165
  };
105
166
  };
167
+ /**
168
+ * Type-safe event builder function
169
+ *
170
+ * @param event - The event definition
171
+ * @param properties - The event properties (type-checked)
172
+ * @returns An object with the event name and properties
173
+ */
174
+ export declare const buildIdentityEvent: <T extends IdentityEvent>(event: T, properties: EventProperties<T>) => {
175
+ name: T["name"];
176
+ properties: EventProperties<T>;
177
+ };
178
+ export type IdentityEventBuilder = typeof buildIdentityEvent;
179
+ export type IdentityEventDefinitions = typeof IDENTITY_EVENTS;
180
+ export {};
106
181
  //# sourceMappingURL=metametrics.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"metametrics.d.mts","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":"AAAA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AAM,MAAM,oBAAoB,GAAG,OAAO,kBAAkB,CAAC;AAC7D,MAAM,MAAM,wBAAwB,GAAG,OAAO,eAAe,CAAC"}
@@ -1,103 +1,153 @@
1
1
  /**
2
- * MetaMetrics event constants for profile-sync-controller
2
+ * MetaMetrics events library for profile-sync-controller
3
3
  *
4
- * This library provides standardized constants for MetaMetrics events
5
- * to avoid magic strings and ensure consistency across clients.
4
+ * This library provides type-safe event definitions that mirror the segment schema,
5
+ * ensuring consistency and providing compile-time validation for event properties.
6
6
  */
7
7
  /**
8
- * Feature names used in profile-sync-controller MetaMetrics events
8
+ * Identity events definitions matching the segment schema
9
9
  */
10
- export const BackupAndSyncFeatureNames = {
11
- /**
12
- * The main backup and sync feature
13
- */
14
- BACKUP_AND_SYNC: 'Backup And Sync',
15
- /**
16
- * Account syncing functionality
17
- */
18
- ACCOUNT_SYNCING: 'Account Syncing',
19
- /**
20
- * Contact syncing functionality
21
- */
22
- CONTACT_SYNCING: 'Contact Syncing',
23
- /**
24
- * Network syncing functionality
25
- */
26
- NETWORK_SYNCING: 'Network Syncing',
27
- /**
28
- * Authentication functionality
29
- */
30
- AUTHENTICATION: 'Authentication',
10
+ export const IDENTITY_EVENTS = {
11
+ ACCOUNT_SYNCING: {
12
+ ACCOUNTS_SYNC_ADDED: {
13
+ name: 'Accounts Sync Added',
14
+ properties: {
15
+ profile_id: {
16
+ required: true,
17
+ type: 'string',
18
+ },
19
+ },
20
+ },
21
+ ACCOUNTS_SYNC_NAME_UPDATED: {
22
+ name: 'Accounts Sync Name Updated',
23
+ properties: {
24
+ profile_id: {
25
+ required: true,
26
+ type: 'string',
27
+ },
28
+ },
29
+ },
30
+ ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {
31
+ name: 'Accounts Sync Erroneous Situation',
32
+ properties: {
33
+ profile_id: {
34
+ required: true,
35
+ type: 'string',
36
+ },
37
+ situation_message: {
38
+ required: true,
39
+ type: 'string',
40
+ },
41
+ },
42
+ },
43
+ },
44
+ NETWORK_SYNCING: {
45
+ NETWORK_SYNC_ADDED: {
46
+ name: 'Network Sync Added',
47
+ properties: {
48
+ profile_id: {
49
+ required: true,
50
+ type: 'string',
51
+ },
52
+ chain_id: {
53
+ required: true,
54
+ type: 'string',
55
+ },
56
+ },
57
+ },
58
+ NETWORK_SYNC_UPDATED: {
59
+ name: 'Network Sync Updated',
60
+ properties: {
61
+ profile_id: {
62
+ required: true,
63
+ type: 'string',
64
+ },
65
+ chain_id: {
66
+ required: true,
67
+ type: 'string',
68
+ },
69
+ },
70
+ },
71
+ NETWORK_SYNC_REMOVED: {
72
+ name: 'Network Sync Removed',
73
+ properties: {
74
+ profile_id: {
75
+ required: true,
76
+ type: 'string',
77
+ },
78
+ chain_id: {
79
+ required: true,
80
+ type: 'string',
81
+ },
82
+ },
83
+ },
84
+ },
85
+ PROFILE: {
86
+ ACTIVITY_UPDATED: {
87
+ name: 'Profile Activity Updated',
88
+ properties: {
89
+ profile_id: {
90
+ required: false,
91
+ type: 'string',
92
+ },
93
+ feature_name: {
94
+ required: true,
95
+ type: 'string',
96
+ fromObject: {
97
+ BACKUP_AND_SYNC: 'Backup And Sync',
98
+ AUTHENTICATION: 'Authentication',
99
+ },
100
+ },
101
+ action: {
102
+ required: true,
103
+ type: 'string',
104
+ fromObject: {
105
+ CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',
106
+ CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',
107
+ CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',
108
+ SETTINGS_TOGGLE_ENABLED: 'settings_toggle_enabled',
109
+ SETTINGS_TOGGLE_DISABLED: 'settings_toggle_disabled',
110
+ SIGN_IN: 'Sign In',
111
+ SIGN_OUT: 'Sign Out',
112
+ AUTHENTICATION_FAILED: 'Authentication Failed',
113
+ },
114
+ },
115
+ additional_description: {
116
+ required: false,
117
+ type: 'string',
118
+ },
119
+ },
120
+ },
121
+ BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {
122
+ name: 'Backup And Sync Introduction Modal Interaction',
123
+ properties: {
124
+ profile_id: {
125
+ required: false,
126
+ type: 'string',
127
+ },
128
+ action: {
129
+ required: true,
130
+ type: 'string',
131
+ fromObject: {
132
+ MODAL_OPENED: 'modal_opened',
133
+ MODAL_CLOSED: 'modal_closed',
134
+ ENABLE_CLICKED: 'enable_clicked',
135
+ DISMISS_CLICKED: 'dismiss_clicked',
136
+ },
137
+ },
138
+ },
139
+ },
140
+ },
31
141
  };
32
142
  /**
33
- * Actions used in profile-sync-controller MetaMetrics events
34
- */
35
- export const BackupAndSyncActions = {
36
- // Account syncing actions
37
- ACCOUNTS_SYNC_ADDED: 'Accounts Sync Added',
38
- ACCOUNTS_SYNC_NAME_UPDATED: 'Accounts Sync Name Updated',
39
- ACCOUNTS_SYNC_ERRONEOUS_SITUATION: 'Accounts Sync Erroneous Situation',
40
- // Contact syncing actions
41
- CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',
42
- CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',
43
- CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',
44
- // Network syncing actions
45
- NETWORK_SYNC_ADDED: 'Network Sync Added',
46
- NETWORK_SYNC_UPDATED: 'Network Sync Updated',
47
- NETWORK_SYNC_REMOVED: 'Network Sync Removed',
48
- // Authentication actions
49
- SIGN_IN: 'Sign In',
50
- SIGN_OUT: 'Sign Out',
51
- AUTHENTICATION_FAILED: 'Authentication Failed',
52
- };
53
- /**
54
- * Helper function to create standardized MetaMetrics event properties
55
- * for profile-sync-controller events
143
+ * Type-safe event builder function
56
144
  *
57
- * @param featureName - The feature name to use in the event properties
58
- * @param action - The action to use in the event properties
59
- * @param additionalProperties - Optional additional properties to include
60
- * @returns An object containing the standardized event properties
145
+ * @param event - The event definition
146
+ * @param properties - The event properties (type-checked)
147
+ * @returns An object with the event name and properties
61
148
  */
62
- export const createBackupAndSyncEventProperties = (featureName, action, additionalProperties) => ({
63
- feature_name: featureName,
64
- action,
65
- ...additionalProperties,
149
+ export const buildIdentityEvent = (event, properties) => ({
150
+ name: event.name,
151
+ properties,
66
152
  });
67
- /**
68
- * Pre-defined event property sets for common profile-sync-controller events
69
- */
70
- export const BackupAndSyncEventProperties = {
71
- // Account syncing events
72
- ACCOUNT_ADDED: (profileId) => ({
73
- profile_id: profileId,
74
- }),
75
- ACCOUNT_NAME_UPDATED: (profileId) => ({
76
- profile_id: profileId,
77
- }),
78
- ACCOUNT_SYNC_ERROR: (profileId, situationMessage) => ({
79
- profile_id: profileId,
80
- situation_message: situationMessage,
81
- }),
82
- // Contact syncing events
83
- CONTACT_UPDATED: (profileId) => createBackupAndSyncEventProperties(BackupAndSyncFeatureNames.BACKUP_AND_SYNC, BackupAndSyncActions.CONTACTS_SYNC_CONTACT_UPDATED, { profile_id: profileId }),
84
- CONTACT_DELETED: (profileId) => createBackupAndSyncEventProperties(BackupAndSyncFeatureNames.BACKUP_AND_SYNC, BackupAndSyncActions.CONTACTS_SYNC_CONTACT_DELETED, { profile_id: profileId }),
85
- CONTACT_SYNC_ERROR: (profileId, situationMessage) => createBackupAndSyncEventProperties(BackupAndSyncFeatureNames.BACKUP_AND_SYNC, BackupAndSyncActions.CONTACTS_SYNC_ERRONEOUS_SITUATION, {
86
- profile_id: profileId,
87
- additional_description: situationMessage,
88
- }),
89
- // Network syncing events
90
- NETWORK_ADDED: (profileId, chainId) => ({
91
- profile_id: profileId,
92
- chain_id: chainId,
93
- }),
94
- NETWORK_UPDATED: (profileId, chainId) => ({
95
- profile_id: profileId,
96
- chain_id: chainId,
97
- }),
98
- NETWORK_REMOVED: (profileId, chainId) => ({
99
- profile_id: profileId,
100
- chain_id: chainId,
101
- }),
102
- };
103
153
  //# sourceMappingURL=metametrics.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"metametrics.mjs","sourceRoot":"","sources":["../../src/shared/metametrics.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C,SAAiB,EAAE,gBAAwB,EAAE,EAAE,CAAC,CAAC;QACpE,UAAU,EAAE,SAAS;QACrB,iBAAiB,EAAE,gBAAgB;KACpC,CAAC;IAEF,yBAAyB;IACzB,eAAe,EAAE,CAAC,SAAiB,EAAE,EAAE,CACrC,kCAAkC,CAChC,yBAAyB,CAAC,eAAe,EACzC,oBAAoB,CAAC,6BAA6B,EAClD,EAAE,UAAU,EAAE,SAAS,EAAE,CAC1B;IACH,eAAe,EAAE,CAAC,SAAiB,EAAE,EAAE,CACrC,kCAAkC,CAChC,yBAAyB,CAAC,eAAe,EACzC,oBAAoB,CAAC,6BAA6B,EAClD,EAAE,UAAU,EAAE,SAAS,EAAE,CAC1B;IACH,kBAAkB,EAAE,CAAC,SAAiB,EAAE,gBAAwB,EAAE,EAAE,CAClE,kCAAkC,CAChC,yBAAyB,CAAC,eAAe,EACzC,oBAAoB,CAAC,iCAAiC,EACtD;QACE,UAAU,EAAE,SAAS;QACrB,sBAAsB,EAAE,gBAAgB;KACzC,CACF;IAEH,yBAAyB;IACzB,aAAa,EAAE,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,CAAC;QACtD,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,eAAe,EAAE,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,CAAC;QACxD,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,eAAe,EAAE,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CAAC,CAAC;QACxD,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,OAAO;KAClB,CAAC;CACM,CAAC","sourcesContent":["/**\n * MetaMetrics event constants for profile-sync-controller\n *\n * This library provides standardized constants for MetaMetrics events\n * to avoid magic strings and ensure consistency across clients.\n */\n\n/**\n * Feature names used in profile-sync-controller MetaMetrics events\n */\nexport const BackupAndSyncFeatureNames = {\n /**\n * The main backup and sync feature\n */\n BACKUP_AND_SYNC: 'Backup And Sync',\n /**\n * Account syncing functionality\n */\n ACCOUNT_SYNCING: 'Account Syncing',\n /**\n * Contact syncing functionality\n */\n CONTACT_SYNCING: 'Contact Syncing',\n /**\n * Network syncing functionality\n */\n NETWORK_SYNCING: 'Network Syncing',\n /**\n * Authentication functionality\n */\n AUTHENTICATION: 'Authentication',\n} as const;\n\n/**\n * Actions used in profile-sync-controller MetaMetrics events\n */\nexport const BackupAndSyncActions = {\n // Account syncing actions\n ACCOUNTS_SYNC_ADDED: 'Accounts Sync Added',\n ACCOUNTS_SYNC_NAME_UPDATED: 'Accounts Sync Name Updated',\n ACCOUNTS_SYNC_ERRONEOUS_SITUATION: 'Accounts Sync Erroneous Situation',\n\n // Contact syncing actions\n CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',\n CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',\n CONTACTS_SYNC_ERRONEOUS_SITUATION: 'Contacts Sync Erroneous Situation',\n\n // Network syncing actions\n NETWORK_SYNC_ADDED: 'Network Sync Added',\n NETWORK_SYNC_UPDATED: 'Network Sync Updated',\n NETWORK_SYNC_REMOVED: 'Network Sync Removed',\n\n // Authentication actions\n SIGN_IN: 'Sign In',\n SIGN_OUT: 'Sign Out',\n AUTHENTICATION_FAILED: 'Authentication Failed',\n} as const;\n\n/**\n * Type definitions for the constants to ensure type safety\n */\nexport type BackupAndSyncFeatureName =\n (typeof BackupAndSyncFeatureNames)[keyof typeof BackupAndSyncFeatureNames];\nexport type BackupAndSyncAction =\n (typeof BackupAndSyncActions)[keyof typeof BackupAndSyncActions];\n\n/**\n * Helper function to create standardized MetaMetrics event properties\n * for profile-sync-controller events\n *\n * @param featureName - The feature name to use in the event properties\n * @param action - The action to use in the event properties\n * @param additionalProperties - Optional additional properties to include\n * @returns An object containing the standardized event properties\n */\nexport const createBackupAndSyncEventProperties = (\n featureName: BackupAndSyncFeatureName,\n action: BackupAndSyncAction,\n additionalProperties?: Record<string, unknown>,\n) => ({\n feature_name: featureName,\n action,\n ...additionalProperties,\n});\n\n/**\n * Pre-defined event property sets for common profile-sync-controller events\n */\nexport const BackupAndSyncEventProperties = {\n // Account syncing events\n ACCOUNT_ADDED: (profileId: string) => ({\n profile_id: profileId,\n }),\n ACCOUNT_NAME_UPDATED: (profileId: string) => ({\n profile_id: profileId,\n }),\n ACCOUNT_SYNC_ERROR: (profileId: string, situationMessage: string) => ({\n profile_id: profileId,\n situation_message: situationMessage,\n }),\n\n // Contact syncing events\n CONTACT_UPDATED: (profileId: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_CONTACT_UPDATED,\n { profile_id: profileId },\n ),\n CONTACT_DELETED: (profileId: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_CONTACT_DELETED,\n { profile_id: profileId },\n ),\n CONTACT_SYNC_ERROR: (profileId: string, situationMessage: string) =>\n createBackupAndSyncEventProperties(\n BackupAndSyncFeatureNames.BACKUP_AND_SYNC,\n BackupAndSyncActions.CONTACTS_SYNC_ERRONEOUS_SITUATION,\n {\n profile_id: profileId,\n additional_description: situationMessage,\n },\n ),\n\n // Network syncing events\n NETWORK_ADDED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n NETWORK_UPDATED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n NETWORK_REMOVED: (profileId: string, chainId: string) => ({\n profile_id: profileId,\n chain_id: chainId,\n }),\n} as const;\n"]}
1
+ {"version":3,"file":"metametrics.mjs","sourceRoot":"","sources":["../../src/shared/metametrics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiDH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe,EAAE;QACf,mBAAmB,EAAE;YACnB,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ACX,CAAC,CAAC","sourcesContent":["/**\n * MetaMetrics events library for profile-sync-controller\n *\n * This library provides type-safe event definitions that mirror the segment schema,\n * ensuring consistency and providing compile-time validation for event properties.\n */\n\n/**\n * Interface defining the structure of an identity event\n */\nexport type IdentityEvent = {\n name: string;\n properties: {\n [key: string]: {\n required: boolean;\n type: 'string' | 'number' | 'boolean';\n fromObject?: Record<string, string>;\n };\n };\n};\n\n/**\n * Type utility to extract property types from event definitions\n */\ntype PropertyType<T, FromObject> =\n FromObject extends Record<string, string>\n ? FromObject[keyof FromObject]\n : T extends 'string'\n ? string\n : T extends 'number'\n ? number\n : T extends 'boolean'\n ? boolean\n : never;\n\n/**\n * Type utility to generate event properties with proper required/optional handling\n */\ntype EventProperties<T extends IdentityEvent> = {\n [K in keyof T['properties'] as T['properties'][K]['required'] extends true\n ? K\n : never]: PropertyType<\n T['properties'][K]['type'],\n T['properties'][K]['fromObject']\n >;\n} & {\n [K in keyof T['properties'] as T['properties'][K]['required'] extends false\n ? K\n : never]?: PropertyType<\n T['properties'][K]['type'],\n T['properties'][K]['fromObject']\n >;\n};\n\n/**\n * Identity events definitions matching the segment schema\n */\nexport const IDENTITY_EVENTS = {\n ACCOUNT_SYNCING: {\n ACCOUNTS_SYNC_ADDED: {\n name: 'Accounts Sync Added',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n },\n },\n ACCOUNTS_SYNC_NAME_UPDATED: {\n name: 'Accounts Sync Name Updated',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n },\n },\n ACCOUNTS_SYNC_ERRONEOUS_SITUATION: {\n name: 'Accounts Sync Erroneous Situation',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n situation_message: {\n required: true,\n type: 'string',\n },\n },\n },\n },\n NETWORK_SYNCING: {\n NETWORK_SYNC_ADDED: {\n name: 'Network Sync Added',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n NETWORK_SYNC_UPDATED: {\n name: 'Network Sync Updated',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n NETWORK_SYNC_REMOVED: {\n name: 'Network Sync Removed',\n properties: {\n profile_id: {\n required: true,\n type: 'string',\n },\n chain_id: {\n required: true,\n type: 'string',\n },\n },\n },\n },\n PROFILE: {\n ACTIVITY_UPDATED: {\n name: 'Profile Activity Updated',\n properties: {\n profile_id: {\n required: false,\n type: 'string',\n },\n feature_name: {\n required: true,\n type: 'string',\n fromObject: {\n BACKUP_AND_SYNC: 'Backup And Sync',\n AUTHENTICATION: 'Authentication',\n },\n },\n action: {\n required: true,\n type: 'string',\n fromObject: {\n CONTACTS_SYNC_CONTACT_UPDATED: 'Contacts Sync Contact Updated',\n CONTACTS_SYNC_CONTACT_DELETED: 'Contacts Sync Contact Deleted',\n CONTACTS_SYNC_ERRONEOUS_SITUATION:\n 'Contacts Sync Erroneous Situation',\n SETTINGS_TOGGLE_ENABLED: 'settings_toggle_enabled',\n SETTINGS_TOGGLE_DISABLED: 'settings_toggle_disabled',\n SIGN_IN: 'Sign In',\n SIGN_OUT: 'Sign Out',\n AUTHENTICATION_FAILED: 'Authentication Failed',\n },\n },\n additional_description: {\n required: false,\n type: 'string',\n },\n },\n },\n BACKUP_AND_SYNC_INTRODUCTION_MODAL_INTERACTION: {\n name: 'Backup And Sync Introduction Modal Interaction',\n properties: {\n profile_id: {\n required: false,\n type: 'string',\n },\n action: {\n required: true,\n type: 'string',\n fromObject: {\n MODAL_OPENED: 'modal_opened',\n MODAL_CLOSED: 'modal_closed',\n ENABLE_CLICKED: 'enable_clicked',\n DISMISS_CLICKED: 'dismiss_clicked',\n },\n },\n },\n },\n },\n} as const satisfies Record<string, Record<string, IdentityEvent>>;\n\n/**\n * Type-safe event builder function\n *\n * @param event - The event definition\n * @param properties - The event properties (type-checked)\n * @returns An object with the event name and properties\n */\nexport const buildIdentityEvent = <T extends IdentityEvent>(\n event: T,\n properties: EventProperties<T>,\n): { name: (typeof event)['name']; properties: typeof properties } => ({\n name: event.name,\n properties,\n});\n\n// Export types for external use\nexport type IdentityEventBuilder = typeof buildIdentityEvent;\nexport type IdentityEventDefinitions = typeof IDENTITY_EVENTS;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/profile-sync-controller",
3
- "version": "19.0.0-preview-f9a5dd05",
3
+ "version": "19.0.0-preview-bfad74b0",
4
4
  "description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
5
5
  "keywords": [
6
6
  "MetaMask",