-
Notifications
You must be signed in to change notification settings - Fork 111
Docs for the push activity tracking #984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
453e1cb
Docs for the push activity tracking
Aviatorscode2 4f6240c
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 adce17b
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 81598ca
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 ae61565
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 269a6a9
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 9162e34
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 d6ffc80
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 64a7acf
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 827b037
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 1fc1dbb
Break last sentente
Aviatorscode2 7cb8754
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 c446ba1
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 73d229d
Implement feedback for Push activity docs
Aviatorscode2 d5d6003
Merge branch 'MRK-1077' of https://github.com/novuhq/docs into MRK-1077
Aviatorscode2 2e45c6d
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 d2de1ee
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 adf64ca
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 d300f61
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 e51b6e8
Update content/docs/platform/integrations/push/push-activity-tracking…
Aviatorscode2 3b87eac
Update content based on feedback
Aviatorscode2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 +1,4 @@ | ||
| { | ||
| "icon": "Smartphone", | ||
| "pages": ["adding-push", "..."] | ||
| "pages": ["adding-push", "...", "push-activity-tracking"] | ||
| } |
147 changes: 147 additions & 0 deletions
147
content/docs/platform/integrations/push/push-activity-tracking.mdx
This file contains hidden or 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,147 @@ | ||
| --- | ||
| pageTitle: 'Push Notification Activity Tracking' | ||
| title: 'Activity Tracking' | ||
| description: 'Learn how to manually forward push notification events from your application to Novu for unified activity tracking.' | ||
| --- | ||
|
|
||
| To enable activity tracking for Push channels notifications, Novu supports a manual integration approach for push notifications. Where your application captures and forwards push notification events to Novu. Once received, Novu processes and displays these events on the dashboard for a unified tracking experience. | ||
|
|
||
| ## How it works | ||
|
|
||
| The process involves a four-step data flow from your subscriber's device to Novu's servers: | ||
|
|
||
| 1. **Client application listens**: Your application listens for push notification interactions. For example, the user opens a notification. | ||
| 2. **Event sent to your backend:** When an event occurs, your app sends a payload containing the event details to an endpoint on your own server. | ||
| 3. **Backend forwards to Novu:** Your server receives this data and uses the Novu SDK to securely forward the event to Novu's API. | ||
| 4. **Event appears in Novu:** Novu processes the event and displays it in the **Activity Feed**, alongside events from your other channels. | ||
|
|
||
| ## Step 1: Enable push activity tracking in Novu | ||
|
|
||
| Enable push activity tracking in your Novu dashboard and get the necessary credentials. | ||
|
|
||
| 1. Log in to the Novu dashboard. | ||
| 2. Navigate to the **Integration Store** page and then select your push provider. | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 3. Enable the **Push Activity Tracking** toggle. | ||
|  | ||
| 4. Once enabled, your unique **Environment ID** and **Integration ID** are displayed. Copy both of these; you will need them for your backend code. | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 5. Click **Save Changes**. | ||
|
|
||
| ## Step 2: Listen for push events in your app | ||
|
|
||
| Next, when push notifications are delivered or interacted with, your app needs to capture those events and forward them to your backend. The exact code implementation depends on the push provider that you use. | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The goal is to capture the event and send a JSON payload to your backend. You need to send these fields: | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `eventType`: A string describing the event (for example, `opened`, `clicked`). | ||
| - `eventId`: The unique identifier for the notification, which Novu includes in the push payload as `__nvMessageId`. | ||
|
|
||
| <Tabs items={['Expo', 'FCM', 'OneSignal']}> | ||
| <Tab value="expo"> | ||
| ```jsx | ||
| import * as Notifications from 'expo-notifications'; | ||
| import Constants from 'expo-constants'; | ||
| import { Platform } from 'react-native'; | ||
|
|
||
| // Listen for notification interactions | ||
| Notifications.addNotificationResponseReceivedListener(async (response) => { | ||
| const eventData = { | ||
| eventType: "opened", | ||
| eventId: response.notification.request.content.data?.__nvMessageId, | ||
| timestamp: new Date().toISOString(), | ||
| actionIdentifier: response.actionIdentifier, | ||
| content: { | ||
| title: response.notification.request.content.title, | ||
| body: response.notification.request.content.body, | ||
| data: response.notification.request.content.data, | ||
| }, | ||
| // Optional device context | ||
| deviceId: Constants.sessionId, | ||
| platform: Platform.OS, | ||
| }}); | ||
|
|
||
| await fetch("https://your-api.com/api/notifications/events", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify(eventData), | ||
| }); | ||
| ``` | ||
| </Tab> | ||
| <Tab value="fcm"> | ||
| ```js | ||
| import messaging from '@react-native-firebase/messaging'; | ||
|
|
||
| messaging().onNotificationOpenedApp((remoteMessage) => { | ||
| const eventData = { | ||
| eventType: "opened", | ||
| eventId: remoteMessage.data?.__nvMessageId, | ||
| timestamp: new Date().toISOString(), | ||
| content: { | ||
| title: remoteMessage.notification?.title, | ||
| body: remoteMessage.notification?.body, | ||
| }, | ||
| deviceId: remoteMessage.messageId, | ||
| platform: 'android', | ||
| }; | ||
|
|
||
| fetch("https://your-api.com/api/notifications/events", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify(eventData), | ||
| }); | ||
| }); | ||
| ``` | ||
| </Tab> | ||
| <Tab value="onesignal"> | ||
| ```js | ||
| import OneSignal from 'react-native-onesignal'; | ||
|
|
||
| OneSignal.setNotificationOpenedHandler((openedEvent) => { | ||
| const { notification } = openedEvent; | ||
|
|
||
| const eventData = { | ||
| eventType: "opened", | ||
| eventId: notification.additionalData?.__nvMessageId, | ||
| timestamp: new Date().toISOString(), | ||
| content: { | ||
| title: notification.title, | ||
| body: notification.body, | ||
| }, | ||
| deviceId: notification.notificationId, | ||
| platform: 'ios', | ||
| }; | ||
|
|
||
| fetch("https://your-api.com/api/notifications/events", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify(eventData), | ||
| }); | ||
| }); | ||
| ``` | ||
| </Tab> | ||
| </Tabs> | ||
|
|
||
| ## Step 3: Forward events to Novu from your backend | ||
|
|
||
| Finally, create an endpoint on your backend that receives the event data from your application and uses the Novu SDK to forward it to Novu. | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```typescript | ||
| import { Novu } from '@novu/api'; | ||
|
|
||
| const novuClient = new Novu({ | ||
| apiKey: process.env.NOVU_API_KEY, | ||
| }); | ||
|
|
||
| // Your backend API endpoint that receives events from your mobile app | ||
| app.post('/api/notifications/events', async (req, res) => { | ||
| // Forward the event data to Novu | ||
| const response = await novuClient.activity.track({ | ||
| environmentId: process.env.NOVU_ENVIRONMENT_ID, | ||
| integrationId: process.env.NOVU_INTEGRATION_ID, | ||
| requestBody: req.body, | ||
| }); | ||
|
|
||
| res.status(200).json({ success: true, data: response }); | ||
| }); | ||
| ``` | ||
| <Callout>Both `Integration ID` and `Environment ID` can be found in the Integration Store under your push provider instance (after enabling Push Activity Tracking).</Callout> | ||
Aviatorscode2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Once these steps are completed, your application will send push notification engagement data to Novu. This gives you a complete, unified view of your notification performance in the Activity Feed. | ||
Binary file added
BIN
+545 KB
...ages/channels-and-providers/push/activity-tracking/enable-activity-tracking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.