Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ export default defineConfig({
description: 'Microsoft Application Insights analytics plugin',
paths: ['docs/plugins/appinsights/**'],
},
{
label: 'Plugin Contentsquare',
description: 'Contentsquare mobile analytics and session replay plugin',
paths: ['docs/plugins/contentsquare/**'],
},
{
label: 'Plugin AppsFlyer',
description: 'AppsFlyer mobile attribution, analytics, and deep linking plugin',
Expand Down Expand Up @@ -866,6 +871,16 @@ export default defineConfig({
],
collapsed: true,
},
{
label: 'Contentsquare',
items: [
{ label: 'Overview', link: '/docs/plugins/contentsquare/' },
{ label: 'Getting started', link: '/docs/plugins/contentsquare/getting-started' },
{ label: 'iOS setup', link: '/docs/plugins/contentsquare/ios' },
{ label: 'Android notes', link: '/docs/plugins/contentsquare/android' },
],
collapsed: true,
},
{
label: 'AppsFlyer',
items: [
Expand Down
6 changes: 6 additions & 0 deletions public/icons/plugins/contentsquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/config/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ export const actions = [
title: 'AppInsights',
icon: 'ChartBar',
},
{
name: '@capgo/capacitor-contentsquare',
author: 'github.com/Cap-go',
description: 'Track mobile consent, screenviews, transactions, dynamic variables, and session replay with Contentsquare',
href: 'https://github.com/Cap-go/capacitor-contentsquare/',
title: 'Contentsquare',
icon: 'ChartBar',
},
{
name: '@capgo/capacitor-app-attest',
author: 'github.com/Cap-go',
Expand Down
41 changes: 41 additions & 0 deletions src/content/docs/docs/plugins/contentsquare/android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Android Notes
description: Android-specific validation and behavior notes for the Contentsquare Capacitor 8 plugin.
sidebar:
order: 4
---

Android does not require extra host-app setup for the plugin itself. Once installed and synced, the plugin registers the main Capacitor `WebView`, injects the Contentsquare event bridge, and exposes the documented JavaScript APIs.

## What the plugin does on Android

- Registers the Capacitor `WebView` with the native Contentsquare SDK.
- Exposes `optIn`, `optOut`, `sendScreenName`, `sendTransaction`, and dynamic variable APIs.
- Injects replay-related commands such as URL exclusion, PII masking, and captured element selectors.

## Validation tips

### Check native logs

Filter Android Studio `Logcat` with:

```text
CSLIB
```

You should see the native Contentsquare SDK startup message and the WebView bridge registration during app launch.

### Track a first session

```ts
await ContentsquarePlugin.optIn();
await ContentsquarePlugin.sendScreenName('Home');
```

Without at least one screenview, the session is not kept by Contentsquare.

## Dynamic variable constraints

- Keys are limited by Contentsquare to 512 characters.
- Values must be either a string or a non-negative integer.
- If you want a value on every session, send it again when the app returns to foreground.
72 changes: 72 additions & 0 deletions src/content/docs/docs/plugins/contentsquare/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Getting Started
description: Install and use Contentsquare in a Capacitor 8 app with consent gating, screenviews, transactions, and dynamic variables.
sidebar:
order: 2
---

## Install (Bun)

```bash
bun add @capgo/capacitor-contentsquare
bunx cap sync
```

## Gate tracking on consent

Users are opted out by default. Only call `optIn()` after your consent flow allows tracking, and keep `optOut()` in the same privacy layer so UI components do not accidentally emit events.

## Send a first screenview

Contentsquare discards sessions that have no screenview. Send a screen name as soon as a meaningful screen is visible (for example after your first route transition settles).

```ts
import { ContentsquarePlugin, CurrencyCode } from '@capgo/capacitor-contentsquare';

await ContentsquarePlugin.optIn();

await ContentsquarePlugin.sendScreenName('Home');

// Track a purchase only once the app has a confirmed outcome (receipt / server confirmation).
await ContentsquarePlugin.sendTransaction({
transactionValue: 29.99,
transactionCurrency: CurrencyCode.EUR,
transactionId: 'order-123',
});

await ContentsquarePlugin.sendDynamicVar({
dynVarKey: 'store',
dynVarValue: 'rome',
});
```

## Screen naming tips

- Use stable names (avoid user-specific strings).
- Keep the same naming conventions across iOS and Android navigation stacks.
- When reopening the app, resend key context (screen name and relevant dynamic vars).

## Session replay helpers (optional)

```ts
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' },
],
});
```

## Platform setup

- For iOS in-app features, complete the extra deeplink wiring in the [iOS setup](/docs/plugins/contentsquare/ios/) page.
- Android requires no extra manifest wiring for the plugin itself; see [Android notes](/docs/plugins/contentsquare/android/) for logging and validation tips.

## Notes

- This plugin is a Capacitor 8 community port of the official Contentsquare Capacitor package.
- The JavaScript API matches the current Contentsquare Capacitor docs, while the packaging and native build setup target Capacitor 8.
41 changes: 41 additions & 0 deletions src/content/docs/docs/plugins/contentsquare/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: "@capgo/capacitor-contentsquare"
description: Contentsquare analytics and session replay integration for Capacitor 8 apps.
sidebar:
order: 1
label: "Introduction"
hero:
tagline: Add Contentsquare consent gating, screen analytics, transactions, dynamic variables, and replay controls to your Capacitor app.
image:
file: ~public/icons/plugins/contentsquare.svg
actions:
- text: Get started
link: /docs/plugins/contentsquare/getting-started/
icon: right-arrow
variant: primary
- text: Github
link: https://github.com/Cap-go/capacitor-contentsquare/
icon: external
variant: minimal
---

This plugin wraps the Contentsquare mobile SDKs and exposes the same JavaScript API shape as the upstream Capacitor package, packaged for Capgo's Capacitor 8 toolchain.

## What you can do

- Gate tracking with `optIn()` and `optOut()` from your consent layer.
- Send screenviews with `sendScreenName()` (required for sessions to be kept).
- Track purchases with `sendTransaction()`.
- Enrich sessions with `sendDynamicVar()`.
- Configure replay masking and capture via the replay helper methods.

## Versions

- iOS SDK: 4.45.4
- Android SDK: 4.43.3

## Next steps

- Follow [Getting Started](/docs/plugins/contentsquare/getting-started/) for install plus your first events.
- If you use Contentsquare in-app tooling on iOS, complete [iOS setup](/docs/plugins/contentsquare/ios/).
- For Android validation tips, see [Android notes](/docs/plugins/contentsquare/android/).
71 changes: 71 additions & 0 deletions src/content/docs/docs/plugins/contentsquare/ios.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: iOS Setup
description: Configure the required iOS deeplink hooks for Contentsquare in-app features in Capacitor apps.
sidebar:
order: 3
---

Contentsquare tracking starts automatically once the plugin is installed, but iOS in-app features such as SDK logs, screenshot capture, and replay configuration still need the upstream URL handling setup.

## 1. Add the URL scheme

Add `cs-$(PRODUCT_BUNDLE_IDENTIFIER)` to your app URL schemes in Xcode or your host app's `Info.plist`.

```xml
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>cs-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>
</dict>
</array>
```

## 2. Forward Contentsquare deeplinks

Wherever your Capacitor host app handles incoming URLs, forward them to the native SDK:

### AppDelegate

```swift
import ContentsquareModule

func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
Contentsquare.handle(url: url)
return true
}
```

### SceneDelegate

```swift
import ContentsquareModule

func scene(_ scene: UIScene, openURLContexts urlContexts: Set<UIOpenURLContext>) {
if let url = urlContexts.first?.url {
Contentsquare.handle(url: url)
}
}
```

### SwiftUI

```swift
import ContentsquareModule

.onOpenURL { url in
Contentsquare.handle(url: url)
}
```

## 3. Validate the installation

- Launch the app on a device or simulator.
- Filter Xcode or Console logs with `CSLIB`.
- Open the Contentsquare mobile tooling and trigger in-app features to confirm the deeplink is handled.
5 changes: 5 additions & 0 deletions src/content/docs/docs/plugins/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ The Updater plugin is the foundation of Capgo Cloud, enabling you to:
description="Application insights and analytics using the Apptopia AppInsights SDK."
href="/docs/plugins/appinsights/"
/>
<LinkCard
title="Contentsquare"
description="Mobile analytics, consent, screen tracking, transactions, and session replay for Capacitor apps."
href="/docs/plugins/contentsquare/"
/>
<LinkCard
title="WeChat"
description="WeChat SDK integration for authentication, sharing, payments, and mini-programs."
Expand Down
52 changes: 52 additions & 0 deletions src/content/plugins-tutorials/en/capacitor-contentsquare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
locale: en
---

# Complete Tutorial: Using @capgo/capacitor-contentsquare in Capacitor 8 Apps

`@capgo/capacitor-contentsquare` wires the Contentsquare mobile SDK into Capacitor 8 projects with a Capgo-friendly plugin surface. This tutorial focuses on the integration decisions you need to make around ownership, privacy, and analytics structure. For installation and API references, use the plugin docs:

## Start with the plugin docs

- Getting started: [Contentsquare Getting Started](/docs/plugins/contentsquare/getting-started/)
- iOS setup notes: [Contentsquare iOS Setup](/docs/plugins/contentsquare/ios/)
- Android notes: [Contentsquare Android Notes](/docs/plugins/contentsquare/android/)

If you only need installation and the basic API examples, those pages are the canonical reference.

## Decide what owns consent

Treat consent as a product feature, not an analytics toggle. The simplest rule is:

- The consent UI (or your privacy layer) is the only code allowed to call `optIn()` or `optOut()`.
- Everyone else can only call tracking methods when the privacy layer says tracking is allowed.

This keeps you from accidentally emitting events before consent is granted.

## Keep screen names stable

For clean analysis, define names as stable templates (not user-specific content). A practical approach:

- Build a centralized set of constants for route names.
- Keep names consistent across iOS and Android route stacks.
- Reuse names when only parameters change, such as an item ID.

## Track transactions at the source of truth

Only emit purchase tracking once the app has a confirmed result (for example, a server receipt or a finalized payment state). Avoid firing on UI intent (button press) unless you explicitly label it as an attempt.

## Keep the plugin behind one service

A low-friction pattern is to centralize Contentsquare behind one analytics service and keep the plugin API out of UI components. That makes it easier to gate calls on consent, keep screen naming stable, and change the implementation later without touching screens.

## Replay privacy checklist

Before enabling replay in production:

- Decide what should never be captured (inputs, payment fields, identity screens).
- Add capture selectors intentionally (favor explicit allow-listing).
- Keep the selector list owned by the same team that owns privacy compliance.

## Final notes

This plugin is a Capgo-maintained Capacitor 8 port of the current Contentsquare Capacitor API surface. Pair it with your existing consent policy and the official Contentsquare documentation for product-level guidance around replay, privacy, and debugging.