开始使用
复制一个设置提示,包括安装步骤和此插件的完整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助手来将敏感内容保留在Session Replay中:
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' }],});平台设置
平台设置- iOS内购功能的实现需要在iOS设置页面完成额外的深度链接配置。 iOS设置 Android不需要为插件本身进行额外的清单配置;请参阅
- Android注意事项 Android notes 注意事项
本插件是Capgo社区对官方Contentsquare包的8版移植。
JavaScript部分与当前Contentsquare文档保持一致,而包装和原生构建设置则针对Capgo 8。- This plugin is a Capacitor 8 community port of the official Contentsquare Capacitor package.
- The JavaScript API stays aligned with the current Contentsquare Capacitor docs, while the packaging and native build setup target Capacitor 8.