react-native-test-adx 0.1.18 → 0.1.20
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/lib/module/AdaxonSdk.js +3 -2
- package/lib/module/sdkVersion.js +1 -1
- package/lib/module/services/logging/AdaxonLogger.js +36 -3
- package/lib/typescript/src/sdkVersion.d.ts +1 -1
- package/lib/typescript/src/services/logging/AdaxonLogger.d.ts +9 -0
- package/lib/typescript/src/types/AdaxonConfig.d.ts +7 -2
- package/package.json +1 -1
package/lib/module/AdaxonSdk.js
CHANGED
|
@@ -7,7 +7,7 @@ import { AdaxonSdkError } from "./errors/AdaxonSdkError.js";
|
|
|
7
7
|
import { detectReactNativePlatform, reactNativeAppInfoReader, reactNativeDeviceReader, reactNativeNetworkInfoReader, reactNativeNetworkStatusReader, reactNativeUrlOpener } from "./platform/reactNative.js";
|
|
8
8
|
import { buildAddToCartProperties, buildPurchaseProperties, normalizeEventValues } from "./services/event/normalizeProperties.js";
|
|
9
9
|
import { AdxEvent } from "./services/event/predefined.js";
|
|
10
|
-
import { AdaxonLogger, logSdkActivity } from "./services/logging/AdaxonLogger.js";
|
|
10
|
+
import { AdaxonLogger, logSdkActivity, resolveAllowRemoteActivityLogging } from "./services/logging/AdaxonLogger.js";
|
|
11
11
|
function openableOfferUrl(url) {
|
|
12
12
|
return url.replace(/[{}]/g, brace => brace === '{' ? '%7B' : '%7D');
|
|
13
13
|
}
|
|
@@ -24,7 +24,8 @@ export class AdaxonSdk {
|
|
|
24
24
|
enabled: Boolean(configuration.activityLogging),
|
|
25
25
|
dsn: configuration.sentryDsn,
|
|
26
26
|
platform,
|
|
27
|
-
testMode: Boolean(configuration.testMode)
|
|
27
|
+
testMode: Boolean(configuration.testMode),
|
|
28
|
+
allowRemoteLogging: resolveAllowRemoteActivityLogging(configuration)
|
|
28
29
|
});
|
|
29
30
|
logSdkActivity({
|
|
30
31
|
eventName: 'sdk.initialize.started',
|
package/lib/module/sdkVersion.js
CHANGED
|
@@ -3,10 +3,29 @@
|
|
|
3
3
|
import { SDK_VERSION } from "../../sdkVersion.js";
|
|
4
4
|
import { AdaxonSdkError } from "../../errors/AdaxonSdkError.js";
|
|
5
5
|
import { sanitizeLogMetadata } from "./sanitizeLogMetadata.js";
|
|
6
|
+
/** Remote Sentry uploads (dev/test only unless host explicitly allows). */
|
|
7
|
+
export function resolveAllowRemoteActivityLogging(input) {
|
|
8
|
+
if (!input.activityLogging) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (input.allowRemoteActivityLogging === false) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!input.sentryDsn?.trim()) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (input.allowRemoteActivityLogging === true) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return Boolean(input.testMode) || isDevBuild();
|
|
21
|
+
}
|
|
6
22
|
const DEFAULT_LEVEL = 'info';
|
|
7
23
|
|
|
8
24
|
/** Milestones + native dev warn/error → Sentry Message when Logs are off. */
|
|
9
25
|
const SENTRY_MESSAGE_EVENTS = new Set(['sdk.initialize.completed', 'sdk.initialize.failed', 'recommendation.response.received', 'ad.displayed', 'ad.dismissed', 'ad.show.failed']);
|
|
26
|
+
|
|
27
|
+
/** Native dev: avoid captureMessage during interstitial UI (fake Sentry Issues + bundle stacks). */
|
|
28
|
+
const NATIVE_DEV_BREADCRUMB_ONLY_EVENTS = new Set(['ad.show.started', 'ad.displayed', 'ad.dismissed']);
|
|
10
29
|
let cachedSentryModule;
|
|
11
30
|
let missingSentryPeerWarningShown = false;
|
|
12
31
|
function isDevBuild() {
|
|
@@ -64,7 +83,10 @@ function planSentryDelivery(input, level, platform, sentStructuredLog, ownsSentr
|
|
|
64
83
|
if (input.captureAsEvent && input.error === undefined) {
|
|
65
84
|
sendMessage = true;
|
|
66
85
|
} else if (SENTRY_MESSAGE_EVENTS.has(input.eventName)) {
|
|
67
|
-
|
|
86
|
+
const skipMessage = nativeDev && NATIVE_DEV_BREADCRUMB_ONLY_EVENTS.has(input.eventName);
|
|
87
|
+
if (!skipMessage) {
|
|
88
|
+
sendMessage = true;
|
|
89
|
+
}
|
|
68
90
|
} else if (nativeDev && (level === 'warn' || level === 'error')) {
|
|
69
91
|
sendMessage = true;
|
|
70
92
|
}
|
|
@@ -131,19 +153,24 @@ class AdaxonLoggerService {
|
|
|
131
153
|
platform = 'web';
|
|
132
154
|
sentryReady = false;
|
|
133
155
|
ownsSentryClient = false;
|
|
156
|
+
remoteLoggingEnabled = false;
|
|
134
157
|
configure(input) {
|
|
135
158
|
this.enabled = Boolean(input.enabled);
|
|
136
159
|
this.platform = input.platform;
|
|
137
160
|
this.sentryReady = false;
|
|
161
|
+
this.remoteLoggingEnabled = Boolean(input.allowRemoteLogging);
|
|
138
162
|
if (!this.enabled) {
|
|
139
163
|
return;
|
|
140
164
|
}
|
|
141
|
-
|
|
142
|
-
|
|
165
|
+
if (this.remoteLoggingEnabled) {
|
|
166
|
+
warnSentryUnavailableOnce(Boolean(input.dsn?.trim()));
|
|
167
|
+
this.ensureSentry(input.dsn, Boolean(input.testMode));
|
|
168
|
+
}
|
|
143
169
|
}
|
|
144
170
|
reset() {
|
|
145
171
|
this.enabled = false;
|
|
146
172
|
this.sentryReady = false;
|
|
173
|
+
this.remoteLoggingEnabled = false;
|
|
147
174
|
this.platform = 'web';
|
|
148
175
|
this.ownsSentryClient = false;
|
|
149
176
|
cachedSentryModule = undefined;
|
|
@@ -161,6 +188,9 @@ class AdaxonLoggerService {
|
|
|
161
188
|
timestamp: new Date().toISOString()
|
|
162
189
|
};
|
|
163
190
|
mirrorToDevConsole(level, input.eventName, sanitizeLogMetadata(baseMetadata));
|
|
191
|
+
if (!this.remoteLoggingEnabled) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
164
194
|
const sentryAttributes = sanitizeLogMetadata({
|
|
165
195
|
...baseMetadata,
|
|
166
196
|
event_name: input.eventName
|
|
@@ -232,6 +262,9 @@ class AdaxonLoggerService {
|
|
|
232
262
|
});
|
|
233
263
|
this.ownsSentryClient = true;
|
|
234
264
|
}
|
|
265
|
+
if (!this.ownsSentryClient) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
235
268
|
for (const [key, value] of [['adaxon_sdk_version', SDK_VERSION], ['adaxon_platform', this.platform]]) {
|
|
236
269
|
sentry.setTag(key, value);
|
|
237
270
|
}
|
|
@@ -13,12 +13,21 @@ export type AdaxonLoggerConfigureInput = {
|
|
|
13
13
|
dsn?: string;
|
|
14
14
|
platform: AdaxonPlatform;
|
|
15
15
|
testMode?: boolean;
|
|
16
|
+
allowRemoteLogging?: boolean;
|
|
16
17
|
};
|
|
18
|
+
/** Remote Sentry uploads (dev/test only unless host explicitly allows). */
|
|
19
|
+
export declare function resolveAllowRemoteActivityLogging(input: {
|
|
20
|
+
activityLogging?: boolean;
|
|
21
|
+
sentryDsn?: string;
|
|
22
|
+
testMode?: boolean;
|
|
23
|
+
allowRemoteActivityLogging?: boolean;
|
|
24
|
+
}): boolean;
|
|
17
25
|
declare class AdaxonLoggerService {
|
|
18
26
|
private enabled;
|
|
19
27
|
private platform;
|
|
20
28
|
private sentryReady;
|
|
21
29
|
private ownsSentryClient;
|
|
30
|
+
private remoteLoggingEnabled;
|
|
22
31
|
configure(input: AdaxonLoggerConfigureInput): void;
|
|
23
32
|
reset(): void;
|
|
24
33
|
logActivity(input: AdaxonActivityLogInput): void;
|
|
@@ -10,10 +10,15 @@ export interface AdaxonSdkConfig {
|
|
|
10
10
|
timeoutMs?: number;
|
|
11
11
|
fetch?: typeof globalThis.fetch;
|
|
12
12
|
testMode?: boolean;
|
|
13
|
-
/** When true,
|
|
13
|
+
/** When true, emits activity diagnostics (local dev console when __DEV__). Default false. */
|
|
14
14
|
activityLogging?: boolean;
|
|
15
|
-
/** Sentry DSN
|
|
15
|
+
/** Sentry DSN for remote activity logging (ignored when allowRemoteActivityLogging is false). */
|
|
16
16
|
sentryDsn?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, activity is sent to Sentry (dev/test). When false, Sentry is never initialized.
|
|
19
|
+
* Host apps should set false in production even if activityLogging is on by mistake.
|
|
20
|
+
*/
|
|
21
|
+
allowRemoteActivityLogging?: boolean;
|
|
17
22
|
}
|
|
18
23
|
export type AdaxonInitializationConfiguration = AdaxonSdkConfig;
|
|
19
24
|
export type AdaxonInitializationErrorCode = 'INVALID_CONFIG' | 'UNKNOWN';
|
package/package.json
CHANGED