commandkit 1.0.0-dev.20250605125234 → 1.0.0-dev.20250605142146
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/analytics.cjs +21 -0
- package/analytics.d.ts +9 -0
- package/dist/{CommandKit-LJlFFidn.d.ts → CommandKit-CEFWQpDo.d.ts} +31 -2
- package/dist/{CommandKit-O_Ra_xRL.js → CommandKit-DKSB7WUZ.js} +158 -10
- package/dist/CommandKit-DKSB7WUZ.js.map +1 -0
- package/dist/CommandKit.d.ts +1 -1
- package/dist/CommandKit.js +9 -8
- package/dist/{CommandKitEventsChannel-BnSPcFdq.js → CommandKitEventsChannel-B6LKgxmv.js} +1 -1
- package/dist/{CommandKitEventsChannel-BnSPcFdq.js.map → CommandKitEventsChannel-B6LKgxmv.js.map} +1 -1
- package/dist/{CommandsRouter-B91EHi6O.js → CommandsRouter-BHaPno8o.js} +1 -1
- package/dist/{CommandsRouter-B91EHi6O.js.map → CommandsRouter-BHaPno8o.js.map} +1 -1
- package/dist/EventWorkerContext-BAKiTqJz.js.map +1 -1
- package/dist/{EventWorkerContext-sHV9x0eB.d.ts → EventWorkerContext-Dk7c6sRe.d.ts} +3 -2
- package/dist/{EventsRouter-C_J0M3uO.js → EventsRouter-CqnrlbjN.js} +1 -1
- package/dist/{EventsRouter-C_J0M3uO.js.map → EventsRouter-CqnrlbjN.js.map} +1 -1
- package/dist/analytics/analytics-engine.d.ts +32 -0
- package/dist/analytics/analytics-engine.js +38 -0
- package/dist/analytics/analytics-provider.d.ts +32 -0
- package/dist/analytics/constants.d.ts +12 -0
- package/dist/analytics/constants.js +4 -0
- package/dist/analytics/utils.d.ts +6 -0
- package/dist/analytics/utils.js +39 -0
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +9 -8
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +9 -8
- package/dist/app/commands/helpers.js +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +2 -2
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +9 -8
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +9 -8
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +11 -10
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +9 -8
- package/dist/app/router/CommandsRouter.js +1 -1
- package/dist/app/router/EventsRouter.js +1 -1
- package/dist/app/router/index.js +3 -3
- package/dist/{app-process-DGKqfi5y.js → app-process-YbSHvqf-.js} +3 -3
- package/dist/{app-process-DGKqfi5y.js.map → app-process-YbSHvqf-.js.map} +1 -1
- package/dist/{build-CTiPICEJ.js → build-DIRQN8GJ.js} +5 -5
- package/dist/{build-CTiPICEJ.js.map → build-DIRQN8GJ.js.map} +1 -1
- package/dist/cli/app-process.js +4 -4
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/build.js +12 -11
- package/dist/cli/common.d.ts +3 -3
- package/dist/cli/common.js +2 -2
- package/dist/cli/development.js +13 -12
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js +1 -1
- package/dist/cli/generators.js +2 -2
- package/dist/cli/information.js +2 -1
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.js +10 -9
- package/dist/cli/production.js +14 -13
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +3 -3
- package/dist/cli/utils.js +1 -1
- package/dist/{common-CoUM9Czx.js → common-CW8v7gAn.js} +2 -2
- package/dist/{common-CoUM9Czx.js.map → common-CW8v7gAn.js.map} +1 -1
- package/dist/components/index.js +9 -8
- package/dist/components/v1/button/Button.js +9 -8
- package/dist/components/v1/button/ButtonKit.js +9 -8
- package/dist/components/v1/modal/Modal.js +9 -8
- package/dist/components/v1/modal/ModalKit.js +9 -8
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +9 -8
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +9 -8
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +9 -8
- package/dist/components/v1/select-menu/SelectMenu.js +9 -8
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +9 -8
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +9 -8
- package/dist/config/config.d.ts +4 -4
- package/dist/config/config.js +9 -8
- package/dist/config/default.d.ts +3 -3
- package/dist/config/default.js +9 -8
- package/dist/config/loader.d.ts +3 -3
- package/dist/config/loader.js +9 -8
- package/dist/config/types.d.ts +2 -2
- package/dist/config/utils.d.ts +3 -3
- package/dist/{config-bs6v9gyT.d.ts → config-BX3KH7XB.d.ts} +3 -3
- package/dist/constants-Do7znYzW.js +26 -0
- package/dist/constants-Do7znYzW.js.map +1 -0
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +9 -8
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +9 -8
- package/dist/{env-D3rn_eei.js → env-ERkaRfQO.js} +1 -1
- package/dist/{env-D3rn_eei.js.map → env-ERkaRfQO.js.map} +1 -1
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.js +1 -1
- package/dist/{feature-flags-BXVYbfWD.js → feature-flags-DpEniib-.js} +29 -3
- package/dist/feature-flags-DpEniib-.js.map +1 -0
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +10 -9
- package/dist/flags/store.d.ts +1 -1
- package/dist/flags/store.js +1 -1
- package/dist/{helpers-blGYXnUH.js → helpers-CswC9gKF.js} +1 -1
- package/dist/{helpers-blGYXnUH.js.map → helpers-CswC9gKF.js.map} +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/dist/{init-B0Ot1AgJ.js → init-BYIeA5Nh.js} +4 -4
- package/dist/{init-B0Ot1AgJ.js.map → init-BYIeA5Nh.js.map} +1 -1
- package/dist/logger/DefaultLogger.js +9 -8
- package/dist/logger/ILogger.js +1 -1
- package/dist/logger/Logger.js +9 -8
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +9 -8
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +9 -8
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +9 -8
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +9 -8
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/router-Dn35v30f.js +0 -0
- package/dist/{store-B9bo6On8.js → store-Ci6ib2C9.js} +1 -1
- package/dist/{store-B9bo6On8.js.map → store-Ci6ib2C9.js.map} +1 -1
- package/dist/{type-checker-FHABnKlq.js → type-checker-CXVdS7qc.js} +2 -2
- package/dist/{type-checker-FHABnKlq.js.map → type-checker-CXVdS7qc.js.map} +1 -1
- package/dist/{types--Jq7UV8B.d.ts → types-DFaFI0H7.d.ts} +2 -2
- package/dist/{types-package-B0Z-xrbB.js → types-package-CTSNSM93.js} +1 -1
- package/dist/{types-package-B0Z-xrbB.js.map → types-package-CTSNSM93.js.map} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{utilities-DpA7EalK.d.ts → utilities-DQT4lzAB.d.ts} +14 -2
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +9 -8
- package/dist/utils/types-package.js +1 -1
- package/dist/utils/utilities.d.ts +2 -2
- package/dist/utils/utilities.js +11 -8
- package/dist/{utils-BJAW-jcv.d.ts → utils-DOSJ2rn3.d.ts} +2 -2
- package/dist/{utils-CU2bkxji.js → utils-IYtoeTur.js} +1 -1
- package/dist/{utils-CU2bkxji.js.map → utils-IYtoeTur.js.map} +1 -1
- package/dist/{version-DexUmgnc.js → version-jzaJoR_o.js} +2 -2
- package/dist/{version-DexUmgnc.js.map → version-jzaJoR_o.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +10 -3
- package/dist/CommandKit-O_Ra_xRL.js.map +0 -1
- package/dist/feature-flags-BXVYbfWD.js.map +0 -1
- /package/dist/{ILogger-dQ7Y9X1f.js → ILogger-DucYb0bG.js} +0 -0
- /package/dist/{app-HN1cVg8J.js → analytics/analytics-provider.js} +0 -0
- /package/dist/{router-DHnFRADH.js → app-CXCbKsPz.js} +0 -0
package/analytics.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { getCommandKit } = require('./dist/context/async-context.js');
|
|
2
|
+
const { AnalyticsEngine } = require('./dist/analytics/analytics-engine.js');
|
|
3
|
+
const { noAnalytics } = require('./dist/analytics/utils.js');
|
|
4
|
+
const { AnalyticsEvents } = require('./dist/analytics/constants.js');
|
|
5
|
+
|
|
6
|
+
function useAnalytics() {
|
|
7
|
+
const commandkit = getCommandKit(true);
|
|
8
|
+
return commandkit.analytics;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function track(event) {
|
|
12
|
+
return useAnalytics().track(event);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
AnalyticsEvents,
|
|
17
|
+
AnalyticsEngine,
|
|
18
|
+
useAnalytics,
|
|
19
|
+
noAnalytics,
|
|
20
|
+
track,
|
|
21
|
+
};
|
package/analytics.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnalyticsEngine } from './dist/analytics/analytics-engine';
|
|
2
|
+
|
|
3
|
+
export * from './dist/analytics/analytics-engine';
|
|
4
|
+
export * from './dist/analytics/analytics-provider';
|
|
5
|
+
export { noAnalytics } from './dist/analytics/utils';
|
|
6
|
+
export { AnalyticsEvents } from './dist/analytics/constants';
|
|
7
|
+
|
|
8
|
+
export function useAnalytics(): AnalyticsEngine;
|
|
9
|
+
export function track(event: AnalyticsEvent): Promise<void>;
|
|
@@ -808,6 +808,7 @@ interface FlagRunner<E, R> {
|
|
|
808
808
|
}
|
|
809
809
|
declare class FeatureFlag<R, T> {
|
|
810
810
|
readonly options: FeatureFlagDefinition<R, T>;
|
|
811
|
+
private commandkit;
|
|
811
812
|
constructor(options: FeatureFlagDefinition<R, T>);
|
|
812
813
|
private getContext;
|
|
813
814
|
execute(res?: T): Promise<R>;
|
|
@@ -817,6 +818,33 @@ declare function flag<Returns = boolean, Entity = Record<any, any>>(options: Fea
|
|
|
817
818
|
//#region src/flags/store.d.ts
|
|
818
819
|
declare class FlagStore extends Collection<string, FeatureFlag<any, any>> {}
|
|
819
820
|
//#endregion
|
|
821
|
+
//#region src/analytics/analytics-provider.d.ts
|
|
822
|
+
interface AnalyticsEvent {
|
|
823
|
+
name: string;
|
|
824
|
+
id?: string;
|
|
825
|
+
data: Record<string, any>;
|
|
826
|
+
}
|
|
827
|
+
type IdentifyEvent = Record<string, any>;
|
|
828
|
+
interface AnalyticsProvider {
|
|
829
|
+
readonly name: string;
|
|
830
|
+
track(engine: AnalyticsEngine, event: AnalyticsEvent): Promise<void>;
|
|
831
|
+
identify?(engine: AnalyticsEngine, event: IdentifyEvent): Promise<void>;
|
|
832
|
+
}
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region src/analytics/analytics-engine.d.ts
|
|
835
|
+
type FilterFunction = (engine: AnalyticsEngine, event: AnalyticsEvent) => boolean;
|
|
836
|
+
declare class AnalyticsEngine {
|
|
837
|
+
#private;
|
|
838
|
+
readonly commandkit: CommandKit;
|
|
839
|
+
constructor(commandkit: CommandKit);
|
|
840
|
+
setFilter(filter: FilterFunction | null): void;
|
|
841
|
+
registerProvider(provider: AnalyticsProvider): void;
|
|
842
|
+
removeProvider(provider: AnalyticsProvider): void;
|
|
843
|
+
getProvider(): AnalyticsProvider | null;
|
|
844
|
+
identify(event: IdentifyEvent): Promise<void>;
|
|
845
|
+
track(event: AnalyticsEvent): Promise<void>;
|
|
846
|
+
}
|
|
847
|
+
//#endregion
|
|
820
848
|
//#region src/CommandKit.d.ts
|
|
821
849
|
interface CommandKitConfiguration {
|
|
822
850
|
defaultLocale: Locale;
|
|
@@ -865,6 +893,7 @@ declare class CommandKit extends EventEmitter {
|
|
|
865
893
|
eventHandler: AppEventsHandler;
|
|
866
894
|
plugins: CommandKitPluginRuntime;
|
|
867
895
|
events: CommandKitEventsChannel;
|
|
896
|
+
analytics: AnalyticsEngine;
|
|
868
897
|
static instance: CommandKit | undefined;
|
|
869
898
|
/**
|
|
870
899
|
* Create a new command and event handler with CommandKit.
|
|
@@ -932,5 +961,5 @@ declare class CommandKit extends EventEmitter {
|
|
|
932
961
|
}
|
|
933
962
|
declare const commandkit: CommandKit;
|
|
934
963
|
//#endregion
|
|
935
|
-
export { AnyCommandExecute, AppCommandHandler, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FlagRunner, FlagStore, GenericFunction, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, useEnvironment };
|
|
936
|
-
//# sourceMappingURL=CommandKit-
|
|
964
|
+
export { AnalyticsEngine, AnalyticsEvent, AnalyticsProvider, AnyCommandExecute, AppCommandHandler, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FilterFunction, FlagRunner, FlagStore, GenericFunction, IdentifyEvent, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, useEnvironment };
|
|
965
|
+
//# sourceMappingURL=CommandKit-CEFWQpDo.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
2
|
const require_colors = require('./colors-Cd4Oz-r-.js');
|
|
3
3
|
const require_error_codes = require('./error-codes-C_UO39jz.js');
|
|
4
|
+
const require_warn_unstable = require('./warn-unstable-DHLaxPC8.js');
|
|
4
5
|
const require_element = require('./element-DcqNz1dV.js');
|
|
5
6
|
const require_EventInterceptor = require('./EventInterceptor-Bvh05z7n.js');
|
|
6
7
|
const require_constants = require('./constants-CCqS_v55.js');
|
|
@@ -10,12 +11,13 @@ const require_EventWorkerContext = require('./EventWorkerContext-BAKiTqJz.js');
|
|
|
10
11
|
const require_resolve_file_url = require('./resolve-file-url-ifwdwqmq.js');
|
|
11
12
|
const require_MessageCommandParser = require('./MessageCommandParser-D02-wpZN.js');
|
|
12
13
|
const require_signals = require('./signals-scJdEbly.js');
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
14
|
+
const require_constants$1 = require('./constants-Do7znYzW.js');
|
|
15
|
+
const require_types_package = require('./types-package-CTSNSM93.js');
|
|
16
|
+
const require_CommandsRouter = require('./CommandsRouter-BHaPno8o.js');
|
|
17
|
+
const require_EventsRouter = require('./EventsRouter-CqnrlbjN.js');
|
|
18
|
+
const require_common = require('./common-CW8v7gAn.js');
|
|
19
|
+
const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-B6LKgxmv.js');
|
|
20
|
+
const require_store = require('./store-Ci6ib2C9.js');
|
|
19
21
|
const node_events = require_chunk.__toESM(require("node:events"));
|
|
20
22
|
const discord_js = require_chunk.__toESM(require("discord.js"));
|
|
21
23
|
const node_async_hooks = require_chunk.__toESM(require("node:async_hooks"));
|
|
@@ -1420,6 +1422,28 @@ function debounce(fn, ms) {
|
|
|
1420
1422
|
};
|
|
1421
1423
|
}
|
|
1422
1424
|
/**
|
|
1425
|
+
* Defers the execution of a function.
|
|
1426
|
+
* @param fn The function to defer.
|
|
1427
|
+
*/
|
|
1428
|
+
function defer(fn, timeout = 0) {
|
|
1429
|
+
setTimeout(() => {
|
|
1430
|
+
return fn();
|
|
1431
|
+
}, timeout).unref();
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Serializes a value to JSON.
|
|
1435
|
+
* @param value The value to serialize.
|
|
1436
|
+
* @param defaultValue The default value to return if the value is not serializable.
|
|
1437
|
+
* @returns The serialized value.
|
|
1438
|
+
*/
|
|
1439
|
+
function JsonSerialize(value, defaultValue = {}) {
|
|
1440
|
+
try {
|
|
1441
|
+
return JSON.parse(JSON.stringify(value));
|
|
1442
|
+
} catch {
|
|
1443
|
+
return defaultValue;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1423
1447
|
* Creates a function from the given function that runs only in development mode.
|
|
1424
1448
|
* @param fn The function to run in development mode.
|
|
1425
1449
|
* @returns The function that runs only in development mode.
|
|
@@ -2141,18 +2165,39 @@ var AppCommandRunner = class {
|
|
|
2141
2165
|
const targetData = prepared.command.data;
|
|
2142
2166
|
const fn = targetData[executionMode];
|
|
2143
2167
|
if (!fn) Logger.warn(`Command ${prepared.command.command.name} has no handler for ${executionMode}`);
|
|
2168
|
+
const analytics = commandkit$1.analytics;
|
|
2144
2169
|
if (fn) try {
|
|
2145
2170
|
const _executeCommand = makeContextAwareFunction(env, async () => {
|
|
2146
|
-
env.registerDeferredFunction((env$1) => {
|
|
2171
|
+
env.registerDeferredFunction(async (env$1) => {
|
|
2172
|
+
var _prepared$command2;
|
|
2147
2173
|
env$1.markEnd();
|
|
2148
2174
|
const error = env$1.getExecutionError();
|
|
2149
2175
|
const marker = env$1.getMarker();
|
|
2150
2176
|
const time = `${env$1.getExecutionTime().toFixed(2)}ms`;
|
|
2151
2177
|
if (error) {
|
|
2178
|
+
var _prepared$command;
|
|
2152
2179
|
Logger.error(`[${marker} - ${time}] Error executing command: ${error.stack || error}`);
|
|
2180
|
+
await analytics.track({
|
|
2181
|
+
name: require_constants$1.AnalyticsEvents.COMMAND_EXECUTION,
|
|
2182
|
+
id: ((_prepared$command = prepared.command) === null || _prepared$command === void 0 || (_prepared$command = _prepared$command.data) === null || _prepared$command === void 0 || (_prepared$command = _prepared$command.command) === null || _prepared$command === void 0 ? void 0 : _prepared$command.name) ?? prepared.command.command.name,
|
|
2183
|
+
data: {
|
|
2184
|
+
error: true,
|
|
2185
|
+
executionTime: env$1.getExecutionTime().toFixed(2),
|
|
2186
|
+
type: executionMode
|
|
2187
|
+
}
|
|
2188
|
+
});
|
|
2153
2189
|
return;
|
|
2154
2190
|
}
|
|
2155
2191
|
Logger.info(`[${marker} - ${time}] Command executed successfully`);
|
|
2192
|
+
await analytics.track({
|
|
2193
|
+
name: require_constants$1.AnalyticsEvents.COMMAND_EXECUTION,
|
|
2194
|
+
id: ((_prepared$command2 = prepared.command) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.data) === null || _prepared$command2 === void 0 || (_prepared$command2 = _prepared$command2.command) === null || _prepared$command2 === void 0 ? void 0 : _prepared$command2.name) ?? prepared.command.command.name,
|
|
2195
|
+
data: {
|
|
2196
|
+
error: false,
|
|
2197
|
+
executionTime: env$1.getExecutionTime().toFixed(2),
|
|
2198
|
+
type: executionMode
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2156
2201
|
});
|
|
2157
2202
|
return fn(ctx.clone());
|
|
2158
2203
|
}, this.#finalizer.bind(this));
|
|
@@ -2570,7 +2615,8 @@ var AppEventsHandler = class {
|
|
|
2570
2615
|
namespace: namespace ?? null,
|
|
2571
2616
|
data: data.event,
|
|
2572
2617
|
commandkit: this.commandkit,
|
|
2573
|
-
arguments: args
|
|
2618
|
+
arguments: args,
|
|
2619
|
+
variables: /* @__PURE__ */ new Map()
|
|
2574
2620
|
}, async () => {
|
|
2575
2621
|
for (const listener of onListeners) try {
|
|
2576
2622
|
await listener.handler(...args);
|
|
@@ -2609,7 +2655,8 @@ var AppEventsHandler = class {
|
|
|
2609
2655
|
namespace: namespace ?? null,
|
|
2610
2656
|
data: data.event,
|
|
2611
2657
|
commandkit: this.commandkit,
|
|
2612
|
-
arguments: args
|
|
2658
|
+
arguments: args,
|
|
2659
|
+
variables: /* @__PURE__ */ new Map()
|
|
2613
2660
|
}, async () => {
|
|
2614
2661
|
try {
|
|
2615
2662
|
if (executedOnceListeners.has(listener.handler)) return;
|
|
@@ -2744,6 +2791,75 @@ function registerDevHooks(commandkit$1) {
|
|
|
2744
2791
|
});
|
|
2745
2792
|
}
|
|
2746
2793
|
|
|
2794
|
+
//#endregion
|
|
2795
|
+
//#region src/analytics/utils.ts
|
|
2796
|
+
function getVariableStore() {
|
|
2797
|
+
const ctx = getContext();
|
|
2798
|
+
if (!ctx) try {
|
|
2799
|
+
const eventContext = require_EventWorkerContext.getEventWorkerContext();
|
|
2800
|
+
return eventContext.variables;
|
|
2801
|
+
} catch {
|
|
2802
|
+
return null;
|
|
2803
|
+
}
|
|
2804
|
+
return ctx.variables;
|
|
2805
|
+
}
|
|
2806
|
+
function getDoNotTrack() {
|
|
2807
|
+
const variables = getVariableStore();
|
|
2808
|
+
return (variables === null || variables === void 0 ? void 0 : variables.get(require_constants$1.DO_NOT_TRACK_KEY)) === true;
|
|
2809
|
+
}
|
|
2810
|
+
function noAnalytics() {
|
|
2811
|
+
const variables = getVariableStore();
|
|
2812
|
+
if (!variables) throw new Error("noAnalytics may only be used inside commandkit context");
|
|
2813
|
+
variables.set(require_constants$1.DO_NOT_TRACK_KEY, true);
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region src/analytics/analytics-engine.ts
|
|
2818
|
+
var AnalyticsEngine = class {
|
|
2819
|
+
#provider = null;
|
|
2820
|
+
#filter = null;
|
|
2821
|
+
constructor(commandkit$1) {
|
|
2822
|
+
this.commandkit = commandkit$1;
|
|
2823
|
+
}
|
|
2824
|
+
setFilter(filter) {
|
|
2825
|
+
this.#filter = filter;
|
|
2826
|
+
}
|
|
2827
|
+
registerProvider(provider) {
|
|
2828
|
+
require_warn_unstable.warnUnstable("analytics");
|
|
2829
|
+
this.#provider = provider;
|
|
2830
|
+
}
|
|
2831
|
+
removeProvider(provider) {
|
|
2832
|
+
if (this.#provider === provider) this.#provider = null;
|
|
2833
|
+
}
|
|
2834
|
+
getProvider() {
|
|
2835
|
+
return this.#provider;
|
|
2836
|
+
}
|
|
2837
|
+
async identify(event) {
|
|
2838
|
+
if (!this.#provider) return;
|
|
2839
|
+
try {
|
|
2840
|
+
var _identify, _ref;
|
|
2841
|
+
await ((_identify = (_ref = this.#provider).identify) === null || _identify === void 0 ? void 0 : _identify.call(_ref, this, event));
|
|
2842
|
+
} catch (error) {
|
|
2843
|
+
Logger.error(`Error identifying with provider ${this.#provider.name}`, error);
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
async track(event) {
|
|
2847
|
+
if (!this.#provider) return;
|
|
2848
|
+
try {
|
|
2849
|
+
if (await this.#doNotTrack(event)) return;
|
|
2850
|
+
await this.#provider.track(this, event);
|
|
2851
|
+
} catch (error) {
|
|
2852
|
+
Logger.error(`Error tracking ${event.name} event with provider ${this.#provider.name}`, error);
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
async #doNotTrack(event) {
|
|
2856
|
+
const dnt = getDoNotTrack();
|
|
2857
|
+
if (dnt) return true;
|
|
2858
|
+
if (this.#filter) return this.#filter(this, event);
|
|
2859
|
+
return false;
|
|
2860
|
+
}
|
|
2861
|
+
};
|
|
2862
|
+
|
|
2747
2863
|
//#endregion
|
|
2748
2864
|
//#region src/CommandKit.ts
|
|
2749
2865
|
const bootstrapHooks = /* @__PURE__ */ new Set();
|
|
@@ -2799,6 +2915,7 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2799
2915
|
eventHandler;
|
|
2800
2916
|
plugins;
|
|
2801
2917
|
events;
|
|
2918
|
+
analytics;
|
|
2802
2919
|
static instance = void 0;
|
|
2803
2920
|
/**
|
|
2804
2921
|
* Create a new command and event handler with CommandKit.
|
|
@@ -2812,6 +2929,7 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2812
2929
|
if (!CommandKit.instance) CommandKit.instance = this;
|
|
2813
2930
|
if (options === null || options === void 0 ? void 0 : options.client) this.setClient(options.client);
|
|
2814
2931
|
this.plugins = new CommandKitPluginRuntime(this);
|
|
2932
|
+
this.analytics = new AnalyticsEngine(this);
|
|
2815
2933
|
this.#bootstrapHooks();
|
|
2816
2934
|
}
|
|
2817
2935
|
async #bootstrapHooks() {
|
|
@@ -2999,6 +3117,12 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2999
3117
|
const commandkit = CommandKit.instance || new CommandKit();
|
|
3000
3118
|
|
|
3001
3119
|
//#endregion
|
|
3120
|
+
Object.defineProperty(exports, 'AnalyticsEngine', {
|
|
3121
|
+
enumerable: true,
|
|
3122
|
+
get: function () {
|
|
3123
|
+
return AnalyticsEngine;
|
|
3124
|
+
}
|
|
3125
|
+
});
|
|
3002
3126
|
Object.defineProperty(exports, 'AppCommandHandler', {
|
|
3003
3127
|
enumerable: true,
|
|
3004
3128
|
get: function () {
|
|
@@ -3095,6 +3219,12 @@ Object.defineProperty(exports, 'DefaultLogger', {
|
|
|
3095
3219
|
return DefaultLogger;
|
|
3096
3220
|
}
|
|
3097
3221
|
});
|
|
3222
|
+
Object.defineProperty(exports, 'JsonSerialize', {
|
|
3223
|
+
enumerable: true,
|
|
3224
|
+
get: function () {
|
|
3225
|
+
return JsonSerialize;
|
|
3226
|
+
}
|
|
3227
|
+
});
|
|
3098
3228
|
Object.defineProperty(exports, 'Logger', {
|
|
3099
3229
|
enumerable: true,
|
|
3100
3230
|
get: function () {
|
|
@@ -3245,6 +3375,12 @@ Object.defineProperty(exports, 'defaultConfig', {
|
|
|
3245
3375
|
return defaultConfig;
|
|
3246
3376
|
}
|
|
3247
3377
|
});
|
|
3378
|
+
Object.defineProperty(exports, 'defer', {
|
|
3379
|
+
enumerable: true,
|
|
3380
|
+
get: function () {
|
|
3381
|
+
return defer;
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3248
3384
|
Object.defineProperty(exports, 'defineConfig', {
|
|
3249
3385
|
enumerable: true,
|
|
3250
3386
|
get: function () {
|
|
@@ -3293,6 +3429,12 @@ Object.defineProperty(exports, 'getCurrentDirectory', {
|
|
|
3293
3429
|
return getCurrentDirectory;
|
|
3294
3430
|
}
|
|
3295
3431
|
});
|
|
3432
|
+
Object.defineProperty(exports, 'getDoNotTrack', {
|
|
3433
|
+
enumerable: true,
|
|
3434
|
+
get: function () {
|
|
3435
|
+
return getDoNotTrack;
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3296
3438
|
Object.defineProperty(exports, 'getPossibleConfigPaths', {
|
|
3297
3439
|
enumerable: true,
|
|
3298
3440
|
get: function () {
|
|
@@ -3323,6 +3465,12 @@ Object.defineProperty(exports, 'makeContextAwareFunction', {
|
|
|
3323
3465
|
return makeContextAwareFunction;
|
|
3324
3466
|
}
|
|
3325
3467
|
});
|
|
3468
|
+
Object.defineProperty(exports, 'noAnalytics', {
|
|
3469
|
+
enumerable: true,
|
|
3470
|
+
get: function () {
|
|
3471
|
+
return noAnalytics;
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3326
3474
|
Object.defineProperty(exports, 'onApplicationBootstrap', {
|
|
3327
3475
|
enumerable: true,
|
|
3328
3476
|
get: function () {
|
|
@@ -3359,4 +3507,4 @@ Object.defineProperty(exports, 'useEnvironment', {
|
|
|
3359
3507
|
return useEnvironment;
|
|
3360
3508
|
}
|
|
3361
3509
|
});
|
|
3362
|
-
//# sourceMappingURL=CommandKit-
|
|
3510
|
+
//# sourceMappingURL=CommandKit-DKSB7WUZ.js.map
|