-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attach feature flags and envs to Sentry reports
- Loading branch information
Showing
11 changed files
with
163 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
[ | ||
{ | ||
"tag_name": "2.43.0", | ||
"body": "\nWe’re constantly adding new integrations and working on performance improvements to make Ledger Live a world-class experience. Here is what’s new in this release.\n\n### 🚀 Features\nWe’re excited to announce that Ledger Live is launching support for Cardano, one of the biggest cryptocurrencies based on its total market value. Now you can send and receive Cardano’s native token, ADA. \n\n### 🐛 Fixes\nWe’ve done some bug fixes and made a few small but important changes behind the curtain.\n" | ||
} | ||
] | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
apps/ledger-live-desktop/src/renderer/components/ConnectEnvsToSentry.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useEffect } from "react"; | ||
import { ipcRenderer } from "electron"; | ||
import { EnvName, getEnv } from "@ledgerhq/live-common/lib/env"; | ||
import { defaultFeatures, useFeatureFlags } from "@ledgerhq/live-common/lib/featureFlags"; | ||
import { FeatureId } from "@ledgerhq/live-common/lib/types"; | ||
import { enabledExperimentalFeatures } from "../experimental"; | ||
import { setTags } from "../../sentry/renderer"; | ||
|
||
function setSentryTagsEverywhere(tags: { [_: string]: any }) { | ||
ipcRenderer.invoke("set-sentry-tags", tags); | ||
setTags(tags); | ||
} | ||
|
||
const MAX_KEYLEN = 32; | ||
function safekey(k: string) { | ||
if (k.length > MAX_KEYLEN) { | ||
const sep = ".."; | ||
const max = MAX_KEYLEN - sep.length; | ||
const split1 = Math.floor(max / 2); | ||
return k.slice(0, split1) + ".." + k.slice(k.length - (max - split1)); | ||
} | ||
return k; | ||
} | ||
|
||
export const ConnectEnvsToSentry = () => { | ||
const featureFlags = useFeatureFlags(); | ||
useEffect(() => { | ||
// This sync the Sentry tags to include the extra information in context of events | ||
const syncTheTags = () => { | ||
const tags: { [_: string]: any } = {}; | ||
// if there are experimental on, we will add them in tags | ||
enabledExperimentalFeatures().forEach((key: EnvName) => { | ||
tags[safekey(key)] = getEnv(key); | ||
}); | ||
// if there are features on, we will add them in tags | ||
const features: { [key in FeatureId]: boolean } = {}; | ||
Object.keys(defaultFeatures).forEach(key => { | ||
const value = featureFlags.getFeature(key); | ||
if (value && value.enabled !== defaultFeatures[key].enabled) { | ||
features[key] = value.enabled; | ||
} | ||
}); | ||
|
||
Object.keys(features).forEach(key => { | ||
tags[safekey(`f_${key}`)] = features[key]; | ||
}); | ||
|
||
setSentryTagsEverywhere(tags); | ||
}; | ||
// We need to wait firebase to load the data and then we set once for all the tags | ||
setTimeout(syncTheTags, 5000); | ||
// We also try to regularly update them so we are sure to get the correct tags (as these are dynamic) | ||
setInterval(syncTheTags, 60000); | ||
}, []); | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters