Skip to content

feat(workflows): add push subscription functionality#473

Open
havenbarnes wants to merge 22 commits intomainfrom
add-push-notifications
Open

feat(workflows): add push subscription functionality#473
havenbarnes wants to merge 22 commits intomainfrom
add-push-notifications

Conversation

@havenbarnes
Copy link
Copy Markdown

@havenbarnes havenbarnes commented Mar 31, 2026

💡 Motivation and Context

This will need to be merged after the posthog PR stack PostHog/posthog#53276 and documentation updates: PostHog/posthog.com#16177

PostHog/posthog#44444

We're adding push notification channel to workflows, and SDKs need to send us their device tokens to fulfill the push subscription on our end

💚 How did you test it?

Tested everything end to end locally with a workflow, using FCM with emulator:

Screenshot 2026-04-22 at 2 58 04 PM

Added tests for new logic

📝 Checklist

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 31, 2026

posthog-android Compliance Report

Date: 2026-04-30 18:24:24 UTC
Duration: 505ms

⚠️ Some Tests Failed

0/1 tests passed, 1 failed


Feature_Flags Tests

⚠️ 0/1 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 293ms

Failures

request_payload.request_with_person_properties_device_id

404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'

@github-actions
Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions Bot closed this Apr 21, 2026
@havenbarnes havenbarnes reopened this Apr 21, 2026
@github-actions github-actions Bot removed the stale label Apr 22, 2026
@havenbarnes havenbarnes marked this pull request as ready for review April 23, 2026 20:56
@havenbarnes havenbarnes requested a review from a team as a code owner April 23, 2026 20:56
@havenbarnes
Copy link
Copy Markdown
Author

@PostHog/team-client-libraries could I get a review on this?

@marandaneto
Copy link
Copy Markdown
Member

@havenbarnes @ioannisj and @turnipdabeets will take a look
CI is unhappy tho /home/runner/work/posthog-android/posthog-android/posthog-android/src/main/java/com/posthog/android/internal/PostHogAndroidUtils.kt:181: Error: Use the KTX extension function String.toUri instead? [UseKtx]
Uri.parse(this)
this sohuld match the iOS bits so its easier to review I guess

@marandaneto marandaneto requested a review from ioannisj April 29, 2026 05:54
Comment thread posthog-android/src/main/java/com/posthog/android/PostHogPushNotifications.kt Outdated
Comment thread posthog-android/src/main/java/com/posthog/android/PostHogPushNotifications.kt Outdated
Comment thread build.gradle.kts Outdated
Comment thread .changeset/strong-moments-strive.md
Comment thread posthog-android/src/main/java/com/posthog/android/PostHogPushNotifications.kt Outdated
import android.util.Base64
import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.core.net.toUri
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rollback those unrelated changes

Comment on lines +52 to +55
import androidx.core.graphics.createBitmap
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isNotEmpty
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rollback those unrelated changes

implementation("androidx.lifecycle:lifecycle-process:${PosthogBuildConfig.Dependencies.LIFECYCLE}")
implementation("androidx.lifecycle:lifecycle-common-java8:${PosthogBuildConfig.Dependencies.LIFECYCLE}")
implementation("androidx.core:core:${PosthogBuildConfig.Dependencies.ANDROIDX_CORE}")
implementation("androidx.core:core-ktx:${PosthogBuildConfig.Dependencies.ANDROIDX_CORE}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ktx brings more dependencies, do we actually need it?

Comment on lines +7 to +15
* @property apiKey the PostHog API Key
* @property distinctId the user's distinct ID
* @property deviceToken the device push token (FCM or APNS)
* @property platform the platform ("android" or "ios")
* @property appId the Firebase project_id (for Android) or APNS bundle_id (for iOS)
*/
internal data class PostHogPushSubscriptionRequest(
@SerializedName("api_key")
val apiKey: String,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apiKey is now called projectToken, since we can use SerializedName, lets use the "new name" from now on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants