commandkit 1.0.0-dev.20250605125234 → 1.0.0-dev.20250605135449
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 +19 -0
- package/analytics.d.ts +8 -0
- package/dist/{CommandKit-LJlFFidn.d.ts → CommandKit-CEFWQpDo.d.ts} +31 -2
- package/dist/{CommandKit-O_Ra_xRL.js → CommandKit-CrZN2bV4.js} +130 -3
- package/dist/CommandKit-CrZN2bV4.js.map +1 -0
- package/dist/CommandKit.d.ts +1 -1
- package/dist/CommandKit.js +2 -1
- package/dist/EventWorkerContext-BAKiTqJz.js.map +1 -1
- package/dist/{EventWorkerContext-sHV9x0eB.d.ts → EventWorkerContext-Dk7c6sRe.d.ts} +3 -2
- 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 +5 -0
- package/dist/analytics/constants.js +3 -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 +2 -1
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +2 -1
- 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 +2 -1
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +2 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +4 -3
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +2 -1
- package/dist/app-CXCbKsPz.js +0 -0
- package/dist/{app-process-DGKqfi5y.js → app-process-WKSL23sj.js} +2 -2
- package/dist/{app-process-DGKqfi5y.js.map → app-process-WKSL23sj.js.map} +1 -1
- package/dist/{build-CTiPICEJ.js → build-BXBmyQOl.js} +4 -4
- package/dist/{build-CTiPICEJ.js.map → build-BXBmyQOl.js.map} +1 -1
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/app-process.js +2 -2
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/build.js +5 -4
- package/dist/cli/common.d.ts +5 -5
- package/dist/cli/development.js +6 -5
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js +1 -1
- package/dist/cli/information.js +2 -1
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/production.d.ts +2 -2
- package/dist/cli/production.js +7 -6
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +1 -1
- package/dist/cli/utils.js +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/v1/button/Button.js +2 -1
- package/dist/components/v1/button/ButtonKit.js +2 -1
- package/dist/components/v1/modal/Modal.js +2 -1
- package/dist/components/v1/modal/ModalKit.js +2 -1
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +2 -1
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +2 -1
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +2 -1
- package/dist/components/v1/select-menu/SelectMenu.js +2 -1
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +2 -1
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +2 -1
- package/dist/config/config.d.ts +4 -4
- package/dist/config/config.js +2 -1
- package/dist/config/default.d.ts +3 -3
- package/dist/config/default.js +2 -1
- package/dist/config/loader.d.ts +3 -3
- package/dist/config/loader.js +2 -1
- 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-CKVeDN4e.js +14 -0
- package/dist/constants-CKVeDN4e.js.map +1 -0
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +2 -1
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +2 -1
- 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/{feature-flags-BXVYbfWD.js → feature-flags-hv18wT96.js} +29 -3
- package/dist/feature-flags-hv18wT96.js.map +1 -0
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +3 -2
- package/dist/flags/store.d.ts +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 +8 -7
- package/dist/index.js.map +1 -1
- package/dist/{init-CEa28dgv.d.ts → init-CT348Okf.d.ts} +3 -3
- package/dist/{init-B0Ot1AgJ.js → init-DRva1YJD.js} +2 -2
- package/dist/{init-B0Ot1AgJ.js.map → init-DRva1YJD.js.map} +1 -1
- package/dist/logger/DefaultLogger.js +2 -1
- package/dist/logger/ILogger.js +1 -1
- package/dist/logger/Logger.js +2 -1
- 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 +2 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -1
- 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 +2 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -1
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/{type-checker-FHABnKlq.js → type-checker-CfABUuLM.js} +1 -1
- package/dist/{type-checker-FHABnKlq.js.map → type-checker-CfABUuLM.js.map} +1 -1
- package/dist/{types--Jq7UV8B.d.ts → types-DFaFI0H7.d.ts} +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/{utilities-DpA7EalK.d.ts → utilities-DQT4lzAB.d.ts} +14 -2
- package/dist/utils/colors.d.ts +2 -2
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +2 -1
- package/dist/utils/utilities.d.ts +2 -2
- package/dist/utils/utilities.js +4 -1
- 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-qguTa2LR.js} +2 -2
- package/dist/{version-DexUmgnc.js.map → version-qguTa2LR.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/analytics.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { getCommandKit } = require('./dist/CommandKit-CykDrHnK.js');
|
|
2
|
+
const { AnalyticsEngine } = require('./dist/analytics/analytics-engine.js');
|
|
3
|
+
const { noAnalytics } = require('./dist/analytics/utils.js');
|
|
4
|
+
|
|
5
|
+
function useAnalytics() {
|
|
6
|
+
const commandkit = getCommandKit(true);
|
|
7
|
+
return commandkit.analytics;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function track(event) {
|
|
11
|
+
return useAnalytics().track(event);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
AnalyticsEngine,
|
|
16
|
+
useAnalytics,
|
|
17
|
+
noAnalytics,
|
|
18
|
+
track,
|
|
19
|
+
};
|
package/analytics.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnalyticsEngine } from './dist/CommandKit-CykDrHnK';
|
|
2
|
+
|
|
3
|
+
export * from './dist/analytics/analytics-engine';
|
|
4
|
+
export * from './dist/analytics/analytics-provider';
|
|
5
|
+
export { noAnalytics } from './dist/analytics/utils';
|
|
6
|
+
|
|
7
|
+
export function useAnalytics(): AnalyticsEngine;
|
|
8
|
+
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');
|
|
@@ -16,6 +17,7 @@ const require_EventsRouter = require('./EventsRouter-C_J0M3uO.js');
|
|
|
16
17
|
const require_common = require('./common-CoUM9Czx.js');
|
|
17
18
|
const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-BnSPcFdq.js');
|
|
18
19
|
const require_store = require('./store-B9bo6On8.js');
|
|
20
|
+
const require_constants$1 = require('./constants-CKVeDN4e.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.
|
|
@@ -2570,7 +2594,8 @@ var AppEventsHandler = class {
|
|
|
2570
2594
|
namespace: namespace ?? null,
|
|
2571
2595
|
data: data.event,
|
|
2572
2596
|
commandkit: this.commandkit,
|
|
2573
|
-
arguments: args
|
|
2597
|
+
arguments: args,
|
|
2598
|
+
variables: /* @__PURE__ */ new Map()
|
|
2574
2599
|
}, async () => {
|
|
2575
2600
|
for (const listener of onListeners) try {
|
|
2576
2601
|
await listener.handler(...args);
|
|
@@ -2609,7 +2634,8 @@ var AppEventsHandler = class {
|
|
|
2609
2634
|
namespace: namespace ?? null,
|
|
2610
2635
|
data: data.event,
|
|
2611
2636
|
commandkit: this.commandkit,
|
|
2612
|
-
arguments: args
|
|
2637
|
+
arguments: args,
|
|
2638
|
+
variables: /* @__PURE__ */ new Map()
|
|
2613
2639
|
}, async () => {
|
|
2614
2640
|
try {
|
|
2615
2641
|
if (executedOnceListeners.has(listener.handler)) return;
|
|
@@ -2744,6 +2770,75 @@ function registerDevHooks(commandkit$1) {
|
|
|
2744
2770
|
});
|
|
2745
2771
|
}
|
|
2746
2772
|
|
|
2773
|
+
//#endregion
|
|
2774
|
+
//#region src/analytics/utils.ts
|
|
2775
|
+
function getVariableStore() {
|
|
2776
|
+
const ctx = getContext();
|
|
2777
|
+
if (!ctx) try {
|
|
2778
|
+
const eventContext = require_EventWorkerContext.getEventWorkerContext();
|
|
2779
|
+
return eventContext.variables;
|
|
2780
|
+
} catch {
|
|
2781
|
+
return null;
|
|
2782
|
+
}
|
|
2783
|
+
return ctx.variables;
|
|
2784
|
+
}
|
|
2785
|
+
function getDoNotTrack() {
|
|
2786
|
+
const variables = getVariableStore();
|
|
2787
|
+
return (variables === null || variables === void 0 ? void 0 : variables.get(require_constants$1.DO_NOT_TRACK_KEY)) === true;
|
|
2788
|
+
}
|
|
2789
|
+
function noAnalytics() {
|
|
2790
|
+
const variables = getVariableStore();
|
|
2791
|
+
if (!variables) throw new Error("noAnalytics may only be used inside commandkit context");
|
|
2792
|
+
variables.set(require_constants$1.DO_NOT_TRACK_KEY, true);
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
//#endregion
|
|
2796
|
+
//#region src/analytics/analytics-engine.ts
|
|
2797
|
+
var AnalyticsEngine = class {
|
|
2798
|
+
#provider = null;
|
|
2799
|
+
#filter = null;
|
|
2800
|
+
constructor(commandkit$1) {
|
|
2801
|
+
this.commandkit = commandkit$1;
|
|
2802
|
+
}
|
|
2803
|
+
setFilter(filter) {
|
|
2804
|
+
this.#filter = filter;
|
|
2805
|
+
}
|
|
2806
|
+
registerProvider(provider) {
|
|
2807
|
+
require_warn_unstable.warnUnstable("analytics");
|
|
2808
|
+
this.#provider = provider;
|
|
2809
|
+
}
|
|
2810
|
+
removeProvider(provider) {
|
|
2811
|
+
if (this.#provider === provider) this.#provider = null;
|
|
2812
|
+
}
|
|
2813
|
+
getProvider() {
|
|
2814
|
+
return this.#provider;
|
|
2815
|
+
}
|
|
2816
|
+
async identify(event) {
|
|
2817
|
+
if (!this.#provider) return;
|
|
2818
|
+
try {
|
|
2819
|
+
var _identify, _ref;
|
|
2820
|
+
await ((_identify = (_ref = this.#provider).identify) === null || _identify === void 0 ? void 0 : _identify.call(_ref, this, event));
|
|
2821
|
+
} catch (error) {
|
|
2822
|
+
Logger.error(`Error identifying with provider ${this.#provider.name}`, error);
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
async track(event) {
|
|
2826
|
+
if (!this.#provider) return;
|
|
2827
|
+
try {
|
|
2828
|
+
if (await this.#doNotTrack(event)) return;
|
|
2829
|
+
await this.#provider.track(this, event);
|
|
2830
|
+
} catch (error) {
|
|
2831
|
+
Logger.error(`Error tracking ${event.name} event with provider ${this.#provider.name}`, error);
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
async #doNotTrack(event) {
|
|
2835
|
+
const dnt = getDoNotTrack();
|
|
2836
|
+
if (dnt) return true;
|
|
2837
|
+
if (this.#filter) return this.#filter(this, event);
|
|
2838
|
+
return false;
|
|
2839
|
+
}
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2747
2842
|
//#endregion
|
|
2748
2843
|
//#region src/CommandKit.ts
|
|
2749
2844
|
const bootstrapHooks = /* @__PURE__ */ new Set();
|
|
@@ -2799,6 +2894,7 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2799
2894
|
eventHandler;
|
|
2800
2895
|
plugins;
|
|
2801
2896
|
events;
|
|
2897
|
+
analytics;
|
|
2802
2898
|
static instance = void 0;
|
|
2803
2899
|
/**
|
|
2804
2900
|
* Create a new command and event handler with CommandKit.
|
|
@@ -2812,6 +2908,7 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2812
2908
|
if (!CommandKit.instance) CommandKit.instance = this;
|
|
2813
2909
|
if (options === null || options === void 0 ? void 0 : options.client) this.setClient(options.client);
|
|
2814
2910
|
this.plugins = new CommandKitPluginRuntime(this);
|
|
2911
|
+
this.analytics = new AnalyticsEngine(this);
|
|
2815
2912
|
this.#bootstrapHooks();
|
|
2816
2913
|
}
|
|
2817
2914
|
async #bootstrapHooks() {
|
|
@@ -2999,6 +3096,12 @@ var CommandKit = class CommandKit extends node_events.default {
|
|
|
2999
3096
|
const commandkit = CommandKit.instance || new CommandKit();
|
|
3000
3097
|
|
|
3001
3098
|
//#endregion
|
|
3099
|
+
Object.defineProperty(exports, 'AnalyticsEngine', {
|
|
3100
|
+
enumerable: true,
|
|
3101
|
+
get: function () {
|
|
3102
|
+
return AnalyticsEngine;
|
|
3103
|
+
}
|
|
3104
|
+
});
|
|
3002
3105
|
Object.defineProperty(exports, 'AppCommandHandler', {
|
|
3003
3106
|
enumerable: true,
|
|
3004
3107
|
get: function () {
|
|
@@ -3095,6 +3198,12 @@ Object.defineProperty(exports, 'DefaultLogger', {
|
|
|
3095
3198
|
return DefaultLogger;
|
|
3096
3199
|
}
|
|
3097
3200
|
});
|
|
3201
|
+
Object.defineProperty(exports, 'JsonSerialize', {
|
|
3202
|
+
enumerable: true,
|
|
3203
|
+
get: function () {
|
|
3204
|
+
return JsonSerialize;
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3098
3207
|
Object.defineProperty(exports, 'Logger', {
|
|
3099
3208
|
enumerable: true,
|
|
3100
3209
|
get: function () {
|
|
@@ -3245,6 +3354,12 @@ Object.defineProperty(exports, 'defaultConfig', {
|
|
|
3245
3354
|
return defaultConfig;
|
|
3246
3355
|
}
|
|
3247
3356
|
});
|
|
3357
|
+
Object.defineProperty(exports, 'defer', {
|
|
3358
|
+
enumerable: true,
|
|
3359
|
+
get: function () {
|
|
3360
|
+
return defer;
|
|
3361
|
+
}
|
|
3362
|
+
});
|
|
3248
3363
|
Object.defineProperty(exports, 'defineConfig', {
|
|
3249
3364
|
enumerable: true,
|
|
3250
3365
|
get: function () {
|
|
@@ -3293,6 +3408,12 @@ Object.defineProperty(exports, 'getCurrentDirectory', {
|
|
|
3293
3408
|
return getCurrentDirectory;
|
|
3294
3409
|
}
|
|
3295
3410
|
});
|
|
3411
|
+
Object.defineProperty(exports, 'getDoNotTrack', {
|
|
3412
|
+
enumerable: true,
|
|
3413
|
+
get: function () {
|
|
3414
|
+
return getDoNotTrack;
|
|
3415
|
+
}
|
|
3416
|
+
});
|
|
3296
3417
|
Object.defineProperty(exports, 'getPossibleConfigPaths', {
|
|
3297
3418
|
enumerable: true,
|
|
3298
3419
|
get: function () {
|
|
@@ -3323,6 +3444,12 @@ Object.defineProperty(exports, 'makeContextAwareFunction', {
|
|
|
3323
3444
|
return makeContextAwareFunction;
|
|
3324
3445
|
}
|
|
3325
3446
|
});
|
|
3447
|
+
Object.defineProperty(exports, 'noAnalytics', {
|
|
3448
|
+
enumerable: true,
|
|
3449
|
+
get: function () {
|
|
3450
|
+
return noAnalytics;
|
|
3451
|
+
}
|
|
3452
|
+
});
|
|
3326
3453
|
Object.defineProperty(exports, 'onApplicationBootstrap', {
|
|
3327
3454
|
enumerable: true,
|
|
3328
3455
|
get: function () {
|
|
@@ -3359,4 +3486,4 @@ Object.defineProperty(exports, 'useEnvironment', {
|
|
|
3359
3486
|
return useEnvironment;
|
|
3360
3487
|
}
|
|
3361
3488
|
});
|
|
3362
|
-
//# sourceMappingURL=CommandKit-
|
|
3489
|
+
//# sourceMappingURL=CommandKit-CrZN2bV4.js.map
|