Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chg: add posthog feature flag (#2070)
teo193ab5051a9b
diff --git a/js/app/packages/app/lib/analytics/posthog.tsx b/js/app/packages/app/lib/analytics/posthog.tsxindex 82d9e8cdd9..64e95b0228 100644--- a/js/app/packages/app/lib/analytics/posthog.tsx+++ b/js/app/packages/app/lib/analytics/posthog.tsx@@ -10,10 +10,12 @@ import {Show,} from 'solid-js';+export const posthogInstance = new PostHog();+export const [PosthogProvider, usePosthog] = createAssertedContextProvider('PosthogProvider',() => {- const instance = new PostHog();+ const instance = posthogInstance;const initialize = () => {const key = import.meta.env.VITE_POSTHOG_API_KEY;diff --git a/js/app/packages/block-channel/definition.ts b/js/app/packages/block-channel/definition.tsindex 5d0b2842a7..208f24a601 100644--- a/js/app/packages/block-channel/definition.ts+++ b/js/app/packages/block-channel/definition.ts@@ -8,11 +8,11 @@ import { NewChannelBlockAdapter } from './component/NewChannelBlockAdapter';export const definition = defineBlock({name: 'channel',description: '',- component: ENABLE_NEW_CHANNELS ? NewChannelBlockAdapter : ChannelBlock,+ component: ENABLE_NEW_CHANNELS() ? NewChannelBlockAdapter : ChannelBlock,liveTrackingEnabled: true,async load(source, _intent) {if (source.type === 'dss') {- if (!ENABLE_NEW_CHANNELS) {+ if (!ENABLE_NEW_CHANNELS()) {await fetchAndCacheChannel(source.id);}return ok({ id: source.id });diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.tsindex 55e1293144..057a648cf6 100644--- a/js/app/packages/core/constant/featureFlags.ts+++ b/js/app/packages/core/constant/featureFlags.ts@@ -1,3 +1,5 @@+import { posthogInstance } from '@app/lib/analytics/posthog';+/*** This constant reflects whether the app is running locally with hot reload enabled*@@ -278,11 +280,18 @@ export const ENABLE_FEATURED_SEARCH_RESULTS = resolveFeatureFlag(true);-export const ENABLE_NEW_CHANNELS = resolveFeatureFlag(- 'ENABLE_NEW_CHANNELS',- false+const ENABLE_NEW_CHANNELS_OVERRIDE = getFeatureFlagOverride(+ 'ENABLE_NEW_CHANNELS');+export function ENABLE_NEW_CHANNELS(): boolean {+ if (ENABLE_NEW_CHANNELS_OVERRIDE !== undefined) {+ return ENABLE_NEW_CHANNELS_OVERRIDE;+ }++ return posthogInstance.isFeatureEnabled('enable-new-channels') ?? false;+}+export const ENABLE_PROXY_EMAIL_IMAGES = resolveFeatureFlag('ENABLE_PROXY_EMAIL_IMAGES',truediff --git a/js/app/packages/queries/channel/message.ts b/js/app/packages/queries/channel/message.tsindex d2fb716fc2..ecfdb12138 100644--- a/js/app/packages/queries/channel/message.ts+++ b/js/app/packages/queries/channel/message.ts@@ -204,7 +204,7 @@ export function optimisticInsertChannelMessage(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {if (target.kind === 'thread_reply') {const optimisticReply = makeOptimisticThreadReply(vars,@@ -249,7 +249,7 @@ export function rollbackInsertChannelMessage(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {removeMessageFromTargetCaches(channelId, context.target);}}@@ -304,7 +304,7 @@ export function replaceOptimisticMessage(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetMessageId(vars.channelId,resolveMessageTarget({@@ -378,7 +378,7 @@ export function optimisticDeleteChannelMessage(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {context.targetSnapshot = captureDeleteSnapshotForTarget(vars.channelId,target@@ -418,7 +418,7 @@ export function rollbackDeleteChannelMessage(});- if (ENABLE_NEW_CHANNELS && context.targetSnapshot) {+ if (ENABLE_NEW_CHANNELS() && context.targetSnapshot) {restoreMessageInTargetCaches(channelId,context.target,@@ -499,7 +499,7 @@ export function optimisticUpdateChannelMessage(});- if (ENABLE_NEW_CHANNELS && context) {+ if (ENABLE_NEW_CHANNELS() && context) {replaceTargetMessageState(vars.channelId, target, {content: vars.content,editedAt: now,@@ -549,7 +549,7 @@ export function rollbackUpdateChannelMessage(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetMessageState(channelId, context.target, {content: context.previousContent,editedAt: normalizeDateValue(context.previousEditedAt),@@ -635,7 +635,7 @@ export function useSendMessageMutation(},onSettled: (_data, _error, variables) => {softInvalidateChannelWithID(variables.channelID);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(variables.channelID,resolveMessageTarget({@@ -711,7 +711,7 @@ export function useDeleteMessageMutation(onSettled: (_data, _error, vars) => {deleteNonce.cleanup(vars);softInvalidateChannelWithID(vars.channelID);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(vars.channelID,resolveMessageTarget({@@ -796,7 +796,7 @@ export function usePatchMessageMutation(onSettled: (_data, _error, vars) => {patchNonce.cleanup(vars);softInvalidateChannelWithID(vars.channelID);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(vars.channelID,resolveMessageTarget({diff --git a/js/app/packages/queries/channel/reaction.ts b/js/app/packages/queries/channel/reaction.tsindex 4236f90419..64c1f9416f 100644--- a/js/app/packages/queries/channel/reaction.ts+++ b/js/app/packages/queries/channel/reaction.ts@@ -161,7 +161,7 @@ export function optimisticAddReaction(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetReactions(vars.channelId, context.target, result.reactions);}@@ -196,7 +196,7 @@ export function rollbackAddReaction(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetReactions(channelId,context.target,@@ -256,7 +256,7 @@ export function optimisticRemoveReaction(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetReactions(vars.channelId, context.target, result.reactions);}@@ -293,7 +293,7 @@ export function rollbackRemoveReaction(});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {replaceTargetReactions(channelId,context.target,@@ -380,7 +380,7 @@ export function useAddReactionMutation(onSettled: (_, __, vars) => {addReactionNonce.cleanup(vars);softInvalidateChannelWithID(vars.channelId);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(vars.channelId,resolveMessageTarget({@@ -453,7 +453,7 @@ export function useRemoveReactionMutation(onSettled: (_, __, vars) => {removeReactionNonce.cleanup(vars);softInvalidateChannelWithID(vars.channelId);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(vars.channelId,resolveMessageTarget({diff --git a/js/app/packages/queries/channel/sync.ts b/js/app/packages/queries/channel/sync.tsindex 6023f2b1aa..153897346f 100644--- a/js/app/packages/queries/channel/sync.ts+++ b/js/app/packages/queries/channel/sync.ts@@ -71,7 +71,7 @@ export function handleCommsMessage(payload: CommsMessagePayload): void {};});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {const threadId = payload.thread_id;if (threadId) {const reply: ApiThreadReply = {@@ -126,7 +126,7 @@ export function handleCommsMessage(payload: CommsMessagePayload): void {}softInvalidateChannelWithID(payload.channel_id);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(payload.channel_id,resolveMessageTarget({@@ -164,7 +164,7 @@ export function handleCommsReaction(payload: CommsReactionPayload): void {};});- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {const target = resolveMessageTarget({channelId: payload.channel_id,messageId: payload.message_id,@@ -177,7 +177,7 @@ export function handleCommsReaction(payload: CommsReactionPayload): void {}softInvalidateChannelWithID(payload.channel_id);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {const target = resolveMessageTarget({channelId: payload.channel_id,messageId: payload.message_id,@@ -197,7 +197,7 @@ export function handleCommsAttachment(payload: CommsAttachmentPayload): void {ChannelNonceKeys.ATTACHMENT,payload.nonce);- const target = ENABLE_NEW_CHANNELS+ const target = ENABLE_NEW_CHANNELS()? resolveMessageTarget({channelId: payload.channel_id,messageId: payload.message_id,@@ -231,7 +231,7 @@ export function handleCommsAttachment(payload: CommsAttachmentPayload): void {};});- if (ENABLE_NEW_CHANNELS && target) {+ if (ENABLE_NEW_CHANNELS() && target) {replaceTargetAttachments(payload.channel_id, target, payload.attachments);}} catch (error) {@@ -239,7 +239,7 @@ export function handleCommsAttachment(payload: CommsAttachmentPayload): void {}softInvalidateChannelWithID(payload.channel_id);- if (ENABLE_NEW_CHANNELS) {+ if (ENABLE_NEW_CHANNELS()) {softInvalidateTargetCaches(payload.channel_id, target);}}diff --git a/js/app/packages/queries/channel/tests/channel-optimistic.test.ts b/js/app/packages/queries/channel/tests/channel-optimistic.test.tsindex baff9455be..830afd7623 100644--- a/js/app/packages/queries/channel/tests/channel-optimistic.test.ts+++ b/js/app/packages/queries/channel/tests/channel-optimistic.test.ts@@ -25,7 +25,7 @@ vi.mock('@core/component/Toast/Toast', () => ({vi.mock('@core/constant/featureFlags', async (importOriginal) => ({...(await importOriginal<typeof import('@core/constant/featureFlags')>()),- ENABLE_NEW_CHANNELS: true,+ ENABLE_NEW_CHANNELS: () => true,}));vi.mock('@service-comms/client', () => ({diff --git a/js/app/packages/queries/channel/tests/sync.test.ts b/js/app/packages/queries/channel/tests/sync.test.tsindex bd0d85a6d1..a96926dc3a 100644--- a/js/app/packages/queries/channel/tests/sync.test.ts+++ b/js/app/packages/queries/channel/tests/sync.test.ts@@ -17,7 +17,7 @@ vi.mock('../../client', () => ({vi.mock('@core/constant/featureFlags', async (importOriginal) => ({...(await importOriginal<typeof import('@core/constant/featureFlags')>()),- ENABLE_NEW_CHANNELS: true,+ ENABLE_NEW_CHANNELS: () => true,}));import type { ChannelMessagesData } from '../channel-messages';