Skip to content

Commit ff8e07c

Browse files
BigLepSgtPooki
andauthored
chore: improve telemetry docs/collecting (#192)
* chore: improve telemetry docs/collecting This is intended to finish off #153 * chore: fix disable code snippet * chore: remove whitespace from README.md * fix: set telemetry appName for cli & upload-action * test: fix sentry init expectation * Apply suggestion from @BigLep * fix: initializeSynapse uses synapse telemetry config * fix: filecoin-pinning-server sets sentry appName * chore: lint fix * deps: update synapse-sdk * fix: use constant for cli telemetry appName --------- Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
1 parent d25734d commit ff8e07c

File tree

15 files changed

+84
-33
lines changed

15 files changed

+84
-33
lines changed

README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Filecoin Pin offers multiple affordances to integrate Filecoin storage into your
3434
Upload IPFS files directly to Filecoin via the command line. Perfect for developers who want to integrate Filecoin storage into scripts, workflows, or local development environments.
3535

3636
- **Repository**: This repo ([filecoin-project/filecoin-pin](https://github.com/filecoin-project/filecoin-pin))
37-
- **Documentation**:
37+
- **Documentation**:
3838
- Run `filecoin-pin --help` to see all available commands and options.
3939
- [CLI Walkthrough](https://docs.filecoin.io/builder-cookbook/filecoin-pin/filecoin-pin-cli)
4040
- **Installation**: `npm install -g filecoin-pin`
@@ -43,7 +43,7 @@ Upload IPFS files directly to Filecoin via the command line. Perfect for develop
4343
Automatically publish websites or build artifacts to IPFS and Filecoin as part of your CI/CD pipeline. Ideal for static websites, documentation sites, and automated deployment workflows.
4444

4545
- **Repository**: This repo ([see upload-action/](./upload-action))
46-
- **Documentation**:
46+
- **Documentation**:
4747
- [GitHub Action Walkthrough](https://docs.filecoin.io/builder-cookbook/filecoin-pin/github-action)
4848
- **Example in Production**: [filecoin-pin-website CI pipeline](https://github.com/filecoin-project/filecoin-pin-website/tree/main/.github/workflows)
4949

@@ -59,13 +59,13 @@ Run a localhost IPFS Pinning Service API server that implements the [IPFS Pinnin
5959

6060
- **Repository**: This repo (`filecoin-pin server` command in CLI)
6161
- **Usage**: `PRIVATE_KEY=0x... npx filecoin-pin server`
62-
- **Status**: Works and is tested, but hasn't received as many features as the CLI. If it would benefit your usecase, please comment on [tracking issue](https://github.com/filecoin-project/filecoin-pin/issues/46) so we can be better informed when it comes to prioritizing.
62+
- **Status**: Works and is tested, but hasn't received as many features as the CLI. If it would benefit your usecase, please comment on [tracking issue](https://github.com/filecoin-project/filecoin-pin/issues/46) so we can be better informed when it comes to prioritizing.
6363

6464
### Management Console GUI
6565
Web-based management console for monitoring and managing your Filecoin Pin deployments. This is effectively a Web UI equivalent to the [CLI](#cli).
6666

6767
- **Status**: Planned
68-
- **Tracking**: See [issue #74](https://github.com/filecoin-project/filecoin-pin/issues/74) for updates. Please leave a comment about your usecase if this would be particularly beneficial.
68+
- **Tracking**: See [issue #74](https://github.com/filecoin-project/filecoin-pin/issues/74) for updates. Please leave a comment about your usecase if this would be particularly beneficial.
6969

7070
## Examples
7171

@@ -98,6 +98,24 @@ The [Synapse SDK](https://synapse.filecoin.services/) is the main library, as it
9898

9999
The affordances were [discussed more above](#affordances). All affordances use the same core library, ensuring consistent behavior and making it easy to add new interfaces in the future.
100100

101+
## Telemetry
102+
103+
Filecoin Pain collects telemetry. A few things:
104+
* Telemetry always [has a way to be disabled](#how-to-disable-telemetry).
105+
* We don't collect Personal identifiable information (PII).
106+
* With our [end user affordance](#affordances) we expect to make telemetry on by default, requiring a consumer/user to opt out. We are defaulting as "enabled" to help make sure we have a good pulse on the user experience and can address issues correctly.
107+
* In this [pre-v1 season](https://github.com/filecoin-project/filecoin-pin/issues/187), we are particularly focused on helping maintainers validate functionality and iron out problems throughout the whole Filecoin Onchain Cloud stack that `filecoin-pin` relies on. We're piggy-backing on the underlying telemetry setup/system of Synapse, which uses sentry.io. The telemetry we get from synapse-sdk is more invasive than we'd do if just setting it up for [Filecoin Pin affordances](#affordances), but this was the most resource efficient way to be able to get a pulse on what errors are happening where in the stack.
108+
* Learn more at the Synapse telemetry docs ([docs site](https://synapse.filecoin.services/guides/telemetry/), [github](https://github.com/FilOzone/synapse-sdk/blob/master/docs/src/content/docs/guides/telemetry.md)).
109+
110+
### How to disable telemetry
111+
Telemetry can be disabled in JS with:
112+
113+
```typescript
114+
const synapse = await initializeSynapse({ ...synapseConfig, telemetry: { sentryInitOptions: { enabled: false } } }, logger)
115+
```
116+
117+
If using a different affordance like the CLI or example GitHub Action, then the following telemetry can be disabled by environment variable. Because filecoin-pin telemetry is tied to synapse's telemetry currently, see the Synapse telemetry docs ([docs site](https://synapse.filecoin.services/guides/telemetry/#how-to-disable-telemetry), [github](https://github.com/FilOzone/synapse-sdk/blob/master/docs/src/content/docs/guides/telemetry.md#how-to-disable-telemetry)) for how to do this.
118+
101119
## Quick Start
102120

103121
### Prerequisites

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"homepage": "https://github.com/filecoin-project/filecoin-pin#readme",
9898
"dependencies": {
9999
"@clack/prompts": "^0.11.0",
100-
"@filoz/synapse-sdk": "^0.35.1",
100+
"@filoz/synapse-sdk": "^0.35.2",
101101
"@helia/unixfs": "^6.0.1",
102102
"@ipld/car": "^5.4.2",
103103
"commander": "^14.0.1",

src/add/add.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { readFile, stat } from 'node:fs/promises'
99
import pc from 'picocolors'
1010
import pino from 'pino'
1111
import { warnAboutCDNPricingLimitations } from '../common/cdn-warning.js'
12+
import { TELEMETRY_CLI_APP_NAME } from '../common/constants.js'
1213
import { displayUploadResults, performAutoFunding, performUpload, validatePaymentSetup } from '../common/upload-flow.js'
1314
import {
1415
cleanupSynapseService,
@@ -112,7 +113,10 @@ export async function runAdd(options: AddOptions): Promise<AddResult> {
112113
if (withCDN) config.withCDN = true
113114

114115
// Initialize just the Synapse SDK
115-
const synapse = await initializeSynapse(config, logger)
116+
const synapse = await initializeSynapse(
117+
{ ...config, telemetry: { sentrySetTags: { appName: TELEMETRY_CLI_APP_NAME } } },
118+
logger
119+
)
116120
const network = synapse.getNetwork()
117121

118122
spinner.stop(`${pc.green('✓')} Connected to ${pc.bold(network)}`)

src/common/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
* Minimum runway in days to ensure WarmStorage can cover costs. Used when `--auto-fund` is passed to import or add commands
33
*/
44
export const MIN_RUNWAY_DAYS = 30
5+
6+
export const TELEMETRY_CLI_APP_NAME = 'filecoinPinCli'

src/core/synapse/index.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ interface BaseSynapseConfig {
6565
warmStorageAddress?: string | undefined
6666
withCDN?: boolean | undefined
6767
/**
68-
* Telemetry configuration, merges fields, but appends "appName" to the existing appName
68+
* Telemetry configuration.
69+
* Defaults to enabled unless explicitly disabled.
6970
* @example
7071
* {
7172
* sentryInitOptions: {
72-
* enabled: true,
73+
* enabled: false, // if want to disable telemetry.
7374
* },
7475
* sentrySetTags: {
7576
* appName: "${your-app-name}",
7677
* },
7778
* }
78-
* will result in your appName being "filecoin-pin@v1.0.0-${your-app-name}"
7979
*/
8080
telemetry?: TelemetryConfig
8181
}
@@ -312,11 +312,7 @@ async function setupSessionKey(synapse: Synapse, sessionWallet: Wallet, logger:
312312
* @param logger - Logger instance for detailed operation tracking
313313
* @returns Initialized Synapse instance
314314
*/
315-
export async function initializeSynapse(
316-
config: Partial<SynapseSetupConfig>,
317-
logger: Logger,
318-
telemetryConfig?: TelemetryConfig
319-
): Promise<Synapse> {
315+
export async function initializeSynapse(config: Partial<SynapseSetupConfig>, logger: Logger): Promise<Synapse> {
320316
try {
321317
const authMode = validateAuthConfig(config)
322318

@@ -340,9 +336,7 @@ export async function initializeSynapse(
340336
if (config.warmStorageAddress) {
341337
synapseOptions.warmStorageAddress = config.warmStorageAddress
342338
}
343-
if (telemetryConfig) {
344-
synapseOptions.telemetry = getTelemetryConfig(telemetryConfig)
345-
}
339+
synapseOptions.telemetry = getTelemetryConfig(config.telemetry)
346340

347341
let synapse: Synapse
348342

src/core/synapse/telemetry-config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import type { TelemetryConfig } from '@filoz/synapse-sdk'
33
import packageJson from '../../../package.json' with { type: 'json' }
44

55
export const getTelemetryConfig = (config?: TelemetryConfig | undefined): TelemetryConfig => {
6-
let appName = `${packageJson.name}@v${packageJson.version}`
7-
if (config?.sentrySetTags?.appName != null) {
8-
appName = `${appName}-${String(config.sentrySetTags.appName)}`
9-
}
10-
116
return {
127
...config,
138
sentryInitOptions: {
@@ -17,7 +12,7 @@ export const getTelemetryConfig = (config?: TelemetryConfig | undefined): Teleme
1712
},
1813
sentrySetTags: {
1914
...config?.sentrySetTags,
20-
appName, // use constructed appName, always.
15+
filecoinPinVersion: `${packageJson.name}@v${packageJson.version}`,
2116
},
2217
}
2318
}

src/data-set/run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { EnhancedDataSetInfo, ProviderInfo, Synapse } from '@filoz/synapse-sdk'
22
import { PDPServer, PDPVerifier, WarmStorageService } from '@filoz/synapse-sdk'
33
import pc from 'picocolors'
4+
import { TELEMETRY_CLI_APP_NAME } from '../common/constants.js'
45
import { cleanupSynapseService, initializeSynapse } from '../core/synapse/index.js'
56
import { getCLILogger, parseCLIAuth } from '../utils/cli-auth.js'
67
import { cancel, createSpinner, intro, outro } from '../utils/cli-helpers.js'
@@ -189,7 +190,10 @@ export async function runDataSetCommand(
189190
})
190191

191192
const logger = getCLILogger()
192-
synapse = await initializeSynapse(authConfig, logger)
193+
synapse = await initializeSynapse(
194+
{ ...authConfig, telemetry: { sentrySetTags: { appName: TELEMETRY_CLI_APP_NAME } } },
195+
logger
196+
)
193197
const network = synapse.getNetwork()
194198
const client = synapse.getClient()
195199
const address = await client.getAddress()

src/filecoin-pinning-server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export async function createFilecoinPinningServer(
3838
{
3939
...config,
4040
privateKey: config.privateKey,
41+
telemetry: {
42+
sentrySetTags: {
43+
appName: 'filecoinPinIPFSPinningServer',
44+
},
45+
},
4146
},
4247
logger,
4348
providerOptions

src/import/import.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CID } from 'multiformats/cid'
1212
import pc from 'picocolors'
1313
import pino from 'pino'
1414
import { warnAboutCDNPricingLimitations } from '../common/cdn-warning.js'
15+
import { TELEMETRY_CLI_APP_NAME } from '../common/constants.js'
1516
import { displayUploadResults, performAutoFunding, performUpload, validatePaymentSetup } from '../common/upload-flow.js'
1617
import {
1718
cleanupSynapseService,
@@ -182,7 +183,10 @@ export async function runCarImport(options: ImportOptions): Promise<ImportResult
182183
if (withCDN) config.withCDN = true
183184

184185
// Initialize just the Synapse SDK
185-
const synapse = await initializeSynapse(config, logger)
186+
const synapse = await initializeSynapse(
187+
{ ...config, telemetry: { sentrySetTags: { appName: TELEMETRY_CLI_APP_NAME } } },
188+
logger
189+
)
186190
const network = synapse.getNetwork()
187191

188192
spinner.stop(`${pc.green('✓')} Connected to ${pc.bold(network)}`)

src/payments/auto.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { ethers } from 'ethers'
1010
import pc from 'picocolors'
11+
import { TELEMETRY_CLI_APP_NAME } from '../common/constants.js'
1112
import {
1213
calculateDepositCapacity,
1314
checkAndSetAllowances,
@@ -56,7 +57,10 @@ export async function runAutoSetup(options: PaymentSetupOptions): Promise<void>
5657
})
5758

5859
const logger = getCLILogger()
59-
const synapse = await initializeSynapse(authConfig, logger)
60+
const synapse = await initializeSynapse(
61+
{ ...authConfig, telemetry: { sentrySetTags: { appName: TELEMETRY_CLI_APP_NAME } } },
62+
logger
63+
)
6064
const network = synapse.getNetwork()
6165
const client = synapse.getClient()
6266
const address = await client.getAddress()

0 commit comments

Comments
 (0)