musora-content-services 2.177.1 → 2.178.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/services/user/memberships.ts +1 -0
- package/src/services/user/revenuecat.ts +59 -0
- package/src/version-info.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.178.1](https://github.com/railroadmedia/musora-content-services/compare/v2.178.0...v2.178.1) (2026-08-31)
|
|
6
|
+
|
|
7
|
+
## [2.178.0](https://github.com/railroadmedia/musora-content-services/compare/v2.177.1...v2.178.0) (2026-08-28)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **BEHLTP-318:** add sendRevenueCatPurchaseMetadata for MA purchase_intent handoff ([#1037](https://github.com/railroadmedia/musora-content-services/issues/1037)) ([1ba4f9d](https://github.com/railroadmedia/musora-content-services/commit/1ba4f9dd6c171423a7b2a5f775571744450ef3be))
|
|
13
|
+
|
|
5
14
|
### [2.177.1](https://github.com/railroadmedia/musora-content-services/compare/v2.177.0...v2.177.1) (2026-08-26)
|
|
6
15
|
|
|
7
16
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -492,6 +492,10 @@ import {
|
|
|
492
492
|
updateProfileVisibility
|
|
493
493
|
} from './services/user/profile.ts';
|
|
494
494
|
|
|
495
|
+
import {
|
|
496
|
+
sendRevenueCatPurchaseMetadata
|
|
497
|
+
} from './services/user/revenuecat.ts';
|
|
498
|
+
|
|
495
499
|
import {
|
|
496
500
|
listOAuthProviders,
|
|
497
501
|
loginAsUser,
|
|
@@ -859,6 +863,7 @@ declare module 'musora-content-services' {
|
|
|
859
863
|
searchAlgolia,
|
|
860
864
|
sendAccountSetupEmail,
|
|
861
865
|
sendPasswordResetEmail,
|
|
866
|
+
sendRevenueCatPurchaseMetadata,
|
|
862
867
|
setStudentViewForUser,
|
|
863
868
|
setUserPinnedProgressRow,
|
|
864
869
|
setUserSignature,
|
package/src/index.js
CHANGED
|
@@ -496,6 +496,10 @@ import {
|
|
|
496
496
|
updateProfileVisibility
|
|
497
497
|
} from './services/user/profile.ts';
|
|
498
498
|
|
|
499
|
+
import {
|
|
500
|
+
sendRevenueCatPurchaseMetadata
|
|
501
|
+
} from './services/user/revenuecat.ts';
|
|
502
|
+
|
|
499
503
|
import {
|
|
500
504
|
listOAuthProviders,
|
|
501
505
|
loginAsUser,
|
|
@@ -858,6 +862,7 @@ export {
|
|
|
858
862
|
searchAlgolia,
|
|
859
863
|
sendAccountSetupEmail,
|
|
860
864
|
sendPasswordResetEmail,
|
|
865
|
+
sendRevenueCatPurchaseMetadata,
|
|
861
866
|
setStudentViewForUser,
|
|
862
867
|
setUserPinnedProgressRow,
|
|
863
868
|
setUserSignature,
|
|
@@ -83,6 +83,7 @@ export interface UpgradeOption {
|
|
|
83
83
|
annual_savings: number
|
|
84
84
|
lowest_monthly_cost: number
|
|
85
85
|
upgrade_type: string
|
|
86
|
+
is_prorated_charge: boolean
|
|
86
87
|
products: UpgradeProduct[] // annual + monthly products, or solely annual product with the same configuration information
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module RevenueCat
|
|
3
|
+
*/
|
|
4
|
+
import { HttpClient } from '../../infrastructure/http/HttpClient'
|
|
5
|
+
import { globalConfig } from '../config'
|
|
6
|
+
|
|
7
|
+
const baseUrl = `/api/revenuecat`
|
|
8
|
+
|
|
9
|
+
export type RevenueCatPurchaseIntent =
|
|
10
|
+
| 'new'
|
|
11
|
+
| 'upgrade_higher_cost'
|
|
12
|
+
| 'upgrade_lower_cost'
|
|
13
|
+
| 'downgrade'
|
|
14
|
+
| 'crossgrade'
|
|
15
|
+
| 'unknown'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sends purchase_intent/previous_product_id metadata to BE for a given RevenueCat/Google
|
|
19
|
+
* transaction, immediately after a purchase completes. Keyed by RC's own transaction id, so BE
|
|
20
|
+
* can resolve it when the corresponding webhook's resulting order is synced later.
|
|
21
|
+
*
|
|
22
|
+
* Safe to retry -- idempotent on BE's side by transaction_id, so a duplicate call after a
|
|
23
|
+
* network failure is harmless.
|
|
24
|
+
*
|
|
25
|
+
* @param transactionId - RC's transactionIdentifier for this purchase (from Purchases.getCustomerInfo())
|
|
26
|
+
* @param purchaseIntent - The classification determined before the purchase was initiated
|
|
27
|
+
* @param previousProductId - The RC product id being upgraded/downgraded/crossgraded from, if applicable
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
* @throws {Error} - Throws an error if the request fails or if required parameters are missing.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* sendRevenueCatPurchaseMetadata('GPA.3378-5280-5022-02864', 'upgrade_higher_cost', 'musora_subscription:annual-plus')
|
|
33
|
+
* .catch(error => console.error(error));
|
|
34
|
+
*/
|
|
35
|
+
export async function sendRevenueCatPurchaseMetadata(
|
|
36
|
+
transactionId: string,
|
|
37
|
+
purchaseIntent: RevenueCatPurchaseIntent,
|
|
38
|
+
previousProductId?: string | null
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
if (!transactionId) {
|
|
41
|
+
throw new Error('transactionId is a required parameter')
|
|
42
|
+
}
|
|
43
|
+
if (!purchaseIntent) {
|
|
44
|
+
throw new Error('purchaseIntent is a required parameter')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const requestBody: { transaction_id: string; purchase_intent: string; previous_product_id?: string } = {
|
|
48
|
+
transaction_id: transactionId,
|
|
49
|
+
purchase_intent: purchaseIntent
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Only include previous_product_id if it has a valid value
|
|
53
|
+
if (previousProductId) {
|
|
54
|
+
requestBody.previous_product_id = previousProductId
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const httpClient = new HttpClient(globalConfig.baseUrl)
|
|
58
|
+
await httpClient.post<void>(`${baseUrl}/v1/purchase-metadata`, requestBody)
|
|
59
|
+
}
|
package/src/version-info.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const MCS_VERSION = '2.
|
|
1
|
+
export const MCS_VERSION = '2.178.1'
|