argus-discord-analytics 0.2.2 → 0.3.0

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.
package/dist/index.d.mts CHANGED
@@ -21,7 +21,7 @@
21
21
  * argus.trackRevenue({ source: 'patreon', amount: 500, tier: 'Premium' });
22
22
  * ```
23
23
  */
24
- declare const SDK_VERSION = "0.2.2";
24
+ declare const SDK_VERSION = "0.3.0";
25
25
  interface ArgusConfig {
26
26
  /** Your Argus API key (starts with arg_live_ or arg_test_) */
27
27
  apiKey: string;
@@ -52,6 +52,23 @@ interface TrackEvent {
52
52
  metadata?: Record<string, unknown>;
53
53
  timestamp?: number;
54
54
  latencyMs?: number;
55
+ /** User segment for monetization analytics (e.g., 'premium', 'free', 'trial') */
56
+ segment?: string;
57
+ }
58
+ /**
59
+ * Options for tracking with user segmentation
60
+ * Use segment to track premium vs free user behavior
61
+ */
62
+ interface TrackOptions {
63
+ serverId?: string;
64
+ userId?: string;
65
+ metadata?: Record<string, unknown>;
66
+ /**
67
+ * User segment for monetization analytics.
68
+ * Track premium vs free users to see conversion insights.
69
+ * @example 'premium', 'free', 'trial', 'supporter', 'legendary'
70
+ */
71
+ segment?: string;
55
72
  }
56
73
  interface HeartbeatConfig {
57
74
  /** Heartbeat interval in ms (default: 30000) */
@@ -112,6 +129,9 @@ declare class Argus {
112
129
  * client.on('interactionCreate', (interaction) => {
113
130
  * argus.track(interaction);
114
131
  * });
132
+ *
133
+ * // With user segmentation for premium vs free analytics
134
+ * argus.track(interaction, { segment: user.isPremium ? 'premium' : 'free' });
115
135
  * ```
116
136
  */
117
137
  track(interaction: {
@@ -127,15 +147,22 @@ declare class Argus {
127
147
  message?: {
128
148
  id: string;
129
149
  };
150
+ }, options?: {
151
+ segment?: string;
130
152
  }): void;
131
153
  /**
132
154
  * Track a custom event
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * // Track with user segment for monetization analytics
159
+ * argus.trackEvent('command', 'gacha', {
160
+ * segment: user.tier, // 'supporter', 'epic', 'legendary'
161
+ * userId: user.id,
162
+ * });
163
+ * ```
133
164
  */
134
- trackEvent(type: 'command' | 'error' | 'custom', name: string, options?: {
135
- serverId?: string;
136
- userId?: string;
137
- metadata?: Record<string, unknown>;
138
- }): void;
165
+ trackEvent(type: 'command' | 'error' | 'custom', name: string, options?: TrackOptions): void;
139
166
  /**
140
167
  * Track a command (convenience method)
141
168
  * Accepts either a command name string or a Discord.js interaction object
@@ -146,10 +173,14 @@ declare class Argus {
146
173
  * // Automatically extracts subcommands: /show profile -> "show profile"
147
174
  * argus.trackCommand(interaction);
148
175
  *
149
- * // Option 2: Pass command name as string
176
+ * // Option 2: With user segmentation for premium vs free analytics
177
+ * argus.trackCommand(interaction, { segment: user.isPremium ? 'premium' : 'free' });
178
+ *
179
+ * // Option 3: Pass command name as string
150
180
  * argus.trackCommand('ban', {
151
181
  * serverId: interaction.guildId,
152
- * userId: interaction.user.id
182
+ * userId: interaction.user.id,
183
+ * segment: 'premium',
153
184
  * });
154
185
  * ```
155
186
  */
@@ -161,11 +192,7 @@ declare class Argus {
161
192
  id: string;
162
193
  };
163
194
  options?: unknown;
164
- }, options?: {
165
- serverId?: string;
166
- userId?: string;
167
- metadata?: Record<string, unknown>;
168
- }): void;
195
+ }, options?: TrackOptions): void;
169
196
  /**
170
197
  * Track an error
171
198
  */
@@ -174,6 +201,8 @@ declare class Argus {
174
201
  serverId?: string;
175
202
  userId?: string;
176
203
  metadata?: Record<string, unknown>;
204
+ /** User segment for monetization analytics */
205
+ segment?: string;
177
206
  }): void;
178
207
  /**
179
208
  * Track a button click interaction
@@ -186,6 +215,9 @@ declare class Argus {
186
215
  * // Tracked as: "button:buy_premium"
187
216
  * }
188
217
  * });
218
+ *
219
+ * // With user segmentation
220
+ * argus.trackButton(interaction, { segment: 'premium' });
189
221
  * ```
190
222
  */
191
223
  trackButton(interaction: {
@@ -197,6 +229,8 @@ declare class Argus {
197
229
  message?: {
198
230
  id: string;
199
231
  };
232
+ }, options?: {
233
+ segment?: string;
200
234
  }): void;
201
235
  /**
202
236
  * Track a select menu interaction
@@ -210,6 +244,9 @@ declare class Argus {
210
244
  * // Metadata includes: selectedValues
211
245
  * }
212
246
  * });
247
+ *
248
+ * // With user segmentation
249
+ * argus.trackSelectMenu(interaction, { segment: 'premium' });
213
250
  * ```
214
251
  */
215
252
  trackSelectMenu(interaction: {
@@ -219,6 +256,8 @@ declare class Argus {
219
256
  user?: {
220
257
  id: string;
221
258
  };
259
+ }, options?: {
260
+ segment?: string;
222
261
  }): void;
223
262
  /**
224
263
  * Track server join or leave events
@@ -334,19 +373,17 @@ declare class Argus {
334
373
  };
335
374
  type?: number;
336
375
  options?: unknown;
376
+ }, options?: {
377
+ segment?: string;
337
378
  }): void;
338
379
  /**
339
380
  * Track an event with latency measurement
340
381
  */
341
- trackEventWithLatency(type: 'command' | 'error' | 'custom', name: string, latencyMs: number, options?: {
342
- serverId?: string;
343
- userId?: string;
344
- metadata?: Record<string, unknown>;
345
- }): void;
382
+ trackEventWithLatency(type: 'command' | 'error' | 'custom', name: string, latencyMs: number, options?: TrackOptions): void;
346
383
  /**
347
384
  * Shutdown the Argus instance, flushing any remaining events
348
385
  */
349
386
  shutdown(): Promise<void>;
350
387
  }
351
388
 
352
- export { Argus, type ArgusConfig, type HeartbeatConfig, type RevenueEvent, SDK_VERSION, type ServerEvent, type TrackEvent, Argus as default };
389
+ export { Argus, type ArgusConfig, type HeartbeatConfig, type RevenueEvent, SDK_VERSION, type ServerEvent, type TrackEvent, type TrackOptions, Argus as default };
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  * argus.trackRevenue({ source: 'patreon', amount: 500, tier: 'Premium' });
22
22
  * ```
23
23
  */
24
- declare const SDK_VERSION = "0.2.2";
24
+ declare const SDK_VERSION = "0.3.0";
25
25
  interface ArgusConfig {
26
26
  /** Your Argus API key (starts with arg_live_ or arg_test_) */
27
27
  apiKey: string;
@@ -52,6 +52,23 @@ interface TrackEvent {
52
52
  metadata?: Record<string, unknown>;
53
53
  timestamp?: number;
54
54
  latencyMs?: number;
55
+ /** User segment for monetization analytics (e.g., 'premium', 'free', 'trial') */
56
+ segment?: string;
57
+ }
58
+ /**
59
+ * Options for tracking with user segmentation
60
+ * Use segment to track premium vs free user behavior
61
+ */
62
+ interface TrackOptions {
63
+ serverId?: string;
64
+ userId?: string;
65
+ metadata?: Record<string, unknown>;
66
+ /**
67
+ * User segment for monetization analytics.
68
+ * Track premium vs free users to see conversion insights.
69
+ * @example 'premium', 'free', 'trial', 'supporter', 'legendary'
70
+ */
71
+ segment?: string;
55
72
  }
56
73
  interface HeartbeatConfig {
57
74
  /** Heartbeat interval in ms (default: 30000) */
@@ -112,6 +129,9 @@ declare class Argus {
112
129
  * client.on('interactionCreate', (interaction) => {
113
130
  * argus.track(interaction);
114
131
  * });
132
+ *
133
+ * // With user segmentation for premium vs free analytics
134
+ * argus.track(interaction, { segment: user.isPremium ? 'premium' : 'free' });
115
135
  * ```
116
136
  */
117
137
  track(interaction: {
@@ -127,15 +147,22 @@ declare class Argus {
127
147
  message?: {
128
148
  id: string;
129
149
  };
150
+ }, options?: {
151
+ segment?: string;
130
152
  }): void;
131
153
  /**
132
154
  * Track a custom event
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * // Track with user segment for monetization analytics
159
+ * argus.trackEvent('command', 'gacha', {
160
+ * segment: user.tier, // 'supporter', 'epic', 'legendary'
161
+ * userId: user.id,
162
+ * });
163
+ * ```
133
164
  */
134
- trackEvent(type: 'command' | 'error' | 'custom', name: string, options?: {
135
- serverId?: string;
136
- userId?: string;
137
- metadata?: Record<string, unknown>;
138
- }): void;
165
+ trackEvent(type: 'command' | 'error' | 'custom', name: string, options?: TrackOptions): void;
139
166
  /**
140
167
  * Track a command (convenience method)
141
168
  * Accepts either a command name string or a Discord.js interaction object
@@ -146,10 +173,14 @@ declare class Argus {
146
173
  * // Automatically extracts subcommands: /show profile -> "show profile"
147
174
  * argus.trackCommand(interaction);
148
175
  *
149
- * // Option 2: Pass command name as string
176
+ * // Option 2: With user segmentation for premium vs free analytics
177
+ * argus.trackCommand(interaction, { segment: user.isPremium ? 'premium' : 'free' });
178
+ *
179
+ * // Option 3: Pass command name as string
150
180
  * argus.trackCommand('ban', {
151
181
  * serverId: interaction.guildId,
152
- * userId: interaction.user.id
182
+ * userId: interaction.user.id,
183
+ * segment: 'premium',
153
184
  * });
154
185
  * ```
155
186
  */
@@ -161,11 +192,7 @@ declare class Argus {
161
192
  id: string;
162
193
  };
163
194
  options?: unknown;
164
- }, options?: {
165
- serverId?: string;
166
- userId?: string;
167
- metadata?: Record<string, unknown>;
168
- }): void;
195
+ }, options?: TrackOptions): void;
169
196
  /**
170
197
  * Track an error
171
198
  */
@@ -174,6 +201,8 @@ declare class Argus {
174
201
  serverId?: string;
175
202
  userId?: string;
176
203
  metadata?: Record<string, unknown>;
204
+ /** User segment for monetization analytics */
205
+ segment?: string;
177
206
  }): void;
178
207
  /**
179
208
  * Track a button click interaction
@@ -186,6 +215,9 @@ declare class Argus {
186
215
  * // Tracked as: "button:buy_premium"
187
216
  * }
188
217
  * });
218
+ *
219
+ * // With user segmentation
220
+ * argus.trackButton(interaction, { segment: 'premium' });
189
221
  * ```
190
222
  */
191
223
  trackButton(interaction: {
@@ -197,6 +229,8 @@ declare class Argus {
197
229
  message?: {
198
230
  id: string;
199
231
  };
232
+ }, options?: {
233
+ segment?: string;
200
234
  }): void;
201
235
  /**
202
236
  * Track a select menu interaction
@@ -210,6 +244,9 @@ declare class Argus {
210
244
  * // Metadata includes: selectedValues
211
245
  * }
212
246
  * });
247
+ *
248
+ * // With user segmentation
249
+ * argus.trackSelectMenu(interaction, { segment: 'premium' });
213
250
  * ```
214
251
  */
215
252
  trackSelectMenu(interaction: {
@@ -219,6 +256,8 @@ declare class Argus {
219
256
  user?: {
220
257
  id: string;
221
258
  };
259
+ }, options?: {
260
+ segment?: string;
222
261
  }): void;
223
262
  /**
224
263
  * Track server join or leave events
@@ -334,19 +373,17 @@ declare class Argus {
334
373
  };
335
374
  type?: number;
336
375
  options?: unknown;
376
+ }, options?: {
377
+ segment?: string;
337
378
  }): void;
338
379
  /**
339
380
  * Track an event with latency measurement
340
381
  */
341
- trackEventWithLatency(type: 'command' | 'error' | 'custom', name: string, latencyMs: number, options?: {
342
- serverId?: string;
343
- userId?: string;
344
- metadata?: Record<string, unknown>;
345
- }): void;
382
+ trackEventWithLatency(type: 'command' | 'error' | 'custom', name: string, latencyMs: number, options?: TrackOptions): void;
346
383
  /**
347
384
  * Shutdown the Argus instance, flushing any remaining events
348
385
  */
349
386
  shutdown(): Promise<void>;
350
387
  }
351
388
 
352
- export { Argus, type ArgusConfig, type HeartbeatConfig, type RevenueEvent, SDK_VERSION, type ServerEvent, type TrackEvent, Argus as default };
389
+ export { Argus, type ArgusConfig, type HeartbeatConfig, type RevenueEvent, SDK_VERSION, type ServerEvent, type TrackEvent, type TrackOptions, Argus as default };
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ __export(index_exports, {
25
25
  default: () => index_default
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
- var SDK_VERSION = "0.2.2";
28
+ var SDK_VERSION = "0.3.0";
29
29
  function hashString(str) {
30
30
  let hash = 0;
31
31
  for (let i = 0; i < str.length; i++) {
@@ -135,9 +135,12 @@ var Argus = class {
135
135
  * client.on('interactionCreate', (interaction) => {
136
136
  * argus.track(interaction);
137
137
  * });
138
+ *
139
+ * // With user segmentation for premium vs free analytics
140
+ * argus.track(interaction, { segment: user.isPremium ? 'premium' : 'free' });
138
141
  * ```
139
142
  */
140
- track(interaction) {
143
+ track(interaction, options) {
141
144
  if (interaction.customId && !interaction.commandName) {
142
145
  if (Array.isArray(interaction.values)) {
143
146
  return this.trackSelectMenu({
@@ -145,14 +148,14 @@ var Argus = class {
145
148
  values: interaction.values,
146
149
  guildId: interaction.guildId,
147
150
  user: interaction.user
148
- });
151
+ }, options);
149
152
  }
150
153
  return this.trackButton({
151
154
  customId: interaction.customId,
152
155
  guildId: interaction.guildId,
153
156
  user: interaction.user,
154
157
  message: interaction.message
155
- });
158
+ }, options);
156
159
  }
157
160
  const name = extractFullCommandName(interaction);
158
161
  const serverId = interaction.guildId || void 0;
@@ -160,6 +163,7 @@ var Argus = class {
160
163
  this.trackEvent("command", name, {
161
164
  serverId,
162
165
  userId,
166
+ segment: options?.segment,
163
167
  metadata: {
164
168
  interactionType: interaction.type
165
169
  }
@@ -167,6 +171,15 @@ var Argus = class {
167
171
  }
168
172
  /**
169
173
  * Track a custom event
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * // Track with user segment for monetization analytics
178
+ * argus.trackEvent('command', 'gacha', {
179
+ * segment: user.tier, // 'supporter', 'epic', 'legendary'
180
+ * userId: user.id,
181
+ * });
182
+ * ```
170
183
  */
171
184
  trackEvent(type, name, options) {
172
185
  const event = {
@@ -176,6 +189,7 @@ var Argus = class {
176
189
  userId: options?.userId,
177
190
  userHash: options?.userId && this.hashUserIds ? hashString(options.userId) : options?.userId,
178
191
  metadata: options?.metadata,
192
+ segment: options?.segment,
179
193
  timestamp: Date.now()
180
194
  };
181
195
  if (this.hashUserIds) {
@@ -197,10 +211,14 @@ var Argus = class {
197
211
  * // Automatically extracts subcommands: /show profile -> "show profile"
198
212
  * argus.trackCommand(interaction);
199
213
  *
200
- * // Option 2: Pass command name as string
214
+ * // Option 2: With user segmentation for premium vs free analytics
215
+ * argus.trackCommand(interaction, { segment: user.isPremium ? 'premium' : 'free' });
216
+ *
217
+ * // Option 3: Pass command name as string
201
218
  * argus.trackCommand('ban', {
202
219
  * serverId: interaction.guildId,
203
- * userId: interaction.user.id
220
+ * userId: interaction.user.id,
221
+ * segment: 'premium',
204
222
  * });
205
223
  * ```
206
224
  */
@@ -216,6 +234,12 @@ var Argus = class {
216
234
  serverId: commandOrInteraction.guildId || void 0,
217
235
  userId: commandOrInteraction.user?.id
218
236
  };
237
+ } else if (!extractedOptions.serverId && !extractedOptions.userId) {
238
+ extractedOptions = {
239
+ ...extractedOptions,
240
+ serverId: commandOrInteraction.guildId || void 0,
241
+ userId: commandOrInteraction.user?.id
242
+ };
219
243
  }
220
244
  }
221
245
  this.trackEvent("command", commandName, extractedOptions);
@@ -229,6 +253,7 @@ var Argus = class {
229
253
  this.trackEvent("error", errorMessage, {
230
254
  serverId: options?.serverId,
231
255
  userId: options?.userId,
256
+ segment: options?.segment,
232
257
  metadata: {
233
258
  ...options?.metadata,
234
259
  command: options?.command,
@@ -247,12 +272,16 @@ var Argus = class {
247
272
  * // Tracked as: "button:buy_premium"
248
273
  * }
249
274
  * });
275
+ *
276
+ * // With user segmentation
277
+ * argus.trackButton(interaction, { segment: 'premium' });
250
278
  * ```
251
279
  */
252
- trackButton(interaction) {
280
+ trackButton(interaction, options) {
253
281
  this.trackEvent("custom", `button:${interaction.customId}`, {
254
282
  serverId: interaction.guildId || void 0,
255
283
  userId: interaction.user?.id,
284
+ segment: options?.segment,
256
285
  metadata: {
257
286
  interactionType: "button",
258
287
  customId: interaction.customId,
@@ -272,12 +301,16 @@ var Argus = class {
272
301
  * // Metadata includes: selectedValues
273
302
  * }
274
303
  * });
304
+ *
305
+ * // With user segmentation
306
+ * argus.trackSelectMenu(interaction, { segment: 'premium' });
275
307
  * ```
276
308
  */
277
- trackSelectMenu(interaction) {
309
+ trackSelectMenu(interaction, options) {
278
310
  this.trackEvent("custom", `select:${interaction.customId}`, {
279
311
  serverId: interaction.guildId || void 0,
280
312
  userId: interaction.user?.id,
313
+ segment: options?.segment,
281
314
  metadata: {
282
315
  interactionType: "select_menu",
283
316
  customId: interaction.customId,
@@ -540,11 +573,11 @@ var Argus = class {
540
573
  * End timing and track the command with latency
541
574
  * Automatically extracts subcommands from the interaction
542
575
  */
543
- endTimer(timerId, interaction) {
576
+ endTimer(timerId, interaction, options) {
544
577
  const startTime = this.commandStartTimes.get(timerId);
545
578
  if (!startTime) {
546
579
  this.log("Timer not found:", timerId);
547
- this.track(interaction);
580
+ this.track(interaction, options);
548
581
  return;
549
582
  }
550
583
  const latencyMs = Date.now() - startTime;
@@ -555,6 +588,7 @@ var Argus = class {
555
588
  this.trackEventWithLatency("command", name, latencyMs, {
556
589
  serverId,
557
590
  userId,
591
+ segment: options?.segment,
558
592
  metadata: {
559
593
  interactionType: interaction.type
560
594
  }
@@ -574,6 +608,7 @@ var Argus = class {
574
608
  ...options?.metadata,
575
609
  latencyMs
576
610
  },
611
+ segment: options?.segment,
577
612
  latencyMs,
578
613
  timestamp: Date.now()
579
614
  };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- var SDK_VERSION = "0.2.2";
2
+ var SDK_VERSION = "0.3.0";
3
3
  function hashString(str) {
4
4
  let hash = 0;
5
5
  for (let i = 0; i < str.length; i++) {
@@ -109,9 +109,12 @@ var Argus = class {
109
109
  * client.on('interactionCreate', (interaction) => {
110
110
  * argus.track(interaction);
111
111
  * });
112
+ *
113
+ * // With user segmentation for premium vs free analytics
114
+ * argus.track(interaction, { segment: user.isPremium ? 'premium' : 'free' });
112
115
  * ```
113
116
  */
114
- track(interaction) {
117
+ track(interaction, options) {
115
118
  if (interaction.customId && !interaction.commandName) {
116
119
  if (Array.isArray(interaction.values)) {
117
120
  return this.trackSelectMenu({
@@ -119,14 +122,14 @@ var Argus = class {
119
122
  values: interaction.values,
120
123
  guildId: interaction.guildId,
121
124
  user: interaction.user
122
- });
125
+ }, options);
123
126
  }
124
127
  return this.trackButton({
125
128
  customId: interaction.customId,
126
129
  guildId: interaction.guildId,
127
130
  user: interaction.user,
128
131
  message: interaction.message
129
- });
132
+ }, options);
130
133
  }
131
134
  const name = extractFullCommandName(interaction);
132
135
  const serverId = interaction.guildId || void 0;
@@ -134,6 +137,7 @@ var Argus = class {
134
137
  this.trackEvent("command", name, {
135
138
  serverId,
136
139
  userId,
140
+ segment: options?.segment,
137
141
  metadata: {
138
142
  interactionType: interaction.type
139
143
  }
@@ -141,6 +145,15 @@ var Argus = class {
141
145
  }
142
146
  /**
143
147
  * Track a custom event
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * // Track with user segment for monetization analytics
152
+ * argus.trackEvent('command', 'gacha', {
153
+ * segment: user.tier, // 'supporter', 'epic', 'legendary'
154
+ * userId: user.id,
155
+ * });
156
+ * ```
144
157
  */
145
158
  trackEvent(type, name, options) {
146
159
  const event = {
@@ -150,6 +163,7 @@ var Argus = class {
150
163
  userId: options?.userId,
151
164
  userHash: options?.userId && this.hashUserIds ? hashString(options.userId) : options?.userId,
152
165
  metadata: options?.metadata,
166
+ segment: options?.segment,
153
167
  timestamp: Date.now()
154
168
  };
155
169
  if (this.hashUserIds) {
@@ -171,10 +185,14 @@ var Argus = class {
171
185
  * // Automatically extracts subcommands: /show profile -> "show profile"
172
186
  * argus.trackCommand(interaction);
173
187
  *
174
- * // Option 2: Pass command name as string
188
+ * // Option 2: With user segmentation for premium vs free analytics
189
+ * argus.trackCommand(interaction, { segment: user.isPremium ? 'premium' : 'free' });
190
+ *
191
+ * // Option 3: Pass command name as string
175
192
  * argus.trackCommand('ban', {
176
193
  * serverId: interaction.guildId,
177
- * userId: interaction.user.id
194
+ * userId: interaction.user.id,
195
+ * segment: 'premium',
178
196
  * });
179
197
  * ```
180
198
  */
@@ -190,6 +208,12 @@ var Argus = class {
190
208
  serverId: commandOrInteraction.guildId || void 0,
191
209
  userId: commandOrInteraction.user?.id
192
210
  };
211
+ } else if (!extractedOptions.serverId && !extractedOptions.userId) {
212
+ extractedOptions = {
213
+ ...extractedOptions,
214
+ serverId: commandOrInteraction.guildId || void 0,
215
+ userId: commandOrInteraction.user?.id
216
+ };
193
217
  }
194
218
  }
195
219
  this.trackEvent("command", commandName, extractedOptions);
@@ -203,6 +227,7 @@ var Argus = class {
203
227
  this.trackEvent("error", errorMessage, {
204
228
  serverId: options?.serverId,
205
229
  userId: options?.userId,
230
+ segment: options?.segment,
206
231
  metadata: {
207
232
  ...options?.metadata,
208
233
  command: options?.command,
@@ -221,12 +246,16 @@ var Argus = class {
221
246
  * // Tracked as: "button:buy_premium"
222
247
  * }
223
248
  * });
249
+ *
250
+ * // With user segmentation
251
+ * argus.trackButton(interaction, { segment: 'premium' });
224
252
  * ```
225
253
  */
226
- trackButton(interaction) {
254
+ trackButton(interaction, options) {
227
255
  this.trackEvent("custom", `button:${interaction.customId}`, {
228
256
  serverId: interaction.guildId || void 0,
229
257
  userId: interaction.user?.id,
258
+ segment: options?.segment,
230
259
  metadata: {
231
260
  interactionType: "button",
232
261
  customId: interaction.customId,
@@ -246,12 +275,16 @@ var Argus = class {
246
275
  * // Metadata includes: selectedValues
247
276
  * }
248
277
  * });
278
+ *
279
+ * // With user segmentation
280
+ * argus.trackSelectMenu(interaction, { segment: 'premium' });
249
281
  * ```
250
282
  */
251
- trackSelectMenu(interaction) {
283
+ trackSelectMenu(interaction, options) {
252
284
  this.trackEvent("custom", `select:${interaction.customId}`, {
253
285
  serverId: interaction.guildId || void 0,
254
286
  userId: interaction.user?.id,
287
+ segment: options?.segment,
255
288
  metadata: {
256
289
  interactionType: "select_menu",
257
290
  customId: interaction.customId,
@@ -514,11 +547,11 @@ var Argus = class {
514
547
  * End timing and track the command with latency
515
548
  * Automatically extracts subcommands from the interaction
516
549
  */
517
- endTimer(timerId, interaction) {
550
+ endTimer(timerId, interaction, options) {
518
551
  const startTime = this.commandStartTimes.get(timerId);
519
552
  if (!startTime) {
520
553
  this.log("Timer not found:", timerId);
521
- this.track(interaction);
554
+ this.track(interaction, options);
522
555
  return;
523
556
  }
524
557
  const latencyMs = Date.now() - startTime;
@@ -529,6 +562,7 @@ var Argus = class {
529
562
  this.trackEventWithLatency("command", name, latencyMs, {
530
563
  serverId,
531
564
  userId,
565
+ segment: options?.segment,
532
566
  metadata: {
533
567
  interactionType: interaction.type
534
568
  }
@@ -548,6 +582,7 @@ var Argus = class {
548
582
  ...options?.metadata,
549
583
  latencyMs
550
584
  },
585
+ segment: options?.segment,
551
586
  latencyMs,
552
587
  timestamp: Date.now()
553
588
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argus-discord-analytics",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "The all-seeing analytics SDK for Discord bots - track commands, errors, servers, and more",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",