开始使用
复制一个包含安装步骤和本插件的完整 Markdown 指南的配置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-contentsquare`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/contentsquare/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
-
安装插件
复制到剪贴板 npm i @capgo/capacitor-contentsquare系统计操例 pnpm add @capgo/capacitor-contentsquare系统计操例 yarn add @capgo/capacitor-contentsquare系统计操例 bun add @capgo/capacitor-contentsquare -
安被简三类编程
系统计操例 npx cap sync终端窗口 pnpm cap sync终端窗口 yarn cap sync终端窗口 bunx cap sync -
查看上游产品配置
遵循官方 Contentsquare Capacitor 指南 了解项目密钥、重放设置和仪表板设置。
基本使用
基本用法import { ContentsquarePlugin, CurrencyCode } from '@capgo/capacitor-contentsquare';
await ContentsquarePlugin.optIn();
await ContentsquarePlugin.sendScreenName('Home');
await ContentsquarePlugin.sendTransaction({ transactionValue: 29.99, transactionCurrency: CurrencyCode.EUR, transactionId: 'order-123',});
await ContentsquarePlugin.sendDynamicVar({ dynVarKey: 'store', dynVarValue: 'rome',});屏幕命名提示
屏幕命名提示- 使用稳定的名称而不是用户特定的值。
- 在 iOS 和 Android 导航堆栈中保持相同的命名约定。
- 当应用程序返回到前台时,重新发送屏幕名称和任何关键动态变量。
重放隐私控制
屏幕命名提示使用内置的masking助手来将敏感内容保留在会话重放中:
await ContentsquarePlugin.excludeURLForReplay('/checkout/');
await ContentsquarePlugin.setCapturedElementsSelector('[data-cs-capture]');
await ContentsquarePlugin.setPIISelectors({ PIISelectors: ['input[type="email"]', '.credit-card'], Attributes: [{ selector: 'input[name="email"]', attrName: 'value' }],});平台设置
平台设置注意
标题:注意- 该插件是 Capacitor 8 社区对官方 Contentsquare Capacitor 包的翻译。
- JavaScript API 与当前 Contentsquare Capacitor 文档保持一致,而本地构建设置和打包目标则是 Capacitor 8。